From e7404200dd661b884e6b24db6df667959b97d509 Mon Sep 17 00:00:00 2001 From: bleeptrack Date: Tue, 6 Oct 2020 11:51:10 +0200 Subject: [PATCH] shortcut to delete words in terminal --- project.godot | 5 +++++ terminal.gd | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/project.godot b/project.godot index 444c39e..2430475 100644 --- a/project.godot +++ b/project.godot @@ -111,6 +111,11 @@ save={ "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":true,"meta":false,"command":true,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null) ] } +delete_word={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":true,"meta":false,"command":true,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null) + ] +} [network] diff --git a/terminal.gd b/terminal.gd index aafb5d4..67b1b1c 100644 --- a/terminal.gd +++ b/terminal.gd @@ -70,6 +70,16 @@ func _input(event): if completions.visible: completions.get_root().get_children().select(0) get_tree().set_input_as_handled() + if event.is_action_pressed("delete_word"): + var first_half = input.text.substr(0,input.caret_position) + var second_half = input.text.substr(input.caret_position) + + var idx = first_half.strip_edges(false, true).find_last(" ") + if idx > 0: + input.text = first_half.substr(0,idx+1) + second_half + input.caret_position = idx+1 + else: + input.text = "" + second_half func load_command(id): input.text = premade_commands[id]