protected boolean forwardChar() { return buf.move(count) != 0; }
protected boolean backwardChar() { return buf.move(-count) != 0; }
protected boolean viCmdMode() { // If we are re-entering move mode from an // aborted yank-to, delete-to, change-to then // don't move the cursor back. The cursor is // only move on an explicit entry to movement // mode. if (state == State.NORMAL) { buf.move(-1); } return setKeyMap(VICMD); }
protected boolean beginningOfLine() { while (count-- > 0) { while (buf.move(-1) == -1 && buf.prevChar() != '\n') ; } return true; }
protected boolean endOfLine() { while (count-- > 0) { while (buf.move(1) == 1 && buf.currChar() != '\n') ; } return true; }
protected boolean viAddNext() { buf.move(1); return setKeyMap(VIINS); }
protected boolean viPutBefore() { if (yankBuffer.indexOf('\n') >= 0) { while (buf.move(-1) == -1 && buf.prevChar() != '\n'); putString(yankBuffer); buf.move(- yankBuffer.length()); } else if (yankBuffer.length () != 0) { if (buf.cursor() > 0) { buf.move(-1); } for (int i = 0; i < count; i++) { putString(yankBuffer); } buf.move(-1); } return true; }
protected boolean viEndOfLine() { if (count < 0) { return false; } while (count-- > 0) { buf.cursor(findeol() + 1); } buf.move(-1); return true; }
protected boolean viOpenLineBelow() { while (buf.move(1) == 1 && buf.currChar() != '\n') ; buf.write('\n'); return setKeyMap(VIINS); }
protected boolean viYankWholeLine() { int s, e; int p = buf.cursor(); while (buf.move(-1) == -1 && buf.prevChar() != '\n') ; s = buf.cursor(); for (int i = 0; i < repeatCount; i++) { while (buf.move(1) == 1 && buf.prevChar() != '\n') ; } e = buf.cursor(); yankBuffer = buf.substring(s, e); if (!yankBuffer.endsWith("\n")) { yankBuffer += "\n"; } buf.cursor(p); return true; }
protected boolean viFirstNonBlank() { beginningOfLine(); while (buf.cursor() < buf.length() && isWhitespace(buf.currChar())) { buf.move(1); } return true; }
protected boolean emacsForwardWord() { if (count < 0) { return callNeg(this::emacsBackwardWord); } while (count-- > 0) { while (buf.cursor() < buf.length() && !isWord(buf.currChar())) { buf.move(1); } if (isInViChangeOperation() && count == 0) { return true; } while (buf.cursor() < buf.length() && isWord(buf.currChar())) { buf.move(1); } } return true; }
protected boolean forwardWord() { if (count < 0) { return callNeg(this::backwardWord); } while (count-- > 0) { while (buf.cursor() < buf.length() && isWord(buf.currChar())) { buf.move(1); } if (isInViChangeOperation() && count == 0) { break; } while (buf.cursor() < buf.length() && !isWord(buf.currChar())) { buf.move(1); } } return true; }
protected boolean viForwardChar() { if (count < 0) { return callNeg(this::viBackwardChar); } int lim = findeol(); if (isInViCmdMode() && !isInViMoveOperation()) { lim--; } if (buf.cursor() >= lim) { return false; } while (count-- > 0 && buf.cursor() < lim) { buf.move(1); } return true; }
protected boolean insertClose(String s) { putString(s); long blink = getLong(BLINK_MATCHING_PAREN, DEFAULT_BLINK_MATCHING_PAREN); if (blink <= 0) { return true; } int closePosition = buf.cursor(); buf.move(-1); doViMatchBracket(); redisplay(); peekCharacter(blink); buf.cursor(closePosition); return true; }
/** * Switches the case of the current character from upper to lower * or lower to upper as necessary and advances the cursor one * position to the right. * @return <code>true</code> if it succeeded, <code>false</code> otherwise */ protected boolean viSwapCase() { for (int i = 0; i < count; i++) { if (buf.cursor() < buf.length()) { int ch = buf.atChar(buf.cursor()); ch = switchCase(ch); buf.currChar(ch); buf.move(1); } else { return false; } } return true; }