feat: reload home screen on keybind namespace changes
This commit is contained in:
parent
bbd42fec16
commit
fac6e37d00
2 changed files with 13 additions and 3 deletions
|
@ -9,6 +9,7 @@ const Button = @import("Button.zig");
|
||||||
const Menu = @import("Menu.zig");
|
const Menu = @import("Menu.zig");
|
||||||
const tui = @import("tui.zig");
|
const tui = @import("tui.zig");
|
||||||
const command = @import("command");
|
const command = @import("command");
|
||||||
|
const keybind = @import("keybind");
|
||||||
|
|
||||||
const fonts = @import("fonts.zig");
|
const fonts = @import("fonts.zig");
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ commands: Commands = undefined,
|
||||||
menu: *Menu.State(*Self),
|
menu: *Menu.State(*Self),
|
||||||
menu_w: usize = 0,
|
menu_w: usize = 0,
|
||||||
max_desc_len: usize = 0,
|
max_desc_len: usize = 0,
|
||||||
|
input_namespace: []const u8,
|
||||||
|
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
|
@ -49,6 +51,7 @@ pub fn create(allocator: std.mem.Allocator, parent: Widget) !Widget {
|
||||||
.parent = parent.plane.*,
|
.parent = parent.plane.*,
|
||||||
.plane = n,
|
.plane = n,
|
||||||
.menu = try Menu.create(*Self, allocator, w, .{ .ctx = self, .on_render = menu_on_render }),
|
.menu = try Menu.create(*Self, allocator, w, .{ .ctx = self, .on_render = menu_on_render }),
|
||||||
|
.input_namespace = keybind.get_namespace(),
|
||||||
};
|
};
|
||||||
try self.commands.init(self);
|
try self.commands.init(self);
|
||||||
self.get_max_desc_len(keybind_mode.keybind_hints);
|
self.get_max_desc_len(keybind_mode.keybind_hints);
|
||||||
|
@ -148,6 +151,8 @@ fn menu_action(comptime command_name: []const u8) *const fn (_: **Menu.State(*Se
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
||||||
|
if (!std.mem.eql(u8, self.input_namespace, keybind.get_namespace()))
|
||||||
|
tp.self_pid().send(.{ "cmd", "show_home" }) catch {};
|
||||||
self.plane.set_base_style(theme.editor);
|
self.plane.set_base_style(theme.editor);
|
||||||
self.plane.erase();
|
self.plane.erase();
|
||||||
self.plane.home();
|
self.plane.home();
|
||||||
|
|
|
@ -687,9 +687,14 @@ fn show_home_async(_: *Self) void {
|
||||||
fn create_home(self: *Self) !void {
|
fn create_home(self: *Self) !void {
|
||||||
tui.reset_drag_context();
|
tui.reset_drag_context();
|
||||||
if (self.editor) |_| return;
|
if (self.editor) |_| return;
|
||||||
var home_widget = try home.create(self.allocator, Widget.to(self));
|
self.widgets.replace(
|
||||||
errdefer home_widget.deinit(self.allocator);
|
self.view_widget_idx,
|
||||||
self.widgets.replace(self.view_widget_idx, home_widget);
|
try Widget.empty(self.allocator, self.widgets_widget.plane.*, .dynamic),
|
||||||
|
);
|
||||||
|
self.widgets.replace(
|
||||||
|
self.view_widget_idx,
|
||||||
|
try home.create(self.allocator, Widget.to(self)),
|
||||||
|
);
|
||||||
tui.current().resize();
|
tui.current().resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue