summaryrefslogtreecommitdiff
path: root/src/tui
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 23:35:20 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:21:29 -0300
commitdbdd21d8ebfaaedb5675a457aa385b97450237f5 (patch)
treec501bfef83afb769f6156cb422ce0d56dd24c822 /src/tui
parente38820811c306e7575e87d3fe9a84c7a1503f7d9 (diff)
downloadpardes-dbdd21d8ebfaaedb5675a457aa385b97450237f5.tar.gz
pardes-dbdd21d8ebfaaedb5675a457aa385b97450237f5.zip
vaxis_input: the core's cell styles as vaxis draws them (style, color, the underline mapped by its name) and a pasted key's text (pasteBytes) are vaxis_input's, the tui's copies gone; the gui's test-mode stdin takes a paste's keys through the same pasteBytes, which also knows the keypad's Enter (its own copy did not)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/tui')
-rw-r--r--src/tui/tui.zig45
1 files changed, 3 insertions, 42 deletions
diff --git a/src/tui/tui.zig b/src/tui/tui.zig
index 6030f797..5cf402a5 100644
--- a/src/tui/tui.zig
+++ b/src/tui/tui.zig
@@ -2581,7 +2581,7 @@ const Shell = struct {
core.update(.{ .eof = .{ .pane = @intCast(e.id) } });
},
.key_press => |key| if (s.in_paste) {
- const bytes = pasteBytes(key);
+ const bytes = vaxis_input.pasteBytes(key);
const room = max_paste_bytes -| s.paste_buf.written().len;
s.paste_buf.writer.writeAll(bytes[0..@min(bytes.len, room)]) catch {};
} else s.feed(vaxis_input.keyEvent(key)),
@@ -3289,15 +3289,6 @@ fn readPty(io: std.Io, gpa: std.mem.Allocator, pty: std.Io.File, id: usize, gen:
const max_paste_bytes: usize = pardes.memory.limits.max_paste_bytes;
-fn pasteBytes(key: vaxis.Key) []const u8 {
- const text = key.text orelse "";
- if (text.len > 0) return text;
- const cp = vaxis_input.mapKey(vaxis_input.effCp(key));
- if (cp == pardes.Key.tab) return "\t";
- if (cp == pardes.Key.enter or (key.mods.ctrl and cp == 'j')) return "\n";
- return "";
-}
-
test "a terminal pane gets function keys as their sequences and lone modifiers not at all" {
const gpa = std.testing.allocator;
var t: TestInput = undefined;
@@ -3379,7 +3370,7 @@ test "keypad Enter matches Return for editor input terminal writes and paste" {
const key: vaxis.Key = .{ .codepoint = codepoint };
const event = vaxis_input.keyEvent(key);
try std.testing.expectEqual(pardes.Key.enter, event.key.cp);
- try std.testing.expectEqualStrings("\n", pasteBytes(key));
+ try std.testing.expectEqualStrings("\n", vaxis_input.pasteBytes(key));
{
const core = try pardes.Pardes.init(std.testing.allocator, .{ .tty_only = true });
defer core.deinit();
@@ -3487,7 +3478,7 @@ fn paintCells(win: vaxis.Window, cells: []const pardes.Cell, cols: u16, rows: u1
if (cell.default) continue;
win.writeCell(x, y, .{
.char = .{ .grapheme = cell.grapheme() },
- .style = vaxisStyle(cell.style),
+ .style = vaxis_input.style(cell.style),
});
}
}
@@ -3732,36 +3723,6 @@ const JumpTrail = struct {
}
};
-fn vaxisStyle(s: pardes.CellStyle) vaxis.Style {
- return .{
- .fg = vaxisColor(s.fg),
- .bg = vaxisColor(s.bg),
- .bold = s.bold,
- .dim = s.dim,
- .italic = s.italic,
- .blink = s.blink,
- .reverse = s.reverse,
- .invisible = s.invisible,
- .strikethrough = s.strikethrough,
- .ul_style = switch (s.ul) {
- .off => .off,
- .single => .single,
- .double => .double,
- .curly => .curly,
- .dotted => .dotted,
- .dashed => .dashed,
- },
- };
-}
-
-fn vaxisColor(c: pardes.Color) vaxis.Color {
- return switch (c) {
- .default => .default,
- .index => |i| .{ .index = i },
- .rgb => |rgb| .{ .rgb = rgb },
- };
-}
-
test "a jump leaves a trail of a few cells behind the cursor that fades in 120 ms" {
const gpa = std.testing.allocator;
const core = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 });