shortcut to delete words in terminal

This commit is contained in:
bleeptrack 2020-10-06 11:51:10 +02:00
parent c400653f9d
commit e7404200dd
2 changed files with 15 additions and 0 deletions

View file

@ -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]

View file

@ -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]