From 3b5a9caff5fbe1dc0d48190fd66c5e7a872ed5c4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 24 Aug 2022 11:16:36 -0700 Subject: [PATCH] hook up more control keys: home, end, page up, page down --- TODO.md | 2 -- src/Window.zig | 4 ++++ src/config.zig | 4 ++++ src/input/key.zig | 4 ++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index 1b0d10762..87902f83d 100644 --- a/TODO.md +++ b/TODO.md @@ -27,8 +27,6 @@ Improvements: * double-click to select a word * triple-click to select a line * shift-click and drag to continue selection -* arrow keys do nothing, should send proper codes -* home/end should scroll to top/bottom of scrollback Major Features: diff --git a/src/Window.zig b/src/Window.zig index b2c98a30a..5eb806e20 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -534,6 +534,10 @@ fn keyCallback( .down => .down, .right => .right, .left => .left, + .home => .home, + .end => .end, + .page_up => .page_up, + .page_down => .page_down, else => .invalid, }, }; diff --git a/src/config.zig b/src/config.zig index 87f773d3f..c8a622ce7 100644 --- a/src/config.zig +++ b/src/config.zig @@ -92,6 +92,10 @@ pub const Config = struct { try result.keybind.set.put(alloc, .{ .key = .down }, .{ .csi = "B" }); try result.keybind.set.put(alloc, .{ .key = .right }, .{ .csi = "C" }); try result.keybind.set.put(alloc, .{ .key = .left }, .{ .csi = "D" }); + try result.keybind.set.put(alloc, .{ .key = .home }, .{ .csi = "H" }); + try result.keybind.set.put(alloc, .{ .key = .end }, .{ .csi = "F" }); + try result.keybind.set.put(alloc, .{ .key = .page_up }, .{ .csi = "5~" }); + try result.keybind.set.put(alloc, .{ .key = .page_down }, .{ .csi = "6~" }); return result; } diff --git a/src/input/key.zig b/src/input/key.zig index 940e7b570..2bb40b4c7 100644 --- a/src/input/key.zig +++ b/src/input/key.zig @@ -54,6 +54,10 @@ pub const Key = enum { down, right, left, + home, + end, + page_up, + page_down, // To support more keys (there are obviously more!) add them here // and ensure the mapping is up to date in the Window key handler.