private static TextStyle createStyleState()

in core/src/com/jediterm/terminal/emulator/JediEmulator.java [972:1110]


  private static TextStyle createStyleState(@NotNull TextStyle textStyle, ControlSequence args) {
    TextStyle.Builder builder = textStyle.toBuilder();
    final int argCount = args.getCount();
    if (argCount == 0) {
      builder = new TextStyle.Builder();
    }

    int i = 0;
    while (i < argCount) {
      int step = 1;

      final int arg = args.getArg(i, -1);
      if (arg == -1) {
        LOG.warn("Error in processing char attributes, arg " + i);
        i++;
        continue;
      }

      switch (arg) {
        case 0: //Normal (default)
          builder = new TextStyle.Builder();
          break;
        case 1:// Bold
          builder.setOption(TextStyle.Option.BOLD, true);
          break;
        case 2:// Dim
          builder.setOption(TextStyle.Option.DIM, true);
          break;
        case 3:// Italic
          builder.setOption(TextStyle.Option.ITALIC, true);
          break;
        case 4:// Underlined
          builder.setOption(TextStyle.Option.UNDERLINED, true);
          break;
        case 5:// Slow Blink
          builder.setOption(TextStyle.Option.SLOW_BLINK, true);
          builder.setOption(TextStyle.Option.RAPID_BLINK, false);
          break;
        case 6:// Rapid Blink
          builder.setOption(TextStyle.Option.SLOW_BLINK, false);
          builder.setOption(TextStyle.Option.RAPID_BLINK, true);
          break;
        case 7:// Inverse
          builder.setOption(TextStyle.Option.INVERSE, true);
          break;
        case 8: // Invisible (hidden)
          builder.setOption(TextStyle.Option.HIDDEN, true);
          break;
        case 22: //Normal (neither bold nor faint)
          builder.setOption(TextStyle.Option.BOLD, false);
          builder.setOption(TextStyle.Option.DIM, false);
          break;
        case 23: // Not italic
          builder.setOption(TextStyle.Option.ITALIC, false);
          break;
        case 24: // Not underlined
          builder.setOption(TextStyle.Option.UNDERLINED, false);
          break;
        case 25: //Steady (not blinking)
          builder.setOption(TextStyle.Option.SLOW_BLINK, false);
          builder.setOption(TextStyle.Option.RAPID_BLINK, false);
          break;
        case 27: //Positive (not inverse)
          builder.setOption(TextStyle.Option.INVERSE, false);
          break;
        case 28: //Visible, i.e. not hidden
          builder.setOption(TextStyle.Option.HIDDEN, false);
          break;
        case 30:
        case 31:
        case 32:
        case 33:
        case 34:
        case 35:
        case 36:
        case 37:
          builder.setForeground(TerminalColor.index(arg - 30));
          break;
        case 38: // Set xterm-256 text color
          TerminalColor color256 = getColor256(args, i);
          if (color256 != null) {
            builder.setForeground(color256);
            step = getColor256Step(args, i);
          }
          break;
        case 39: // Default (original) foreground
          builder.setForeground(null);
          break;
        case 40:
        case 41:
        case 42:
        case 43:
        case 44:
        case 45:
        case 46:
        case 47:
          builder.setBackground(TerminalColor.index(arg - 40));
          break;
        case 48: // Set xterm-256 background color
          TerminalColor bgColor256 = getColor256(args, i);
          if (bgColor256 != null) {
            builder.setBackground(bgColor256);
            step = getColor256Step(args, i);
          }
          break;
        case 49: //Default (original) foreground
          builder.setBackground(null);
          break;
        case 90:
        case 91:
        case 92:
        case 93:
        case 94:
        case 95:
        case 96:
        case 97:
          //Bright versions of the ISO colors for foreground
          builder.setForeground(ColorPalette.getIndexedTerminalColor(arg - 82));
          break;
        case 100:
        case 101:
        case 102:
        case 103:
        case 104:
        case 105:
        case 106:
        case 107:
          //Bright versions of the ISO colors for background
          builder.setBackground(ColorPalette.getIndexedTerminalColor(arg - 92));
          break;
        default:
          if (LOG.isDebugEnabled()) {
            LOG.debug("Unknown character attribute:{}", arg);
          }
      }
      i = i + step;
    }
    return builder.build();
  }