Esempio n. 1
0
 @Override
 public void backspace() {
   myCursorX -= 1;
   if (myCursorX < 0) {
     myCursorY -= 1;
     myCursorX = myTerminalWidth - 1;
   }
   myDisplay.setCursor(myCursorX, myCursorY);
 }
Esempio n. 2
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();
   }
 }
Esempio n. 3
0
 @Override
 public void cursorUp(final int countY) {
   myTerminalTextBuffer.lock();
   try {
     myCursorY -= countY;
     myCursorY = Math.max(myCursorY, scrollingRegionTop());
     myDisplay.setCursor(myCursorX, myCursorY);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
Esempio n. 4
0
  @Override
  public void newLine() {
    myCursorY += 1;

    scrollY();

    if (isAutoNewLine()) {
      carriageReturn();
    }

    myDisplay.setCursor(myCursorX, myCursorY);
  }
Esempio n. 5
0
 @Override
 public void nextLine() {
   myTerminalTextBuffer.lock();
   try {
     myCursorX = 0;
     if (myCursorY == myScrollRegionBottom) {
       scrollArea(myScrollRegionTop, scrollingRegionSize(), -1);
     } else {
       myCursorY += 1;
     }
     myDisplay.setCursor(myCursorX, myCursorY);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
Esempio n. 6
0
 public void scrollY() {
   myTerminalTextBuffer.lock();
   try {
     if (myCursorY > myScrollRegionBottom) {
       final int dy = myScrollRegionBottom - myCursorY;
       myCursorY = myScrollRegionBottom;
       scrollArea(myScrollRegionTop, scrollingRegionSize(), dy);
       myDisplay.setCursor(myCursorX, myCursorY);
     }
     if (myCursorY < myScrollRegionTop) {
       myCursorY = myScrollRegionTop;
     }
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
Esempio n. 7
0
 @Override
 public void reverseIndex() {
   // Moves the cursor up one line in the same
   // column. If the cursor is at the top margin,
   // the page scrolls down.
   myTerminalTextBuffer.lock();
   try {
     if (myCursorY == myScrollRegionTop) {
       scrollArea(myScrollRegionTop, scrollingRegionSize(), 1);
     } else {
       myCursorY -= 1;
       myDisplay.setCursor(myCursorX, myCursorY);
     }
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
Esempio n. 8
0
 @Override
 public void index() {
   // Moves the cursor down one line in the
   // same column. If the cursor is at the
   // bottom margin, the page scrolls up
   myTerminalTextBuffer.lock();
   try {
     if (myCursorY == myScrollRegionBottom) {
       scrollArea(myScrollRegionTop, scrollingRegionSize(), -1);
     } else {
       myCursorY += 1;
       myDisplay.setCursor(myCursorX, myCursorY);
     }
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
Esempio n. 9
0
 @Override
 public void horizontalTab() {
   if (myCursorX >= myTerminalWidth) {
     return;
   }
   int length = myTerminalTextBuffer.getLine(myCursorY - 1).getText().length();
   int stop = myTabulator.nextTab(myCursorX);
   myCursorX = Math.max(myCursorX, length);
   if (myCursorX < stop) {
     char[] chars = new char[stop - myCursorX];
     Arrays.fill(chars, CharUtils.EMPTY_CHAR);
     doWriteString(new String(chars));
   } else {
     myCursorX = stop;
   }
   myDisplay.setCursor(myCursorX, myCursorY);
 }
Esempio n. 10
0
  @Override
  public void restoreCursor() {
    if (myStoredCursor != null) {
      restoreCursor(myStoredCursor);
    } else { // If nothing was saved by DECSC
      setModeEnabled(TerminalMode.OriginMode, false); // Resets origin mode (DECOM)
      cursorPosition(1, 1); // Moves the cursor to the home position (upper left of screen).
      myStyleState.reset(); // Turns all character attributes off (normal setting).

      myGraphicSetState.resetState();
      // myGraphicSetState.designateGraphicSet(0, CharacterSet.ASCII);//Maps the ASCII character set
      // into GL
      // mapCharsetToGL(0);
      // myGraphicSetState.designateGraphicSet(1, CharacterSet.DEC_SUPPLEMENTAL);
      // mapCharsetToGR(1); //and the DEC Supplemental Graphic set into GR
    }
    myDisplay.setCursor(myCursorX, myCursorY);
  }
Esempio n. 11
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);
  }
Esempio n. 12
0
 @Override
 public void linePositionAbsolute(int y) {
   myCursorY = y;
   myDisplay.setCursor(myCursorX, myCursorY);
 }
Esempio n. 13
0
 @Override
 public void cursorBackward(final int dX) {
   myCursorX -= dX;
   myCursorX = Math.max(myCursorX, 0);
   myDisplay.setCursor(myCursorX, myCursorY);
 }
Esempio n. 14
0
 @Override
 public void cursorForward(final int dX) {
   myCursorX += dX;
   myCursorX = Math.min(myCursorX, myTerminalWidth - 1);
   myDisplay.setCursor(myCursorX, myCursorY);
 }
Esempio n. 15
0
 @Override
 public void carriageReturn() {
   myCursorX = 0;
   myDisplay.setCursor(myCursorX, myCursorY);
 }
Esempio n. 16
0
 private void finishText() {
   myDisplay.setCursor(myCursorX, myCursorY);
   scrollY();
 }