private void drawCharacters()

in ui/src/com/jediterm/terminal/ui/TerminalPanel.java [1309:1356]


  private void drawCharacters(int x, int y, TextStyle style, CharBuffer buf, Graphics2D gfx,
                              boolean includeSpaceBetweenLines) {
    if (myTextBlinkingTracker.shouldBlinkNow(style)) {
      style = getInversedStyle(style);
    }

    int xCoord = x * myCharSize.width + getInsetX();
    int yCoord = y * myCharSize.height + (includeSpaceBetweenLines ? 0 : mySpaceBetweenLines / 2);

    if (xCoord < 0 || xCoord > getWidth() || yCoord < 0 || yCoord > getHeight()) {
      return;
    }

    int textLength = CharUtils.getTextLengthDoubleWidthAware(buf.getBuf(), buf.getStart(), buf.length(), mySettingsProvider.ambiguousCharsAreDoubleWidth());
    int height = Math.min(myCharSize.height - (includeSpaceBetweenLines ? 0 : mySpaceBetweenLines), getHeight() - yCoord);
    int width = Math.min(textLength * TerminalPanel.this.myCharSize.width, TerminalPanel.this.getWidth() - xCoord);

    if (style instanceof HyperlinkStyle) {
      HyperlinkStyle hyperlinkStyle = (HyperlinkStyle) style;

      if (hyperlinkStyle.getHighlightMode() == HyperlinkStyle.HighlightMode.ALWAYS || (isHoveredHyperlink(hyperlinkStyle) && hyperlinkStyle.getHighlightMode() == HyperlinkStyle.HighlightMode.HOVER)) {

        // substitute text style with the hyperlink highlight style if applicable
        style = hyperlinkStyle.getHighlightStyle();
      }
    }

    java.awt.Color backgroundColor = getEffectiveBackground(style);
    gfx.setColor(backgroundColor);
    gfx.fillRect(xCoord,
            yCoord,
            width,
            height);

    if (buf.isNul()) {
      return; // nothing more to do
    }

    gfx.setColor(getStyleForeground(style));

    drawChars(x, y, buf, style, gfx);

    if (style.hasOption(TextStyle.Option.UNDERLINED)) {
      int baseLine = (y + 1) * myCharSize.height - mySpaceBetweenLines / 2 - myDescent;
      int lineY = baseLine + 3;
      gfx.drawLine(xCoord, lineY, (x + textLength) * myCharSize.width + getInsetX(), lineY);
    }
  }