summaryrefslogtreecommitdiff
path: root/src/panes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/panes.zig')
-rw-r--r--src/panes.zig42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/panes.zig b/src/panes.zig
index 6a5a2739..d72e1611 100644
--- a/src/panes.zig
+++ b/src/panes.zig
@@ -89,6 +89,8 @@ pub const Pane = struct {
rows: u16,
greet: bool = false,
pending_command: Terminal.PendingCommand = .{},
+ /// Native host queues the Linux v9fs launcher in this pane's initial shell.
+ v9fs_on_spawn: bool = false,
file: ?File.State = null,
image: ?Image.State = null,
pdf: PdfSlot = if (Pdf.enabled) null else {},
@@ -6290,8 +6292,46 @@ pub const Terminal = struct {
}
/// Encode one key for the program that owns a raw terminal and queue its pty
- /// write. Global chords and mode routing have already been handled by core.
+ /// write, respecting the application's keyboard protocol and terminal modes.
pub fn forwardKey(p: *Pardes, id: usize, key: Key) void {
+ if (comptime enabled) {
+ const pane = p.panes[id] orelse return;
+ const state = pane.terminal orelse return;
+ const input = ghostty_vt.input;
+ const physical: input.Key = switch (key.cp) {
+ Key.enter => .enter,
+ Key.backspace => .backspace,
+ Key.tab => .tab,
+ Key.escape => .escape,
+ Key.up => .arrow_up,
+ Key.down => .arrow_down,
+ Key.left => .arrow_left,
+ Key.right => .arrow_right,
+ Key.home => .home,
+ Key.end => .end,
+ Key.page_up => .page_up,
+ Key.page_down => .page_down,
+ Key.delete => .delete,
+ else => if (key.cp < 128) input.Key.fromASCII(@intCast(key.cp)) orelse .unidentified else .unidentified,
+ };
+ var utf8: [4]u8 = undefined;
+ const text_cp = if (key.shift and key.cp >= 'a' and key.cp <= 'z') key.cp - 'a' + 'A' else key.cp;
+ const text = if (key.text.len > 0) key.text else if (key.cp >= 32 and key.cp < Key.up and key.cp != Key.backspace)
+ utf8[0 .. std.unicode.utf8Encode(text_cp, &utf8) catch return]
+ else
+ "";
+ var buffer: [256]u8 = undefined;
+ var writer = std.Io.Writer.fixed(&buffer);
+ input.encodeKey(&writer, .{
+ .key = physical,
+ .mods = .{ .ctrl = key.ctrl, .alt = key.alt, .shift = key.shift },
+ .consumed_mods = .{ .shift = key.text.len > 0 and key.shift },
+ .utf8 = text,
+ .unshifted_codepoint = if (key.cp >= 'A' and key.cp <= 'Z') key.cp - 'A' + 'a' else if (key.cp < Key.up) key.cp else 0,
+ }, input.KeyEncodeOptions.fromTerminal(&state.vt)) catch return;
+ if (writer.end > 0) p.emit(.{ .write = .{ .pane = @intCast(id), .bytes = .from(writer.buffered()) } });
+ return;
+ }
var control: [1]u8 = undefined;
const bytes: ?[]const u8 = blk: {
if (key.ctrl) {