-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeme.zig
More file actions
591 lines (563 loc) · 22.3 KB
/
Copy paththeme.zig
File metadata and controls
591 lines (563 loc) · 22.3 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
const std = @import("std");
const vaxis = @import("vaxis");
const builtin = @import("builtin");
const platform = @import("../kernel/platform.zig");
pub const RGB = struct { u8, u8, u8 };
// Runtime truecolor capability flag. Set by `detectTruecolor()` once
// at startup. Default chosen so the binary still produces usable
// (16-colour) output if detection is never called.
//
// Why this exists: most syntax/decoration colours are 24-bit RGB,
// which is fine on every modern terminal *except* the classic Windows
// conhost (cmd.exe in the legacy console host). conhost silently
// drops 24-bit SGR codes, leaving the buffer text rendered with the
// terminal default foreground — exactly the "status bar is colourful,
// buffer is flat" symptom that prompted this. Index/palette colours
// (16-colour) work everywhere including legacy conhost.
pub var truecolor_enabled: bool = builtin.os.tag != .windows;
/// Probe the environment for truecolor support and set
/// `truecolor_enabled` accordingly. Call once at startup, before any
/// rendering happens. The heuristic, in order:
/// 1. COLORTERM == "truecolor" / "24bit" → yes
/// 2. WT_SESSION is set (Microsoft Windows Terminal) → yes
/// 3. TERM_PROGRAM != Apple_Terminal* (iTerm, ghostty, vscode,
/// WezTerm, alacritty, etc.) → yes
/// 4. Otherwise default to platform tradition: yes on POSIX, no on
/// Windows (covers classic conhost / cmd.exe).
///
/// "Apple_Terminal*" is excluded because macOS Terminal.app is
/// 256-colour only, not truecolor — falls through to step 4.
pub fn detectTruecolor(
allocator: std.mem.Allocator,
environ_block: std.process.Environ.Block,
) void {
if (platform.getEnv(allocator, environ_block, "COLORTERM") catch null) |val| {
defer allocator.free(val);
if (std.mem.eql(u8, val, "truecolor") or std.mem.eql(u8, val, "24bit")) {
truecolor_enabled = true;
return;
}
}
if (platform.getEnv(allocator, environ_block, "WT_SESSION") catch null) |val| {
defer allocator.free(val);
truecolor_enabled = true;
return;
}
if (platform.getEnv(allocator, environ_block, "TERM_PROGRAM") catch null) |val| {
defer allocator.free(val);
if (!std.mem.startsWith(u8, val, "Apple_Terminal")) {
truecolor_enabled = true;
return;
}
}
truecolor_enabled = builtin.os.tag != .windows;
}
/// Return a vaxis color that uses 24-bit RGB if the terminal can
/// render it, otherwise the supplied 16-colour palette index fallback.
/// Centralising the choice here means each call site stays a one-liner
/// instead of branching on `truecolor_enabled` everywhere.
pub fn fg(rgb_color: RGB, palette_index: u8) vaxis.Cell.Color {
return if (truecolor_enabled)
.{ .rgb = .{ rgb_color[0], rgb_color[1], rgb_color[2] } }
else
.{ .index = palette_index };
}
pub const colors = struct {
pub const syntax = struct {
pub const keyword: RGB = .{ 203, 166, 247 };
pub const function: RGB = .{ 137, 180, 250 };
pub const variable: RGB = .{ 243, 139, 168 };
pub const parameter: RGB = .{ 235, 160, 172 };
pub const property: RGB = .{ 137, 220, 235 };
pub const type_name: RGB = .{ 249, 226, 175 };
pub const string: RGB = .{ 166, 227, 161 };
pub const number: RGB = .{ 250, 179, 135 };
pub const comment: RGB = .{ 108, 112, 134 };
pub const operator: RGB = .{ 148, 226, 213 };
pub const builtin: RGB = .{ 245, 194, 231 };
pub const namespace: RGB = .{ 180, 190, 254 };
pub const other: RGB = .{ 205, 214, 244 };
};
pub const diff = struct {
pub const add: RGB = .{ 152, 195, 121 };
pub const remove: RGB = .{ 224, 108, 117 };
pub const hunk: RGB = .{ 86, 182, 194 };
pub const file: RGB = .{ 229, 192, 123 };
};
pub const brackets = struct {
pub const level_1: RGB = .{ 224, 108, 117 };
pub const level_2: RGB = .{ 209, 154, 102 };
pub const level_3: RGB = .{ 229, 192, 123 };
pub const level_4: RGB = .{ 152, 195, 121 };
pub const level_5: RGB = .{ 86, 182, 194 };
pub const level_6: RGB = .{ 198, 120, 221 };
pub const scope: RGB = .{ 255, 215, 0 };
};
pub const log = struct {
pub const timestamp: u8 = 14;
pub const scope: u8 = 13;
pub const info: u8 = 10;
pub const warn: u8 = 11;
pub const err: u8 = 9;
pub const debug: u8 = 8;
pub const message: u8 = 15;
};
pub const palette = struct {
pub const black: u8 = 0;
pub const red: u8 = 1;
pub const green: u8 = 2;
pub const yellow: u8 = 3;
pub const blue: u8 = 4;
pub const magenta: u8 = 5;
pub const cyan: u8 = 6;
pub const white: u8 = 7;
pub const bright_black: u8 = 8;
pub const bright_red: u8 = 9;
pub const bright_green: u8 = 10;
pub const bright_yellow: u8 = 11;
pub const bright_blue: u8 = 12;
pub const bright_magenta: u8 = 13;
pub const bright_cyan: u8 = 14;
pub const bright_white: u8 = 15;
};
};
pub const styles = struct {
pub const mode = struct {
pub const select: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_white },
.bg = .{ .index = colors.palette.magenta },
};
pub const insert: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.green },
};
pub const visual: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.yellow },
};
pub const view: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_white },
.bg = .{ .index = colors.palette.blue },
};
pub const terminal: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.yellow },
};
pub const file_picker: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_white },
.bg = .{ .index = colors.palette.cyan },
};
pub const buffer_picker: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_white },
.bg = .{ .index = colors.palette.cyan },
};
pub const save_as: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_white },
.bg = .{ .index = colors.palette.cyan },
};
pub const visual_search: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.yellow },
};
pub const command_palette: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_white },
.bg = .{ .index = colors.palette.blue },
};
pub const go_to_line: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_white },
.bg = .{ .index = colors.palette.magenta },
};
pub const symbol_picker: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_white },
.bg = .{ .index = colors.palette.magenta },
};
pub const log_view: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_white },
.bg = .{ .index = colors.palette.blue },
};
pub const global_search: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.yellow },
};
};
pub const status_bar = struct {
pub const base: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.white },
};
pub const info: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
.bg = .{ .index = colors.palette.white },
};
pub const modified: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.red },
.bg = .{ .index = colors.palette.white },
.bold = true,
};
pub const prefix: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.bright_yellow },
.bold = true,
};
};
pub const tab_bar = struct {
pub const background: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
.bg = .{ .index = colors.palette.black },
};
pub const active: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.white },
.bold = true,
};
pub const inactive: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
.bg = .{ .index = colors.palette.black },
};
pub const modified: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.yellow },
.bg = .{ .index = colors.palette.black },
};
pub const scroll_indicator: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.cyan },
.bg = .{ .index = colors.palette.black },
};
pub const number_active: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.white },
.bold = true,
};
pub const number_inactive: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.cyan },
.bg = .{ .index = colors.palette.black },
};
};
pub const picker = struct {
pub const overlay: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
.bg = .{ .index = colors.palette.black },
};
pub const header: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.cyan },
.bold = true,
};
pub const normal: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
.bg = .{ .index = colors.palette.black },
};
pub const selected: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.blue },
.bold = true,
};
pub const selected_white: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.white },
};
pub const directory: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.blue },
.bg = .{ .index = colors.palette.black },
};
pub const directory_selected: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.blue },
.bg = .{ .index = colors.palette.white },
};
pub const active_marker: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.green },
.bg = .{ .index = colors.palette.black },
};
pub const number: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.cyan },
.bg = .{ .index = colors.palette.black },
};
pub const input: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.yellow },
.bold = true,
};
pub const footer: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
.bg = .{ .index = colors.palette.black },
};
pub const scrollbar: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
};
pub const scrollbar_thumb: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
.reverse = true,
};
};
pub const editor = struct {
pub const line_number: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
};
pub const default: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
.bg = .{ .index = colors.palette.black },
};
pub const cursor_line: vaxis.Cell.Style = .{
.bg = .{ .rgb = .{ 49, 50, 68 } },
};
};
pub const panel = struct {
pub const background: vaxis.Cell.Style = .{
.bg = .{ .index = colors.palette.black },
.fg = .{ .index = colors.palette.white },
};
pub const title: vaxis.Cell.Style = .{
.bold = true,
.bg = .{ .index = colors.palette.blue },
.fg = .{ .index = colors.palette.bright_white },
};
};
pub const split = struct {
pub const header_focused: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.blue },
};
pub const header_unfocused: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
.bg = .{ .index = colors.palette.bright_black },
};
pub const content: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
.bg = .{ .index = colors.palette.black },
};
};
pub const help = struct {
pub const title: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.blue },
.bold = true,
};
pub const h1: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.cyan },
.bold = true,
};
pub const h2: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.magenta },
.bold = true,
};
pub const h3: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.yellow },
.bold = true,
};
pub const key: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.green },
.bold = true,
};
pub const desc: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
};
pub const bullet: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.yellow },
};
pub const command: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.cyan },
};
pub const separator: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
};
pub const diff_add: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_green },
.bg = .{ .index = colors.palette.black },
.bold = true,
};
pub const diff_remove: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_red },
.bg = .{ .index = colors.palette.black },
.bold = true,
};
pub const diff_hunk: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_cyan },
.bg = .{ .index = colors.palette.black },
.bold = true,
};
pub const diff_file: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_yellow },
.bg = .{ .index = colors.palette.black },
.bold = true,
};
};
pub const popup = struct {
pub const border: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
.bg = .{ .index = colors.palette.black },
};
pub const title: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.blue },
.bg = .{ .index = colors.palette.black },
};
pub const code: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.cyan },
.bg = .{ .index = colors.palette.black },
};
pub const doc: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
.bg = .{ .index = colors.palette.black },
};
pub const dim: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
.bg = .{ .index = colors.palette.black },
};
};
pub const completion = struct {
pub const background: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
.bg = .{ .index = colors.palette.black },
};
pub const selected: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.cyan },
.bold = true,
};
pub const selected_alt: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.white },
};
pub const kind: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_yellow },
.bg = .{ .index = colors.palette.black },
};
pub const detail: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
.bg = .{ .index = colors.palette.black },
};
};
pub const terminal = struct {
pub const output_bg: vaxis.Cell.Style = .{
.bg = .{ .index = colors.palette.black },
};
pub const scroll: vaxis.Cell.Style = .{
.bg = .{ .index = colors.palette.bright_black },
};
};
pub const overlay = struct {
pub const background: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
.bg = .{ .index = colors.palette.black },
};
pub const label: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.blue },
.bg = .{ .index = colors.palette.black },
};
pub const input: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
.bg = .{ .index = colors.palette.black },
};
pub const input_bg: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.bright_black },
};
pub const match_highlight: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_yellow },
.bg = .{ .index = colors.palette.black },
};
};
pub const global_search = struct {
pub const border: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.yellow },
.bg = .{ .index = colors.palette.black },
};
pub const option_on: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.yellow },
.bold = true,
};
pub const option_off: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
.bg = .{ .index = colors.palette.black },
};
pub const file_header: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.blue },
.bg = .{ .index = colors.palette.black },
.bold = true,
};
pub const match_line: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
.bg = .{ .index = colors.palette.black },
};
pub const match_highlight: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.yellow },
.bg = .{ .index = colors.palette.black },
.bold = true,
};
pub const line_number: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
.bg = .{ .index = colors.palette.black },
};
pub const selected: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.yellow },
.bold = true,
};
pub const stats: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.green },
.bg = .{ .index = colors.palette.black },
};
pub const input_label: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.yellow },
.bg = .{ .index = colors.palette.black },
};
pub const replace_label: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.magenta },
.bg = .{ .index = colors.palette.black },
};
};
pub const command_palette = struct {
pub const overlay: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
.bg = .{ .index = colors.palette.black },
};
pub const border: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.blue },
.bg = .{ .index = colors.palette.black },
};
pub const title: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_white },
.bg = .{ .index = colors.palette.blue },
.bold = true,
};
pub const input: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
.bg = .{ .index = colors.palette.black },
};
pub const input_prefix: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.cyan },
.bg = .{ .index = colors.palette.black },
};
pub const item: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
.bg = .{ .index = colors.palette.black },
};
pub const item_selected: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.black },
.bg = .{ .index = colors.palette.blue },
.bold = true,
};
pub const keybinding: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
.bg = .{ .index = colors.palette.black },
};
pub const keybinding_selected: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
.bg = .{ .index = colors.palette.blue },
};
pub const footer: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
.bg = .{ .index = colors.palette.black },
};
pub const scrollbar: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.bright_black },
};
pub const scrollbar_thumb: vaxis.Cell.Style = .{
.fg = .{ .index = colors.palette.white },
};
};
};
pub fn rgb(color: RGB) vaxis.Color {
return .{ .rgb = color };
}
pub fn indexed(idx: u8) vaxis.Color {
return .{ .index = idx };
}