mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-22 01:30:25 +01:00
feat(editor): make editor terminal functional
This commit is contained in:
parent
ad2dc46414
commit
5c151c3244
2 changed files with 28 additions and 27 deletions
|
@ -13,7 +13,8 @@ var editor_settings: EditorSettings
|
||||||
func _set_terminal_colors(color_map: Dictionary) -> void:
|
func _set_terminal_colors(color_map: Dictionary) -> void:
|
||||||
for key in color_map.keys():
|
for key in color_map.keys():
|
||||||
var val: String = color_map[key]
|
var val: String = color_map[key]
|
||||||
var color: Color = editor_settings.get_setting("text_editor/highlighting/%s" % val)
|
var editor_color = editor_settings.get_setting("text_editor/theme/highlighting/%s" % val)
|
||||||
|
var color: Color = editor_color if editor_color else Color.BLACK
|
||||||
add_theme_color_override(key, color)
|
add_theme_color_override(key, color)
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,35 +27,35 @@ func _ready():
|
||||||
# better to use a dedicated terminal theme, rather than relying on this.
|
# better to use a dedicated terminal theme, rather than relying on this.
|
||||||
_set_terminal_colors(
|
_set_terminal_colors(
|
||||||
{
|
{
|
||||||
"ansi_0_color": "completion_background_color",
|
|
||||||
"ansi_1_color": "keyword_color",
|
|
||||||
"ansi_2_color": "gdscript/node_path_color",
|
|
||||||
"ansi_3_color": "string_color",
|
|
||||||
"ansi_4_color": "function_color",
|
|
||||||
"ansi_5_color": "symbol_color",
|
|
||||||
"ansi_6_color": "gdscript/function_definition_color",
|
|
||||||
"ansi_7_color": "text_color",
|
|
||||||
"ansi_8_color": "comment_color",
|
|
||||||
"ansi_9_color": "breakpoint_color",
|
|
||||||
"ansi_10_color": "base_type_color",
|
|
||||||
"ansi_11_color": "search_result_color",
|
|
||||||
"ansi_12_color": "member_variable_color",
|
|
||||||
"ansi_13_color": "code_folding_color",
|
|
||||||
"ansi_14_color": "user_type_color",
|
|
||||||
"ansi_15_color": "text_selected_color",
|
|
||||||
"background_color": "background_color",
|
"background_color": "background_color",
|
||||||
"foreground_color": "caret_color",
|
"foreground_color": "text_color",
|
||||||
|
"ansi_0_color": "caret_background_color",
|
||||||
|
"ansi_1_color": "brace_mismatch_color",
|
||||||
|
"ansi_2_color": "gdscript/node_reference_color",
|
||||||
|
"ansi_3_color": "executing_line_color",
|
||||||
|
"ansi_4_color": "bookmark_color",
|
||||||
|
"ansi_5_color": "control_flow_keyword_color",
|
||||||
|
"ansi_6_color": "engine_type_color",
|
||||||
|
"ansi_7_color": "comment_color",
|
||||||
|
"ansi_8_color": "completion_background_color",
|
||||||
|
"ansi_9_color": "keyword_color",
|
||||||
|
"ansi_10_color": "base_type_color",
|
||||||
|
"ansi_11_color": "string_color",
|
||||||
|
"ansi_12_color": "function_color",
|
||||||
|
"ansi_13_color": "gdscript/global_function_color",
|
||||||
|
"ansi_14_color": "gdscript/function_definition_color",
|
||||||
|
"ansi_15_color": "caret_color",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if has_focus() and event is InputEventKey and event.is_pressed():
|
if has_focus() and event is InputEventKey and event.is_pressed():
|
||||||
if event.ctrl_pressed and event.scancode in [KEY_PAGEUP, KEY_PAGEDOWN]:
|
if event.ctrl_pressed and event.keycode in [KEY_PAGEUP, KEY_PAGEDOWN]:
|
||||||
# Handled by switch tabs shortcut.
|
# Handled by switch tabs shortcut.
|
||||||
return
|
return
|
||||||
|
|
||||||
if event.control and event.shift:
|
if event.ctrl_pressed and event.shift_pressed:
|
||||||
# Not handled by terminal.
|
# Not handled by terminal.
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -70,8 +71,6 @@ func _input(event):
|
||||||
# "propagated shortcuts" consisting of an array of shortcut editor setting strings.
|
# "propagated shortcuts" consisting of an array of shortcut editor setting strings.
|
||||||
# For example "editor/save_scene" which saves the scene and by default maps to 'Ctrl + S'.
|
# For example "editor/save_scene" which saves the scene and by default maps to 'Ctrl + S'.
|
||||||
# Then any shortcut events listed here can be handled by the terminal *and* the editor.
|
# Then any shortcut events listed here can be handled by the terminal *and* the editor.
|
||||||
get_tree().set_input_as_handled()
|
|
||||||
_gui_input(event)
|
|
||||||
|
|
||||||
|
|
||||||
func _on_PTY_exited(exit_code: int, signum: int):
|
func _on_PTY_exited(exit_code: int, signum: int):
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://bkcyv0w3setep"]
|
[gd_scene load_steps=3 format=3 uid="uid://bkcyv0w3setep"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://addons/godot_xterm/editor_plugins/terminal/editor_terminal.gd" id="1"]
|
[ext_resource type="Script" path="res://addons/godot_xterm/editor_plugins/terminal/editor_terminal.gd" id="1"]
|
||||||
[ext_resource type="Theme" uid="uid://0gk8swmcldbg" path="res://themes/demo.tres" id="1_h7osn"]
|
[ext_resource type="Theme" uid="uid://0gk8swmcldbg" path="res://themes/demo.tres" id="1_h7osn"]
|
||||||
[ext_resource type="Script" path="res://addons/godot_xterm/pty.gd" id="2"]
|
|
||||||
|
|
||||||
[node name="Terminal" type="Terminal"]
|
[node name="Terminal" type="Terminal"]
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
|
@ -16,10 +15,13 @@ focus_mode = 1
|
||||||
theme = ExtResource("1_h7osn")
|
theme = ExtResource("1_h7osn")
|
||||||
script = ExtResource("1")
|
script = ExtResource("1")
|
||||||
|
|
||||||
[node name="PTY" type="Node" parent="."]
|
[node name="PTY" type="PTY" parent="."]
|
||||||
script = ExtResource("2")
|
cols = 128
|
||||||
|
rows = 32
|
||||||
terminal_path = NodePath("..")
|
terminal_path = NodePath("..")
|
||||||
|
|
||||||
[node name="Bell" type="AudioStreamPlayer" parent="."]
|
[node name="Bell" type="AudioStreamPlayer" parent="."]
|
||||||
|
|
||||||
[connection signal="exited" from="PTY" to="." method="_on_PTY_exited"]
|
[connection signal="data_sent" from="." to="PTY" method="write"]
|
||||||
|
[connection signal="size_changed" from="." to="PTY" method="resizev"]
|
||||||
|
[connection signal="data_received" from="PTY" to="." method="write"]
|
||||||
|
|
Loading…
Reference in a new issue