Example #1
0
  public Dimension resize(final Dimension pendingResize, final RequestOrigin origin) {
    final int oldHeight = myTerminalHeight;
    if (pendingResize.width <= MIN_WIDTH) {
      pendingResize.setSize(MIN_WIDTH, pendingResize.height);
    }
    final Dimension pixelSize =
        myDisplay.requestResize(
            pendingResize,
            origin,
            myCursorY,
            new ResizeHandler() {
              @Override
              public void sizeUpdated(int termWidth, int termHeight, int cursorY) {
                myTerminalWidth = termWidth;
                myTerminalHeight = termHeight;
                myCursorY = cursorY;
                myCursorX = Math.min(myCursorX, myTerminalWidth - 1);

                myTabulator.resize(myTerminalWidth);
              }
            });

    myScrollRegionBottom += myTerminalHeight - oldHeight;
    return pixelSize;
  }
Example #2
0
 @Override
 public void backspace() {
   myCursorX -= 1;
   if (myCursorX < 0) {
     myCursorY -= 1;
     myCursorX = myTerminalWidth - 1;
   }
   myDisplay.setCursor(myCursorX, myCursorY);
 }
Example #3
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();
   }
 }
Example #4
0
  public JediTerminal(
      final TerminalDisplay display,
      final TerminalTextBuffer buf,
      final StyleState initialStyleState) {
    myDisplay = display;
    myTerminalTextBuffer = buf;
    myStyleState = initialStyleState;

    myTerminalWidth = display.getColumnCount();
    myTerminalHeight = display.getRowCount();

    myScrollRegionTop = 1;
    myScrollRegionBottom = myTerminalHeight;

    myTabulator = new DefaultTabulator(myTerminalWidth);

    myGraphicSetState = new GraphicSetState();

    reset();
  }
Example #5
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();
   }
 }
Example #6
0
  @Override
  public void newLine() {
    myCursorY += 1;

    scrollY();

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

    myDisplay.setCursor(myCursorX, myCursorY);
  }
Example #7
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();
   }
 }
Example #8
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();
   }
 }
Example #9
0
  @Override
  public void reset() {
    myGraphicSetState.resetState();

    myStyleState.reset();

    myTerminalTextBuffer.clearAll();

    myDisplay.setScrollingEnabled(true);

    initModes();

    initMouseModes();

    cursorPosition(1, 1);
  }
Example #10
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);
 }
Example #11
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();
   }
 }
Example #12
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();
   }
 }
Example #13
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);
  }
Example #14
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);
  }
Example #15
0
 @Override
 public void disconnected() {
   myDisplay.setCursorVisible(false);
 }
Example #16
0
 @Override
 public void setWindowTitle(String name) {
   myDisplay.setWindowTitle(name);
 }
Example #17
0
 @Override
 public void beep() {
   myDisplay.beep();
 }
Example #18
0
 @Override
 public void setCurrentPath(String path) {
   myDisplay.setCurrentPath(path);
 }
Example #19
0
 @Override
 public void linePositionAbsolute(int y) {
   myCursorY = y;
   myDisplay.setCursor(myCursorX, myCursorY);
 }
Example #20
0
 @Override
 public void cursorBackward(final int dX) {
   myCursorX -= dX;
   myCursorX = Math.max(myCursorX, 0);
   myDisplay.setCursor(myCursorX, myCursorY);
 }
Example #21
0
 @Override
 public void cursorForward(final int dX) {
   myCursorX += dX;
   myCursorX = Math.min(myCursorX, myTerminalWidth - 1);
   myDisplay.setCursor(myCursorX, myCursorY);
 }
Example #22
0
 @Override
 public void carriageReturn() {
   myCursorX = 0;
   myDisplay.setCursor(myCursorX, myCursorY);
 }
Example #23
0
 @Override
 public void setCursorVisible(boolean visible) {
   myDisplay.setCursorVisible(visible);
 }
Example #24
0
 @Override
 public void setMouseMode(@NotNull MouseMode mode) {
   myMouseMode = mode;
   myDisplay.terminalMouseModeSet(mode);
 }
Example #25
0
 @Override
 public void useAlternateBuffer(boolean enabled) {
   myTerminalTextBuffer.useAlternateBuffer(enabled);
   myDisplay.setScrollingEnabled(!enabled);
 }
Example #26
0
 @Override
 public void setBlinkingCursor(boolean enabled) {
   myDisplay.setBlinkingCursor(enabled);
 }
Example #27
0
 private void scrollArea(int scrollRegionTop, int scrollRegionSize, int dy) {
   myDisplay.scrollArea(scrollRegionTop, scrollRegionSize, dy);
   myTerminalTextBuffer.scrollArea(scrollRegionTop, dy, scrollRegionTop + scrollRegionSize - 1);
 }
Example #28
0
 private void finishText() {
   myDisplay.setCursor(myCursorX, myCursorY);
   scrollY();
 }