@@ -45,29 +45,14 @@ func _ready():
45
45
history_position = game .state ["history" ].size ()
46
46
47
47
func _input (event ):
48
- if not input .has_focus ():
48
+ if not input .has_focus () or not event . is_pressed () :
49
49
return
50
50
51
- if game .state ["history" ].size () > 0 :
52
- if event .is_action_pressed ("ui_up" ):
53
- if history_position > 0 :
54
- history_position -= 1
55
- input .text = game .state ["history" ][history_position ]
56
- input .caret_position = input .text .length ()
57
- # This prevents the Input taking the arrow as a "skip to beginning" command.
58
- get_tree ().set_input_as_handled ()
59
- if event .is_action_pressed ("ui_down" ):
60
- if history_position < game .state ["history" ].size ()- 1 :
61
- history_position += 1
62
- input .text = game .state ["history" ][history_position ]
63
- input .caret_position = input .text .length ()
64
- get_tree ().set_input_as_handled ()
65
-
66
- if event .is_action_pressed ("tab_complete" ):
51
+ if event .is_action ("tab_complete" ):
67
52
if completions .visible :
68
53
completions .get_root ().get_children ().select (0 )
69
54
get_tree ().set_input_as_handled ()
70
- if event .is_action_pressed ("delete_word" ):
55
+ elif event .is_action ("delete_word" ):
71
56
var first_half = input .text .substr (0 ,input .caret_position )
72
57
var second_half = input .text .substr (input .caret_position )
73
58
@@ -77,9 +62,32 @@ func _input(event):
77
62
input .caret_position = idx + 1
78
63
else :
79
64
input .text = "" + second_half
80
- if event .is_action_pressed ("clear" ):
65
+ elif event .is_action ("clear" ):
81
66
clear ()
82
-
67
+ elif event .is_action ("ui_page_up" ):
68
+ var scroll = output .get_v_scroll ()
69
+ scroll .set_value (scroll .value - output .get_rect ().size .y / 2 )
70
+ elif event .is_action ("ui_page_down" ):
71
+ var scroll = output .get_v_scroll ()
72
+ scroll .set_value (scroll .value + output .get_rect ().size .y / 2 )
73
+ elif game .state ["history" ].size () > 0 :
74
+ if event .is_action ("ui_up" ):
75
+ if history_position > 0 :
76
+ history_position -= 1
77
+ input .text = game .state ["history" ][history_position ]
78
+ input .caret_position = input .text .length ()
79
+ # This prevents the Input taking the arrow as a "skip to beginning" command.
80
+ get_tree ().set_input_as_handled ()
81
+ elif event .is_action ("ui_down" ):
82
+ if history_position < game .state ["history" ].size ():
83
+ history_position += 1
84
+ if history_position == game .state ["history" ].size ():
85
+ input .text = ""
86
+ else :
87
+ input .text = game .state ["history" ][history_position ]
88
+ input .caret_position = input .text .length ()
89
+ get_tree ().set_input_as_handled ()
90
+
83
91
func load_command (id ):
84
92
input .text = premade_commands [id ]
85
93
input .caret_position = input .text .length ()
0 commit comments