refactor: make focus_termimal a toggle
This commit is contained in:
parent
3d1658541a
commit
613b95c2af
2 changed files with 10 additions and 3 deletions
|
|
@ -982,10 +982,13 @@ const cmds = struct {
|
|||
pub const open_terminal_meta: Meta = .{ .description = "Open terminal", .arguments = &.{.string} };
|
||||
|
||||
pub fn focus_terminal(self: *Self, _: Ctx) Result {
|
||||
if (self.get_panel_view(terminal_view)) |vt|
|
||||
vt.focus()
|
||||
else
|
||||
if (self.get_panel_view(terminal_view)) |vt| {
|
||||
vt.toggle_focus();
|
||||
} else {
|
||||
try self.toggle_panel_view(terminal_view, .enable);
|
||||
if (self.get_panel_view(terminal_view)) |vt|
|
||||
vt.focus();
|
||||
}
|
||||
}
|
||||
pub const focus_terminal_meta: Meta = .{ .description = "Focus terminal panel" };
|
||||
|
||||
|
|
|
|||
|
|
@ -148,6 +148,10 @@ pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
|||
return true;
|
||||
}
|
||||
|
||||
pub fn toggle_focus(self: *Self) void {
|
||||
if (self.focused) self.unfocus() else self.focus();
|
||||
}
|
||||
|
||||
pub fn focus(self: *Self) void {
|
||||
self.focused = true;
|
||||
tui.set_keyboard_focus(Widget.to(self));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue