refactor(terminal): render terminal panel as unfocused if outer terminal looses focus
This commit is contained in:
parent
581bbdb210
commit
c4f6b6c945
2 changed files with 12 additions and 2 deletions
|
|
@ -352,7 +352,7 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
|
||||||
const software_cursor = build_options.gui or !tui.config().enable_terminal_cursor;
|
const software_cursor = build_options.gui or !tui.config().enable_terminal_cursor;
|
||||||
const focused_cursor_color: ?[3]u8 = if (theme.editor_cursor.bg) |bg| RGB.to_u8s(RGB.from_u24(bg.color)) else null;
|
const focused_cursor_color: ?[3]u8 = if (theme.editor_cursor.bg) |bg| RGB.to_u8s(RGB.from_u24(bg.color)) else null;
|
||||||
const unfocused_cursor_color: ?[3]u8 = if (theme.editor_cursor_secondary.bg) |bg| RGB.to_u8s(RGB.from_u24(bg.color)) else focused_cursor_color;
|
const unfocused_cursor_color: ?[3]u8 = if (theme.editor_cursor_secondary.bg) |bg| RGB.to_u8s(RGB.from_u24(bg.color)) else focused_cursor_color;
|
||||||
self.vt.vt.draw(self.allocator, self.plane.window, self.focused, software_cursor, focused_cursor_color, unfocused_cursor_color) catch |e| {
|
self.vt.vt.draw(self.allocator, self.plane.window, self.focused and tui.terminal_has_focus(), software_cursor, focused_cursor_color, unfocused_cursor_color) catch |e| {
|
||||||
std.log.err("terminal_view: draw failed: {}", .{e});
|
std.log.err("terminal_view: draw failed: {}", .{e});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ keyboard_focus: ?Widget = null,
|
||||||
keyboard_focus_outer: ?Widget = null,
|
keyboard_focus_outer: ?Widget = null,
|
||||||
mini_mode_: ?MiniMode = null,
|
mini_mode_: ?MiniMode = null,
|
||||||
hover_focus: ?Widget = null,
|
hover_focus: ?Widget = null,
|
||||||
|
terminal_focus: bool = true,
|
||||||
last_hover_x: c_int = -1,
|
last_hover_x: c_int = -1,
|
||||||
last_hover_y: c_int = -1,
|
last_hover_y: c_int = -1,
|
||||||
commands: Commands = undefined,
|
commands: Commands = undefined,
|
||||||
|
|
@ -519,15 +520,19 @@ fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) !void {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (try m.match(.{"focus_in"})) {
|
if (try m.match(.{"focus_in"})) {
|
||||||
|
self.terminal_focus = true;
|
||||||
std.log.debug("focus_in", .{});
|
std.log.debug("focus_in", .{});
|
||||||
|
need_render(@src());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (try m.match(.{"focus_out"})) {
|
if (try m.match(.{"focus_out"})) {
|
||||||
|
self.terminal_focus = false;
|
||||||
std.log.debug("focus_out", .{});
|
std.log.debug("focus_out", .{});
|
||||||
self.clear_hover_focus(@src()) catch {};
|
self.clear_hover_focus(@src()) catch {};
|
||||||
self.last_hover_x = -1;
|
self.last_hover_x = -1;
|
||||||
self.last_hover_y = -1;
|
self.last_hover_y = -1;
|
||||||
|
need_render(@src());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -949,7 +954,7 @@ pub fn save_config() (root.ConfigDirError || root.ConfigWriteError)!void {
|
||||||
|
|
||||||
pub fn is_mainview_focused() bool {
|
pub fn is_mainview_focused() bool {
|
||||||
const self = current();
|
const self = current();
|
||||||
return self.mini_mode_ == null and self.input_mode_outer_ == null and !is_keyboard_focused();
|
return self.mini_mode_ == null and self.input_mode_outer_ == null and !is_keyboard_focused() and self.terminal_focus;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enter_overlay_mode(self: *Self, mode: type) command.Result {
|
fn enter_overlay_mode(self: *Self, mode: type) command.Result {
|
||||||
|
|
@ -2705,3 +2710,8 @@ pub fn jump_mode() bool {
|
||||||
const self = current();
|
const self = current();
|
||||||
return self.jump_mode_;
|
return self.jump_mode_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn terminal_has_focus() bool {
|
||||||
|
const self = current();
|
||||||
|
return self.terminal_focus;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue