Exemplo n.º 1
0
 public void clearLines(final int beginY, final int endY) {
   myTerminalTextBuffer.lock();
   try {
     myTerminalTextBuffer.clearLines(beginY, endY);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
Exemplo n.º 2
0
 @Override
 public void deleteLines(int count) {
   myTerminalTextBuffer.lock();
   try {
     myTerminalTextBuffer.deleteLines(myCursorY - 1, count, myScrollRegionBottom);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
Exemplo n.º 3
0
 @Override
 public void scrollDown(int count) {
   myTerminalTextBuffer.lock();
   try {
     scrollArea(myScrollRegionTop, scrollingRegionSize(), count);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
Exemplo n.º 4
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();
   }
 }
Exemplo n.º 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();
   }
 }
Exemplo n.º 6
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();
   }
 }
Exemplo n.º 7
0
 private void wrapLines() {
   if (myCursorX >= myTerminalWidth) {
     myCursorX = 0;
     // clear the end of the line in the text buffer
     myTerminalTextBuffer.getLine(myCursorY - 1).deleteCharacters(myTerminalWidth);
     if (isAutoWrap()) {
       myTerminalTextBuffer.getLine(myCursorY - 1).setWrapped(true);
       myCursorY += 1;
     }
   }
 }
Exemplo n.º 8
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();
   }
 }
Exemplo n.º 9
0
  private void doWriteString(String string) {
    myTerminalTextBuffer.lock();
    try {
      wrapLines();
      scrollY();

      myTerminalTextBuffer.writeString(myCursorX, myCursorY, string);
      myCursorX += string.length();
      finishText();
    } finally {
      myTerminalTextBuffer.unlock();
    }
  }
Exemplo n.º 10
0
  @Override
  public void fillScreen(final char c) {
    myTerminalTextBuffer.lock();
    try {
      final char[] chars = new char[myTerminalWidth];
      Arrays.fill(chars, c);
      final String str = new String(chars);

      for (int row = 1; row <= myTerminalHeight; row++) {
        myTerminalTextBuffer.writeString(0, row, str);
      }
    } finally {
      myTerminalTextBuffer.unlock();
    }
  }
Exemplo n.º 11
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();
   }
 }
Exemplo n.º 12
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();
   }
 }
Exemplo n.º 13
0
  private void writeCharacters(final char[] chosenBuffer, final int start, final int length) {
    myTerminalTextBuffer.lock();
    try {
      wrapLines();
      scrollY();

      if (length != 0) {
        myTerminalTextBuffer.writeBytes(myCursorX, myCursorY, chosenBuffer, start, length);
      }

      myCursorX += CharUtils.getTextLength(chosenBuffer, start, length);
      finishText();
    } finally {
      myTerminalTextBuffer.unlock();
    }
  }
Exemplo n.º 14
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();
   }
 }
Exemplo n.º 15
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();
   }
 }
Exemplo n.º 16
0
  @Override
  public void eraseInDisplay(final int arg) {
    myTerminalTextBuffer.lock();
    try {
      int beginY;
      int endY;

      switch (arg) {
        case 0:
          // Initial line
          if (myCursorX < myTerminalWidth) {
            myTerminalTextBuffer.eraseCharacters(myCursorX, myTerminalWidth, myCursorY - 1);
          }
          // Rest
          beginY = myCursorY;
          endY = myTerminalHeight;

          break;
        case 1:
          // initial line
          myTerminalTextBuffer.eraseCharacters(0, myCursorX + 1, myCursorY - 1);

          beginY = 0;
          endY = myCursorY - 1;
          break;
        case 2:
          beginY = 0;
          endY = myTerminalHeight;
          break;
        default:
          LOG.error("Unsupported erase in display mode:" + arg);
          beginY = 1;
          endY = 1;
          break;
      }
      // Rest of lines
      if (beginY != endY) {
        clearLines(beginY, endY);
      }
    } finally {
      myTerminalTextBuffer.unlock();
    }
  }
Exemplo n.º 17
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();
   }
 }
Exemplo n.º 18
0
  @Override
  public void reset() {
    myGraphicSetState.resetState();

    myStyleState.reset();

    myTerminalTextBuffer.clearAll();

    myDisplay.setScrollingEnabled(true);

    initModes();

    initMouseModes();

    cursorPosition(1, 1);
  }
Exemplo n.º 19
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);
 }
Exemplo n.º 20
0
 private void scrollArea(int scrollRegionTop, int scrollRegionSize, int dy) {
   myDisplay.scrollArea(scrollRegionTop, scrollRegionSize, dy);
   myTerminalTextBuffer.scrollArea(scrollRegionTop, dy, scrollRegionTop + scrollRegionSize - 1);
 }
Exemplo n.º 21
0
 @Override
 public void useAlternateBuffer(boolean enabled) {
   myTerminalTextBuffer.useAlternateBuffer(enabled);
   myDisplay.setScrollingEnabled(!enabled);
 }