/** * Deletes the character you are sitting on and sucks the rest of * the line in from the right. * @return <code>true</code> if it succeeded, <code>false</code> otherwise */ protected boolean viDeleteChar() { for (int i = 0; i < count; i++) { if (!buf.delete()) { return false; } } return true; }
protected boolean deleteChar() { if (count < 0) { return callNeg(this::backwardDeleteChar); } if (buf.cursor() == buf.length()) { return false; } buf.delete(count); return true; }
buf.delete(endPos - startPos);
protected boolean viKillEol() { int eol = findeol(); if (buf.cursor() == eol) { return false; } killRing.add(buf.substring(buf.cursor(), eol)); buf.delete(eol - buf.cursor()); return true; }
protected boolean deleteWord() { if (count < 0) { return callNeg(this::backwardDeleteWord); } int x = buf.cursor(); while (count-- > 0) { while (x < buf.length() && !isWord(buf.atChar(x))) { x++; } while (x < buf.length() && isWord(buf.atChar(x))) { x++; } } buf.delete(x - buf.cursor()); return true; }
/** * Kill the buffer ahead of the current cursor position. * * @return true if successful */ public boolean killLine() { if (count < 0) { return callNeg(this::backwardKillLine); } if (buf.cursor() == buf.length()) { return false; } int cp = buf.cursor(); int len = cp; while (count-- > 0) { if (buf.atChar(len) == '\n') { len++; } else { while (buf.atChar(len) != 0 && buf.atChar(len) != '\n') { len++; } } } int num = len - cp; String killed = buf.substring(cp, cp + num); buf.delete(num); killRing.add(killed); return true; }
public boolean backwardKillLine() { if (count < 0) { return callNeg(this::killLine); } if (buf.cursor() == 0) { return false; } int cp = buf.cursor(); int beg = cp; while (count-- > 0) { if (beg == 0) { break; } if (buf.atChar(beg - 1) == '\n') { beg--; } else { while (beg > 0 && buf.atChar(beg - 1) != 0 && buf.atChar(beg - 1) != '\n') { beg--; } } } int num = cp - beg; String killed = buf.substring(cp - beg, cp); buf.cursor(beg); buf.delete(num); killRing.add(killed); return true; }
protected boolean killWord() { if (count < 0) { return callNeg(this::backwardKillWord); } int x = buf.cursor(); while (count-- > 0) { while (x < buf.length() && !isWord(buf.atChar(x))) { x++; } while (x < buf.length() && isWord(buf.atChar(x))) { x++; } } killRing.add(buf.substring(buf.cursor(), x)); buf.delete(x - buf.cursor()); return true; }
buf.delete(end - start); killRing.add(killed); return true;