diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 886e4cb5c9f..a063f0f6adf 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -933,9 +933,10 @@ }, "cursorShape": { "default": "bar", - "description": "Sets the shape of the cursor. Possible values:\n -\"bar\" ( ┃, default )\n -\"emptyBox\" ( ▯ )\n -\"filledBox\" ( █ )\n -\"underscore\" ( ▁ )\n -\"vintage\" ( ▃ )", + "description": "Sets the shape of the cursor. Possible values:\n -\"bar\" ( ┃, default )\n -\"doubleUnderscore\" ( ‗ )\n -\"emptyBox\" ( ▯ )\n -\"filledBox\" ( █ )\n -\"underscore\" ( ▁ )\n -\"vintage\" ( ▃ )", "enum": [ "bar", + "doubleUnderscore", "emptyBox", "filledBox", "underscore", diff --git a/src/cascadia/TerminalCore/ICoreSettings.idl b/src/cascadia/TerminalCore/ICoreSettings.idl index a41bac07bda..ebba05f4864 100644 --- a/src/cascadia/TerminalCore/ICoreSettings.idl +++ b/src/cascadia/TerminalCore/ICoreSettings.idl @@ -8,6 +8,7 @@ namespace Microsoft.Terminal.TerminalControl Vintage, Bar, Underscore, + DoubleUnderscore, FilledBox, EmptyBox }; diff --git a/src/cascadia/TerminalCore/Terminal.cpp b/src/cascadia/TerminalCore/Terminal.cpp index 0ace3a8ae16..81fd5bf75eb 100644 --- a/src/cascadia/TerminalCore/Terminal.cpp +++ b/src/cascadia/TerminalCore/Terminal.cpp @@ -130,6 +130,9 @@ void Terminal::UpdateSettings(ICoreSettings settings) case CursorStyle::Vintage: cursorShape = CursorType::Legacy; break; + case CursorStyle::DoubleUnderscore: + cursorShape = CursorType::DoubleUnderscore; + break; default: case CursorStyle::Bar: cursorShape = CursorType::VerticalBar; diff --git a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw index e56227509d2..6a86976ab7b 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw @@ -505,6 +505,10 @@ Vintage ( ▃ ) {Locked="▃"} + + Double Underscore ( ‗ ) + {Locked="‗"} + Font face diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h index 227ef4c8857..82b16cdefb0 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h @@ -20,10 +20,11 @@ Module Name: JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::TerminalControl::CursorStyle) { - static constexpr std::array mappings = { + static constexpr std::array mappings = { pair_type{ "bar", ValueType::Bar }, pair_type{ "vintage", ValueType::Vintage }, pair_type{ "underscore", ValueType::Underscore }, + pair_type{ "doubleUnderscore", ValueType::DoubleUnderscore }, pair_type{ "filledBox", ValueType::FilledBox }, pair_type{ "emptyBox", ValueType::EmptyBox } }; diff --git a/src/inc/conattrs.hpp b/src/inc/conattrs.hpp index 426c78e6985..482e427a787 100644 --- a/src/inc/conattrs.hpp +++ b/src/inc/conattrs.hpp @@ -42,7 +42,8 @@ enum class CursorType : unsigned int VerticalBar = 0x1, // A single vertical line, '|' Underscore = 0x2, // a single horizontal underscore, smaller that the min height legacy cursor. EmptyBox = 0x3, // Just the outline of a full box - FullBox = 0x4 // a full box, similar to legacy with height=100% + FullBox = 0x4, // a full box, similar to legacy with height=100% + DoubleUnderscore = 0x5 // a double horizontal underscore }; // Valid COLORREFs are of the pattern 0x00bbggrr. -1 works as an invalid color, diff --git a/src/renderer/dx/CustomTextRenderer.cpp b/src/renderer/dx/CustomTextRenderer.cpp index 84979ea0469..9ba700f2708 100644 --- a/src/renderer/dx/CustomTextRenderer.cpp +++ b/src/renderer/dx/CustomTextRenderer.cpp @@ -294,6 +294,14 @@ try } CursorPaintType paintType = CursorPaintType::Fill; + Microsoft::WRL::ComPtr brush{ drawingContext.foregroundBrush }; + + if (options.fUseColor) + { + // Make sure to make the cursor opaque + RETURN_IF_FAILED(d2dContext->CreateSolidColorBrush(til::color{ OPACITY_OPAQUE | options.cursorColor }, + &brush)); + } switch (options.cursorType) { @@ -318,6 +326,18 @@ try rect.top = rect.bottom - 1; break; } + case CursorType::DoubleUnderscore: + { + // Use rect for lower line. + rect.top = rect.bottom - 1; + + // Draw upper line directly. + D2D1_RECT_F upperLine = rect; + upperLine.top -= 2; + upperLine.bottom -= 2; + d2dContext->FillRectangle(upperLine, brush.Get()); + break; + } case CursorType::EmptyBox: { paintType = CursorPaintType::Outline; @@ -331,15 +351,6 @@ try return E_NOTIMPL; } - Microsoft::WRL::ComPtr brush{ drawingContext.foregroundBrush }; - - if (options.fUseColor) - { - // Make sure to make the cursor opaque - RETURN_IF_FAILED(d2dContext->CreateSolidColorBrush(til::color{ OPACITY_OPAQUE | options.cursorColor }, - &brush)); - } - switch (paintType) { case CursorPaintType::Fill: diff --git a/src/renderer/gdi/paint.cpp b/src/renderer/gdi/paint.cpp index 0885b975572..61e8e05ec0b 100644 --- a/src/renderer/gdi/paint.cpp +++ b/src/renderer/gdi/paint.cpp @@ -587,6 +587,19 @@ using namespace Microsoft::Console::Render; cursorInvertRects.push_back(rcInvert); break; + case CursorType::DoubleUnderscore: + { + RECT top, bottom; + top = bottom = rcBoundaries; + RETURN_IF_FAILED(LongAdd(bottom.bottom, -1, &bottom.top)); + RETURN_IF_FAILED(LongAdd(top.bottom, -3, &top.top)); + RETURN_IF_FAILED(LongAdd(top.top, 1, &top.bottom)); + + cursorInvertRects.push_back(top); + cursorInvertRects.push_back(bottom); + } + break; + case CursorType::EmptyBox: { RECT top, left, right, bottom;