コード例 #1
0
ファイル: TerminalPanel.java プロジェクト: bitekas/jediterm
  public Dimension requestResize(
      final Dimension newSize,
      final RequestOrigin origin,
      int cursorY,
      JediTerminal.ResizeHandler resizeHandler) {
    if (!newSize.equals(myTermSize)) {
      myTerminalTextBuffer.lock();
      try {
        myTerminalTextBuffer.resize(newSize, origin, cursorY, resizeHandler, mySelection);
        myTermSize = (Dimension) newSize.clone();

        final Dimension pixelDimension = new Dimension(getPixelWidth(), getPixelHeight());

        setPreferredSize(pixelDimension);
        if (myTerminalPanelListener != null) {
          myTerminalPanelListener.onPanelResize(pixelDimension, origin);
        }
        SwingUtilities.invokeLater(
            new Runnable() {
              @Override
              public void run() {
                updateScrolling();
              }
            });
      } finally {
        myTerminalTextBuffer.unlock();
      }
    }

    return new Dimension(getPixelWidth(), getPixelHeight());
  }
コード例 #2
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 public void clearLines(final int beginY, final int endY) {
   myTerminalTextBuffer.lock();
   try {
     myTerminalTextBuffer.clearLines(beginY, endY);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
コード例 #3
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 @Override
 public void deleteLines(int count) {
   myTerminalTextBuffer.lock();
   try {
     myTerminalTextBuffer.deleteLines(myCursorY - 1, count, myScrollRegionBottom);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
コード例 #4
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 @Override
 public void scrollDown(int count) {
   myTerminalTextBuffer.lock();
   try {
     scrollArea(myScrollRegionTop, scrollingRegionSize(), count);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
コード例 #5
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 @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();
   }
 }
コード例 #6
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 @Override
 public void cursorUp(final int countY) {
   myTerminalTextBuffer.lock();
   try {
     myCursorY -= countY;
     myCursorY = Math.max(myCursorY, scrollingRegionTop());
     myDisplay.setCursor(myCursorX, myCursorY);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
コード例 #7
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 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;
     }
   }
 }
コード例 #8
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 @Override
 public void cursorDown(final int dY) {
   myTerminalTextBuffer.lock();
   try {
     myCursorY += dY;
     myCursorY = Math.min(myCursorY, scrollingRegionBottom());
     myDisplay.setCursor(myCursorX, myCursorY);
   } finally {
     myTerminalTextBuffer.unlock();
   }
 }
コード例 #9
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 @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();
   }
 }
コード例 #10
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
  private void doWriteString(String string) {
    myTerminalTextBuffer.lock();
    try {
      wrapLines();
      scrollY();

      myTerminalTextBuffer.writeString(myCursorX, myCursorY, string);
      myCursorX += string.length();
      finishText();
    } finally {
      myTerminalTextBuffer.unlock();
    }
  }
コード例 #11
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
  @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();
    }
  }
コード例 #12
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 @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();
   }
 }
コード例 #13
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 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();
   }
 }
コード例 #14
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
  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();
    }
  }
コード例 #15
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 @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();
   }
 }
コード例 #16
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 @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();
   }
 }
コード例 #17
0
ファイル: TerminalPanel.java プロジェクト: bitekas/jediterm
  private void clearBuffer() {
    if (!myTerminalTextBuffer.isUsingAlternateBuffer()) {
      myTerminalTextBuffer.clearHistory();

      if (myCoordsAccessor != null && myCoordsAccessor.getY() > 0) {
        TerminalLine line = myTerminalTextBuffer.getLine(myCoordsAccessor.getY() - 1);

        myTerminalTextBuffer.clearAll();

        myCoordsAccessor.setY(0);
        myCursor.setY(1);
        myTerminalTextBuffer.addLine(line);
      }

      updateScrolling();

      myClientScrollOrigin = myBoundedRangeModel.getValue();
    }
  }
コード例 #18
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
  @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();
    }
  }
コード例 #19
0
ファイル: TerminalPanel.java プロジェクト: bitekas/jediterm
 private void updateScrolling() {
   if (myScrollingEnabled) {
     myBoundedRangeModel.setRangeProperties(
         0,
         myTermSize.height,
         -myTerminalTextBuffer.getHistoryBuffer().getLineCount(),
         myTermSize.height,
         false);
   } else {
     myBoundedRangeModel.setRangeProperties(0, myTermSize.height, 0, myTermSize.height, false);
   }
 }
コード例 #20
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 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();
   }
 }
コード例 #21
0
ファイル: TerminalPanel.java プロジェクト: bitekas/jediterm
  public TerminalPanel(
      @NotNull SettingsProvider settingsProvider,
      @NotNull TerminalTextBuffer terminalTextBuffer,
      @NotNull StyleState styleState) {
    mySettingsProvider = settingsProvider;
    myTerminalTextBuffer = terminalTextBuffer;
    myStyleState = styleState;
    myTermSize.width = terminalTextBuffer.getWidth();
    myTermSize.height = terminalTextBuffer.getHeight();
    myMaxFPS = mySettingsProvider.maxRefreshRate();

    updateScrolling();

    enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.INPUT_METHOD_EVENT_MASK);
    enableInputMethods(true);

    terminalTextBuffer.addModelListener(
        new TerminalModelListener() {
          @Override
          public void modelChanged() {
            repaint();
          }
        });
  }
コード例 #22
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
  @Override
  public void reset() {
    myGraphicSetState.resetState();

    myStyleState.reset();

    myTerminalTextBuffer.clearAll();

    myDisplay.setScrollingEnabled(true);

    initModes();

    initMouseModes();

    cursorPosition(1, 1);
  }
コード例 #23
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 @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);
 }
コード例 #24
0
ファイル: TerminalPanel.java プロジェクト: bitekas/jediterm
  @Override
  public void paintComponent(final Graphics g) {
    final Graphics2D gfx = (Graphics2D) g;

    setupAntialiasing(gfx);

    gfx.setColor(getBackground());

    gfx.fillRect(0, 0, getWidth(), getHeight());

    myTerminalTextBuffer.processHistoryAndScreenLines(
        myClientScrollOrigin,
        new StyledTextConsumer() {
          final int columnCount = getColumnCount();

          @Override
          public void consume(
              int x,
              int y,
              @NotNull TextStyle style,
              @NotNull CharBuffer characters,
              int startRow) {
            int row = y - startRow;
            drawCharacters(x, row, style, characters, gfx);
            if (mySelection != null) {
              Pair<Integer, Integer> interval =
                  mySelection.intersect(x, row + myClientScrollOrigin, characters.length());
              if (interval != null) {
                TextStyle selectionStyle = getSelectionStyle(style);
                CharBuffer selectionChars =
                    characters.subBuffer(interval.first - x, interval.second);

                drawCharacters(interval.first, row, selectionStyle, selectionChars, gfx);
              }
            }
          }

          @Override
          public void consumeNul(
              int x, int y, int nulIndex, TextStyle style, CharBuffer characters, int startRow) {
            int row = y - startRow;
            if (mySelection != null) {
              // compute intersection with all NUL areas, non-breaking
              Pair<Integer, Integer> interval =
                  mySelection.intersect(
                      nulIndex, row + myClientScrollOrigin, columnCount - nulIndex);
              if (interval != null) {
                TextStyle selectionStyle = getSelectionStyle(style);
                drawCharacters(x, row, selectionStyle, characters, gfx);
                return;
              }
            }
            drawCharacters(x, row, style, characters, gfx);
          }

          @Override
          public void consumeQueue(int x, int y, int nulIndex, int startRow) {
            if (x < columnCount) {
              consumeNul(
                  x,
                  y,
                  nulIndex,
                  TextStyle.EMPTY,
                  new CharBuffer(CharUtils.EMPTY_CHAR, columnCount - x),
                  startRow);
            }
          }
        });

    int cursorY = myCursor.getCoordY();
    if (myClientScrollOrigin + getRowCount() > cursorY) {
      int cursorX = myCursor.getCoordX();
      Pair<Character, TextStyle> sc = myTerminalTextBuffer.getStyledCharAt(cursorX, cursorY);
      TextStyle normalStyle = sc.second != null ? sc.second : myStyleState.getCurrent();
      TextStyle selectionStyle = getSelectionStyle(normalStyle);
      boolean inSelection = inSelection(cursorX, cursorY);
      myCursor.drawCursor(sc.first, gfx, inSelection ? selectionStyle : normalStyle);
    }

    drawInputMethodUncommitedChars(gfx);

    drawMargins(gfx, getWidth(), getHeight());
  }
コード例 #25
0
ファイル: TerminalPanel.java プロジェクト: bitekas/jediterm
 public LinesBuffer getScrollBuffer() {
   return myTerminalTextBuffer.getHistoryBuffer();
 }
コード例 #26
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 private void scrollArea(int scrollRegionTop, int scrollRegionSize, int dy) {
   myDisplay.scrollArea(scrollRegionTop, scrollRegionSize, dy);
   myTerminalTextBuffer.scrollArea(scrollRegionTop, dy, scrollRegionTop + scrollRegionSize - 1);
 }
コード例 #27
0
ファイル: JediTerminal.java プロジェクト: patsimm/jediterm
 @Override
 public void useAlternateBuffer(boolean enabled) {
   myTerminalTextBuffer.useAlternateBuffer(enabled);
   myDisplay.setScrollingEnabled(!enabled);
 }