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
|
//! The terminal as the core sees it (docs/next-terminal.md, Phase 1): the
//! records its draw group takes and gives, plain data. src/Term.zig is the
//! core's side of it.
const std = @import("std");
const plain = @import("plain.zig");
const Color = plain.Color;
const CellStyle = plain.CellStyle;
/// How much of a row the prompt it starts with is.
pub const PromptCut = union(enum) {
/// no prompt: the row as the emulator dumps it
keep,
/// all prompt, nothing typed yet: show nothing of it
blank,
/// this many leading COLUMNS are the prompt; the rest is what was typed
/// at it
cut: usize,
};
// ---- its colours on the body ----
/// A theme's colours as a terminal's paint takes them.
pub const Ink = struct {
fg: ?[3]u8,
bg: ?[3]u8,
tag_fg: [3]u8,
tag_bg: [3]u8,
/// The theme's own sixteen, when it has them.
palette: ?[16][3]u8,
/// The sixteen the filter keys a program's colours to: `palette`, else
/// made of the theme's roles.
base: [16][3]u8,
/// A palette index as the theme draws it: its own sixteen, else the
/// index.
pub fn palColor(ink: *const Ink, idx: u8) Color {
if (ink.palette) |pal| if (idx < 16) return .{ .rgb = pal[idx] };
return .{ .index = idx };
}
};
/// The theme's 256 colours as the filter maps onto them, kept while the
/// theme is the same (`Pardes.tty_filter_palette`).
pub const FilterPalette = struct {
key: ?Key = null,
colors: [256][3]u8 = undefined,
pub const Key = struct { bg: [3]u8, fg: [3]u8, base: [16][3]u8 };
};
/// A program's colours mapped to the theme, once a frame: what a +Pager's
/// spans are drawn through (`spanColor`), as a terminal's cells are.
pub const Filter = struct {
target: *const [256][3]u8,
/// The theme's page and ink, and the page a program's colours are
/// drawn on (its OSC 11, keyed to the theme, else the theme's).
theme_bg: [3]u8,
theme_fg: [3]u8,
default_bg: [3]u8,
/// What a foreground too near the page's background becomes instead.
fallback_fg: [3]u8,
default_bg_luminance: f64,
fg_for_palette: [256]Color,
bg_for_palette: [256]Color,
/// The two answers for a cell that names no colour of its own.
fg_default: Color,
bg_default: Color,
cache_rgb: [256][3]u8 = undefined,
cache_key: [256]u8 = undefined,
cache_valid: [256]bool = @splat(false),
};
/// One cell of a terminal's view as its paint gives it: its style (its
/// colours the theme's already), the bytes it spells in the view's text,
/// and whether it is half of a wide one.
pub const Painted = struct {
style: CellStyle,
bytes: u16,
wide: enum(u2) { narrow, wide, spacer_tail, spacer_head },
};
/// One row of a terminal's view as its paint gives it.
pub const PaintedRow = struct {
/// The shell marked it a prompt's: how much of it the prompt is.
prompt: ?PromptCut,
/// It holds kitty placeholder cells.
placeholder: bool,
/// Its cells given, from its first: the grid's past them are none.
len: u16,
};
/// Where a terminal's kitty images go, as the body lays out its rows:
/// `rows_of[v]` is the body row its view's row `v` shows on, null for one
/// not shown.
pub const ImagesAt = struct {
pane: u8,
serial: u32,
tx: u16,
body_y: u16,
cols: u16,
rows_of: []const ?u16,
/// The pane shows its terminal's rows as they are (tty mode): a prompt
/// row is the grid's then, and its images show.
tty_mode: bool,
/// The core's clock (animations step on it), and a cell's size in
/// pixels.
now_ms: u64,
cell_w: u32,
cell_h: u32,
};
|