reload_config keybinding (defaults to ctrl+alt+super+space)

This commit is contained in:
Mitchell Hashimoto
2023-03-13 22:00:10 -07:00
parent a9928cfb90
commit f5c1dfa374
4 changed files with 20 additions and 0 deletions

View File

@ -135,7 +135,9 @@ fn drainMailbox(self: *App, rt_app: *apprt.App) !void {
}
fn reloadConfig(self: *App, rt_app: *apprt.App) !void {
log.debug("reloading configuration", .{});
if (try rt_app.reloadConfig()) |new| {
log.debug("new configuration received, applying", .{});
try self.updateConfig(new);
}
}

View File

@ -852,6 +852,12 @@ pub fn keyCallback(
.unbind => unreachable,
.ignore => {},
.reload_config => {
_ = self.app_mailbox.push(.{
.reload_config = {},
}, .{ .instant = {} });
},
.csi => |data| {
_ = self.io_thread.mailbox.push(.{
.write_stable = "\x1B[",

View File

@ -239,6 +239,12 @@ pub const Config = struct {
const alloc = result._arena.?.allocator();
// Add our default keybindings
try result.keybind.set.put(
alloc,
.{ .key = .space, .mods = .{ .super = true, .alt = true, .ctrl = true } },
.{ .reload_config = {} },
);
{
// On macOS we default to super but Linux ctrl+shift since
// ctrl+c is to kill the process.

View File

@ -187,6 +187,12 @@ pub const Action = union(enum) {
/// Focus on a split in a given direction.
goto_split: SplitFocusDirection,
/// Reload the configuration. The exact meaning depends on the app runtime
/// in use but this usually involves re-reading the configuration file
/// and applying any changes. Note that not all changes can be applied at
/// runtime.
reload_config: void,
/// Close the current "surface", whether that is a window, tab, split,
/// etc. This only closes ONE surface.
close_surface: void,