Changeset 2046
- Timestamp:
- 10/20/15 10:15:31 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ConsoleTabComposite.java
r1243 r2046 53 53 54 54 protected java.util.List<String> commandHistory = new LinkedList<String>(); 55 56 protected int commandHistoryIndex = 0; 55 57 56 58 protected Text textCommand; … … 73 75 public void commandNotification(String command) { 74 76 commandHistory.add(command); 77 commandHistoryIndex = commandHistory.size(); 75 78 } 76 79 … … 183 186 184 187 private void setToPreviousCommand() { 185 String currentCommand = textCommand.getText().trim(); 186 187 int index = 0; 188 for (index = 0; index < commandHistory.size(); index++) { 189 if (currentCommand.equals(commandHistory.get(index))) { 190 break; 191 } 192 } 193 194 if (index > 0) { 195 textCommand.setText(commandHistory.get(index - 1)); 196 textCommand.setSelection(commandHistory.get(index - 1).length()); 188 if (commandHistoryIndex > 0) { 189 commandHistoryIndex--; 190 191 textCommand.setText(commandHistory.get(commandHistoryIndex)); 192 textCommand.setSelection(commandHistory.get(commandHistoryIndex).length()); 197 193 } 198 194 } 199 195 200 196 private void setToNextCommand() { 201 String currentCommand = textCommand.getText().trim(); 202 203 int index = 0; 204 for (index = 0; index < commandHistory.size(); index++) { 205 if (currentCommand.equals(commandHistory.get(index))) { 206 break; 207 } 208 } 209 210 if (index < (commandHistory.size() - 1)) { 211 textCommand.setText(commandHistory.get(index + 1)); 212 textCommand.setSelection(commandHistory.get(index + 1).length()); 197 if (commandHistoryIndex < (commandHistory.size() - 1)) { 198 commandHistoryIndex++; 199 200 textCommand.setText(commandHistory.get(commandHistoryIndex)); 201 textCommand.setSelection(commandHistory.get(commandHistoryIndex).length()); 213 202 } 214 203 }
Note: See TracChangeset
for help on using the changeset viewer.