private List<String> resetCompletions() { String text = getText(); updateCurrentWord(false); completions = null; if (isEqualsRequired && !text.startsWith("=")) return null; boolean korean = app.getLocale().getLanguage().equals("ko"); // start autocompletion only for words with at least two characters if (korean) { if (Korean.flattenKorean(curWord.toString()).length() < 2) { completions = null; return null; } } else { if (curWord.length() < 2) { completions = null; return null; } } cmdPrefix = curWord.toString(); if (korean) completions = dict.getCompletionsKorean(cmdPrefix); else completions = dict.getCompletions(cmdPrefix); completions = getSyntaxes(completions); return completions; }
public void keyReleased(KeyEvent e) { // Application.debug(e+""); /* test code to generate unicode strings for Virtual Keyboard String text = getText(); String outStr = ""; for (int i = 0 ; i < text.length() ; i++) { int ch = text.charAt(i); if (ch < 128) outStr += text.charAt(i); else { String unicode = Integer.toHexString(ch); if (unicode.length() < 4) unicode = "\\u0"+unicode; else unicode = "\\u"+unicode; outStr += unicode; } } Application.debug(outStr); //*/ // ctrl pressed on Mac // or alt on Windows boolean modifierKeyPressed = Application.MAC_OS ? e.isControlDown() : e.isAltDown(); // we don't want to act when AltGr is down // as it is used eg for entering {[}] is some locales // NB e.isAltGraphDown() doesn't work if (e.isAltDown() && e.isControlDown()) modifierKeyPressed = false; char charPressed = e.getKeyChar(); if ((!isLetterOrDigit(charPressed) && !modifierKeyPressed) || (ctrlC && Application.MAC_OS) // don't want selection cleared ) return; clearSelection(); // handle alt-p etc super.keyReleased(e); mergeKoreanDoubles(); if (getAutoComplete()) { updateCurrentWord(false); startAutoCompletion(); } /* if (charCodePressed == KeyEvent.VK_BACK_SPACE && isTextSelected && input.length() > 0) { setText(input.substring(0, input.length())); }*/ }
/* * attempt to give Syntax help for when eg "Radius[ <Conic> ]" is typed * see CommandProcessor.argErr() for similar error */ public void showError(Exception e) { if (e instanceof MyException) { updateCurrentWord(true); int err = ((MyException) e).getErrorType(); if (err == MyException.INVALID_INPUT) { String command = app.getReverseCommand(getCurrentWord()); if (command != null) { app.showError( new MyError( app, app.getError("InvalidInput") + "\n\n" + app.getPlain("Syntax") + ":\n" + app.getCommandSyntax(command), getCurrentWord())); return; } } } // can't work out anything better, just show "Invalid Input" app.showError(e.getLocalizedMessage()); }