update our default bindings that are performable

This commit is contained in:
Mitchell Hashimoto
2025-01-02 15:49:35 -08:00
parent 95b73f197f
commit e6399c947a
2 changed files with 24 additions and 18 deletions

View File

@ -1156,7 +1156,6 @@ pub fn updateConfig(
} }
// If we are in the middle of a key sequence, clear it. // If we are in the middle of a key sequence, clear it.
self.keyboard.bindings = null;
self.endKeySequence(.drop, .free); self.endKeySequence(.drop, .free);
// Before sending any other config changes, we give the renderer a new font // Before sending any other config changes, we give the renderer a new font
@ -1853,9 +1852,6 @@ fn maybeHandleBinding(
if (self.keyboard.bindings != null and if (self.keyboard.bindings != null and
!event.key.modifier()) !event.key.modifier())
{ {
// Reset to the root set
self.keyboard.bindings = null;
// Encode everything up to this point // Encode everything up to this point
self.endKeySequence(.flush, .retain); self.endKeySequence(.flush, .retain);
} }
@ -1947,10 +1943,7 @@ fn maybeHandleBinding(
// If we're in a sequence, we treat this as if we pressed a key // If we're in a sequence, we treat this as if we pressed a key
// that doesn't exist in the sequence. Reset our sequence and flush // that doesn't exist in the sequence. Reset our sequence and flush
// any queued events. // any queued events.
if (self.keyboard.bindings != null) {
self.keyboard.bindings = null;
self.endKeySequence(.flush, .retain); self.endKeySequence(.flush, .retain);
}
return null; return null;
} }
@ -1958,7 +1951,7 @@ fn maybeHandleBinding(
// If we consume this event, then we are done. If we don't consume // If we consume this event, then we are done. If we don't consume
// it, we processed the action but we still want to process our // it, we processed the action but we still want to process our
// encodings, too. // encodings, too.
if (performed and consumed) { if (consumed) {
// If we had queued events, we deinit them since we consumed // If we had queued events, we deinit them since we consumed
self.endKeySequence(.drop, .retain); self.endKeySequence(.drop, .retain);
@ -2000,6 +1993,10 @@ fn endKeySequence(
); );
}; };
// No matter what we clear our current binding set. This restores
// the set we look at to the root set.
self.keyboard.bindings = null;
if (self.keyboard.queued.items.len > 0) { if (self.keyboard.queued.items.len > 0) {
switch (action) { switch (action) {
.flush => for (self.keyboard.queued.items) |write_req| { .flush => for (self.keyboard.queued.items) |write_req| {

View File

@ -2133,45 +2133,53 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
); );
// Expand Selection // Expand Selection
try result.keybind.set.put( try result.keybind.set.putFlags(
alloc, alloc,
.{ .key = .{ .translated = .left }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .left }, .mods = .{ .shift = true } },
.{ .adjust_selection = .left }, .{ .adjust_selection = .left },
.{ .performable = true },
); );
try result.keybind.set.put( try result.keybind.set.putFlags(
alloc, alloc,
.{ .key = .{ .translated = .right }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .right }, .mods = .{ .shift = true } },
.{ .adjust_selection = .right }, .{ .adjust_selection = .right },
.{ .performable = true },
); );
try result.keybind.set.put( try result.keybind.set.putFlags(
alloc, alloc,
.{ .key = .{ .translated = .up }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .up }, .mods = .{ .shift = true } },
.{ .adjust_selection = .up }, .{ .adjust_selection = .up },
.{ .performable = true },
); );
try result.keybind.set.put( try result.keybind.set.putFlags(
alloc, alloc,
.{ .key = .{ .translated = .down }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .down }, .mods = .{ .shift = true } },
.{ .adjust_selection = .down }, .{ .adjust_selection = .down },
.{ .performable = true },
); );
try result.keybind.set.put( try result.keybind.set.putFlags(
alloc, alloc,
.{ .key = .{ .translated = .page_up }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .page_up }, .mods = .{ .shift = true } },
.{ .adjust_selection = .page_up }, .{ .adjust_selection = .page_up },
.{ .performable = true },
); );
try result.keybind.set.put( try result.keybind.set.putFlags(
alloc, alloc,
.{ .key = .{ .translated = .page_down }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .page_down }, .mods = .{ .shift = true } },
.{ .adjust_selection = .page_down }, .{ .adjust_selection = .page_down },
.{ .performable = true },
); );
try result.keybind.set.put( try result.keybind.set.putFlags(
alloc, alloc,
.{ .key = .{ .translated = .home }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .home }, .mods = .{ .shift = true } },
.{ .adjust_selection = .home }, .{ .adjust_selection = .home },
.{ .performable = true },
); );
try result.keybind.set.put( try result.keybind.set.putFlags(
alloc, alloc,
.{ .key = .{ .translated = .end }, .mods = .{ .shift = true } }, .{ .key = .{ .translated = .end }, .mods = .{ .shift = true } },
.{ .adjust_selection = .end }, .{ .adjust_selection = .end },
.{ .performable = true },
); );
// Tabs common to all platforms // Tabs common to all platforms
@ -2421,10 +2429,11 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
.{ .key = .{ .translated = .q }, .mods = .{ .super = true } }, .{ .key = .{ .translated = .q }, .mods = .{ .super = true } },
.{ .quit = {} }, .{ .quit = {} },
); );
try result.keybind.set.put( try result.keybind.set.putFlags(
alloc, alloc,
.{ .key = .{ .translated = .k }, .mods = .{ .super = true } }, .{ .key = .{ .translated = .k }, .mods = .{ .super = true } },
.{ .clear_screen = {} }, .{ .clear_screen = {} },
.{ .performable = true },
); );
try result.keybind.set.put( try result.keybind.set.put(
alloc, alloc,