void flush(boolean force) throws IOException { if (needFlush || force) { driver.flush(); needFlush = false; } }
@Override public void flush() throws IOException { console.driver.flush(); }
@Override public String readLine(String msg, boolean echo) throws IOException, InterruptedException { Reader waiter = new Reader(Thread.currentThread(), echo); if (editor.compareAndSet(null, waiter)) { if (msg != null && msg.length() > 0) { console.driver.write(msg); console.driver.flush(); } console.iterate(); try { return waiter.line.take(); } finally { editor.set(null); } } else { throw new IllegalStateException("A thread is already reading the line"); } }
@Override void perform(Editor editor, EditorBuffer buffer) throws IOException { editor.console.driver.cls(); StringBuilder sb = new StringBuilder(); int index = 0; List<String> lines = buffer.getLines(); for (String line : lines) { if (index == 0) { String prompt = editor.console.shell.getPrompt(); sb.append(prompt == null ? "" : prompt); } else { sb.append("\n> "); } sb.append(line); index++; } editor.console.driver.write(sb.toString()); editor.console.driver.flush(); } };
/** * Switch to edit. */ Editor edit() { String prompt = shell.getPrompt(); if (prompt != null && prompt.length() > 0) { try { driver.write(prompt); driver.flush(); } catch (IOException e) { // Swallow for now... } } editor.reset(); handler.set(editor); return editor; }
/** * Initiali */ public void init() { // Take care of pormpt String welcome = shell.getWelcome(); if (welcome != null && welcome.length() > 0) { try { driver.write(welcome); driver.flush(); } catch (IOException e) { // Log it } } edit(); }
console.driver.flush();
@Override String execute(Editor editor, EditorBuffer buffer, int[] sequence, boolean flush) throws IOException { editor.lineParser.reset(); buffer.reset(); editor.console.driver.writeCRLF(); String prompt = editor.console.shell.getPrompt(); if (prompt != null) { editor.console.driver.write(prompt); } if (flush) { editor.console.driver.flush(); } return null; } };
editor.console.driver.flush(); } else { String commonCompletion = Utils.findLongestCommonPrefix(completions.getValues());
void flush(boolean force) throws IOException { if (needFlush || force) { driver.flush(); needFlush = false; } }
@Override public void flush() throws IOException { console.driver.flush(); }
void flush(boolean force) throws IOException { if (needFlush || force) { driver.flush(); needFlush = false; } }
@Override public void flush() throws IOException { console.driver.flush(); }
@Override String execute(Editor editor, EditorBuffer buffer, int[] sequence, boolean flush) throws IOException { editor.historyCursor = -1; editor.historyBuffer = null; String line = buffer.getLine(); editor.lineParser.append(line); if (editor.console.getMode() == Mode.VI_MOVE) { editor.console.setMode(Mode.VI_INSERT); } if (editor.lineParser.crlf()) { editor.console.driver.writeCRLF(); editor.console.driver.flush(); String request = editor.visitor.getRaw(); if (request.length() > 0) { editor.addToHistory(request); } return request; } else { buffer.append('\n'); editor.console.driver.write("> "); if (flush) { buffer.flush(); } return null; } } };
@Override public String readLine(String msg, boolean echo) throws IOException, InterruptedException { Reader waiter = new Reader(Thread.currentThread(), echo); if (editor.compareAndSet(null, waiter)) { if (msg != null && msg.length() > 0) { console.driver.write(msg); console.driver.flush(); } console.iterate(); try { return waiter.line.take(); } finally { editor.set(null); } } else { throw new IllegalStateException("A thread is already reading the line"); } }
/** * Switch to edit. */ Editor edit() { String prompt = shell.getPrompt(); if (prompt != null && prompt.length() > 0) { try { driver.write(prompt); driver.flush(); } catch (IOException e) { // Swallow for now... } } editor.reset(); handler.set(editor); return editor; }
/** * Initiali */ public void init() { // Take care of pormpt String welcome = shell.getWelcome(); if (welcome != null && welcome.length() > 0) { try { driver.write(welcome); driver.flush(); } catch (IOException e) { // Log it } } edit(); }
/** * Initiali */ public void init() { // Take care of pormpt String welcome = shell.getWelcome(); if (welcome != null && welcome.length() > 0) { try { driver.write(welcome); driver.flush(); } catch (IOException e) { // Log it } } edit(); }
@Override String execute(Editor editor, EditorBuffer buffer, int[] sequence, boolean flush) throws IOException { editor.lineParser.reset(); buffer.reset(); editor.console.driver.writeCRLF(); String prompt = editor.console.shell.getPrompt(); if (prompt != null) { editor.console.driver.write(prompt); } if (flush) { editor.console.driver.flush(); } return null; } };
@Override String execute(Editor editor, EditorBuffer buffer, int[] sequence, boolean flush) throws IOException { editor.lineParser.reset(); buffer.reset(); editor.console.driver.writeCRLF(); String prompt = editor.console.shell.getPrompt(); if (prompt != null) { editor.console.driver.write(prompt); } if (flush) { editor.console.driver.flush(); } return null; } };