@Override public synchronized void flush() { try { if (jline) { reader.print(ConsoleReader.RESET_LINE + ""); reader.flush(); super.flush(); try { reader.drawLine(); } catch (Throwable ex) { reader.getCursorBuffer().clear(); } reader.flush(); } else { super.flush(); } } catch (IOException ex) { logger.log(Level.SEVERE, "I/O exception flushing console output", ex); } } }
/** * Clear the line and redraw it. */ public void redrawLine() throws IOException { tputs("carriage_return"); drawLine(); }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // only method we are proxying is handle() terminal.init(); try { drawLine(); flush(); } catch (IOException e) { e.printStackTrace(); } return null; } });
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(); }
public boolean complete(final ConsoleReader reader, final List<CharSequence> candidates, final int pos) throws IOException { CursorBuffer buf = reader.getCursorBuffer(); // if there is only one completion, then fill in the buffer if (candidates.size() == 1) { String value = Ansi.stripAnsi(candidates.get(0).toString()); if (buf.cursor == buf.buffer.length() && printSpaceAfterFullCompletion && !value.endsWith(" ")) { value += " "; } // fail if the only candidate is the same as the current buffer if (value.equals(buf.toString())) { return false; } setBuffer(reader, value, pos); return true; } else if (candidates.size() > 1) { String value = getUnambiguousCompletions(candidates); setBuffer(reader, value, pos); } printCandidates(reader, candidates); // redraw the current console buffer reader.drawLine(); return true; }
public void print(String s) { for ( ChatColor color : colors ) { s = s.replaceAll( "(?i)" + color.toString(), replacements.get( color ) ); } try { console.print( Ansi.ansi().eraseLine( Erase.ALL ).toString() + ConsoleReader.RESET_LINE + s + Ansi.ansi().reset().toString() ); console.drawLine(); console.flush(); } catch ( IOException ex ) { } }
/** * Possible states in which the current readline operation may be in. */ private static enum State { /** * The user is just typing away */ NORMAL, /** * In the middle of a emacs seach */ SEARCH, FORWARD_SEARCH, /** * VI "yank-to" operation ("y" during move mode) */ VI_YANK_TO, /** * VI "delete-to" operation ("d" during move mode) */ VI_DELETE_TO, /** * VI "change-to" operation ("c" during move mode) */ VI_CHANGE_TO }
/** * Clear the line and redraw it. */ public void redrawLine() throws IOException { tputs("carriage_return"); drawLine(); }
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(); }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // only method we are proxying is handle() terminal.init(); try { drawLine(); flush(); } catch (IOException e) { e.printStackTrace(); } return null; } });
public void printAnsi(String message) { try { reader.setPrompt(message); reader.drawLine(); reader.flush(); } catch (IOException e) { logger.error("print error.", e); } finally { reader.setPrompt(null); } }
reader.drawLine(); } catch (Throwable ex) { reader.getCursorBuffer().clear();
public boolean complete(ConsoleReader reader, @SuppressWarnings("rawtypes") List<CharSequence> candidates, int pos) throws IOException { CursorBuffer buf = reader.getCursorBuffer(); // if there is only one completion, then fill in the buffer if (candidates.size() == 1) { String value = candidates.get(0).toString(); // fail if the only candidate is the same as the current buffer if (value.equals(buf.toString())) { return false; } jline.console.completer.CandidateListCompletionHandler.setBuffer(reader, value, pos); return true; } if (candidates.size() > 1) { String value = getUnambiguousCompletions(candidates); jline.console.completer.CandidateListCompletionHandler.setBuffer(reader, value, pos); } if (eagerNewlines) { reader.println(); } jline.console.completer.CandidateListCompletionHandler.printCandidates(reader, candidates); // redraw the current console buffer reader.drawLine(); return true; }
public boolean complete(final ConsoleReader reader, final List<CharSequence> candidates, final int pos) throws IOException { CursorBuffer buffer = reader.getCursorBuffer(); // if there is only one completion, then fill in the buffer, that's all if (candidates.size() == 1) { CharSequence candidate = candidates.get(0); // fail if the only candidate is the same as the current buffer if (candidate.equals(buffer.toString())) { return false; } updateBuffer(reader, candidate, pos); return true; } //if there are more suggestions, then fill in the buffer with the longer common prefix available //and show auto-suggestions if (candidates.size() > 1) { String commonPrefix = getUnambiguousCompletions(candidates); updateBuffer(reader, commonPrefix, pos); } printCandidates(reader, candidates); //next line seems to cause small problems when cursor is not at the end of the buffer //e.g. FilterBuilders.queryFilter(QueryBuilders.) reader.drawLine(); return true; }
private void printUsage(Command command) { try { int maxOptionsLength = 0; List<OptionHelpLine> optionHelpLines = new ArrayList<>(); for (OptionHelp optionHelp : command.getOptionsHelp()) { OptionHelpLine optionHelpLine = new OptionHelpLine(optionHelp); optionHelpLines.add(optionHelpLine); maxOptionsLength = Math.max(maxOptionsLength, optionHelpLine.getOptions().length()); } this.console.println(); this.console.println("Usage:"); this.console.println(command.getName() + " " + command.getUsageHelp()); for (OptionHelpLine optionHelpLine : optionHelpLines) { this.console.println(String.format("\t%" + maxOptionsLength + "s: %s", optionHelpLine.getOptions(), optionHelpLine.getUsage())); } this.console.drawLine(); } catch (IOException ex) { Log.error(ex.getMessage() + " (" + ex.getClass().getName() + ")"); } }
private void printUsage(Command command) { try { int maxOptionsLength = 0; List<OptionHelpLine> optionHelpLines = new ArrayList<OptionHelpLine>(); for (OptionHelp optionHelp : command.getOptionsHelp()) { OptionHelpLine optionHelpLine = new OptionHelpLine(optionHelp); optionHelpLines.add(optionHelpLine); maxOptionsLength = Math.max(maxOptionsLength, optionHelpLine.getOptions() .length()); } this.console.println(); this.console.println("Usage:"); this.console.println(command.getName() + " " + command.getUsageHelp()); for (OptionHelpLine optionHelpLine : optionHelpLines) { this.console.println(String.format("\t%" + maxOptionsLength + "s: %s", optionHelpLine.getOptions(), optionHelpLine.getUsage())); } this.console.drawLine(); } catch (IOException ex) { Log.error(ex.getMessage() + " (" + ex.getClass().getName() + ")"); } }
public void print(String s) { for ( ChatColor color : colors ) { s = s.replaceAll( "(?i)" + color.toString(), replacements.get( color ) ); } try { console.print( Ansi.ansi().eraseLine( Erase.ALL ).toString() + ConsoleReader.RESET_LINE + s + Ansi.ansi().reset().toString() ); console.drawLine(); console.flush(); } catch ( IOException ex ) { } }
/** * Possible states in which the current readline operation may be in. */ private static enum State { /** * The user is just typing away */ NORMAL, /** * In the middle of a emacs seach */ SEARCH, FORWARD_SEARCH, /** * VI "yank-to" operation ("y" during move mode) */ VI_YANK_TO, /** * VI "delete-to" operation ("d" during move mode) */ VI_DELETE_TO, /** * VI "change-to" operation ("c" during move mode) */ VI_CHANGE_TO }
@Override public void publish(LogRecord record) { if (closed) return; String formatMessage = getFormatter().formatMessage(record); for (ICloudLoggerHandler handler : CloudLogger.this.getHandler()) handler.handleConsole(formatMessage); if (isLoggable(record)) { try { reader.print(ConsoleReader.RESET_LINE + getFormatter().format(record)); reader.drawLine(); reader.flush(); } catch (IOException e) { e.printStackTrace(); } } }