@@ -94,54 +94,55 @@ private void MoveCursorToPos(int position)
94
94
95
95
private void HandleTab ( )
96
96
{
97
- if ( KeyDown ( "tab" ) ) {
98
- if ( input != "" ) { // don't do anything if the input field is still blank.
99
- List < string > search = consoleCommandsRepository . SearchCommands ( input ) ;
100
- if ( search . Count == 0 ) { // nothing found
101
- consoleLog . Log ( "No command start with \" " + input + "\" ." ) ;
102
- input = "" ; // clear input
103
- return ;
104
- } else if ( search . Count == 1 ) {
105
- input = search [ 0 ] + " " ; // only found one command - type it in for the guy
106
- MoveCursorToPos ( input . Length ) ;
107
- } else {
108
- consoleLog . Log ( "Commands starting with \" " + input + "\" :" ) ;
109
- string largestMatch = search [ 0 ] ; // keep track of the largest substring that matches all searches
110
- foreach ( string command in search )
111
- {
112
- consoleLog . Log ( command ) ;
113
- largestMatch = LargestSubString ( largestMatch , command ) ;
114
- }
115
- input = largestMatch ;
116
- MoveCursorToPos ( input . Length ) ;
97
+ if ( ! KeyDown ( "tab" ) )
98
+ return ;
99
+
100
+ if ( input != "" ) { // don't do anything if the input field is still blank.
101
+ List < string > search = consoleCommandsRepository . SearchCommands ( input ) ;
102
+ if ( search . Count == 0 ) { // nothing found
103
+ consoleLog . Log ( "No command start with \" " + input + "\" ." ) ;
104
+ input = "" ; // clear input
105
+ } else if ( search . Count == 1 ) {
106
+ input = search [ 0 ] + " " ; // only found one command - type it in for the guy
107
+ MoveCursorToPos ( input . Length ) ;
108
+ } else {
109
+ consoleLog . Log ( "Commands starting with \" " + input + "\" :" ) ;
110
+ string largestMatch = search [ 0 ] ; // keep track of the largest substring that matches all searches
111
+ foreach ( string command in search )
112
+ {
113
+ consoleLog . Log ( command ) ;
114
+ largestMatch = LargestSubString ( largestMatch , command ) ;
117
115
}
116
+ input = largestMatch ;
117
+ MoveCursorToPos ( input . Length ) ;
118
118
}
119
119
}
120
120
}
121
121
122
122
private void HandleUp ( )
123
123
{
124
- if ( KeyDown ( "up" ) ) {
125
- consoleHistoryPosition += 1 ;
126
- if ( consoleHistoryPosition > consoleHistoryCommands . Count - 1 ) consoleHistoryPosition = consoleHistoryCommands . Count - 1 ;
127
- input = consoleHistoryCommands [ consoleHistoryPosition ] ;
128
- fixPositionNextFrame = true ;
129
- //MoveCursorToPos(input.Length) ;
130
- }
124
+ if ( ! KeyDown ( "up" ) )
125
+ return ;
126
+
127
+ consoleHistoryPosition += 1 ;
128
+ if ( consoleHistoryPosition > consoleHistoryCommands . Count - 1 ) consoleHistoryPosition = consoleHistoryCommands . Count - 1 ;
129
+ input = consoleHistoryCommands [ consoleHistoryPosition ] ;
130
+ fixPositionNextFrame = true ;
131
131
}
132
132
133
133
private void HandleDown ( )
134
134
{
135
- if ( KeyDown ( "down" ) ) {
136
- consoleHistoryPosition -= 1 ;
137
- if ( consoleHistoryPosition < 0 ) {
138
- consoleHistoryPosition = - 1 ;
139
- input = "" ;
140
- }
141
- else
142
- input = consoleHistoryCommands [ consoleHistoryPosition ] ;
143
- MoveCursorToPos ( input . Length ) ;
135
+ if ( ! KeyDown ( "down" ) )
136
+ return ;
137
+
138
+ consoleHistoryPosition -= 1 ;
139
+ if ( consoleHistoryPosition < 0 ) {
140
+ consoleHistoryPosition = - 1 ;
141
+ input = "" ;
142
+ } else {
143
+ input = consoleHistoryCommands [ consoleHistoryPosition ] ;
144
144
}
145
+ MoveCursorToPos ( input . Length ) ;
145
146
}
146
147
147
148
private void HandleSubmit ( ) {
0 commit comments