Esempio n. 1
0
 private TextStyle getInversedStyle(TextStyle style) {
   TextStyle selectionStyle;
   selectionStyle = style.clone();
   selectionStyle.setOption(Option.INVERSE, !selectionStyle.hasOption(Option.INVERSE));
   if (selectionStyle.getForeground() == null) {
     selectionStyle.setForeground(myStyleState.getForeground());
   }
   if (selectionStyle.getBackground() == null) {
     selectionStyle.setBackground(myStyleState.getBackground());
   }
   return selectionStyle;
 }
Esempio n. 2
0
  private void drawCharacters(int x, int y, TextStyle style, CharBuffer buf, Graphics2D gfx) {
    int xCoord = x * myCharSize.width;
    int yCoord = y * myCharSize.height;

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

    gfx.setColor(getPalette().getColor(myStyleState.getBackground(style.getBackgroundForRun())));
    int textLength =
        CharUtils.getTextLengthDoubleWidthAware(
            buf.getBuf(),
            buf.getStart(),
            buf.length(),
            mySettingsProvider.ambiguousCharsAreDoubleWidth());

    gfx.fillRect(
        xCoord,
        yCoord,
        Math.min(textLength * myCharSize.width, getWidth() - xCoord),
        Math.min(myCharSize.height, getHeight() - yCoord));

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

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

    gfx.setColor(getPalette().getColor(myStyleState.getForeground(style.getForegroundForRun())));

    int baseLine = (y + 1) * myCharSize.height - myDescent;

    if (style.hasOption(TextStyle.Option.UNDERLINED)) {
      gfx.drawLine(xCoord, baseLine + 1, (x + textLength) * myCharSize.width, baseLine + 1);
    }
  }
Esempio n. 3
0
 @Override
 public Color getBackground() {
   return getPalette().getColor(myStyleState.getBackground());
 }