mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-22 09:40:25 +01:00
More shortcuts
- Copy - Paste - Kill
This commit is contained in:
parent
6106b7f100
commit
703eb68f11
6 changed files with 80 additions and 3 deletions
|
@ -1,3 +1,11 @@
|
||||||
[gd_resource type="ShortCut" format=2]
|
[gd_resource type="ShortCut" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[sub_resource type="InputEventKey" id=1]
|
||||||
|
shift = true
|
||||||
|
control = true
|
||||||
|
command = true
|
||||||
|
pressed = true
|
||||||
|
scancode = 67
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
|
shortcut = SubResource( 1 )
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
[gd_resource type="ShortCut" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[sub_resource type="InputEventKey" id=1]
|
||||||
|
shift = true
|
||||||
|
control = true
|
||||||
|
command = true
|
||||||
|
pressed = true
|
||||||
|
scancode = 88
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
shortcut = SubResource( 1 )
|
|
@ -1,3 +1,11 @@
|
||||||
[gd_resource type="ShortCut" format=2]
|
[gd_resource type="ShortCut" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[sub_resource type="InputEventKey" id=1]
|
||||||
|
shift = true
|
||||||
|
control = true
|
||||||
|
command = true
|
||||||
|
pressed = true
|
||||||
|
scancode = 86
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
|
shortcut = SubResource( 1 )
|
||||||
|
|
|
@ -13,6 +13,7 @@ enum CWDType {
|
||||||
### Shortcuts ###
|
### Shortcuts ###
|
||||||
|
|
||||||
export (ShortCut) var new_terminal_shortcut = preload("./default_new_terminal_shortcut.tres")
|
export (ShortCut) var new_terminal_shortcut = preload("./default_new_terminal_shortcut.tres")
|
||||||
|
export (ShortCut) var kill_terminal_shortcut = preload("./default_kill_terminal_shortcut.tres")
|
||||||
export (ShortCut) var copy_shortcut = preload("./default_copy_shortcut.tres")
|
export (ShortCut) var copy_shortcut = preload("./default_copy_shortcut.tres")
|
||||||
export (ShortCut) var paste_shortcut = preload("./default_paste_shortcut.tres")
|
export (ShortCut) var paste_shortcut = preload("./default_paste_shortcut.tres")
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,24 @@ func _update_settings() -> void:
|
||||||
|
|
||||||
tabs.tab_close_display_policy = Tabs.CLOSE_BUTTON_SHOW_ALWAYS
|
tabs.tab_close_display_policy = Tabs.CLOSE_BUTTON_SHOW_ALWAYS
|
||||||
|
|
||||||
|
# Update shortcuts.
|
||||||
|
if _settings.new_terminal_shortcut:
|
||||||
|
terminal_popup_menu.set_item_shortcut(
|
||||||
|
TerminalPopupMenuOptions.NEW_TERMINAL, _settings.new_terminal_shortcut, true
|
||||||
|
)
|
||||||
|
if _settings.kill_terminal_shortcut:
|
||||||
|
terminal_popup_menu.set_item_shortcut(
|
||||||
|
TerminalPopupMenuOptions.KILL_TERMINAL, _settings.kill_terminal_shortcut, false
|
||||||
|
)
|
||||||
|
if _settings.copy_shortcut:
|
||||||
|
terminal_popup_menu.set_item_shortcut(
|
||||||
|
TerminalPopupMenuOptions.COPY, _settings.copy_shortcut, false
|
||||||
|
)
|
||||||
|
if _settings.paste_shortcut:
|
||||||
|
terminal_popup_menu.set_item_shortcut(
|
||||||
|
TerminalPopupMenuOptions.PASTE, _settings.paste_shortcut, false
|
||||||
|
)
|
||||||
|
|
||||||
_update_terminal_tabs()
|
_update_terminal_tabs()
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,6 +137,11 @@ func _on_Tabs_tab_changed(tab_index):
|
||||||
func _on_Tabs_tab_close(tab_index):
|
func _on_Tabs_tab_close(tab_index):
|
||||||
tabs.remove_tab(tab_index)
|
tabs.remove_tab(tab_index)
|
||||||
tab_container.get_child(tab_index).queue_free()
|
tab_container.get_child(tab_index).queue_free()
|
||||||
|
|
||||||
|
# Switch focus to the next active tab.
|
||||||
|
if tabs.get_tab_count() > 0:
|
||||||
|
tab_container.get_child(tabs.current_tab).grab_focus()
|
||||||
|
|
||||||
_update_terminal_tabs()
|
_update_terminal_tabs()
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,12 +163,36 @@ func _input(event: InputEvent) -> void:
|
||||||
if not _settings or not event.is_pressed():
|
if not _settings or not event.is_pressed():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Global shortcut to open new terminal and make terminal panel visible.
|
||||||
if _settings.new_terminal_shortcut and _settings.new_terminal_shortcut.shortcut:
|
if _settings.new_terminal_shortcut and _settings.new_terminal_shortcut.shortcut:
|
||||||
if event.shortcut_match(_settings.new_terminal_shortcut.shortcut):
|
if event.shortcut_match(_settings.new_terminal_shortcut.shortcut):
|
||||||
get_tree().set_input_as_handled()
|
get_tree().set_input_as_handled()
|
||||||
editor_plugin.make_bottom_panel_item_visible(self)
|
editor_plugin.make_bottom_panel_item_visible(self)
|
||||||
_on_AddButton_pressed()
|
_on_AddButton_pressed()
|
||||||
|
|
||||||
|
# Non-global shortcuts, only applied if terminal is active and focused.
|
||||||
|
if (
|
||||||
|
tabs.get_tab_count() > 0 and tab_container.get_child(tabs.current_tab).has_focus()
|
||||||
|
or terminal_popup_menu.has_focus()
|
||||||
|
):
|
||||||
|
# Kill terminal.
|
||||||
|
if _settings.kill_terminal_shortcut and _settings.kill_terminal_shortcut.shortcut:
|
||||||
|
if event.shortcut_match(_settings.kill_terminal_shortcut.shortcut):
|
||||||
|
get_tree().set_input_as_handled()
|
||||||
|
_on_TerminalPopupMenu_id_pressed(TerminalPopupMenuOptions.KILL_TERMINAL)
|
||||||
|
|
||||||
|
# Copy.
|
||||||
|
if _settings.copy_shortcut and _settings.copy_shortcut.shortcut:
|
||||||
|
if event.shortcut_match(_settings.copy_shortcut.shortcut):
|
||||||
|
get_tree().set_input_as_handled()
|
||||||
|
_on_TerminalPopupMenu_id_pressed(TerminalPopupMenuOptions.COPY)
|
||||||
|
|
||||||
|
# Paste.
|
||||||
|
if _settings.paste_shortcut and _settings.paste_shortcut.shortcut:
|
||||||
|
if event.shortcut_match(_settings.paste_shortcut.shortcut):
|
||||||
|
get_tree().set_input_as_handled()
|
||||||
|
_on_TerminalPopupMenu_id_pressed(TerminalPopupMenuOptions.PASTE)
|
||||||
|
|
||||||
|
|
||||||
func _on_TabContainer_gui_input(event):
|
func _on_TabContainer_gui_input(event):
|
||||||
if event is InputEventMouseButton and event.button_index == BUTTON_RIGHT:
|
if event is InputEventMouseButton and event.button_index == BUTTON_RIGHT:
|
||||||
|
@ -161,6 +208,8 @@ func _on_TerminalPopupMenu_id_pressed(id):
|
||||||
if tabs.get_tab_count() > 0:
|
if tabs.get_tab_count() > 0:
|
||||||
var terminal = tab_container.get_child(tab_container.current_tab)
|
var terminal = tab_container.get_child(tab_container.current_tab)
|
||||||
match id:
|
match id:
|
||||||
|
TerminalPopupMenuOptions.COPY:
|
||||||
|
OS.clipboard = terminal.copy_selection()
|
||||||
TerminalPopupMenuOptions.PASTE:
|
TerminalPopupMenuOptions.PASTE:
|
||||||
for i in OS.clipboard.length():
|
for i in OS.clipboard.length():
|
||||||
var event = InputEventKey.new()
|
var event = InputEventKey.new()
|
||||||
|
|
|
@ -107,7 +107,7 @@ margin_right = 193.0
|
||||||
margin_bottom = 160.0
|
margin_bottom = 160.0
|
||||||
size_flags_horizontal = 0
|
size_flags_horizontal = 0
|
||||||
size_flags_vertical = 0
|
size_flags_vertical = 0
|
||||||
items = [ "New Terminal [Ctrl+Shift+T]", null, 0, false, false, 0, 0, null, "", false, "", null, 0, false, true, 1, 0, null, "", true, "Copy [Ctrl+Shift+C]", null, 0, false, false, 2, 0, null, "", false, "Paste [Ctrl+Shift+V]", null, 0, false, false, 3, 0, null, "", false, "Select All", null, 0, false, true, 4, 0, null, "", false, "", null, 0, false, false, 5, 0, null, "", true, "Clear", null, 0, false, false, 6, 0, null, "", false, "Kill Terminal", null, 0, false, false, 7, 0, null, "", false ]
|
items = [ "New Terminal", null, 0, false, false, 0, 0, null, "", false, "", null, 0, false, true, 1, 0, null, "", true, "Copy", null, 0, false, false, 2, 0, null, "", false, "Paste", null, 0, false, false, 3, 0, null, "", false, "Select All", null, 0, false, true, 4, 0, null, "", false, "", null, 0, false, false, 5, 0, null, "", true, "Clear", null, 0, false, false, 6, 0, null, "", false, "Kill Terminal", null, 0, false, false, 7, 0, null, "", false ]
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue