bool AdaptDispatch::SetGraphicsRendition()

in src/terminal/adapter/adaptDispatchGraphics.cpp [76:265]


bool AdaptDispatch::SetGraphicsRendition(const VTParameters options)
{
    TextAttribute attr;
    bool success = _pConApi->PrivateGetTextAttributes(attr);

    if (success)
    {
        // Run through the graphics options and apply them
        for (size_t i = 0; i < options.size(); i++)
        {
            const GraphicsOptions opt = options.at(i);
            switch (opt)
            {
            case Off:
                attr.SetDefaultForeground();
                attr.SetDefaultBackground();
                attr.SetDefaultMetaAttrs();
                break;
            case ForegroundDefault:
                attr.SetDefaultForeground();
                break;
            case BackgroundDefault:
                attr.SetDefaultBackground();
                break;
            case Intense:
                attr.SetIntense(true);
                break;
            case RGBColorOrFaint:
                attr.SetFaint(true);
                break;
            case NotIntenseOrFaint:
                attr.SetIntense(false);
                attr.SetFaint(false);
                break;
            case Italics:
                attr.SetItalic(true);
                break;
            case NotItalics:
                attr.SetItalic(false);
                break;
            case BlinkOrXterm256Index:
            case RapidBlink: // We just interpret rapid blink as an alias of blink.
                attr.SetBlinking(true);
                break;
            case Steady:
                attr.SetBlinking(false);
                break;
            case Invisible:
                attr.SetInvisible(true);
                break;
            case Visible:
                attr.SetInvisible(false);
                break;
            case CrossedOut:
                attr.SetCrossedOut(true);
                break;
            case NotCrossedOut:
                attr.SetCrossedOut(false);
                break;
            case Negative:
                attr.SetReverseVideo(true);
                break;
            case Positive:
                attr.SetReverseVideo(false);
                break;
            case Underline:
                attr.SetUnderlined(true);
                break;
            case DoublyUnderlined:
                attr.SetDoublyUnderlined(true);
                break;
            case NoUnderline:
                attr.SetUnderlined(false);
                attr.SetDoublyUnderlined(false);
                break;
            case Overline:
                attr.SetOverlined(true);
                break;
            case NoOverline:
                attr.SetOverlined(false);
                break;
            case ForegroundBlack:
                attr.SetIndexedForeground(TextColor::DARK_BLACK);
                break;
            case ForegroundBlue:
                attr.SetIndexedForeground(TextColor::DARK_BLUE);
                break;
            case ForegroundGreen:
                attr.SetIndexedForeground(TextColor::DARK_GREEN);
                break;
            case ForegroundCyan:
                attr.SetIndexedForeground(TextColor::DARK_CYAN);
                break;
            case ForegroundRed:
                attr.SetIndexedForeground(TextColor::DARK_RED);
                break;
            case ForegroundMagenta:
                attr.SetIndexedForeground(TextColor::DARK_MAGENTA);
                break;
            case ForegroundYellow:
                attr.SetIndexedForeground(TextColor::DARK_YELLOW);
                break;
            case ForegroundWhite:
                attr.SetIndexedForeground(TextColor::DARK_WHITE);
                break;
            case BackgroundBlack:
                attr.SetIndexedBackground(TextColor::DARK_BLACK);
                break;
            case BackgroundBlue:
                attr.SetIndexedBackground(TextColor::DARK_BLUE);
                break;
            case BackgroundGreen:
                attr.SetIndexedBackground(TextColor::DARK_GREEN);
                break;
            case BackgroundCyan:
                attr.SetIndexedBackground(TextColor::DARK_CYAN);
                break;
            case BackgroundRed:
                attr.SetIndexedBackground(TextColor::DARK_RED);
                break;
            case BackgroundMagenta:
                attr.SetIndexedBackground(TextColor::DARK_MAGENTA);
                break;
            case BackgroundYellow:
                attr.SetIndexedBackground(TextColor::DARK_YELLOW);
                break;
            case BackgroundWhite:
                attr.SetIndexedBackground(TextColor::DARK_WHITE);
                break;
            case BrightForegroundBlack:
                attr.SetIndexedForeground(TextColor::BRIGHT_BLACK);
                break;
            case BrightForegroundBlue:
                attr.SetIndexedForeground(TextColor::BRIGHT_BLUE);
                break;
            case BrightForegroundGreen:
                attr.SetIndexedForeground(TextColor::BRIGHT_GREEN);
                break;
            case BrightForegroundCyan:
                attr.SetIndexedForeground(TextColor::BRIGHT_CYAN);
                break;
            case BrightForegroundRed:
                attr.SetIndexedForeground(TextColor::BRIGHT_RED);
                break;
            case BrightForegroundMagenta:
                attr.SetIndexedForeground(TextColor::BRIGHT_MAGENTA);
                break;
            case BrightForegroundYellow:
                attr.SetIndexedForeground(TextColor::BRIGHT_YELLOW);
                break;
            case BrightForegroundWhite:
                attr.SetIndexedForeground(TextColor::BRIGHT_WHITE);
                break;
            case BrightBackgroundBlack:
                attr.SetIndexedBackground(TextColor::BRIGHT_BLACK);
                break;
            case BrightBackgroundBlue:
                attr.SetIndexedBackground(TextColor::BRIGHT_BLUE);
                break;
            case BrightBackgroundGreen:
                attr.SetIndexedBackground(TextColor::BRIGHT_GREEN);
                break;
            case BrightBackgroundCyan:
                attr.SetIndexedBackground(TextColor::BRIGHT_CYAN);
                break;
            case BrightBackgroundRed:
                attr.SetIndexedBackground(TextColor::BRIGHT_RED);
                break;
            case BrightBackgroundMagenta:
                attr.SetIndexedBackground(TextColor::BRIGHT_MAGENTA);
                break;
            case BrightBackgroundYellow:
                attr.SetIndexedBackground(TextColor::BRIGHT_YELLOW);
                break;
            case BrightBackgroundWhite:
                attr.SetIndexedBackground(TextColor::BRIGHT_WHITE);
                break;
            case ForegroundExtended:
                i += _SetRgbColorsHelper(options.subspan(i + 1), attr, true);
                break;
            case BackgroundExtended:
                i += _SetRgbColorsHelper(options.subspan(i + 1), attr, false);
                break;
            }
        }
        success = _pConApi->PrivateSetTextAttributes(attr);
    }

    return success;
}