示例#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);
    }
示例#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));
    }
示例#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;
    }
示例#4
0
 @Override
 public void setTabStop(int position) {
   myTabStops.add(Integer.valueOf(position));
 }
示例#5
0
 @Override
 public void clearAllTabStops() {
   myTabStops.clear();
 }
示例#6
0
 @Override
 public void clearTabStop(int position) {
   myTabStops.remove(Integer.valueOf(position));
 }
示例#7
0
 private void initTabStops(int columns, int tabLength) {
   for (int i = tabLength; i < columns; i += tabLength) {
     myTabStops.add(i);
   }
 }