/** * Write out the specified string to the buffer and the output stream. * @param str the char sequence to write in the buffer */ public void putString(final CharSequence str) { buf.write(str, overTyping); }
/** * Set the current buffer's content to the specified {@link String}. The * visual terminal will be modified to show the current buffer. * * @param buffer the new contents of the buffer. */ protected void setBuffer(final String buffer) { buf.clear(); buf.write(buffer); }
protected boolean expandHistory() { String str = buf.toString(); String exp = expander.expandHistory(history, str); if (!exp.equals(str)) { buf.clear(); buf.write(exp); return true; } else { return false; } }
protected boolean viOpenLineBelow() { while (buf.move(1) == 1 && buf.currChar() != '\n') ; buf.write('\n'); return setKeyMap(VIINS); }
protected boolean viOpenLineAbove() { while (buf.move(-1) == -1 && buf.prevChar() != '\n') ; buf.write('\n'); buf.move(-1); return setKeyMap(VIINS); }
protected boolean viJoin() { if (buf.down()) { while (buf.move(-1) == -1 && buf.prevChar() != '\n') ; buf.backspace(); buf.write(' '); buf.move(-1); return true; } return false; }
public boolean beginPaste() { final Object SELF_INSERT = new Object(); final Object END_PASTE = new Object(); KeyMap<Object> keyMap = new KeyMap<>(); keyMap.setUnicode(SELF_INSERT); keyMap.setNomatch(SELF_INSERT); keyMap.setAmbiguousTimeout(0); keyMap.bind(END_PASTE, BRACKETED_PASTE_END); StringBuilder sb = new StringBuilder(); while (true) { Object b = bindingReader.readBinding(keyMap); if (b == END_PASTE) { break; } String s = getLastBinding(); if ("\r".equals(s)) { s = "\n"; } sb.append(s); } regionActive = RegionType.PASTE; regionMark = getBuffer().cursor(); getBuffer().write(sb); return true; }
protected boolean acceptLine() { parsedLine = null; if (!isSet(Option.DISABLE_EVENT_EXPANSION)) { try { String str = buf.toString(); String exp = expander.expandHistory(history, str); if (!exp.equals(str)) { buf.clear(); buf.write(exp); if (isSet(Option.HISTORY_VERIFY)) { return true; } } } catch (IllegalArgumentException e) { // Ignore } } try { parsedLine = parser.parse(buf.toString(), buf.cursor(), ParseContext.ACCEPT_LINE); } catch (EOFError e) { buf.write("\n"); return true; } catch (SyntaxError e) { // do nothing } callWidget(CALLBACK_FINISH); state = State.DONE; return true; }
protected boolean viRepeatSearch() { if (searchDir == 0) { return false; } int si = searchDir < 0 ? searchBackwards(searchString, searchIndex, false) : searchForwards(searchString, searchIndex, false); if (si == -1 || si == history.index()) { return false; } searchIndex = si; /* * Show the match. */ buf.clear(); history.moveTo(searchIndex); buf.write(history.get(searchIndex)); if (VICMD.equals(keyMap)) { buf.move(-1); } return true; }
protected boolean copyPrevWord() { if (count <= 0) { return false; } int t1, t0 = buf.cursor(); while (true) { t1 = t0; while (t0 > 0 && !isWord(buf.atChar(t0 - 1))) { t0--; } while (t0 > 0 && isWord(buf.atChar(t0 - 1))) { t0--; } if (--count == 0) { break; } if (t0 == 0) { return false; } } buf.write(buf.substring(t0, t1)); return true; }
buf.backspace(line.word().length()); buf.write(w); return true; buf.backspace(line.rawWordLength()); buf.write(line.escape(completion.value(), completion.complete())); if (completion.complete()) { if (buf.currChar() != ' ') { buf.write(" "); } else { buf.move(1); buf.backspace(completion.suffix().length()); if (getLastBinding().charAt(0) != ' ') { buf.write(' '); buf.write(line.escape(commonPrefix, false)); current = commonPrefix; if ((!isSet(Option.AUTO_LIST) && isSet(Option.AUTO_MENU))
buf.write(getLastBinding()); if (cands.isEmpty()) { post = null;
private void update() { buf.backspace(word.length()); word = escaper.apply(completion().value(), true).toString(); buf.write(word);
&& getLastBinding().charAt(0) != ' ' && (SELF_INSERT.equals(ref) || getLastBinding().charAt(0) != ' ')) { buf.write(' ');
buf.clear(); if (buffer != null) { buf.write(buffer);