mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
Merge pull request #1044 from mitchellh/keybind-clear
config: keybind = clear clears unmaps all keybinds
This commit is contained in:
@ -462,6 +462,13 @@ class: ?[:0]const u8 = null,
|
|||||||
/// send a string value that includes spaces, wrap the entire
|
/// send a string value that includes spaces, wrap the entire
|
||||||
/// trigger/action in double quotes. Example: --keybind="up=csi:A B"
|
/// trigger/action in double quotes. Example: --keybind="up=csi:A B"
|
||||||
///
|
///
|
||||||
|
/// There are some additional special values that can be specified for
|
||||||
|
/// keybind:
|
||||||
|
///
|
||||||
|
/// - `keybind = clear` will clear all set keybindings. Warning: this
|
||||||
|
/// removes ALL keybindings up to this point, including the default
|
||||||
|
/// keybindings.
|
||||||
|
///
|
||||||
keybind: Keybinds = .{},
|
keybind: Keybinds = .{},
|
||||||
|
|
||||||
/// Window padding. This applies padding between the terminal cells and
|
/// Window padding. This applies padding between the terminal cells and
|
||||||
@ -2307,6 +2314,17 @@ pub const Keybinds = struct {
|
|||||||
};
|
};
|
||||||
errdefer if (copy) |v| alloc.free(v);
|
errdefer if (copy) |v| alloc.free(v);
|
||||||
|
|
||||||
|
// Check for special values
|
||||||
|
if (std.mem.eql(u8, value, "clear")) {
|
||||||
|
// We don't clear the memory because its in the arena and unlikely
|
||||||
|
// to be free-able anyways (since arenas can only clear the last
|
||||||
|
// allocated value). This isn't a memory leak because the arena
|
||||||
|
// will be freed when the config is freed.
|
||||||
|
log.info("config has 'keybind = clear', all keybinds cleared", .{});
|
||||||
|
self.set = .{};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const binding = try inputpkg.Binding.parse(value);
|
const binding = try inputpkg.Binding.parse(value);
|
||||||
switch (binding.action) {
|
switch (binding.action) {
|
||||||
.unbind => self.set.remove(binding.trigger),
|
.unbind => self.set.remove(binding.trigger),
|
||||||
|
Reference in New Issue
Block a user