本文整理汇总了Java中jline.console.completer.CandidateListCompletionHandler类的典型用法代码示例。如果您正苦于以下问题:Java CandidateListCompletionHandler类的具体用法?Java CandidateListCompletionHandler怎么用?Java CandidateListCompletionHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CandidateListCompletionHandler类属于jline.console.completer包,在下文中一共展示了CandidateListCompletionHandler类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printCompletionCandidates
import jline.console.completer.CandidateListCompletionHandler; //导入依赖的package包/类
protected void printCompletionCandidates() throws IOException {
// debug ("tab for (" + buf + ")");
if (completers.size() == 0) {
return;
}
List<CharSequence> candidates = new LinkedList<CharSequence>();
String bufstr = buf.buffer.toString();
int cursor = buf.cursor;
for (Completer comp : completers) {
if (comp.complete(bufstr, cursor, candidates) != -1) {
break;
}
}
CandidateListCompletionHandler.printCandidates(this, candidates);
drawLine();
}
示例2: listen
import jline.console.completer.CandidateListCompletionHandler; //导入依赖的package包/类
/**
* コンソールからの入力のリスン
*
* @throws IOException I/O例外
*/
private void listen() throws IOException {
console.setPrompt("uroborosql > ");
console.setHandleUserInterrupt(true);
// コマンドのコード補完
console.addCompleter((buffer, cursor, candidates) -> {
String buff = buffer.trim();
if (buff.length() > 0 && !buffer.endsWith(" ") || buff.isEmpty()) {
Stream.of(Command.values()).filter(c -> c.match(buff)).map(Object::toString).forEach(candidates::add);
}
return candidates.isEmpty() ? -1 : 0;
});
// SQL名のコード補完
console.addCompleter(new SqlNameCompleter(config.getSqlManager().getSqlPathList()));
// バインドパラメータのコード補完
console.addCompleter(new BindParamCompleter());
// テーブル名のコード補完
console.addCompleter(new TableNameCompleter());
// SQLキーワードのコード補完
console.addCompleter(new SqlKeywordCompleter());
CandidateListCompletionHandler handler = new CandidateListCompletionHandler();
handler.setPrintSpaceAfterFullCompletion(false);
console.setCompletionHandler(handler);
while (true) { // ユーザの一行入力を待つ
try {
String line = console.readLine();
if (!commandExecute(line)) {
break;
}
} catch (UserInterruptException uie) {
break;
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
}
示例3: start
import jline.console.completer.CandidateListCompletionHandler; //导入依赖的package包/类
public void start() throws Exception {
console = new ConsoleReader();
console.getTerminal().setEchoEnabled(false);
console.setPrompt("\u001B[32menkan\u001B[0m> ");
History history = new FileHistory(new File(System.getProperty("user.home"), ".enkan_history"));
console.setHistory(history);
CandidateListCompletionHandler handler = new CandidateListCompletionHandler();
console.setCompletionHandler(handler);
consoleHandler = new ConsoleHandler(console);
clientThread.execute(consoleHandler);
clientThread.shutdown();
}
示例4: initializeConsoleReader
import jline.console.completer.CandidateListCompletionHandler; //导入依赖的package包/类
private void initializeConsoleReader() {
this.consoleReader.setHistoryEnabled(true);
this.consoleReader.setBellEnabled(false);
this.consoleReader.setExpandEvents(false);
this.consoleReader.addCompleter(new CommandCompleter(this.consoleReader,
this.argumentDelimiter, this.commandRunner));
this.consoleReader.setCompletionHandler(new CandidateListCompletionHandler());
}
示例5: readLine
import jline.console.completer.CandidateListCompletionHandler; //导入依赖的package包/类
private static String readLine(ConsoleReader console) throws IOException {
ConsoleUtils.begin(31);
ConsoleUtils.println(">>>");
ConsoleUtils.end();
List<Completer> completors = new LinkedList<Completer>();
// completors.add(new AnsiStringsCompleter("\u001B[1mfoo\u001B[0m",
// "bar", "\u001B[32mbaz\u001B[0m"));
CandidateListCompletionHandler handler = new CandidateListCompletionHandler();
handler.setStripAnsi(true);
console.setCompletionHandler(handler);
for (Completer c : completors) {
console.addCompleter(c);
}
// History h = console.getHistory();
// ("hoge\rhoge");
StringBuilder sb = new StringBuilder();
while (true) {
String line = console.readLine();
if (line == null) {
return null;
}
if (line.equals("")) {
return sb.toString();
}
sb.append(line);
sb.append("\n");
}
// h = console.getHistory();
}
示例6: addCompleter
import jline.console.completer.CandidateListCompletionHandler; //导入依赖的package包/类
@Override
public void addCompleter(Completer completer) {
CandidateListCompletionHandler handler = new CandidateListCompletionHandler();
// handler.setPrintSpaceAfterFullCompletion(false);
console.setCompletionHandler(handler);
console.addCompleter(new JLineCompleter(completer));
}