Exemple #1
0
    @Override
    public int previousTab(int position) {
      int tabStop = 0;

      // Search for the first tab stop before the given position...
      SortedSet<Integer> headSet = myTabStops.headSet(Integer.valueOf(position));
      if (!headSet.isEmpty()) {
        tabStop = headSet.last();
      }

      // Don't go beyond the start of the line...
      return Math.max(0, tabStop);
    }
Exemple #2
0
    @Override
    public int nextTab(int position) {
      int tabStop = Integer.MAX_VALUE;

      // Search for the first tab stop after the given position...
      SortedSet<Integer> tailSet = myTabStops.tailSet(position + 1);
      if (!tailSet.isEmpty()) {
        tabStop = tailSet.first();
      }

      // Don't go beyond the end of the line...
      return Math.min(tabStop, (myWidth - 1));
    }
Exemple #3
0
    public void resize(int columns) {
      if (columns > myWidth) {
        for (int i = myTabLength * (myWidth / myTabLength); i < columns; i += myTabLength) {
          if (i >= myWidth) {
            myTabStops.add(i);
          }
        }
      } else {
        Iterator<Integer> it = myTabStops.iterator();
        while (it.hasNext()) {
          int i = it.next();
          if (i > columns) {
            it.remove();
          }
        }
      }

      myWidth = columns;
    }
Exemple #4
0
 @Override
 public void setTabStop(int position) {
   myTabStops.add(Integer.valueOf(position));
 }
Exemple #5
0
 @Override
 public void clearAllTabStops() {
   myTabStops.clear();
 }
Exemple #6
0
 @Override
 public void clearTabStop(int position) {
   myTabStops.remove(Integer.valueOf(position));
 }
Exemple #7
0
 private void initTabStops(int columns, int tabLength) {
   for (int i = tabLength; i < columns; i += tabLength) {
     myTabStops.add(i);
   }
 }