Changeset 1243 for trunk/autoquest-ui-swt/src/main/java/de/ugoe
- Timestamp:
- 06/28/13 14:38:46 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ConsoleTabComposite.java
r1236 r1243 35 35 import org.eclipse.swt.events.KeyEvent; 36 36 37 import de.ugoe.cs.util.FileTools; 38 import de.ugoe.cs.util.StringTools; 37 39 import de.ugoe.cs.util.console.CommandExecuter; 38 40 import de.ugoe.cs.util.console.Console; 41 import de.ugoe.cs.util.console.GlobalDataContainer; 39 42 import de.ugoe.cs.util.console.listener.ICommandListener; 40 43 … … 143 146 144 147 private void autoCompleteCommand() { 145 String commandPrefix = textCommand.getText().trim(); 146 String completedPrefix = CommandExecuter.getInstance().autoCompleteCommand(commandPrefix); 147 148 textCommand.setText(completedPrefix.toString()); 149 textCommand.setSelection(completedPrefix.length()); 148 String prefix = textCommand.getText(); 149 int end = textCommand.getCaretPosition() - 1; 150 int start = 0; 151 152 for (int i = end; i >= 0; i--) { 153 if (Character.isWhitespace(prefix.charAt(i))) { 154 start = i + 1; 155 break; 156 } 157 } 158 159 String textPrefix = prefix.substring(0, start); 160 String textSuffix = prefix.substring(end + 1); 161 prefix = prefix.substring(start, end + 1); 162 163 String completedPrefix = null; 164 if ("".equals(textCommand.getText().substring(0, start).trim())) { 165 // search for a command completion 166 completedPrefix = CommandExecuter.getInstance().autoCompleteCommand(prefix); 167 } 168 else { 169 // complete an object in the data store or a file name 170 completedPrefix = FileTools.autoCompletePath(prefix); 171 172 if (prefix.equals(completedPrefix)) { 173 // file completion wasn't possible, so try to complete using data objects 174 String[] completions = 175 GlobalDataContainer.getInstance().getAllKeys().toArray(new String[0]); 176 completedPrefix = StringTools.autocomplete(prefix, completions); 177 } 178 } 179 180 textCommand.setText(textPrefix + completedPrefix + textSuffix); 181 textCommand.setSelection(textPrefix.length() + completedPrefix.length()); 150 182 } 151 183
Note: See TracChangeset
for help on using the changeset viewer.