1 21 22 package org.armedbear.j; 23 24 import java.util.List ; 25 26 public final class ExecuteCommandTextFieldHandler extends DefaultTextFieldHandler 27 { 28 public ExecuteCommandTextFieldHandler(Editor editor, HistoryTextField textField) 29 { 30 super(editor, textField); 31 } 32 33 public void enter() 34 { 35 String input = textField.getText(); 36 if (input == null) 37 return; 38 input = input.trim(); 39 if (input.length() == 0) 40 return; 41 History history = textField.getHistory(); 43 if (history != null) { 44 history.append(input); 45 history.save(); 46 } 47 if (!input.equals("inbox")) { 48 String value = editor.getAlias(input); 50 if (value != null) 51 input = value; 52 } 53 editor.ensureActive(); 54 editor.setFocusToDisplay(); 55 editor.updateLocation(); 56 editor.executeCommand(input, true); 57 editor.getDispatcher().eventHandled(); 58 } 59 60 public boolean wantTab() 61 { 62 return true; 63 } 64 65 public final List getCompletions(String prefix) 66 { 67 return CommandTable.getCompletionsForPrefix(prefix); 68 } 69 } 70 | Popular Tags |