refactor(terminal): close terminal on escape keypress if exited
This commit is contained in:
parent
57aae0d45c
commit
0a37c2b05b
1 changed files with 12 additions and 6 deletions
|
|
@ -155,12 +155,18 @@ pub fn receive(self: *Self, from: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
||||||
.mods = @bitCast(modifiers),
|
.mods = @bitCast(modifiers),
|
||||||
.text = if (text.len > 0) text else null,
|
.text = if (text.len > 0) text else null,
|
||||||
};
|
};
|
||||||
if (self.vt.process_exited and (keypress == input.key.enter or keypress == '\r')) {
|
if (self.vt.process_exited) {
|
||||||
self.vt.process_exited = false;
|
if (keypress == input.key.enter) {
|
||||||
self.restart() catch |e|
|
self.vt.process_exited = false;
|
||||||
std.log.err("terminal_view: restart failed: {}", .{e});
|
self.restart() catch |e|
|
||||||
tui.need_render(@src());
|
std.log.err("terminal_view: restart failed: {}", .{e});
|
||||||
return true;
|
tui.need_render(@src());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (keypress == input.key.escape) {
|
||||||
|
tp.self_pid().send(.{ "cmd", "close_terminal", .{} }) catch {};
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.vt.vt.scrollToBottom();
|
self.vt.vt.scrollToBottom();
|
||||||
self.vt.vt.update(.{ .key_press = key }) catch |e|
|
self.vt.vt.update(.{ .key_press = key }) catch |e|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue