mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-22 09:40:25 +01:00
Close terminal on successful exit
This commit is contained in:
parent
ec0d4ddf43
commit
7c6300c8dc
3 changed files with 18 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
tool
|
||||
extends "res://addons/godot_xterm/nodes/terminal/terminal.gd"
|
||||
|
||||
signal exited(exit_code, signum)
|
||||
|
||||
var editor_settings: EditorSettings
|
||||
var timer := Timer.new()
|
||||
|
||||
|
@ -83,3 +85,8 @@ func _input(event):
|
|||
if event is InputEventKey:
|
||||
get_tree().set_input_as_handled()
|
||||
_gui_input(event)
|
||||
|
||||
|
||||
func _on_PTY_exited(exit_code: int, signum: int):
|
||||
print("exit_code: ", exit_code, " signum: ", signum)
|
||||
emit_signal("exited", exit_code, signum)
|
||||
|
|
|
@ -23,3 +23,5 @@ env = {
|
|||
"COLORTERM": "truecolor",
|
||||
"TERM": "xterm-256color"
|
||||
}
|
||||
|
||||
[connection signal="exited" from="PTY" to="." method="_on_PTY_exited"]
|
||||
|
|
|
@ -8,6 +8,7 @@ tool
|
|||
extends Control
|
||||
|
||||
const EditorTerminal := preload("./editor_terminal.tscn")
|
||||
const PTY := preload("../../nodes/pty/pty.gd")
|
||||
const TerminalSettings := preload("./settings/terminal_settings.gd")
|
||||
|
||||
const SETTINGS_FILE_PATH := "res://.gdxterm/settings.tres"
|
||||
|
@ -128,6 +129,7 @@ func _on_AddButton_pressed():
|
|||
terminal.editor_settings = editor_settings
|
||||
terminal.set_anchors_preset(PRESET_WIDE)
|
||||
terminal.connect("gui_input", self, "_on_TabContainer_gui_input")
|
||||
terminal.connect("exited", self, "_on_Terminal_exited", [terminal])
|
||||
tab_container.add_child(terminal)
|
||||
terminal.pty.fork(shell)
|
||||
terminal.grab_focus()
|
||||
|
@ -269,3 +271,10 @@ func _on_Panel_resized():
|
|||
func _on_SizeLabelTimer_timeout():
|
||||
if size_label:
|
||||
size_label.visible = false
|
||||
|
||||
|
||||
func _on_Terminal_exited(exit_code, signum, terminal):
|
||||
# Leave non-zero exit code terminals open in case they have some important
|
||||
# error information.
|
||||
if exit_code == 0:
|
||||
_on_Tabs_tab_close(terminal.get_index())
|
||||
|
|
Loading…
Reference in a new issue