Beispiel #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();
   }
 }
Beispiel #2
0
 public void clearLines(final int beginY, final int endY) {
   myTerminalTextBuffer.lock();
   try {
     myTerminalTextBuffer.clearLines(beginY, endY);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
Beispiel #3
0
 @Override
 public void scrollDown(int count) {
   myTerminalTextBuffer.lock();
   try {
     scrollArea(myScrollRegionTop, scrollingRegionSize(), count);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
Beispiel #4
0
 @Override
 public void deleteLines(int count) {
   myTerminalTextBuffer.lock();
   try {
     myTerminalTextBuffer.deleteLines(myCursorY - 1, count, myScrollRegionBottom);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
Beispiel #5
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();
   }
 }
Beispiel #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();
   }
 }
Beispiel #7
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();
   }
 }
Beispiel #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();
   }
 }
Beispiel #9
0
  private void doWriteString(String string) {
    myTerminalTextBuffer.lock();
    try {
      wrapLines();
      scrollY();

      myTerminalTextBuffer.writeString(myCursorX, myCursorY, string);
      myCursorX += string.length();
      finishText();
    } finally {
      myTerminalTextBuffer.unlock();
    }
  }
Beispiel #10
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();
   }
 }
Beispiel #11
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();
    }
  }
Beispiel #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();
   }
 }
Beispiel #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();
    }
  }
Beispiel #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();
   }
 }
Beispiel #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();
   }
 }
Beispiel #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();
    }
  }