示例#1
0
  /** DOCUMENT ME! */
  public void previous() {
    for (int count = 0, i = buffer.getCurrentLine(); i >= 0; ) {
      Element line = init(i);

      int offset = line.getStartOffset();
      int start = 0;
      int end = 0;

      while (matcher.find()) {
        start = offset + matcher.start();
        end = offset + matcher.end();
      }

      if (start != end) {
        buffer.select(start, end);

        break;
      }

      if (PreferenceManager.getBoolean("snr.warp", false) && (i == 0)) {
        if (count > 1) {
          Toolkit.getDefaultToolkit().beep();

          break;
        }

        count++;

        i = buffer.getLineCount() - 1;
      } else {
        i--;
      }
    }
  }
示例#2
0
  /** DOCUMENT ME! */
  public void next() {
    for (int count = 0, i = buffer.getCurrentLine(); i < buffer.getLineCount(); ) {
      Element line = init(i);

      int offset = line.getStartOffset();

      if (PreferenceManager.getInt("snr.direction", FORWARD) == FORWARD) {
        if ((buffer.getSelectionEnd() > line.getStartOffset())
            && (buffer.getSelectionEnd() <= line.getEndOffset())) {
          offset = buffer.getSelectionEnd();
        }
      }

      if (matcher.find()) {
        int start = offset + matcher.start();
        int end = offset + matcher.end();

        buffer.select(start, end);

        break;
      }

      if (PreferenceManager.getBoolean("snr.warp", false) && (i == (buffer.getLineCount() - 1))) {
        if (count > 1) {
          Toolkit.getDefaultToolkit().beep();

          break;
        }

        count++;

        i = 0;
      } else {
        i++;
      }
    }
  }