mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
feat: add new noop action for key bindings (#4680)
Introduces a “noop” action for key bindings, allowing shortcuts to be defined without triggering any action, while still passing the key event to the pseudoterminal (pty). - Unlike “ignore,” it does not block the key event from reaching the pty. - Unlike “unbind,” it overrides OS-level shortcuts, effectively disabling the default OS-level action.
This commit is contained in:
@ -437,6 +437,7 @@ pub fn performAction(
|
|||||||
switch (action) {
|
switch (action) {
|
||||||
.unbind => unreachable,
|
.unbind => unreachable,
|
||||||
.ignore => {},
|
.ignore => {},
|
||||||
|
.noop => {},
|
||||||
.quit => try rt_app.performAction(.app, .quit, {}),
|
.quit => try rt_app.performAction(.app, .quit, {}),
|
||||||
.new_window => try self.newWindow(rt_app, .{ .parent = null }),
|
.new_window => try self.newWindow(rt_app, .{ .parent = null }),
|
||||||
.open_config => try rt_app.performAction(.app, .open_config, {}),
|
.open_config => try rt_app.performAction(.app, .open_config, {}),
|
||||||
@ -581,3 +582,4 @@ pub const Wasm = if (!builtin.target.isWasm()) struct {} else struct {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1968,7 +1968,10 @@ fn maybeHandleBinding(
|
|||||||
|
|
||||||
// If we have the performable flag and the action was not performed,
|
// If we have the performable flag and the action was not performed,
|
||||||
// then we act as though a binding didn't exist.
|
// then we act as though a binding didn't exist.
|
||||||
if (leaf.flags.performable and !performed) {
|
if (leaf.flags.performable and !performed or switch (action) {
|
||||||
|
.noop => true,
|
||||||
|
else => false,
|
||||||
|
}) {
|
||||||
// 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.
|
||||||
@ -4643,3 +4646,4 @@ fn presentSurface(self: *Surface) !void {
|
|||||||
{},
|
{},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,6 +229,11 @@ pub const Action = union(enum) {
|
|||||||
/// assertion to verify this.
|
/// assertion to verify this.
|
||||||
unbind: void,
|
unbind: void,
|
||||||
|
|
||||||
|
/// This action is similar to `unbind` but it is used to flag that the
|
||||||
|
/// binding should be removed from the set and the key should be unbound
|
||||||
|
/// from the system.
|
||||||
|
noop: void,
|
||||||
|
|
||||||
/// Send a CSI sequence. The value should be the CSI sequence without the
|
/// Send a CSI sequence. The value should be the CSI sequence without the
|
||||||
/// CSI header (`ESC [` or `\x1b[`).
|
/// CSI header (`ESC [` or `\x1b[`).
|
||||||
csi: []const u8,
|
csi: []const u8,
|
||||||
@ -685,6 +690,7 @@ pub const Action = union(enum) {
|
|||||||
// Doesn't really matter, so we'll see app.
|
// Doesn't really matter, so we'll see app.
|
||||||
.ignore,
|
.ignore,
|
||||||
.unbind,
|
.unbind,
|
||||||
|
.noop,
|
||||||
=> .app,
|
=> .app,
|
||||||
|
|
||||||
// Obviously app actions.
|
// Obviously app actions.
|
||||||
|
Reference in New Issue
Block a user