summaryrefslogtreecommitdiff
path: root/src/gui/gui.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/gui.zig')
-rw-r--r--src/gui/gui.zig41
1 files changed, 17 insertions, 24 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 98527842..aa6fc92b 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -10,7 +10,6 @@ const posix = std.posix;
/// libc: pipes and fcntl for the window's wakes, and a test harness's capture files written from the render thread.
const libc = std.c;
const vaxis = @import("vaxis"); // test modes only: the stdin escape-seq parser
-const ghostty_vt = @import("ghostty-vt"); // 256-color palette for .index cells
const pardes = @import("../pardes.zig");
const vaxis_input = @import("../vaxis_input.zig");
const dump = @import("../dump.zig");
@@ -184,7 +183,6 @@ const opaque_bg_bit = Cells.opaque_bg_bit;
const OverlayColor = struct { r: f32, g: f32, b: f32, a: f32 };
-
const PreparedImage = struct {
premultiplied: bool = false,
place: pardes.Placement,
@@ -498,7 +496,7 @@ const Gui = struct {
/// picture follows on a spring (Glide), never the other way round.
scroll_notch: i32 = 0,
/// A touchpad's fraction toward the next turn sent to a program that
- /// owns the wheel (terminal.ownsWheel).
+ /// owns the wheel (Term.Modes.wheel).
program_wheel: f32 = 0,
/// A trackpad's horizontal fraction toward the next turn (wheelAt).
program_wheel_x: f32 = 0,
@@ -676,12 +674,12 @@ fn fixedCellLayout(g: *const Gui) CellLayout {
const Group = Cells.Group;
/// The frame's draw groups, bottom to top: the page and the panes, the
-/// notices floating over them, the guides and the debug box the core paints
-/// over those, and ink (the bar cursors; the cursor's glide draws after it).
+/// notices floating over them, the debug box the core paints over those,
+/// and ink (the bar cursors; the cursor's glide draws after it).
const Groups = struct {
items: [4]Group = @splat(.{}),
notices: usize = 1,
- guides: usize = 2,
+ debug: usize = 2,
ink: usize = 3,
len: usize = 4,
};
@@ -691,7 +689,7 @@ const Groups = struct {
const Cover = packed struct(u16) {
/// A layer draws it; the grid's copy is not drawn.
layer: bool = false,
- /// Under a guide or the debug box: drawn from the grid over the panes.
+ /// Under the debug box: drawn from the grid over the panes.
floating: bool = false,
/// In a pane's grip, `grip_offset` cells from its left: the grip's
/// glyph is the cell that far to the left.
@@ -758,7 +756,7 @@ fn coverFrame(cover: []Cover, cols: u16, rows: u16, body_layers: []const pardes.
mark.rect(cover, cols, rows, .{ .x = region.rect.x, .y = 0, .w = 1, .h = rows }, "anchor", true);
if (region.active) if (bar) |b| mark.rect(cover, cols, rows, .{ .x = region.rect.x, .y = b.y, .w = region.rect.w, .h = b.h }, "focus", true);
},
- .guide, .debug => mark.rect(cover, cols, rows, region.rect, "floating", true),
+ .debug => mark.rect(cover, cols, rows, region.rect, "floating", true),
else => {},
};
}
@@ -1350,11 +1348,11 @@ fn remoteSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
const have: ?*replica.Have = if (far) &have_store else null;
const allocs = pardes.memory.init(gpa);
defer pardes.memory.deinit();
- pardes.TerminalImages.start(allocs.image);
+ pardes.Term.start(allocs.image);
pardes.Kind.heap = allocs.addon;
pardes.syntax.start(allocs.tree_sitter);
defer {
- pardes.TerminalImages.stop();
+ pardes.Term.stop();
pardes.syntax.stop();
}
var o = opts_in;
@@ -2135,7 +2133,7 @@ fn wheelAt(g: *Gui, in: *Input, w: WheelTurn, mc: MouseCell) void {
// touchpad's fraction of a notch too (pa_mouse.amount).
resetScroll(g);
in.post(.{ .mouse = .{ .button = if (w.y < 0) .wheel_down else .wheel_up, .kind = .press, .col = mc.col, .row = mc.row, .tag_hit = mc.tag_hit, .body_hit = mc.body_hit, .ctrl = w.mods.ctrl, .shift = w.mods.shift, .alt = w.mods.alt, .amount = @abs(w.y) } });
- } else if (!w.mods.shift and pane.isTerminal() and pardes.panes.terminal.ownsWheel(pane)) {
+ } else if (!w.mods.shift and pane.isTerminal() and pardes.Term.modes(pane.terminal).wheel) {
// The program's (codex, htop, less): every whole turn goes
// to it, no glide, for nothing of ours moves. Shift keeps
// a terminal's wheel pardes's.
@@ -2658,6 +2656,7 @@ const Shell = struct {
.set_clipboard = setClipboard,
.read_clipboard = readClipboard,
.open_link = openLink,
+ .start = host_io.startDetached,
.lsp = lsp,
.pipe = pipe,
.search = search,
@@ -4137,7 +4136,7 @@ fn renderFrame(
while (col < surface.cols) : (col += 1) {
const at = @as(usize, row) * surface.cols + col;
if (covered[at].layer and !covered[at].floating) continue;
- const group_index = if (covered[at].floating) groups.guides else 0;
+ const group_index = if (covered[at].floating) groups.debug else 0;
groups.items[group_index].cell_count = std.math.add(u32, groups.items[group_index].cell_count, cellInstanceCount(&surface.cells[at])) catch return error.GpuCapacity;
}
}
@@ -4183,7 +4182,7 @@ fn renderFrame(
while (col < surface.cols) : (col += 1) {
const at = @as(usize, row) * surface.cols + col;
if (covered[at].layer and !covered[at].floating) continue;
- const group_index = if (covered[at].floating) groups.guides else 0;
+ const group_index = if (covered[at].floating) groups.debug else 0;
emitSurfaceCell(
g,
chrome,
@@ -4274,12 +4273,12 @@ fn resolveCell(g: *Gui, line: []const pardes.Cell, at: usize, cursor: ?usize, ro
const st = cell.style;
fg = switch (st.fg) {
.default => fg_default,
- .index => |i| palColor(i),
+ .index => |i| pardes.colors.xterm[i],
.rgb => |rgb| rgb,
};
switch (st.bg) {
.default => {},
- .index => |i| bg = palColor(i),
+ .index => |i| bg = pardes.colors.xterm[i],
.rgb => |rgb| bg = rgb,
}
if (st.reverse) reverse = !reverse;
@@ -4651,11 +4650,6 @@ fn cellCodepoint(cell: *const pardes.Cell) u32 {
return if (cell.default or grapheme.len == 0) ' ' else firstCp(grapheme);
}
-fn palColor(idx: u8) [3]u8 {
- const p = ghostty_vt.color.default[idx];
- return .{ p.r, p.g, p.b };
-}
-
fn firstCp(s: []const u8) u32 {
if (s.len == 0) return ' ';
const n = std.unicode.utf8ByteSequenceLength(s[0]) catch return ' ';
@@ -4802,7 +4796,7 @@ fn cellSlot(g: *Gui, line: []const pardes.Cell, at: usize, cursor: ?usize, role:
// An underlined or struck-out space is a glyph of its own: it draws its line.
if (here.cp == ' ' and !here.decoration.drawsBlank()) return g.atlas.space_slot;
if (ruleArms(here.cp) != null)
- return cachedGlyph(g, .{ .face = 0, .glyph = here.cp, .role = @enumFromInt(@intFromEnum(role)), .rule = true }) orelse g.atlas.space_slot;
+ return cachedGlyph(g, .{ .face = 0, .glyph = here.cp, .role = @fromBackingInt(@intCast(@backingInt(role))), .rule = true }) orelse g.atlas.space_slot;
const gpa = g.atlas.glyphs.allocator;
const cell_key: Words.CellKey = .{ .cp = @intCast(here.cp), .role = role, .decoration = here.decoration };
const known = words.cells.getOrPut(gpa, cell_key) catch return g.atlas.space_slot;
@@ -4811,7 +4805,7 @@ fn cellSlot(g: *Gui, line: []const pardes.Cell, at: usize, cursor: ?usize, role:
known.value_ptr.* = if (role == .body and g.atlas.substitutes(drawn.face, drawn.glyph))
Words.shape_slot
else
- cachedGlyph(g, .{ .face = drawn.face, .glyph = drawn.glyph, .role = @enumFromInt(@intFromEnum(role)), .decoration = @bitCast(here.decoration) }) orelse g.atlas.space_slot;
+ cachedGlyph(g, .{ .face = drawn.face, .glyph = drawn.glyph, .role = @fromBackingInt(@intCast(@backingInt(role))), .decoration = @bitCast(here.decoration) }) orelse g.atlas.space_slot;
}
const plain = known.value_ptr.*;
if (!std.meta.eql(plain, Words.shape_slot)) return plain;
@@ -6145,7 +6139,6 @@ test "installed Nerd Symbols fallback covers Yazi directory icons" {
try std.testing.expect(atlas.glyphForCodepoint(0xe5ff).glyph != 0);
}
-
test "GUI PTY reader delivers a real shell tail before EOF and joins on close" {
const gpa = std.testing.allocator;
const core = try pardes.Pardes.init(gpa, .{ .tty_only = true });
@@ -6440,7 +6433,7 @@ test "the window's function and editing keys reach a terminal as its cursor keys
.{ .modes = "\x1b[?1l\x1b[>7u", .sym = 'c', .mod = c.SDL_KMOD_LCTRL, .sent = "\x1b[99;5u" },
.{ .modes = "", .sym = 'a', .mod = c.SDL_KMOD_LALT, .sent = "\x1b[97;3u" },
// With event types asked for (2), an arrow says it is a press, as
- // ghostty says it.
+ // the emulator's encoder says it.
.{ .modes = "", .sym = c.SDLK_UP, .sent = "\x1b[1;1:1A" },
};
for (cases) |case| {