final StringBuffer buffer = reader.getCursorBuffer().getBuffer(); final int cursor = reader.getCursorBuffer().cursor; if (reader.getCursorBuffer().length() > 0) { reader.getCursorBuffer().setBuffer(new StringBuffer()); reader.getCursorBuffer().cursor = 0; reader.getCursorBuffer().setBuffer(buffer); reader.getCursorBuffer().cursor = cursor;
public static String processMessegeForExtraCharactersFromConsoleBuffer(String messege){ ConsoleReader reader = Gfsh.getConsoleReader(); if (reader != null) { StringBuffer buffer = reader.getCursorBuffer().getBuffer(); if(buffer.length() > messege.length()){ int appendSpaces = buffer.length() - messege.length(); for(int i = 0; i < appendSpaces; i++){ messege = messege + " "; } } } return messege; } }
private static String readLine(ConsoleReader reader, String prompt) throws IOException { String earlierLine = reader.getCursorBuffer().toString(); String readLine = null; try { readLine = reader.readLine(prompt); } catch (IndexOutOfBoundsException e) { if (earlierLine.length() == 0) { reader.printNewline(); readLine = LINE_SEPARATOR; reader.getCursorBuffer().cursor = 0; } else { readLine = readLine(reader, prompt); } } return readLine; }
public synchronized void clearEvents() { resultLatch = new CountDownLatch(1); commandExecError = null; eis.clearEvents(); completorOutput.clear(); commandOutput.clear(); Util.debug("buffer before clear <" + reader.getCursorBuffer().toString() + ">"); reader.getCursorBuffer().clearBuffer(); Util.debug("buffer after clear <" + reader.getCursorBuffer().toString() + ">"); output.reset(); try { output.flush(); } catch (IOException e){ Util.error(e); } }
public void setProgress(int completed, int total) { int w = reader.getTermwidth(); int progress = (completed * 50) / total; String totalStr = String.valueOf(total); String percent = String.format(" %0" + totalStr.length() + "d/%s [", completed, totalStr); String result = percent + repetition("=", progress) + repetition(" ", 50 - progress) + "]"; try { reader.getCursorBuffer().clearBuffer(); reader.getCursorBuffer().write(result); reader.setCursorPosition(w); reader.redrawLine(); } catch (IOException e) { e.printStackTrace(); } }
final StringBuffer buffer = reader.getCursorBuffer().getBuffer(); final int cursor = reader.getCursorBuffer().cursor; if (reader.getCursorBuffer().length() > 0) { reader.getCursorBuffer().setBuffer(new StringBuffer()); reader.getCursorBuffer().cursor = 0; reader.getCursorBuffer().setBuffer(buffer); reader.getCursorBuffer().cursor = cursor;
reader.getCursorBuffer().clearBuffer(); interrupt();
} else { prompt = getDefaultSecondaryPrompt(); reader.getCursorBuffer().cursor = 0; reader.getCursorBuffer().write(removeBackslash(line) + LINE_SEPARATOR);