/** * @param command command name in local language * @return syntax description of command as html text or null */ private String getCmdSyntax(String command) { if (command == null || command.length() == 0) return null; // try macro first Macro macro = app.getKernel().getMacro(command); if (macro != null) { return macro.toString(); } // translate command to internal name and get syntax description // note: the translation ignores the case of command String internalCmd = app.translateCommand(command); // String key = internalCmd + "Syntax"; // String syntax = app.getCommand(key); String syntax; if (isCASInput) { syntax = app.getCommandSyntaxCAS(internalCmd); } else { syntax = app.getCommandSyntax(internalCmd); } // check if we really found syntax information // if (key.equals(syntax)) return null; if (syntax.indexOf(app.syntaxStr) == -1) return null; // build html tooltip syntax = syntax.replaceAll("<", "<"); syntax = syntax.replaceAll(">", ">"); syntax = syntax.replaceAll("\n", "<br>"); StringBuilder sb = new StringBuilder(); sb.append("<html>"); sb.append(syntax); sb.append("</html>"); return sb.toString(); }
/* * Take a list of commands and return all possible syntaxes * for these commands */ private List<String> getSyntaxes(List<String> commands) { if (commands == null) { return null; } ArrayList<String> syntaxes = new ArrayList<String>(); for (String cmd : commands) { String cmdInt = app.getInternalCommand(cmd); String syntaxString; if (isCASInput) { syntaxString = app.getCommandSyntaxCAS(cmdInt); } else { syntaxString = app.getCommandSyntax(cmdInt); } if (syntaxString.endsWith(isCASInput ? app.syntaxCAS : app.syntaxStr)) { // command not found, check for macros Macro macro = isCASInput ? null : app.getKernel().getMacro(cmd); if (macro != null) { syntaxes.add(macro.toString()); } else { // syntaxes.add(cmdInt + "[]"); Application.debug("Can't find syntax for: " + cmd); } continue; } for (String syntax : syntaxString.split("\\n")) { syntaxes.add(syntax); } } return syntaxes; }