/** * Implements a close facsimile of the vi end-of-word movement. * If the character is on white space, it takes you to the end * of the next word. If it is on the last character of a word * it takes you to the next of the next word. Any other character * of a word, takes you to the end of the current word. * * @param count Number of times to repeat the action * @return true if it worked. */ private boolean viEndWord(int count) throws IOException { int pos = buf.cursor; int end = buf.buffer.length(); for (int i = 0; pos < end && i < count; i++) { if (pos < (end-1) && !isDelimiter(buf.buffer.charAt(pos)) && isDelimiter(buf.buffer.charAt (pos+1))) { ++pos; } // If we are on white space, then move back. while (pos < end && isDelimiter(buf.buffer.charAt(pos))) { ++pos; } while (pos < (end-1) && !isDelimiter(buf.buffer.charAt(pos+1))) { ++pos; } } setCursorPosition(pos); return true; }
while (pos < end && !isDelimiter(buf.buffer.charAt(pos))) { ++pos; while (pos < end && isDelimiter(buf.buffer.charAt(pos))) { ++pos;
private boolean capitalizeWord() throws IOException { boolean first = true; int i = 1; char c; while (buf.cursor + i - 1< buf.length() && !isDelimiter((c = buf.buffer.charAt(buf.cursor + i - 1)))) { buf.buffer.setCharAt(buf.cursor + i - 1, first ? Character.toUpperCase(c) : Character.toLowerCase(c)); first = false; i++; } drawBuffer(); moveCursor(i - 1); return true; }
private boolean upCaseWord() throws IOException { int i = 1; char c; while (buf.cursor + i - 1 < buf.length() && !isDelimiter((c = buf.buffer.charAt(buf.cursor + i - 1)))) { buf.buffer.setCharAt(buf.cursor + i - 1, Character.toUpperCase(c)); i++; } drawBuffer(); moveCursor(i - 1); return true; }
private boolean downCaseWord() throws IOException { int i = 1; char c; while (buf.cursor + i - 1 < buf.length() && !isDelimiter((c = buf.buffer.charAt(buf.cursor + i - 1)))) { buf.buffer.setCharAt(buf.cursor + i - 1, Character.toLowerCase(c)); i++; } drawBuffer(); moveCursor(i - 1); return true; }
private boolean previousWord() throws IOException { while (isDelimiter(buf.current()) && (moveCursor(-1) != 0)) { // nothing } while (!isDelimiter(buf.current()) && (moveCursor(-1) != 0)) { // nothing } return true; }
private boolean nextWord() throws IOException { while (isDelimiter(buf.nextChar()) && (moveCursor(1) != 0)) { // nothing } while (!isDelimiter(buf.nextChar()) && (moveCursor(1) != 0)) { // nothing } return true; }
private boolean deletePreviousWord() throws IOException { StringBuilder killed = new StringBuilder(); char c; while (isDelimiter((c = buf.current()))) { if (c == 0) { break; } killed.append(c); backspace(); } while (!isDelimiter((c = buf.current()))) { if (c == 0) { break; } killed.append(c); backspace(); } String copy = killed.reverse().toString(); killRing.addBackwards(copy); return true; }
private boolean deleteNextWord() throws IOException { StringBuilder killed = new StringBuilder(); char c; while (isDelimiter((c = buf.nextChar()))) { if (c == 0) { break; } killed.append(c); delete(); } while (!isDelimiter((c = buf.nextChar()))) { if (c == 0) { break; } killed.append(c); delete(); } String copy = killed.toString(); killRing.add(copy); return true; }
/** * This is a close facsimile of the actual vi previous word logic. In * actual vi words are determined by boundaries of identity characterse. * This logic is a bit more simple and simply looks at white space or * digits or characters. It should be revised at some point. * * @param count number of iterations * @return true if the move was successful, false otherwise */ private boolean viPreviousWord(int count) throws IOException { boolean ok = true; if (buf.cursor == 0) { return false; } int pos = buf.cursor - 1; for (int i = 0; pos > 0 && i < count; i++) { // If we are on white space, then move back. while (pos > 0 && isWhitespace(buf.buffer.charAt(pos))) { --pos; } while (pos > 0 && !isDelimiter(buf.buffer.charAt(pos-1))) { --pos; } if (pos > 0 && i < (count-1)) { --pos; } } setCursorPosition(pos); return ok; }
/** * Implements a close facsimile of the vi end-of-word movement. * If the character is on white space, it takes you to the end * of the next word. If it is on the last character of a word * it takes you to the next of the next word. Any other character * of a word, takes you to the end of the current word. * * @param count Number of times to repeat the action * @return true if it worked. */ private boolean viEndWord(int count) throws IOException { int pos = buf.cursor; int end = buf.buffer.length(); for (int i = 0; pos < end && i < count; i++) { if (pos < (end-1) && !isDelimiter(buf.buffer.charAt(pos)) && isDelimiter(buf.buffer.charAt (pos+1))) { ++pos; } // If we are on white space, then move back. while (pos < end && isDelimiter(buf.buffer.charAt(pos))) { ++pos; } while (pos < (end-1) && !isDelimiter(buf.buffer.charAt(pos+1))) { ++pos; } } setCursorPosition(pos); return true; }
while (pos < end && !isDelimiter(buf.buffer.charAt(pos))) { ++pos; while (pos < end && isDelimiter(buf.buffer.charAt(pos))) { ++pos;
private boolean capitalizeWord() throws IOException { boolean first = true; int i = 1; char c; while (buf.cursor + i - 1< buf.length() && !isDelimiter((c = buf.buffer.charAt(buf.cursor + i - 1)))) { buf.buffer.setCharAt(buf.cursor + i - 1, first ? Character.toUpperCase(c) : Character.toLowerCase(c)); first = false; i++; } drawBuffer(); moveCursor(i - 1); return true; }
private boolean upCaseWord() throws IOException { int i = 1; char c; while (buf.cursor + i - 1 < buf.length() && !isDelimiter((c = buf.buffer.charAt(buf.cursor + i - 1)))) { buf.buffer.setCharAt(buf.cursor + i - 1, Character.toUpperCase(c)); i++; } drawBuffer(); moveCursor(i - 1); return true; }
private boolean downCaseWord() throws IOException { int i = 1; char c; while (buf.cursor + i - 1 < buf.length() && !isDelimiter((c = buf.buffer.charAt(buf.cursor + i - 1)))) { buf.buffer.setCharAt(buf.cursor + i - 1, Character.toLowerCase(c)); i++; } drawBuffer(); moveCursor(i - 1); return true; }
private boolean previousWord() throws IOException { while (isDelimiter(buf.current()) && (moveCursor(-1) != 0)) { // nothing } while (!isDelimiter(buf.current()) && (moveCursor(-1) != 0)) { // nothing } return true; }
private boolean nextWord() throws IOException { while (isDelimiter(buf.nextChar()) && (moveCursor(1) != 0)) { // nothing } while (!isDelimiter(buf.nextChar()) && (moveCursor(1) != 0)) { // nothing } return true; }
private boolean deletePreviousWord() throws IOException { StringBuilder killed = new StringBuilder(); char c; while (isDelimiter((c = buf.current()))) { if (c == 0) { break; } killed.append(c); backspace(); } while (!isDelimiter((c = buf.current()))) { if (c == 0) { break; } killed.append(c); backspace(); } String copy = killed.reverse().toString(); killRing.addBackwards(copy); return true; }
private boolean deleteNextWord() throws IOException { StringBuilder killed = new StringBuilder(); char c; while (isDelimiter((c = buf.nextChar()))) { if (c == 0) { break; } killed.append(c); delete(); } while (!isDelimiter((c = buf.nextChar()))) { if (c == 0) { break; } killed.append(c); delete(); } String copy = killed.toString(); killRing.add(copy); return true; }
/** * This is a close facsimile of the actual vi previous word logic. In * actual vi words are determined by boundaries of identity characterse. * This logic is a bit more simple and simply looks at white space or * digits or characters. It should be revised at some point. * * @param count number of iterations * @return true if the move was successful, false otherwise */ private boolean viPreviousWord(int count) throws IOException { boolean ok = true; if (buf.cursor == 0) { return false; } int pos = buf.cursor - 1; for (int i = 0; pos > 0 && i < count; i++) { // If we are on white space, then move back. while (pos > 0 && isWhitespace(buf.buffer.charAt(pos))) { --pos; } while (pos > 0 && !isDelimiter(buf.buffer.charAt(pos-1))) { --pos; } if (pos > 0 && i < (count-1)) { --pos; } } setCursorPosition(pos); return ok; }