Repository navigation
Expand file tree
/
Copy pathpalette.go
More file actions
243 lines (212 loc) · 9.83 KB
/
Copy pathpalette.go
File metadata and controls
243 lines (212 loc) · 9.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
package vtui
// Palette indices (mapped to far2l's enum PaletteColors)
const (
ColMenuText = iota
ColMenuSelectedText
ColMenuHighlight
ColMenuSelectedHighlight
ColMenuBox
ColMenuTitle
ColTableText
ColTableSelectedText
ColTableTitle
ColTableBox
ColTableColumnTitle
ColScrollBar
ColDialogText
ColDialogHighlightText
ColDialogBox
ColDialogBoxTitle
ColDialogHighlightBoxTitle
ColDialogEdit
ColDialogButton
ColDialogSelectedButton
ColDialogHighlightButton
ColDialogHighlightSelectedButton
ColDesktopBackground
ColDialogEditUnchanged
ColDialogEditSelected
ColKeyBarNum
ColKeyBarText
ColMenuBarItem
ColMenuBarSelected
ColMenuBarHighlight
ColMenuBarSelectedHighlight
ColShadow
ColHelpText
ColHelpBold
ColHelpLink
ColHelpSelectedLink
ColHelpBox
ColHelpBoxTitle
ColWarnText
ColWarnHighlightText
ColWarnBox
ColWarnBoxTitle
ColWarnHighlightBoxTitle
ColWarnEdit
ColWarnButton
ColWarnSelectedButton
ColWarnHighlightButton
ColWarnHighlightSelectedButton
// Combo box dropdowns carry their own set so that a dropdown does not
// vanish into the dialog behind it. Names follow far2l's Dialog.Combo.*
// group (COL_DIALOGCBOX*).
ColDialogComboText
ColDialogComboSelectedText
ColDialogComboHighlight
ColDialogComboSelectedHighlight
ColDialogComboBox
ColDialogComboTitle
ColDialogComboScrollbar
// The help viewer draws its scrollbar inside its own window, so it needs a
// slot of its own instead of the shared list color: far2l splits the same
// way (Help.Scrollbar next to Menu.Scrollbar and Dialog.List.Scrollbar).
ColHelpScrollbar
// Tree lines are drawn by TreeView only. Keeping them apart from
// ColTableBox lets that slot mean exactly one thing, the column separator
// of a table.
ColTreeLine
// Background only for checkbox/radio indicators. Zero inherits the
// normal control background, preserving themes that omit this slot.
ColDialogIndicatorBackground
// A menu draws its scrollbar on its own frame, over the menu background,
// while ColScrollBar belongs to Table, ListBox and TreeView, which sit on
// the table background. One slot cannot match both surfaces, and far2l
// keeps them apart as well (Menu.Scrollbar and Dialog.List.Scrollbar).
ColMenuScrollbar
// Helper for array size
LastPaletteColor
)
// Palette holds the current color attributes for all UI elements.
var Palette = make([]uint64, LastPaletteColor)
// SetDefaultPalette initializes the palette with standard Far Manager colors.
func SetDefaultPalette() {
if len(Palette) < LastPaletteColor {
Palette = make([]uint64, LastPaletteColor)
}
Palette[ColDialogIndicatorBackground] = 0
// Standard Far colors translated to 24-bit RGB for vtinput
black := uint32(0x000000)
white := uint32(0xFFFFFF)
cyan := uint32(0x00A0A0)
blue := uint32(0x0000A0)
yellow := uint32(0xFFFF00)
lightGray := uint32(0xC0C0C0)
darkGray := uint32(0x808080)
// Menus (White on Cyan)
Palette[ColMenuText] = SetRGBBoth(0, white, cyan)
Palette[ColMenuSelectedText] = SetRGBBoth(0, white, black)
Palette[ColMenuHighlight] = SetRGBBoth(0, yellow, cyan)
Palette[ColMenuSelectedHighlight] = SetRGBBoth(0, yellow, black)
Palette[ColMenuBox] = SetRGBBoth(0, white, cyan)
Palette[ColMenuTitle] = SetRGBBoth(0, white, cyan)
// The scrollbar runs down the menu frame, so it follows the frame colour
// (far2l's Menu.Scrollbar default equals its Menu.Box).
Palette[ColMenuScrollbar] = Palette[ColMenuBox]
// Table (White on Blue)
Palette[ColTableText] = SetRGBBoth(0, lightGray, blue)
Palette[ColTableSelectedText] = SetRGBBoth(0, black, cyan)
Palette[ColTableTitle] = SetRGBBoth(0, white, blue)
Palette[ColTableBox] = SetRGBBoth(0, lightGray, blue)
Palette[ColTableColumnTitle] = SetRGBBoth(0, yellow, blue)
Palette[ColScrollBar] = SetRGBBoth(0, lightGray, blue)
Palette[ColTreeLine] = Palette[ColTableBox]
// Dialogs (Black on LightGray)
Palette[ColDialogText] = SetRGBBoth(0, black, lightGray)
Palette[ColDialogHighlightText] = SetRGBBoth(0, yellow, lightGray)
Palette[ColDialogBox] = SetRGBBoth(0, black, lightGray)
Palette[ColDialogBoxTitle] = SetRGBBoth(0, black, lightGray)
Palette[ColDialogHighlightBoxTitle] = SetRGBBoth(0, yellow, lightGray)
// Dialog Edits (Black on Cyan)
Palette[ColDialogEdit] = SetRGBBoth(0, black, cyan)
Palette[ColDialogEditSelected] = SetRGBBoth(0, black, lightGray)
Palette[ColDialogEditUnchanged] = SetRGBBoth(0, darkGray, cyan)
// Dialog Buttons
Palette[ColDialogButton] = SetRGBBoth(0, black, lightGray)
Palette[ColDialogHighlightButton] = SetRGBBoth(0, yellow, lightGray)
Palette[ColDialogSelectedButton] = SetRGBBoth(0, black, cyan)
Palette[ColDialogHighlightSelectedButton] = SetRGBBoth(0, yellow, cyan)
// Combo dropdowns (far2l defaults: White on Cyan, inverted when selected)
Palette[ColDialogComboText] = SetRGBBoth(0, white, cyan)
Palette[ColDialogComboSelectedText] = SetRGBBoth(0, white, black)
Palette[ColDialogComboHighlight] = SetRGBBoth(0, yellow, cyan)
Palette[ColDialogComboSelectedHighlight] = SetRGBBoth(0, yellow, black)
Palette[ColDialogComboBox] = SetRGBBoth(0, white, cyan)
Palette[ColDialogComboTitle] = SetRGBBoth(0, white, cyan)
Palette[ColDialogComboScrollbar] = SetRGBBoth(0, white, cyan)
// Desktop (Classic Blue)
Palette[ColDesktopBackground] = SetRGBBoth(0, lightGray, blue)
// KeyBar (Match f4/far2l defaults: LightGray on DarkGray / DarkGray on Teal)
Palette[ColKeyBarNum] = SetRGBBoth(0, 0xD3D7CF, 0x2E3436)
Palette[ColKeyBarText] = SetRGBBoth(0, 0x2E3436, 0x06989A)
// MenuBar (Black on LightGray, Green on LightGray for selection)
Palette[ColMenuBarItem] = SetRGBBoth(0, black, lightGray)
Palette[ColMenuBarSelected] = SetRGBBoth(0, black, 0x00FF00) // Green background
Palette[ColMenuBarHighlight] = SetRGBBoth(0, yellow, lightGray)
Palette[ColMenuBarSelectedHighlight] = SetRGBBoth(0, yellow, 0x00FF00)
// Shadow (Solid black background)
Palette[ColShadow] = SetRGBBoth(0, black, black)
// Help (Match far2l: DarkGray on LightGray/White)
Palette[ColHelpText] = SetRGBBoth(0, black, 0xD3D7CF)
Palette[ColHelpBold] = SetRGBBoth(0, white, 0xD3D7CF)
Palette[ColHelpLink] = SetRGBBoth(0, 0x0000A0, 0xD3D7CF) // Blue links
Palette[ColHelpSelectedLink] = SetRGBBoth(0, white, 0x0000A0) // White on Blue
Palette[ColHelpBox] = Palette[ColHelpText]
Palette[ColHelpBoxTitle] = Palette[ColHelpText]
// The shared list scrollbar sits on blue, which does not belong in the
// light help window, so the help scrollbar follows the help frame instead.
Palette[ColHelpScrollbar] = Palette[ColHelpBox]
red := uint32(0x800000)
// Warnings (White/Yellow on Red)
Palette[ColWarnText] = SetRGBBoth(0, white, red)
Palette[ColWarnHighlightText] = SetRGBBoth(0, yellow, red)
Palette[ColWarnBox] = SetRGBBoth(0, white, red)
Palette[ColWarnBoxTitle] = SetRGBBoth(0, white, red)
Palette[ColWarnHighlightBoxTitle] = SetRGBBoth(0, yellow, red)
Palette[ColWarnEdit] = SetRGBBoth(0, black, cyan)
Palette[ColWarnButton] = SetRGBBoth(0, white, red)
Palette[ColWarnSelectedButton] = SetRGBBoth(0, black, cyan)
Palette[ColWarnHighlightButton] = SetRGBBoth(0, yellow, red)
Palette[ColWarnHighlightSelectedButton] = SetRGBBoth(0, yellow, cyan)
}
// ThemePalette is the host application's 256-color palette for UI indexing.
var ThemePalette [256]uint32
func init() {
copy(ThemePalette[:], XTerm256Palette[:])
}
// XTerm256Palette is the standard 256-color lookup table.
var XTerm256Palette = [256]uint32{
0x000000, 0x800000, 0x008000, 0x808000, 0x000080, 0x800080, 0x008080, 0xc0c0c0,
0x808080, 0xff0000, 0x00ff00, 0xffff00, 0x0000ff, 0xff00ff, 0x00ffff, 0xffffff,
0x000000, 0x00005f, 0x000087, 0x0000af, 0x0000d7, 0x0000ff, 0x005f00, 0x005f5f,
0x005f87, 0x005faf, 0x005fd7, 0x005fff, 0x008700, 0x00875f, 0x008787, 0x0087af,
0x0087d7, 0x0087ff, 0x00af00, 0x00af5f, 0x00af87, 0x00afaf, 0x00afd7, 0x00afff,
0x00d700, 0x00d75f, 0x00d787, 0x00d7af, 0x00d7d7, 0x00d7ff, 0x00ff00, 0x00ff5f,
0x00ff87, 0x00ffaf, 0x00ffd7, 0x00ffff, 0x5f0000, 0x5f005f, 0x5f0087, 0x5f00af,
0x5f00d7, 0x5f00ff, 0x5f5f00, 0x5f5f5f, 0x5f5f87, 0x5f5faf, 0x5f5fd7, 0x5f5fff,
0x5f8700, 0x5f875f, 0x5f8787, 0x5f87af, 0x5f87d7, 0x5f87ff, 0x5faf00, 0x5faf5f,
0x5faf87, 0x5fafaf, 0x5fafd7, 0x5fafff, 0x5fd700, 0x5fd75f, 0x5fd787, 0x5fd7af,
0x5fd7d7, 0x5fd7ff, 0x5fff00, 0x5fff5f, 0x5fff87, 0x5fffaf, 0x5fffd7, 0x5fffff,
0x870000, 0x87005f, 0x870087, 0x8700af, 0x8700d7, 0x8700ff, 0x875f00, 0x875f5f,
0x875f87, 0x875faf, 0x875fd7, 0x875fff, 0x878700, 0x87875f, 0x878787, 0x8787af,
0x8787d7, 0x8787ff, 0x87af00, 0x87af5f, 0x87af87, 0x87afaf, 0x87afd7, 0x87afff,
0x87d700, 0x87d75f, 0x87d787, 0x87d7af, 0x87d7d7, 0x87d7ff, 0x87ff00, 0x87ff5f,
0x87ff87, 0x87ffaf, 0x87ffd7, 0x87ffff, 0xaf0000, 0xaf005f, 0xaf0087, 0xaf00af,
0xaf00d7, 0xaf00ff, 0xaf5f00, 0xaf5f5f, 0xaf5f87, 0xaf5faf, 0xaf5fd7, 0xaf5fff,
0xaf8700, 0xaf875f, 0xaf8787, 0xaf87af, 0xaf87d7, 0xaf87ff, 0xafaf00, 0xafaf5f,
0xafaf87, 0xafafaf, 0xafafd7, 0xafafff, 0xafd700, 0xafd75f, 0xafd787, 0xafd7af,
0xafd7d7, 0xafd7ff, 0xafff00, 0xafff5f, 0xafff87, 0xafffaf, 0xafffd7, 0xafffff,
0xd70000, 0xd7005f, 0xd70087, 0xd700af, 0xd700d7, 0xd700ff, 0xd75f00, 0xd75f5f,
0xd75f87, 0xd75faf, 0xd75fd7, 0xd75fff, 0xd78700, 0xd7875f, 0xd78787, 0xd787af,
0xd787d7, 0xd787ff, 0xd7af00, 0xd7af5f, 0xd7af87, 0xd7afaf, 0xd7afd7, 0xd7afff,
0xd7d700, 0xd7d75f, 0xd7d787, 0xd7d7af, 0xd7d7d7, 0xd7d7ff, 0xd7ff00, 0xd7ff5f,
0xd7ff87, 0xd7ffaf, 0xd7ffd7, 0xd7ffff, 0xff0000, 0xff005f, 0xff0087, 0xff00af,
0xff00d7, 0xff00ff, 0xff5f00, 0xff5f5f, 0xff5f87, 0xff5faf, 0xff5fd7, 0xff5fff,
0xff8700, 0xff875f, 0xff8787, 0xff87af, 0xff87d7, 0xff87ff, 0xffaf00, 0xffaf5f,
0xffaf87, 0xffafaf, 0xffafd7, 0xffafff, 0xffd700, 0xffd75f, 0xffd787, 0xffd7af,
0xffd7d7, 0xffd7ff, 0xffff00, 0xffff5f, 0xffff87, 0xffffaf, 0xffffd7, 0xffffff,
0x080808, 0x121212, 0x1c1c1c, 0x262626, 0x303030, 0x3a3a3a, 0x444444, 0x4e4e4e,
0x585858, 0x626262, 0x6c6c6c, 0x767676, 0x808080, 0x8a8a8a, 0x949494, 0x9e9e9e,
0xa8a8a8, 0xb2b2b2, 0xbcbcbc, 0xc6c6c6, 0xd0d0d0, 0xdadada, 0xe4e4e4, 0xeeeeee,
}