示例#1
0
 public void eraseInLine(int arg) {
   myTerminalTextBuffer.lock();
   try {
     switch (arg) {
       case 0:
         if (myCursorX < myTerminalWidth) {
           myTerminalTextBuffer.eraseCharacters(myCursorX, myTerminalWidth, myCursorY - 1);
         }
         // delete to the end of line : line is no more wrapped
         myTerminalTextBuffer.getLine(myCursorY - 1).setWrapped(false);
         break;
       case 1:
         final int extent = Math.min(myCursorX + 1, myTerminalWidth);
         myTerminalTextBuffer.eraseCharacters(0, extent, myCursorY - 1);
         break;
       case 2:
         myTerminalTextBuffer.eraseCharacters(0, myTerminalWidth, myCursorY - 1);
         break;
       default:
         LOG.error("Unsupported erase in line mode:" + arg);
         break;
     }
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
示例#2
0
 @Override
 public void insertBlankCharacters(int count) {
   myTerminalTextBuffer.lock();
   try {
     final int extent = Math.min(count, myTerminalWidth - myCursorX);
     myTerminalTextBuffer.insertBlankCharacters(myCursorX, myCursorY - 1, extent);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
示例#3
0
  @Override
  public void setScrollingRegion(int top, int bottom) {
    if (top > bottom) {
      LOG.error("Top margin of scroll region can't be greater then bottom: " + top + ">" + bottom);
    }
    myScrollRegionTop = Math.max(1, top);
    myScrollRegionBottom = Math.min(myTerminalHeight, bottom);

    // DECSTBM moves the cursor to column 1, line 1 of the page
    cursorPosition(1, 1);
  }
示例#4
0
 @Override
 public void cursorDown(final int dY) {
   myTerminalTextBuffer.lock();
   try {
     myCursorY += dY;
     myCursorY = Math.min(myCursorY, scrollingRegionBottom());
     myDisplay.setCursor(myCursorX, myCursorY);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
示例#5
0
 public void writeUnwrappedString(String string) {
   int length = string.length();
   int off = 0;
   while (off < length) {
     int amountInLine = Math.min(distanceToLineEnd(), length - off);
     writeString(string.substring(off, off + amountInLine));
     wrapLines();
     scrollY();
     off += amountInLine;
   }
 }
示例#6
0
 @Override
 public void eraseCharacters(int count) {
   // Clear the next n characters on the cursor's line, including the cursor's
   // position.
   myTerminalTextBuffer.lock();
   try {
     final int extent = Math.min(count, myTerminalWidth - myCursorX);
     myTerminalTextBuffer.eraseCharacters(myCursorX, myCursorX + extent, myCursorY - 1);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
示例#7
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));
    }
示例#8
0
  @Override
  public void cursorPosition(int x, int y) {
    if (isOriginMode()) {
      myCursorY = y + scrollingRegionTop() - 1;
    } else {
      myCursorY = y;
    }

    if (myCursorY > scrollingRegionBottom()) {
      myCursorY = scrollingRegionBottom();
    }

    // avoid issue due to malformed sequence
    myCursorX = Math.max(0, x - 1);
    myCursorX = Math.min(myCursorX, myTerminalWidth - 1);

    myCursorY = Math.max(0, myCursorY);

    myDisplay.setCursor(myCursorX, myCursorY);
  }
示例#9
0
 @Override
 public void cursorForward(final int dX) {
   myCursorX += dX;
   myCursorX = Math.min(myCursorX, myTerminalWidth - 1);
   myDisplay.setCursor(myCursorX, myCursorY);
 }