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]