@Override public Screenable append(CharSequence csq, int start, int end) throws IOException { console.driver.write(csq, start, end); return this; }
private void writeNoFlush(char c) throws IOException { if (previousCR && c == '\n') { previousCR = false; } else if (c == '\r' || c == '\n') { previousCR = c == '\r'; io.writeCRLF(); } else { io.write(c); } } }
@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 public Screenable append(CharSequence s) throws IOException { console.driver.write(s); return this; }
String msg = response.getMessage(); if (msg.length() > 0) { console.driver.write(msg);
@Override public Screenable append(Style style) throws IOException { console.driver.write(style); return this; }
@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 Screenable append(char c) throws IOException { console.driver.write(c); return this; }
private void writeNoFlush(char c) throws IOException { if (previousCR && c == '\n') { previousCR = false; } else if (c == '\r' || c == '\n') { previousCR = c == '\r'; io.writeCRLF(); } else { io.write(c); } } }
@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(); }
disp.append(current, cursor, current.length()); disp.append(' '); driver.write(disp); int amount = current.length() - cursor + 1; while (amount > 0) {
editor.console.driver.write(sb.toString());
@Override public Screenable append(CharSequence s) throws IOException { console.driver.write(s); return this; }
@Override public Screenable append(CharSequence s) throws IOException { console.driver.write(s); return this; }
@Override public Screenable append(char c) throws IOException { console.driver.write(c); return this; }
@Override public Screenable append(char c) throws IOException { console.driver.write(c); return this; }