Exemplo n.º 1
0
  /**
   * Issue <em>num</em> deletes.
   *
   * @return the number of characters backed up
   */
  private final int delete(final int num) throws IOException {
    /* Commented out beacuse of DWA-2949:
    if (buf.cursor == 0)
                return 0;*/

    buf.buffer.delete(buf.cursor, buf.cursor + 1);
    drawBuffer(1);

    return 1;
  }
Exemplo n.º 2
0
 public final boolean replace(int num, String replacement) {
   buf.buffer.replace(buf.cursor - num, buf.cursor, replacement);
   try {
     moveCursor(-num);
     drawBuffer(Math.max(0, num - replacement.length()));
     moveCursor(replacement.length());
   } catch (IOException e) {
     e.printStackTrace();
     return false;
   }
   return true;
 }
Exemplo n.º 3
0
  /** Clear the echoed characters for the specified character code. */
  int clearEcho(int c) throws IOException {
    // if the terminal is not echoing, then just return...
    if (!terminal.getEcho()) {
      return 0;
    }

    // otherwise, clear
    int num = countEchoCharacters((char) c);
    back(num);
    drawBuffer(num);

    return num;
  }
Exemplo n.º 4
0
  /** Delete the character at the current position and redraw the remainder of the buffer. */
  private final boolean deleteCurrentCharacter() throws IOException {
    boolean success = buf.buffer.length() > 0;
    if (!success) {
      return false;
    }

    if (buf.cursor == buf.buffer.length()) {
      return false;
    }

    buf.buffer.deleteCharAt(buf.cursor);
    drawBuffer(1);
    return true;
  }
Exemplo n.º 5
0
  /**
   * Issue <em>num</em> backspaces.
   *
   * @return the number of characters backed up
   */
  private final int backspace(final int num) throws IOException {
    if (buf.cursor == 0) {
      return 0;
    }

    int count = 0;

    count = moveCursor(-1 * num) * -1;
    // debug ("Deleting from " + buf.cursor + " for " + count);
    buf.buffer.delete(buf.cursor, buf.cursor + count);
    drawBuffer(count);

    return count;
  }
Exemplo n.º 6
0
  /** Output the specified character, both to the buffer and the output stream. */
  private final void putChar(final int c, final boolean print) throws IOException {
    buf.write((char) c);

    if (print) {
      // no masking...
      if (mask == null) {
        printCharacter(c);
      }
      // null mask: don't print anything...
      else if (mask.charValue() == 0) {;
      }
      // otherwise print the mask...
      else {
        printCharacter(mask.charValue());
      }

      drawBuffer();
    }
  }
Exemplo n.º 7
0
 /** Write out the specified string to the buffer and the output stream. */
 public final void putString(final String str) throws IOException {
   buf.write(str);
   printString(str);
   drawBuffer();
 }
Exemplo n.º 8
0
 /**
  * Redraw the rest of the buffer from the cursor onwards. This is necessary for inserting text
  * into the buffer.
  */
 private final void drawBuffer() throws IOException {
   drawBuffer(0);
 }