Changeset 2046 for trunk


Ignore:
Timestamp:
10/20/15 10:15:31 (9 years ago)
Author:
pharms
Message:
  • corrected auto completion
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ConsoleTabComposite.java

    r1243 r2046  
    5353 
    5454    protected java.util.List<String> commandHistory = new LinkedList<String>(); 
     55     
     56    protected int commandHistoryIndex = 0; 
    5557 
    5658    protected Text textCommand; 
     
    7375    public void commandNotification(String command) { 
    7476        commandHistory.add(command); 
     77        commandHistoryIndex = commandHistory.size(); 
    7578    } 
    7679 
     
    183186     
    184187    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()); 
    197193        } 
    198194    } 
    199195 
    200196    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()); 
    213202        } 
    214203    } 
Note: See TracChangeset for help on using the changeset viewer.