Compare commits
15 commits
dev/migrie
...
main
Author | SHA1 | Date | |
---|---|---|---|
f2386de422 | |||
80f8383860 | |||
bb71179a24 | |||
df06c54e70 | |||
a98d18c030 | |||
dc01926e3e | |||
6ad848e158 | |||
ea456cf121 | |||
442432ea15 | |||
fc85bdf314 | |||
a68b0d4f08 | |||
6742965bb8 | |||
131f5d2b32 | |||
7bfaad4592 | |||
c455418659 |
19
.github/ISSUE_TEMPLATE/Bug_Report.yml
vendored
19
.github/ISSUE_TEMPLATE/Bug_Report.yml
vendored
|
@ -10,14 +10,21 @@ body:
|
|||
|
||||
- type: input
|
||||
attributes:
|
||||
label: Windows Terminal version (or Windows build number)
|
||||
placeholder: "10.0.19042.0, 1.7.3651.0"
|
||||
label: Windows Terminal version
|
||||
placeholder: "1.7.3651.0"
|
||||
description: |
|
||||
If you are reporting an issue in Windows Terminal, you can find the version in the about dialog.
|
||||
|
||||
If you are reporting an issue with the Windows Console, please run `ver` or `[Environment]::OSVersion`.
|
||||
You can find the version in the about dialog, or by running `wt -v` at the commandline.
|
||||
validations:
|
||||
required: true
|
||||
required: false
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: Windows build number
|
||||
placeholder: "10.0.19042.0"
|
||||
description: |
|
||||
Please run `ver` or `[Environment]::OSVersion`.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
|
|
1
.github/actions/spelling/allow/allow.txt
vendored
1
.github/actions/spelling/allow/allow.txt
vendored
|
@ -32,6 +32,7 @@ hyperlink
|
|||
hyperlinking
|
||||
hyperlinks
|
||||
img
|
||||
inlined
|
||||
It'd
|
||||
kje
|
||||
liga
|
||||
|
|
1
.github/actions/spelling/allow/apis.txt
vendored
1
.github/actions/spelling/allow/apis.txt
vendored
|
@ -169,6 +169,7 @@ toupper
|
|||
TTask
|
||||
TVal
|
||||
UChar
|
||||
UFIELD
|
||||
ULARGE
|
||||
UPDATEINIFILE
|
||||
userenv
|
||||
|
|
1
.github/actions/spelling/expect/expect.txt
vendored
1
.github/actions/spelling/expect/expect.txt
vendored
|
@ -508,6 +508,7 @@ dealloc
|
|||
Debian
|
||||
debolden
|
||||
debugtype
|
||||
DECAC
|
||||
DECALN
|
||||
DECANM
|
||||
DECAUPSS
|
||||
|
|
|
@ -4,7 +4,7 @@ https://www\.itscj\.ipsj\.or\.jp/iso-ir/[-0-9]+\.pdf
|
|||
https://www\.vt100\.net/docs/[-a-zA-Z0-9#_\/.]*
|
||||
https://www.w3.org/[-a-zA-Z0-9?&=\/_#]*
|
||||
https://(?:(?:www\.|)youtube\.com|youtu.be)/[-a-zA-Z0-9?&=]*
|
||||
https://(?:[a-z-]+\.|)github(?:usercontent|)\.com/[-a-zA-Z0-9?%&=_\/.]*
|
||||
https://(?:[a-z-]+\.|)github(?:usercontent|)\.com/[-a-zA-Z0-9?%&=_\/.+]*
|
||||
https://www.xfree86.org/[-a-zA-Z0-9?&=\/_#]*
|
||||
[Pp]ublicKeyToken="?[0-9a-fA-F]{16}"?
|
||||
(?:[{"]|UniqueIdentifier>)[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}(?:[}"]|</UniqueIdentifier)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
"Microsoft.Net.Component.4.5.TargetingPack",
|
||||
"Microsoft.VisualStudio.Component.DiagnosticTools",
|
||||
"Microsoft.VisualStudio.Component.Debugger.JustInTime",
|
||||
"Microsoft.VisualStudio.Component.Windows10SDK.19041",
|
||||
"Microsoft.VisualStudio.Component.Windows10SDK.22000",
|
||||
"Microsoft.VisualStudio.ComponentGroup.UWP.Support",
|
||||
"Microsoft.VisualStudio.Component.VC.CoreIde",
|
||||
"Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core",
|
||||
|
|
|
@ -99,15 +99,29 @@ If you don't have any additional info/context to add but would like to indicate
|
|||
|
||||
## Contributing fixes / features
|
||||
|
||||
For those able & willing to help fix issues and/or implement features ...
|
||||
If you're able & willing to help fix issues and/or implement features, we'd love your contribution!
|
||||
|
||||
The best place to start is the list of ["Easy Starter"](https://github.com/microsoft/terminal/issues?q=is%3Aopen+is%3Aissue+label%3A%22Help+Wanted%22+label%3A%22Easy+Starter%22+) issues. These are bugs or tasks that we on the team believe would be easier to implement for someone without any prior experience in the codebase. Once you're feeling more comfortable in the codebase, feel free to just use the ["Help Wanted"](https://github.com/microsoft/terminal/issues?q=is%3Aopen+is%3Aissue+label%3A%22Help+Wanted%22+) label, or just find an issue your interested in and hop in!
|
||||
|
||||
Generally, we categorize issues in the following way, which is largely derived from our old internal work tracking system:
|
||||
* ["Bugs"](https://github.com/microsoft/terminal/issues?q=is%3Aopen+is%3Aissue+label%3A%22Issue-Bug%22+) are parts of the Terminal & Console that are not quite working the right way. There's code to already support some scenario, but it's not quite working right. Fixing these is generally a matter of debugging the broken functionality and fixing the wrong code.
|
||||
* ["Tasks"](https://github.com/microsoft/terminal/issues?q=is%3Aopen+is%3Aissue+label%3A%22Issue-Task%22+) are usually new pieces of functionality that aren't yet implemented for the Terminal/Console. These are usually smaller features, which we believe
|
||||
- could be a single, atomic PR
|
||||
- Don't require much design consideration, or we've already written the spec for the larger feature they belong to.
|
||||
* ["Features"](https://github.com/microsoft/terminal/issues?q=is%3Aopen+is%3Aissue+label%3A%22Issue-Feature%22+) are larger pieces of new functionality. These are usually things we believe would require larger discussion of how they should be implemented, or they'll require some complicated new settings. They might just be features that are composed of many individual tasks. Often times, with features, we like to have a spec written before development work is started, to make sure we're all on the same page (see below).
|
||||
|
||||
Bugs and tasks are obviously the easiest to get started with, but don't feel afraid of features either! We've had some community members contribute some amazing "feature"-level work to the Terminal (albeit, with lots of discussion 😄).
|
||||
|
||||
|
||||
Often, we like to assign issues that generally belong to somebody's area of expertise to the team member that owns that area. This doesn't mean the community can't jump in -- they should reach out and have a chat with the assignee to see if it'd okay to take. If an issue's been assigned more than a month ago, there's a good chance it's fair game to try yourself.
|
||||
|
||||
### To Spec or not to Spec
|
||||
|
||||
Some issues/features may be quick and simple to describe and understand. For such scenarios, once a team member has agreed with your approach, skip ahead to the section headed "Fork, Branch, and Create your PR", below.
|
||||
|
||||
Small issues that do not require a spec will be labelled Issue-Bug or Issue-Task.
|
||||
Small issues that do not require a spec will be labelled `Issue-Bug` or `Issue-Task`.
|
||||
|
||||
However, some issues/features will require careful thought & formal design before implementation. For these scenarios, we'll request that a spec is written and the associated issue will be labeled Issue-Feature.
|
||||
However, some issues/features will require careful thought & formal design before implementation. For these scenarios, we'll request that a spec is written and the associated issue will be labeled `Issue-Feature`. More often than not, we'll add such features to the ["Specification Tracker" project](https://github.com/microsoft/terminal/projects/1).
|
||||
|
||||
Specs help collaborators discuss different approaches to solve a problem, describe how the feature will behave, how the feature will impact the user, what happens if something goes wrong, etc. Driving towards agreement in a spec, before any code is written, often results in simpler code, and less wasted effort in the long run.
|
||||
|
||||
|
|
|
@ -63,8 +63,14 @@
|
|||
Outputs="$(OpenConsoleCommonOutDir)\inc\TilFeatureStaging.h"
|
||||
DependsOnTargets="_GenerateBranchAndBrandingCache">
|
||||
<MakeDir Directories="$(OpenConsoleCommonOutDir)\inc" />
|
||||
<!-- This commandline is escaped like:
|
||||
|
||||
powershell -Command "&'$(SolutionDir)\tools\Generate-FeatureStagingHeader.ps1' -Path '%(FeatureFlagFile.FullPath)'' -Branding $(_WTBrandingName)"
|
||||
|
||||
which was the only way I could find to get it to obey spaces in the SolutionDir
|
||||
-->
|
||||
<Exec
|
||||
Command="powershell -NoLogo -NoProfile -NonInteractive -ExecutionPolicy ByPass -Command "$(SolutionDir)\tools\Generate-FeatureStagingHeader.ps1" -Path "%(FeatureFlagFile.FullPath)" -Branding $(_WTBrandingName)"
|
||||
Command="powershell -NoLogo -NoProfile -NonInteractive -ExecutionPolicy ByPass -Command "&'$(SolutionDir)\tools\Generate-FeatureStagingHeader.ps1' -Path '%(FeatureFlagFile.FullPath)' -Branding $(_WTBrandingName)""
|
||||
ConsoleToMsBuild="true"
|
||||
StandardOutputImportance="low">
|
||||
<Output TaskParameter="ConsoleOutput" ItemName="_FeatureFlagFileLines" />
|
||||
|
|
|
@ -22,7 +22,7 @@ Param(
|
|||
[Parameter(HelpMessage="Path to makeappx.exe")]
|
||||
[ValidateScript({Test-Path $_ -Type Leaf})]
|
||||
[string]
|
||||
$MakeAppxPath = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86\MakeAppx.exe"
|
||||
$MakeAppxPath = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x86\MakeAppx.exe"
|
||||
)
|
||||
|
||||
If ($null -Eq (Get-Item $MakeAppxPath -EA:SilentlyContinue)) {
|
||||
|
|
|
@ -8,7 +8,7 @@ Param(
|
|||
[Parameter(HelpMessage="Path to Windows Kit")]
|
||||
[ValidateScript({Test-Path $_ -Type Leaf})]
|
||||
[string]
|
||||
$WindowsKitPath = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0"
|
||||
$WindowsKitPath = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
|
|
@ -380,7 +380,7 @@ Here's the AppxManifest we're using:
|
|||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.18362.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.18362.0" MaxVersionTested="10.0.22000.0" />
|
||||
<PackageDependency Name="Microsoft.VCLibs.140.00.Debug" MinVersion="14.0.27023.1" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
<PackageDependency Name="Microsoft.VCLibs.140.00.Debug.UWPDesktop" MinVersion="14.0.27027.1" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
</Dependencies>
|
||||
|
@ -517,7 +517,7 @@ This is because of a few key lines we already put in the appxmanifest:
|
|||
|
||||
```xml
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.18362.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.18362.0" MaxVersionTested="10.0.22000.0" />
|
||||
<PackageDependency Name="Microsoft.VCLibs.140.00.Debug" MinVersion="14.0.27023.1" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
<PackageDependency Name="Microsoft.VCLibs.140.00.Debug.UWPDesktop" MinVersion="14.0.27027.1" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
</Dependencies>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<ProjectGuid>{96274800-9574-423E-892A-909FBE2AC8BE}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>EchoCon</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.22000.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
|
@ -163,4 +163,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.18362.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.18362.0" MaxVersionTested="10.0.22000.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
|
|
|
@ -118,6 +118,23 @@
|
|||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--
|
||||
BODGY
|
||||
|
||||
The wapproj `GetResolvedWinMD` target tries to get a winmd from every cppwinrt
|
||||
executable we put in the package. But we DON'T produce a winmd. This makes the
|
||||
FastUpToDate check fail every time, and leads to the whole wapproj build
|
||||
running even if you're just f5'ing the package. EVEN AFTER A SUCCESSFUL BUILD.
|
||||
|
||||
Setting GenerateWindowsMetadata=false is enough to tell the build system that
|
||||
we don't produce one, and get it off our backs.
|
||||
-->
|
||||
<ItemDefinitionGroup>
|
||||
<Link>
|
||||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
<Import Project="$(OpenConsoleDir)src\cppwinrt.build.post.props" />
|
||||
|
||||
<Import Project="..\..\..\packages\Microsoft.UI.Xaml.2.7.0-prerelease.210913003\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\..\packages\Microsoft.UI.Xaml.2.7.0-prerelease.210913003\build\native\Microsoft.UI.Xaml.targets')" />
|
||||
|
|
|
@ -128,22 +128,22 @@ bool TextAttribute::IsLegacy() const noexcept
|
|||
// - Calculates rgb colors based off of current color table and active modification attributes.
|
||||
// Arguments:
|
||||
// - colorTable: the current color table rgb values.
|
||||
// - defaultFgColor: the default foreground color rgb value.
|
||||
// - defaultBgColor: the default background color rgb value.
|
||||
// - defaultFgIndex: the color table index of the default foreground color.
|
||||
// - defaultBgIndex: the color table index of the default background color.
|
||||
// - reverseScreenMode: true if the screen mode is reversed.
|
||||
// - blinkingIsFaint: true if blinking should be interpreted as faint. (defaults to false)
|
||||
// - boldIsBright: true if "bold" should be interpreted as bright. (defaults to true)
|
||||
// Return Value:
|
||||
// - the foreground and background colors that should be displayed.
|
||||
std::pair<COLORREF, COLORREF> TextAttribute::CalculateRgbColors(const std::array<COLORREF, 256>& colorTable,
|
||||
const COLORREF defaultFgColor,
|
||||
const COLORREF defaultBgColor,
|
||||
std::pair<COLORREF, COLORREF> TextAttribute::CalculateRgbColors(const std::array<COLORREF, TextColor::TABLE_SIZE>& colorTable,
|
||||
const size_t defaultFgIndex,
|
||||
const size_t defaultBgIndex,
|
||||
const bool reverseScreenMode,
|
||||
const bool blinkingIsFaint,
|
||||
const bool boldIsBright) const noexcept
|
||||
{
|
||||
auto fg = _foreground.GetColor(colorTable, defaultFgColor, boldIsBright && IsBold());
|
||||
auto bg = _background.GetColor(colorTable, defaultBgColor);
|
||||
auto fg = _foreground.GetColor(colorTable, defaultFgIndex, boldIsBright && IsBold());
|
||||
auto bg = _background.GetColor(colorTable, defaultBgIndex);
|
||||
if (IsFaint() || (IsBlinking() && blinkingIsFaint))
|
||||
{
|
||||
fg = (fg >> 1) & 0x7F7F7F; // Divide foreground color components by two.
|
||||
|
|
|
@ -64,9 +64,9 @@ public:
|
|||
static TextAttribute StripErroneousVT16VersionsOfLegacyDefaults(const TextAttribute& attribute) noexcept;
|
||||
WORD GetLegacyAttributes() const noexcept;
|
||||
|
||||
std::pair<COLORREF, COLORREF> CalculateRgbColors(const std::array<COLORREF, 256>& colorTable,
|
||||
const COLORREF defaultFgColor,
|
||||
const COLORREF defaultBgColor,
|
||||
std::pair<COLORREF, COLORREF> CalculateRgbColors(const std::array<COLORREF, TextColor::TABLE_SIZE>& colorTable,
|
||||
const size_t defaultFgIndex,
|
||||
const size_t defaultBgIndex,
|
||||
const bool reverseScreenMode = false,
|
||||
const bool blinkingIsFaint = false,
|
||||
const bool boldIsBright = true) const noexcept;
|
||||
|
|
|
@ -139,14 +139,16 @@ void TextColor::SetDefault() noexcept
|
|||
// Arguments:
|
||||
// - colorTable: The table of colors we should use to look up the value of
|
||||
// an indexed attribute from.
|
||||
// - defaultColor: The color value to use if we're a default attribute.
|
||||
// - defaultIndex: The color table index to use if we're a default attribute.
|
||||
// - brighten: if true, we'll brighten a dark color table index.
|
||||
// Return Value:
|
||||
// - a COLORREF containing the real value of this TextColor.
|
||||
COLORREF TextColor::GetColor(const std::array<COLORREF, 256>& colorTable, const COLORREF defaultColor, bool brighten) const noexcept
|
||||
COLORREF TextColor::GetColor(const std::array<COLORREF, TextColor::TABLE_SIZE>& colorTable, const size_t defaultIndex, bool brighten) const noexcept
|
||||
{
|
||||
if (IsDefault())
|
||||
{
|
||||
const auto defaultColor = til::at(colorTable, defaultIndex);
|
||||
|
||||
if (brighten)
|
||||
{
|
||||
// See MSFT:20266024 for context on this fix.
|
||||
|
|
|
@ -65,6 +65,11 @@ public:
|
|||
static constexpr BYTE BRIGHT_CYAN = 14;
|
||||
static constexpr BYTE BRIGHT_WHITE = 15;
|
||||
|
||||
static constexpr size_t DEFAULT_FOREGROUND = 256;
|
||||
static constexpr size_t DEFAULT_BACKGROUND = 257;
|
||||
static constexpr size_t CURSOR_COLOR = 258;
|
||||
static constexpr size_t TABLE_SIZE = 259;
|
||||
|
||||
constexpr TextColor() noexcept :
|
||||
_meta{ ColorType::IsDefault },
|
||||
_red{ 0 },
|
||||
|
@ -103,7 +108,7 @@ public:
|
|||
void SetIndex(const BYTE index, const bool isIndex256) noexcept;
|
||||
void SetDefault() noexcept;
|
||||
|
||||
COLORREF GetColor(const std::array<COLORREF, 256>& colorTable, const COLORREF defaultColor, bool brighten = false) const noexcept;
|
||||
COLORREF GetColor(const std::array<COLORREF, TABLE_SIZE>& colorTable, const size_t defaultIndex, bool brighten = false) const noexcept;
|
||||
BYTE GetLegacyIndex(const BYTE defaultIndex) const noexcept;
|
||||
|
||||
constexpr BYTE GetIndex() const noexcept
|
||||
|
|
|
@ -27,9 +27,7 @@ Cursor::Cursor(const ULONG ulSize, TextBuffer& parentBuffer) noexcept :
|
|||
_fDeferCursorRedraw(false),
|
||||
_fHaveDeferredCursorRedraw(false),
|
||||
_ulSize(ulSize),
|
||||
_cursorType(CursorType::Legacy),
|
||||
_fUseColor(false),
|
||||
_color(s_InvertCursorColor)
|
||||
_cursorType(CursorType::Legacy)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -143,10 +141,9 @@ void Cursor::SetSize(const ULONG ulSize) noexcept
|
|||
_RedrawCursor();
|
||||
}
|
||||
|
||||
void Cursor::SetStyle(const ULONG ulSize, const COLORREF color, const CursorType type) noexcept
|
||||
void Cursor::SetStyle(const ULONG ulSize, const CursorType type) noexcept
|
||||
{
|
||||
_ulSize = ulSize;
|
||||
_color = color;
|
||||
_cursorType = type;
|
||||
|
||||
_RedrawCursor();
|
||||
|
@ -285,7 +282,6 @@ void Cursor::CopyProperties(const Cursor& OtherCursor) noexcept
|
|||
// Size will be handled separately in the resize operation.
|
||||
//_ulSize = OtherCursor._ulSize;
|
||||
_cursorType = OtherCursor._cursorType;
|
||||
_color = OtherCursor._color;
|
||||
}
|
||||
|
||||
void Cursor::DelayEOLWrap(const COORD coordDelayedAt) noexcept
|
||||
|
@ -335,21 +331,6 @@ const CursorType Cursor::GetType() const noexcept
|
|||
return _cursorType;
|
||||
}
|
||||
|
||||
const bool Cursor::IsUsingColor() const noexcept
|
||||
{
|
||||
return GetColor() != INVALID_COLOR;
|
||||
}
|
||||
|
||||
const COLORREF Cursor::GetColor() const noexcept
|
||||
{
|
||||
return _color;
|
||||
}
|
||||
|
||||
void Cursor::SetColor(const unsigned int color) noexcept
|
||||
{
|
||||
_color = gsl::narrow_cast<COLORREF>(color);
|
||||
}
|
||||
|
||||
void Cursor::SetType(const CursorType type) noexcept
|
||||
{
|
||||
_cursorType = type;
|
||||
|
|
|
@ -24,7 +24,6 @@ class TextBuffer;
|
|||
class Cursor final
|
||||
{
|
||||
public:
|
||||
static const unsigned int s_InvertCursorColor = INVALID_COLOR;
|
||||
// the following values are used to create the textmode cursor.
|
||||
static constexpr unsigned int CURSOR_SMALL_SIZE = 25; // large enough to be one pixel on a six pixel font
|
||||
|
||||
|
@ -51,8 +50,6 @@ public:
|
|||
COORD GetPosition() const noexcept;
|
||||
|
||||
const CursorType GetType() const noexcept;
|
||||
const bool IsUsingColor() const noexcept;
|
||||
const COLORREF GetColor() const noexcept;
|
||||
|
||||
void StartDeferDrawing() noexcept;
|
||||
bool IsDeferDrawing() noexcept;
|
||||
|
@ -67,7 +64,7 @@ public:
|
|||
void SetIsPopupShown(const bool fIsPopupShown) noexcept;
|
||||
void SetDelay(const bool fDelay) noexcept;
|
||||
void SetSize(const ULONG ulSize) noexcept;
|
||||
void SetStyle(const ULONG ulSize, const COLORREF color, const CursorType type) noexcept;
|
||||
void SetStyle(const ULONG ulSize, const CursorType type) noexcept;
|
||||
|
||||
void SetPosition(const COORD cPosition) noexcept;
|
||||
void SetXPosition(const int NewX) noexcept;
|
||||
|
@ -84,7 +81,6 @@ public:
|
|||
COORD GetDelayedAtPosition() const noexcept;
|
||||
bool IsDelayedEOLWrap() const noexcept;
|
||||
|
||||
void SetColor(const unsigned int color) noexcept;
|
||||
void SetType(const CursorType type) noexcept;
|
||||
|
||||
private:
|
||||
|
@ -117,6 +113,4 @@ private:
|
|||
void _RedrawCursorAlways() noexcept;
|
||||
|
||||
CursorType _cursorType;
|
||||
bool _fUseColor;
|
||||
COLORREF _color;
|
||||
};
|
||||
|
|
|
@ -24,9 +24,11 @@ class TextAttributeTests
|
|||
TEST_METHOD(TestRoundtripDefaultColors);
|
||||
TEST_METHOD(TestBoldAsBright);
|
||||
|
||||
std::array<COLORREF, 256> _colorTable;
|
||||
COLORREF _defaultFg = RGB(1, 2, 3);
|
||||
COLORREF _defaultBg = RGB(4, 5, 6);
|
||||
std::array<COLORREF, TextColor::TABLE_SIZE> _colorTable;
|
||||
const COLORREF _defaultFg = RGB(1, 2, 3);
|
||||
const COLORREF _defaultBg = RGB(4, 5, 6);
|
||||
const size_t _defaultFgIndex = TextColor::DEFAULT_FOREGROUND;
|
||||
const size_t _defaultBgIndex = TextColor::DEFAULT_BACKGROUND;
|
||||
};
|
||||
|
||||
bool TextAttributeTests::ClassSetup()
|
||||
|
@ -47,6 +49,8 @@ bool TextAttributeTests::ClassSetup()
|
|||
_colorTable[13] = RGB(180, 0, 158); // Bright Magenta
|
||||
_colorTable[14] = RGB(249, 241, 165); // Bright Yellow
|
||||
_colorTable[15] = RGB(242, 242, 242); // White
|
||||
_colorTable[_defaultFgIndex] = _defaultFg;
|
||||
_colorTable[_defaultBgIndex] = _defaultBg;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -132,17 +136,17 @@ void TextAttributeTests::TestTextAttributeColorGetters()
|
|||
// values when reverse video is not set
|
||||
VERIFY_IS_FALSE(attr.IsReverseVideo());
|
||||
|
||||
VERIFY_ARE_EQUAL(red, attr.GetForeground().GetColor(_colorTable, _defaultFg));
|
||||
VERIFY_ARE_EQUAL(green, attr.GetBackground().GetColor(_colorTable, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(red, green), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(red, attr.GetForeground().GetColor(_colorTable, _defaultFgIndex));
|
||||
VERIFY_ARE_EQUAL(green, attr.GetBackground().GetColor(_colorTable, _defaultBgIndex));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(red, green), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex));
|
||||
|
||||
// with reverse video set, calculated foreground/background values should be
|
||||
// switched while getters stay the same
|
||||
attr.SetReverseVideo(true);
|
||||
|
||||
VERIFY_ARE_EQUAL(red, attr.GetForeground().GetColor(_colorTable, _defaultFg));
|
||||
VERIFY_ARE_EQUAL(green, attr.GetBackground().GetColor(_colorTable, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(green, red), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(red, attr.GetForeground().GetColor(_colorTable, _defaultFgIndex));
|
||||
VERIFY_ARE_EQUAL(green, attr.GetBackground().GetColor(_colorTable, _defaultBgIndex));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(green, red), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex));
|
||||
|
||||
// reset the reverse video
|
||||
attr.SetReverseVideo(false);
|
||||
|
@ -151,17 +155,17 @@ void TextAttributeTests::TestTextAttributeColorGetters()
|
|||
// while the background and getters stay the same
|
||||
attr.SetFaint(true);
|
||||
|
||||
VERIFY_ARE_EQUAL(red, attr.GetForeground().GetColor(_colorTable, _defaultFg));
|
||||
VERIFY_ARE_EQUAL(green, attr.GetBackground().GetColor(_colorTable, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(faintRed, green), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(red, attr.GetForeground().GetColor(_colorTable, _defaultFgIndex));
|
||||
VERIFY_ARE_EQUAL(green, attr.GetBackground().GetColor(_colorTable, _defaultBgIndex));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(faintRed, green), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex));
|
||||
|
||||
// with reverse video set, calculated foreground/background values should be
|
||||
// switched, and the background fainter, while getters stay the same
|
||||
attr.SetReverseVideo(true);
|
||||
|
||||
VERIFY_ARE_EQUAL(red, attr.GetForeground().GetColor(_colorTable, _defaultFg));
|
||||
VERIFY_ARE_EQUAL(green, attr.GetBackground().GetColor(_colorTable, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(green, faintRed), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(red, attr.GetForeground().GetColor(_colorTable, _defaultFgIndex));
|
||||
VERIFY_ARE_EQUAL(green, attr.GetBackground().GetColor(_colorTable, _defaultBgIndex));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(green, faintRed), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex));
|
||||
|
||||
// reset the reverse video and faint attributes
|
||||
attr.SetReverseVideo(false);
|
||||
|
@ -171,17 +175,17 @@ void TextAttributeTests::TestTextAttributeColorGetters()
|
|||
// background, while getters stay the same
|
||||
attr.SetInvisible(true);
|
||||
|
||||
VERIFY_ARE_EQUAL(red, attr.GetForeground().GetColor(_colorTable, _defaultFg));
|
||||
VERIFY_ARE_EQUAL(green, attr.GetBackground().GetColor(_colorTable, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(green, green), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(red, attr.GetForeground().GetColor(_colorTable, _defaultFgIndex));
|
||||
VERIFY_ARE_EQUAL(green, attr.GetBackground().GetColor(_colorTable, _defaultBgIndex));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(green, green), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex));
|
||||
|
||||
// with reverse video set, the calculated background value should match
|
||||
// the foreground, while getters stay the same
|
||||
attr.SetReverseVideo(true);
|
||||
|
||||
VERIFY_ARE_EQUAL(red, attr.GetForeground().GetColor(_colorTable, _defaultFg));
|
||||
VERIFY_ARE_EQUAL(green, attr.GetBackground().GetColor(_colorTable, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(red, red), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(red, attr.GetForeground().GetColor(_colorTable, _defaultFgIndex));
|
||||
VERIFY_ARE_EQUAL(green, attr.GetBackground().GetColor(_colorTable, _defaultBgIndex));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(red, red), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex));
|
||||
}
|
||||
|
||||
void TextAttributeTests::TestReverseDefaultColors()
|
||||
|
@ -194,34 +198,34 @@ void TextAttributeTests::TestReverseDefaultColors()
|
|||
// values when reverse video is not set
|
||||
VERIFY_IS_FALSE(attr.IsReverseVideo());
|
||||
|
||||
VERIFY_ARE_EQUAL(_defaultFg, attr.GetForeground().GetColor(_colorTable, _defaultFg));
|
||||
VERIFY_ARE_EQUAL(_defaultBg, attr.GetBackground().GetColor(_colorTable, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(_defaultFg, attr.GetForeground().GetColor(_colorTable, _defaultFgIndex));
|
||||
VERIFY_ARE_EQUAL(_defaultBg, attr.GetBackground().GetColor(_colorTable, _defaultBgIndex));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex));
|
||||
|
||||
// with reverse video set, calculated foreground/background values should be
|
||||
// switched while getters stay the same
|
||||
attr.SetReverseVideo(true);
|
||||
VERIFY_IS_TRUE(attr.IsReverseVideo());
|
||||
|
||||
VERIFY_ARE_EQUAL(_defaultFg, attr.GetForeground().GetColor(_colorTable, _defaultFg));
|
||||
VERIFY_ARE_EQUAL(_defaultBg, attr.GetBackground().GetColor(_colorTable, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultBg, _defaultFg), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(_defaultFg, attr.GetForeground().GetColor(_colorTable, _defaultFgIndex));
|
||||
VERIFY_ARE_EQUAL(_defaultBg, attr.GetBackground().GetColor(_colorTable, _defaultBgIndex));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultBg, _defaultFg), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex));
|
||||
|
||||
attr.SetForeground(red);
|
||||
VERIFY_IS_TRUE(attr.IsReverseVideo());
|
||||
|
||||
VERIFY_ARE_EQUAL(red, attr.GetForeground().GetColor(_colorTable, _defaultFg));
|
||||
VERIFY_ARE_EQUAL(_defaultBg, attr.GetBackground().GetColor(_colorTable, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultBg, red), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(red, attr.GetForeground().GetColor(_colorTable, _defaultFgIndex));
|
||||
VERIFY_ARE_EQUAL(_defaultBg, attr.GetBackground().GetColor(_colorTable, _defaultBgIndex));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultBg, red), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex));
|
||||
|
||||
attr.Invert();
|
||||
VERIFY_IS_FALSE(attr.IsReverseVideo());
|
||||
attr.SetDefaultForeground();
|
||||
attr.SetBackground(green);
|
||||
|
||||
VERIFY_ARE_EQUAL(_defaultFg, attr.GetForeground().GetColor(_colorTable, _defaultFg));
|
||||
VERIFY_ARE_EQUAL(green, attr.GetBackground().GetColor(_colorTable, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, green), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(_defaultFg, attr.GetForeground().GetColor(_colorTable, _defaultFgIndex));
|
||||
VERIFY_ARE_EQUAL(green, attr.GetBackground().GetColor(_colorTable, _defaultBgIndex));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, green), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex));
|
||||
}
|
||||
|
||||
void TextAttributeTests::TestRoundtripDefaultColors()
|
||||
|
@ -277,43 +281,43 @@ void TextAttributeTests::TestBoldAsBright()
|
|||
// values when not bold
|
||||
VERIFY_IS_FALSE(attr.IsBold());
|
||||
|
||||
VERIFY_ARE_EQUAL(_defaultFg, attr.GetForeground().GetColor(_colorTable, _defaultFg));
|
||||
VERIFY_ARE_EQUAL(_defaultBg, attr.GetBackground().GetColor(_colorTable, _defaultBg));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, true));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, false));
|
||||
VERIFY_ARE_EQUAL(_defaultFg, attr.GetForeground().GetColor(_colorTable, _defaultFgIndex));
|
||||
VERIFY_ARE_EQUAL(_defaultBg, attr.GetBackground().GetColor(_colorTable, _defaultBgIndex));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex, false, false, true));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex, false, false, false));
|
||||
|
||||
// with bold set, calculated foreground/background values shouldn't change for the default colors.
|
||||
attr.SetBold(true);
|
||||
VERIFY_IS_TRUE(attr.IsBold());
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, true));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, false));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex, false, false, true));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex, false, false, false));
|
||||
|
||||
attr.SetIndexedForeground(TextColor::DARK_BLACK);
|
||||
VERIFY_IS_TRUE(attr.IsBold());
|
||||
|
||||
Log::Comment(L"Foreground should be bright black when bold is bright is enabled");
|
||||
VERIFY_ARE_EQUAL(std::make_pair(brightBlack, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, true));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(brightBlack, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex, false, false, true));
|
||||
|
||||
Log::Comment(L"Foreground should be dark black when bold is bright is disabled");
|
||||
VERIFY_ARE_EQUAL(std::make_pair(darkBlack, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, false));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(darkBlack, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex, false, false, false));
|
||||
|
||||
attr.SetIndexedBackground(TextColor::DARK_GREEN);
|
||||
VERIFY_IS_TRUE(attr.IsBold());
|
||||
|
||||
Log::Comment(L"background should be unaffected by 'bold is bright'");
|
||||
VERIFY_ARE_EQUAL(std::make_pair(brightBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, true));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(darkBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, false));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(brightBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex, false, false, true));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(darkBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex, false, false, false));
|
||||
|
||||
attr.SetBold(false);
|
||||
VERIFY_IS_FALSE(attr.IsBold());
|
||||
Log::Comment(L"when not bold, 'bold is bright' changes nothing");
|
||||
VERIFY_ARE_EQUAL(std::make_pair(darkBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, true));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(darkBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, false));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(darkBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex, false, false, true));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(darkBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex, false, false, false));
|
||||
|
||||
Log::Comment(L"When set to a bright color, and bold, 'bold is bright' changes nothing");
|
||||
attr.SetBold(true);
|
||||
attr.SetIndexedForeground(TextColor::BRIGHT_BLACK);
|
||||
VERIFY_IS_TRUE(attr.IsBold());
|
||||
VERIFY_ARE_EQUAL(std::make_pair(brightBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, true));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(brightBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, false));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(brightBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex, false, false, true));
|
||||
VERIFY_ARE_EQUAL(std::make_pair(brightBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFgIndex, _defaultBgIndex, false, false, false));
|
||||
}
|
||||
|
|
|
@ -23,9 +23,11 @@ class TextColorTests
|
|||
TEST_METHOD(TestRgbColor);
|
||||
TEST_METHOD(TestChangeColor);
|
||||
|
||||
std::array<COLORREF, 256> _colorTable;
|
||||
COLORREF _defaultFg = RGB(1, 2, 3);
|
||||
COLORREF _defaultBg = RGB(4, 5, 6);
|
||||
std::array<COLORREF, TextColor::TABLE_SIZE> _colorTable;
|
||||
const COLORREF _defaultFg = RGB(1, 2, 3);
|
||||
const COLORREF _defaultBg = RGB(4, 5, 6);
|
||||
const size_t _defaultFgIndex = TextColor::DEFAULT_FOREGROUND;
|
||||
const size_t _defaultBgIndex = TextColor::DEFAULT_BACKGROUND;
|
||||
};
|
||||
|
||||
bool TextColorTests::ClassSetup()
|
||||
|
@ -46,6 +48,8 @@ bool TextColorTests::ClassSetup()
|
|||
_colorTable[13] = RGB(180, 0, 158); // Bright Magenta
|
||||
_colorTable[14] = RGB(249, 241, 165); // Bright Yellow
|
||||
_colorTable[15] = RGB(242, 242, 242); // White
|
||||
_colorTable[_defaultFgIndex] = _defaultFg;
|
||||
_colorTable[_defaultBgIndex] = _defaultBg;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -57,16 +61,16 @@ void TextColorTests::TestDefaultColor()
|
|||
VERIFY_IS_FALSE(defaultColor.IsLegacy());
|
||||
VERIFY_IS_FALSE(defaultColor.IsRgb());
|
||||
|
||||
auto color = defaultColor.GetColor(_colorTable, _defaultFg, false);
|
||||
auto color = defaultColor.GetColor(_colorTable, _defaultFgIndex, false);
|
||||
VERIFY_ARE_EQUAL(_defaultFg, color);
|
||||
|
||||
color = defaultColor.GetColor(_colorTable, _defaultFg, true);
|
||||
color = defaultColor.GetColor(_colorTable, _defaultFgIndex, true);
|
||||
VERIFY_ARE_EQUAL(_defaultFg, color);
|
||||
|
||||
color = defaultColor.GetColor(_colorTable, _defaultBg, false);
|
||||
color = defaultColor.GetColor(_colorTable, _defaultBgIndex, false);
|
||||
VERIFY_ARE_EQUAL(_defaultBg, color);
|
||||
|
||||
color = defaultColor.GetColor(_colorTable, _defaultBg, true);
|
||||
color = defaultColor.GetColor(_colorTable, _defaultBgIndex, true);
|
||||
VERIFY_ARE_EQUAL(_defaultBg, color);
|
||||
}
|
||||
|
||||
|
@ -78,16 +82,16 @@ void TextColorTests::TestDarkIndexColor()
|
|||
VERIFY_IS_TRUE(indexColor.IsLegacy());
|
||||
VERIFY_IS_FALSE(indexColor.IsRgb());
|
||||
|
||||
auto color = indexColor.GetColor(_colorTable, _defaultFg, false);
|
||||
auto color = indexColor.GetColor(_colorTable, _defaultFgIndex, false);
|
||||
VERIFY_ARE_EQUAL(_colorTable[7], color);
|
||||
|
||||
color = indexColor.GetColor(_colorTable, _defaultFg, true);
|
||||
color = indexColor.GetColor(_colorTable, _defaultFgIndex, true);
|
||||
VERIFY_ARE_EQUAL(_colorTable[15], color);
|
||||
|
||||
color = indexColor.GetColor(_colorTable, _defaultBg, false);
|
||||
color = indexColor.GetColor(_colorTable, _defaultBgIndex, false);
|
||||
VERIFY_ARE_EQUAL(_colorTable[7], color);
|
||||
|
||||
color = indexColor.GetColor(_colorTable, _defaultBg, true);
|
||||
color = indexColor.GetColor(_colorTable, _defaultBgIndex, true);
|
||||
VERIFY_ARE_EQUAL(_colorTable[15], color);
|
||||
}
|
||||
|
||||
|
@ -99,16 +103,16 @@ void TextColorTests::TestBrightIndexColor()
|
|||
VERIFY_IS_TRUE(indexColor.IsLegacy());
|
||||
VERIFY_IS_FALSE(indexColor.IsRgb());
|
||||
|
||||
auto color = indexColor.GetColor(_colorTable, _defaultFg, false);
|
||||
auto color = indexColor.GetColor(_colorTable, _defaultFgIndex, false);
|
||||
VERIFY_ARE_EQUAL(_colorTable[15], color);
|
||||
|
||||
color = indexColor.GetColor(_colorTable, _defaultFg, true);
|
||||
color = indexColor.GetColor(_colorTable, _defaultFgIndex, true);
|
||||
VERIFY_ARE_EQUAL(_colorTable[15], color);
|
||||
|
||||
color = indexColor.GetColor(_colorTable, _defaultBg, false);
|
||||
color = indexColor.GetColor(_colorTable, _defaultBgIndex, false);
|
||||
VERIFY_ARE_EQUAL(_colorTable[15], color);
|
||||
|
||||
color = indexColor.GetColor(_colorTable, _defaultBg, true);
|
||||
color = indexColor.GetColor(_colorTable, _defaultBgIndex, true);
|
||||
VERIFY_ARE_EQUAL(_colorTable[15], color);
|
||||
}
|
||||
|
||||
|
@ -121,16 +125,16 @@ void TextColorTests::TestRgbColor()
|
|||
VERIFY_IS_FALSE(rgbColor.IsLegacy());
|
||||
VERIFY_IS_TRUE(rgbColor.IsRgb());
|
||||
|
||||
auto color = rgbColor.GetColor(_colorTable, _defaultFg, false);
|
||||
auto color = rgbColor.GetColor(_colorTable, _defaultFgIndex, false);
|
||||
VERIFY_ARE_EQUAL(myColor, color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFg, true);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFgIndex, true);
|
||||
VERIFY_ARE_EQUAL(myColor, color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBg, false);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBgIndex, false);
|
||||
VERIFY_ARE_EQUAL(myColor, color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBg, true);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBgIndex, true);
|
||||
VERIFY_ARE_EQUAL(myColor, color);
|
||||
}
|
||||
|
||||
|
@ -143,55 +147,55 @@ void TextColorTests::TestChangeColor()
|
|||
VERIFY_IS_FALSE(rgbColor.IsLegacy());
|
||||
VERIFY_IS_TRUE(rgbColor.IsRgb());
|
||||
|
||||
auto color = rgbColor.GetColor(_colorTable, _defaultFg, false);
|
||||
auto color = rgbColor.GetColor(_colorTable, _defaultFgIndex, false);
|
||||
VERIFY_ARE_EQUAL(myColor, color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFg, true);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFgIndex, true);
|
||||
VERIFY_ARE_EQUAL(myColor, color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBg, false);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBgIndex, false);
|
||||
VERIFY_ARE_EQUAL(myColor, color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBg, true);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBgIndex, true);
|
||||
VERIFY_ARE_EQUAL(myColor, color);
|
||||
|
||||
rgbColor.SetDefault();
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFg, false);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFgIndex, false);
|
||||
VERIFY_ARE_EQUAL(_defaultFg, color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFg, true);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFgIndex, true);
|
||||
VERIFY_ARE_EQUAL(_defaultFg, color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBg, false);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBgIndex, false);
|
||||
VERIFY_ARE_EQUAL(_defaultBg, color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBg, true);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBgIndex, true);
|
||||
VERIFY_ARE_EQUAL(_defaultBg, color);
|
||||
|
||||
rgbColor.SetIndex(7, false);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFg, false);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFgIndex, false);
|
||||
VERIFY_ARE_EQUAL(_colorTable[7], color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFg, true);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFgIndex, true);
|
||||
VERIFY_ARE_EQUAL(_colorTable[15], color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBg, false);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBgIndex, false);
|
||||
VERIFY_ARE_EQUAL(_colorTable[7], color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBg, true);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBgIndex, true);
|
||||
VERIFY_ARE_EQUAL(_colorTable[15], color);
|
||||
|
||||
rgbColor.SetIndex(15, false);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFg, false);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFgIndex, false);
|
||||
VERIFY_ARE_EQUAL(_colorTable[15], color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFg, true);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultFgIndex, true);
|
||||
VERIFY_ARE_EQUAL(_colorTable[15], color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBg, false);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBgIndex, false);
|
||||
VERIFY_ARE_EQUAL(_colorTable[15], color);
|
||||
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBg, true);
|
||||
color = rgbColor.GetColor(_colorTable, _defaultBgIndex, true);
|
||||
VERIFY_ARE_EQUAL(_colorTable[15], color);
|
||||
}
|
||||
|
|
|
@ -61,13 +61,26 @@
|
|||
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\CascadiaResources.build.items" />
|
||||
<Import Project="$(OpenConsoleDir)src\wap-common.build.post.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WindowsTerminal\WindowsTerminal.vcxproj" />
|
||||
<ProjectReference Include="..\..\host\exe\Host.EXE.vcxproj" />
|
||||
<ProjectReference Include="..\..\host\proxy\Host.Proxy.vcxproj" />
|
||||
<ProjectReference Include="..\TerminalAzBridge\TerminalAzBridge.vcxproj" />
|
||||
<ProjectReference Include="..\ShellExtension\WindowsTerminalShellExt.vcxproj" />
|
||||
<ProjectReference Include="..\wt\wt.vcxproj" />
|
||||
<ProjectReference Include="$(OpenConsoleDir)src\cascadia\WindowsTerminal\WindowsTerminal.vcxproj">
|
||||
<Project>{CA5CAD1A-1754-4A9D-93D7-857A9D17CB1B}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="$(OpenConsoleDir)src\cascadia\TerminalAzBridge\TerminalAzBridge.vcxproj">
|
||||
<Project>{067F0A06-FCB7-472C-96E9-B03B54E8E18D}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="$(OpenConsoleDir)src\cascadia\ShellExtension\WindowsTerminalShellExt.vcxproj">
|
||||
<Project>{f2ed628a-db22-446f-a081-4cc845b51a2b}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="$(OpenConsoleDir)src\cascadia\wt\wt.vcxproj">
|
||||
<Project>{506fd703-baa7-4f6e-9361-64f550ec8fca}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="$(OpenConsoleDir)src\host\exe\Host.EXE.vcxproj">
|
||||
<Project>{9CBD7DFA-1754-4A9D-93D7-857A9D17CB1B}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="$(OpenConsoleDir)src\host\proxy\Host.Proxy.vcxproj">
|
||||
<Project>{71CC9D78-BA29-4D93-946F-BEF5D9A3A6EF}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="OpenConsoleStompSourceProjectForWapProject" BeforeTargets="_ConvertItems">
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.18362.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.18362.0" MaxVersionTested="10.0.22000.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.18362.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.18362.0" MaxVersionTested="10.0.22000.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.18362.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.18362.0" MaxVersionTested="10.0.22000.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.22000.0" />
|
||||
<PackageDependency Name="Microsoft.VCLibs.140.00.Debug" MinVersion="14.0.27023.1" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
<PackageDependency Name="Microsoft.VCLibs.140.00.Debug.UWPDesktop" MinVersion="14.0.27027.1" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
</Dependencies>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<uap:SupportedUsers>multiple</uap:SupportedUsers>
|
||||
</Properties>
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.22000.0" />
|
||||
</Dependencies>
|
||||
<Resources>
|
||||
<Resource Language="x-generate" />
|
||||
|
|
|
@ -239,8 +239,8 @@ HRESULT HwndTerminal::Initialize()
|
|||
_terminal->SetBackgroundCallback([](auto) {});
|
||||
|
||||
_terminal->Create(COORD{ 80, 25 }, 1000, *_renderer);
|
||||
_terminal->SetDefaultBackground(RGB(12, 12, 12));
|
||||
_terminal->SetDefaultForeground(RGB(204, 204, 204));
|
||||
_terminal->SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, RGB(12, 12, 12));
|
||||
_terminal->SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, RGB(204, 204, 204));
|
||||
_terminal->SetWriteInputCallback([=](std::wstring& input) noexcept { _WriteTextToConnection(input); });
|
||||
localPointerToThread->EnablePainting();
|
||||
|
||||
|
@ -781,8 +781,8 @@ void _stdcall TerminalSetTheme(void* terminal, TerminalTheme theme, LPCWSTR font
|
|||
{
|
||||
auto lock = publicTerminal->_terminal->LockForWriting();
|
||||
|
||||
publicTerminal->_terminal->SetDefaultForeground(theme.DefaultForeground);
|
||||
publicTerminal->_terminal->SetDefaultBackground(theme.DefaultBackground);
|
||||
publicTerminal->_terminal->SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, theme.DefaultForeground);
|
||||
publicTerminal->_terminal->SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, theme.DefaultBackground);
|
||||
publicTerminal->_renderEngine->SetSelectionBackground(theme.DefaultSelectionBackground, theme.SelectionBackgroundAlpha);
|
||||
|
||||
// Set the font colors
|
||||
|
|
|
@ -318,7 +318,29 @@
|
|||
</ProjectReference>
|
||||
<!-- For whatever reason, we can't include the TerminalControl and
|
||||
TerminalSettings projects' winmds via project references. So we'll have to
|
||||
manually include the winmds as References below -->
|
||||
manually include the winmds as References below
|
||||
|
||||
BODGY: we do need to add a ProjectReference to TerminalControl.vcxproj,
|
||||
with Private=true, ReferenceOutputAssembly=false, so that Visual Studio's
|
||||
"Fast Up-to-date Check" will work with this project. If we don't, the Fast
|
||||
Up-to-date Check will look for the .xaml files from that project in our
|
||||
output, which won't actually be there.
|
||||
|
||||
We do still need to separately reference the winmds manually below, which is annoying.
|
||||
-->
|
||||
<ProjectReference Include="$(OpenConsoleDir)src\cascadia\TerminalControl\dll\TerminalControl.vcxproj">
|
||||
<!-- Private:true and ReferenceOutputAssembly:false, in combination with
|
||||
the manual reference to TerminalControl.winmd below make sure that this
|
||||
project will compile correct, and that we won't roll up the TermControl
|
||||
xbf's into the packaging project twice. -->
|
||||
<Private>true</Private>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="$(OpenConsoleDir)src\cascadia\TerminalSettingsEditor\Microsoft.Terminal.Settings.Editor.vcxproj">
|
||||
<Private>true</Private>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<!-- This is a hack to get the ARM64 CI build working. See
|
||||
|
|
|
@ -3,38 +3,38 @@
|
|||
|
||||
#include "pch.h"
|
||||
#include "TerminalPage.h"
|
||||
#include "Utils.h"
|
||||
#include "../../types/inc/utils.hpp"
|
||||
#include "TerminalPage.g.cpp"
|
||||
#include "RenameWindowRequestedArgs.g.cpp"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#include <inc/WindowingBehavior.h>
|
||||
#include <LibraryResources.h>
|
||||
#include <TerminalCore/ControlKeyStates.hpp>
|
||||
#include <til/latch.h>
|
||||
|
||||
#include "TerminalPage.g.cpp"
|
||||
#include <winrt/Windows.Storage.h>
|
||||
|
||||
#include "TabRowControl.h"
|
||||
#include "../../types/inc/utils.hpp"
|
||||
#include "ColorHelper.h"
|
||||
#include "DebugTapConnection.h"
|
||||
#include "SettingsTab.h"
|
||||
#include "RenameWindowRequestedArgs.g.cpp"
|
||||
#include "../inc/WindowingBehavior.h"
|
||||
|
||||
#include <til/latch.h>
|
||||
#include "TabRowControl.h"
|
||||
|
||||
using namespace winrt;
|
||||
using namespace winrt::Windows::Foundation::Collections;
|
||||
using namespace winrt::Windows::UI::Xaml;
|
||||
using namespace winrt::Windows::UI::Xaml::Controls;
|
||||
using namespace winrt::Windows::UI::Core;
|
||||
using namespace winrt::Windows::System;
|
||||
using namespace winrt::Windows::ApplicationModel::DataTransfer;
|
||||
using namespace winrt::Windows::UI::Text;
|
||||
using namespace winrt::Microsoft::Terminal;
|
||||
using namespace winrt::Microsoft::Terminal::Control;
|
||||
using namespace winrt::Microsoft::Terminal::TerminalConnection;
|
||||
using namespace winrt::Microsoft::Terminal::Settings::Model;
|
||||
using namespace winrt::Microsoft::Terminal::TerminalConnection;
|
||||
using namespace winrt::Microsoft::Terminal;
|
||||
using namespace winrt::Windows::ApplicationModel::DataTransfer;
|
||||
using namespace winrt::Windows::Foundation::Collections;
|
||||
using namespace winrt::Windows::System;
|
||||
using namespace winrt::Windows::System;
|
||||
using namespace winrt::Windows::UI::Core;
|
||||
using namespace winrt::Windows::UI::Text;
|
||||
using namespace winrt::Windows::UI::Xaml::Controls;
|
||||
using namespace winrt::Windows::UI::Xaml;
|
||||
using namespace ::TerminalApp;
|
||||
using namespace ::Microsoft::Console;
|
||||
using namespace ::Microsoft::Terminal::Core;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
#define HOOKUP_ACTION(action) _actionDispatch->action({ this, &TerminalPage::_Handle##action });
|
||||
|
@ -1038,29 +1038,153 @@ namespace winrt::TerminalApp::implementation
|
|||
}
|
||||
|
||||
// Method Description:
|
||||
// Called when the users pressed keyBindings while CommandPalette is open.
|
||||
// - Called when the users pressed keyBindings while CommandPalette is open.
|
||||
// - This method is effectively an extract of TermControl::_KeyHandler and TermControl::_TryHandleKeyBinding.
|
||||
// Arguments:
|
||||
// - e: the KeyRoutedEventArgs containing info about the keystroke.
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void TerminalPage::_KeyDownHandler(Windows::Foundation::IInspectable const& /*sender*/, Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e)
|
||||
{
|
||||
const auto key = e.OriginalKey();
|
||||
const auto scanCode = e.KeyStatus().ScanCode;
|
||||
const auto coreWindow = CoreWindow::GetForCurrentThread();
|
||||
const auto ctrlDown = WI_IsFlagSet(coreWindow.GetKeyState(winrt::Windows::System::VirtualKey::Control), CoreVirtualKeyStates::Down);
|
||||
const auto altDown = WI_IsFlagSet(coreWindow.GetKeyState(winrt::Windows::System::VirtualKey::Menu), CoreVirtualKeyStates::Down);
|
||||
const auto shiftDown = WI_IsFlagSet(coreWindow.GetKeyState(winrt::Windows::System::VirtualKey::Shift), CoreVirtualKeyStates::Down);
|
||||
const auto keyStatus = e.KeyStatus();
|
||||
const auto vkey = gsl::narrow_cast<WORD>(e.OriginalKey());
|
||||
const auto scanCode = gsl::narrow_cast<WORD>(keyStatus.ScanCode);
|
||||
const auto modifiers = _GetPressedModifierKeys();
|
||||
|
||||
winrt::Microsoft::Terminal::Control::KeyChord kc{ ctrlDown, altDown, shiftDown, false, static_cast<int32_t>(key), static_cast<int32_t>(scanCode) };
|
||||
if (const auto cmd{ _settings.ActionMap().GetActionByKeyChord(kc) })
|
||||
// GH#11076:
|
||||
// For some weird reason we sometimes receive a WM_KEYDOWN
|
||||
// message without vkey or scanCode if a user drags a tab.
|
||||
// The KeyChord constructor has a debug assertion ensuring that all KeyChord
|
||||
// either have a valid vkey/scanCode. This is important, because this prevents
|
||||
// accidential insertion of invalid KeyChords into classes like ActionMap.
|
||||
if (!vkey && !scanCode)
|
||||
{
|
||||
if (CommandPalette().Visibility() == Visibility::Visible && cmd.ActionAndArgs().Action() != ShortcutAction::ToggleCommandPalette)
|
||||
return;
|
||||
}
|
||||
|
||||
// Alt-Numpad# input will send us a character once the user releases
|
||||
// Alt, so we should be ignoring the individual keydowns. The character
|
||||
// will be sent through the TSFInputControl. See GH#1401 for more
|
||||
// details
|
||||
if (modifiers.IsAltPressed() && (vkey >= VK_NUMPAD0 && vkey <= VK_NUMPAD9))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// GH#2235: Terminal::Settings hasn't been modified to differentiate
|
||||
// between AltGr and Ctrl+Alt yet.
|
||||
// -> Don't check for key bindings if this is an AltGr key combination.
|
||||
if (modifiers.IsAltGrPressed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto actionMap = _settings.ActionMap();
|
||||
if (!actionMap)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto cmd = actionMap.GetActionByKeyChord({
|
||||
modifiers.IsCtrlPressed(),
|
||||
modifiers.IsAltPressed(),
|
||||
modifiers.IsShiftPressed(),
|
||||
modifiers.IsWinPressed(),
|
||||
vkey,
|
||||
scanCode,
|
||||
});
|
||||
if (!cmd)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_actionDispatch->DoAction(cmd.ActionAndArgs()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (const auto p = CommandPalette(); p.Visibility() == Visibility::Visible && cmd.ActionAndArgs().Action() != ShortcutAction::ToggleCommandPalette)
|
||||
{
|
||||
p.Visibility(Visibility::Collapsed);
|
||||
}
|
||||
|
||||
// Let's assume the user has bound the dead key "^" to a sendInput command that sends "b".
|
||||
// If the user presses the two keys "^a" it'll produce "bâ", despite us marking the key event as handled.
|
||||
// The following is used to manually "consume" such dead keys and clear them from the keyboard state.
|
||||
_ClearKeyboardState(vkey, scanCode);
|
||||
e.Handled(true);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Get the modifier keys that are currently pressed. This can be used to
|
||||
// find out which modifiers (ctrl, alt, shift) are pressed in events that
|
||||
// don't necessarily include that state.
|
||||
// - This is a copy of TermControl::_GetPressedModifierKeys.
|
||||
// Return Value:
|
||||
// - The Microsoft::Terminal::Core::ControlKeyStates representing the modifier key states.
|
||||
ControlKeyStates TerminalPage::_GetPressedModifierKeys() noexcept
|
||||
{
|
||||
const CoreWindow window = CoreWindow::GetForCurrentThread();
|
||||
// DONT USE
|
||||
// != CoreVirtualKeyStates::None
|
||||
// OR
|
||||
// == CoreVirtualKeyStates::Down
|
||||
// Sometimes with the key down, the state is Down | Locked.
|
||||
// Sometimes with the key up, the state is Locked.
|
||||
// IsFlagSet(Down) is the only correct solution.
|
||||
|
||||
struct KeyModifier
|
||||
{
|
||||
VirtualKey vkey;
|
||||
ControlKeyStates flags;
|
||||
};
|
||||
|
||||
constexpr std::array<KeyModifier, 7> modifiers{ {
|
||||
{ VirtualKey::RightMenu, ControlKeyStates::RightAltPressed },
|
||||
{ VirtualKey::LeftMenu, ControlKeyStates::LeftAltPressed },
|
||||
{ VirtualKey::RightControl, ControlKeyStates::RightCtrlPressed },
|
||||
{ VirtualKey::LeftControl, ControlKeyStates::LeftCtrlPressed },
|
||||
{ VirtualKey::Shift, ControlKeyStates::ShiftPressed },
|
||||
{ VirtualKey::RightWindows, ControlKeyStates::RightWinPressed },
|
||||
{ VirtualKey::LeftWindows, ControlKeyStates::LeftWinPressed },
|
||||
} };
|
||||
|
||||
ControlKeyStates flags;
|
||||
|
||||
for (const auto& mod : modifiers)
|
||||
{
|
||||
const auto state = window.GetKeyState(mod.vkey);
|
||||
const auto isDown = WI_IsFlagSet(state, CoreVirtualKeyStates::Down);
|
||||
|
||||
if (isDown)
|
||||
{
|
||||
CommandPalette().Visibility(Visibility::Collapsed);
|
||||
flags |= mod.flags;
|
||||
}
|
||||
_actionDispatch->DoAction(cmd.ActionAndArgs());
|
||||
e.Handled(true);
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Discards currently pressed dead keys.
|
||||
// - This is a copy of TermControl::_ClearKeyboardState.
|
||||
// Arguments:
|
||||
// - vkey: The vkey of the key pressed.
|
||||
// - scanCode: The scan code of the key pressed.
|
||||
void TerminalPage::_ClearKeyboardState(const WORD vkey, const WORD scanCode) noexcept
|
||||
{
|
||||
std::array<BYTE, 256> keyState;
|
||||
if (!GetKeyboardState(keyState.data()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// As described in "Sometimes you *want* to interfere with the keyboard's state buffer":
|
||||
// http://archives.miloush.net/michkap/archive/2006/09/10/748775.html
|
||||
// > "The key here is to keep trying to pass stuff to ToUnicode until -1 is not returned."
|
||||
std::array<wchar_t, 16> buffer;
|
||||
while (ToUnicodeEx(vkey, scanCode, keyState.data(), buffer.data(), gsl::narrow_cast<int>(buffer.size()), 0b1, nullptr) < 0)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,12 +14,17 @@
|
|||
|
||||
static constexpr uint32_t DefaultRowsToScroll{ 3 };
|
||||
static constexpr std::wstring_view TabletInputServiceKey{ L"TabletInputService" };
|
||||
// fwdecl unittest classes
|
||||
|
||||
namespace TerminalAppLocalTests
|
||||
{
|
||||
class TabTests;
|
||||
class SettingsTests;
|
||||
};
|
||||
}
|
||||
|
||||
namespace Microsoft::Terminal::Core
|
||||
{
|
||||
class ControlKeyStates;
|
||||
}
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
|
@ -225,6 +230,8 @@ namespace winrt::TerminalApp::implementation
|
|||
void _ThirdPartyNoticesOnClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
|
||||
|
||||
void _KeyDownHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e);
|
||||
static ::Microsoft::Terminal::Core::ControlKeyStates _GetPressedModifierKeys() noexcept;
|
||||
static void _ClearKeyboardState(const WORD vkey, const WORD scanCode) noexcept;
|
||||
void _HookupKeyBindings(const Microsoft::Terminal::Settings::Model::IActionMapView& actionMap) noexcept;
|
||||
void _RegisterActionCallbacks();
|
||||
|
||||
|
|
|
@ -68,5 +68,22 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
<!--
|
||||
BODGY
|
||||
|
||||
The wapproj `GetResolvedWinMD` target tries to get a winmd from every cppwinrt
|
||||
executable we put in the package. But we DON'T produce a winmd. This makes the
|
||||
FastUpToDate check fail every time, and leads to the whole wapproj build
|
||||
running even if you're just f5'ing the package. EVEN AFTER A SUCCESSFUL BUILD.
|
||||
|
||||
Setting GenerateWindowsMetadata=false is enough to tell the build system that
|
||||
we don't produce one, and get it off our backs.
|
||||
-->
|
||||
<ItemDefinitionGroup>
|
||||
<Link>
|
||||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
<Import Project="$(OpenConsoleDir)\build\rules\GenerateSxsManifestsFromWinmds.targets" />
|
||||
</Project>
|
||||
|
|
|
@ -97,4 +97,39 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(SolutionDir)build\rules\CollectWildcardResources.targets" />
|
||||
</Project>
|
||||
|
||||
<!--
|
||||
BODGY:
|
||||
|
||||
We depend on `cpprest142*.dll`, which comes from our vcpkg dependency. As a
|
||||
part of the vcpkg dependency restore, msbuild will call the `deployBinary()`
|
||||
function in
|
||||
`packages\vcpkg-cpprestsdk.2.10.14\scripts\BuildSystems\msbuild\AppLocal.ps1`.
|
||||
That function does the actual job of copying the file. It copies it outside of
|
||||
MsBuild. MsBuild then, in the `_CopyFilesMarkedCopyLocal` target, determines
|
||||
that it needs to copy `cpprest142*.dll`, because that dll is a member of
|
||||
`@(ReferencesCopiedInThisBuild)`. However, the file's already been copied, so
|
||||
MsBuild never copies it. But that also prevents MsBuild from setting
|
||||
`WroteAtLeastOneFile`, which then means that MsBuild will never create the
|
||||
.CopyComplete file for this project.
|
||||
|
||||
Because that file is missing, MsBuild will never think the project is up to
|
||||
date, and the FastUpToDate check in VS will always force MsBuild to run a pass
|
||||
on this project.
|
||||
|
||||
To mitigate this, we're adding this other target here, which runs after
|
||||
_CopyFilesMarkedCopyLocal, and always creates the CopyUpToDateMarker. This
|
||||
makes the FastUpToDate check succeed.
|
||||
-->
|
||||
|
||||
<Target
|
||||
Name="_Post_CopyFilesMarkedCopyLocal"
|
||||
AfterTargets="_CopyFilesMarkedCopyLocal"
|
||||
Condition="'@(ReferenceCopyLocalPaths)' != ''">
|
||||
|
||||
<Touch Files="@(CopyUpToDateMarker)"
|
||||
AlwaysCreate="true" />
|
||||
</Target>
|
||||
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1089,7 +1089,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
|
||||
til::color ControlCore::BackgroundColor() const
|
||||
{
|
||||
return _terminal->GetDefaultBackground();
|
||||
return _terminal->GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
|
|
@ -773,12 +773,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
_HidePointerCursorHandlers(*this, nullptr);
|
||||
|
||||
const auto ch = e.Character();
|
||||
const auto scanCode = gsl::narrow_cast<WORD>(e.KeyStatus().ScanCode);
|
||||
const auto keyStatus = e.KeyStatus();
|
||||
const auto scanCode = gsl::narrow_cast<WORD>(keyStatus.ScanCode);
|
||||
auto modifiers = _GetPressedModifierKeys();
|
||||
if (e.KeyStatus().IsExtendedKey)
|
||||
|
||||
if (keyStatus.IsExtendedKey)
|
||||
{
|
||||
modifiers |= ControlKeyStates::EnhancedKey;
|
||||
}
|
||||
|
||||
const bool handled = _core.SendCharEvent(ch, scanCode, modifiers);
|
||||
e.Handled(handled);
|
||||
}
|
||||
|
@ -873,6 +876,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
const auto scanCode = gsl::narrow_cast<WORD>(keyStatus.ScanCode);
|
||||
auto modifiers = _GetPressedModifierKeys();
|
||||
|
||||
if (keyStatus.IsExtendedKey)
|
||||
{
|
||||
modifiers |= ControlKeyStates::EnhancedKey;
|
||||
}
|
||||
|
||||
// GH#11076:
|
||||
// For some weird reason we sometimes receive a WM_KEYDOWN
|
||||
// message without vkey or scanCode if a user drags a tab.
|
||||
|
@ -906,11 +914,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
return;
|
||||
}
|
||||
|
||||
if (keyStatus.IsExtendedKey)
|
||||
{
|
||||
modifiers |= ControlKeyStates::EnhancedKey;
|
||||
}
|
||||
|
||||
// Alt-Numpad# input will send us a character once the user releases
|
||||
// Alt, so we should be ignoring the individual keydowns. The character
|
||||
// will be sent through the TSFInputControl. See GH#1401 for more
|
||||
|
@ -988,7 +991,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// Arguments:
|
||||
// - vkey: The vkey of the key pressed.
|
||||
// - scanCode: The scan code of the key pressed.
|
||||
void TermControl::_ClearKeyboardState(const WORD vkey, const WORD scanCode) const noexcept
|
||||
void TermControl::_ClearKeyboardState(const WORD vkey, const WORD scanCode) noexcept
|
||||
{
|
||||
std::array<BYTE, 256> keyState;
|
||||
if (!GetKeyboardState(keyState.data()))
|
||||
|
@ -2060,7 +2063,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// don't necessarily include that state.
|
||||
// Return Value:
|
||||
// - The Microsoft::Terminal::Core::ControlKeyStates representing the modifier key states.
|
||||
ControlKeyStates TermControl::_GetPressedModifierKeys() const
|
||||
ControlKeyStates TermControl::_GetPressedModifierKeys() noexcept
|
||||
{
|
||||
const CoreWindow window = CoreWindow::GetForCurrentThread();
|
||||
// DONT USE
|
||||
|
|
|
@ -245,9 +245,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
void _UpdateAutoScroll(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e);
|
||||
|
||||
void _KeyHandler(Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e, const bool keyDown);
|
||||
::Microsoft::Terminal::Core::ControlKeyStates _GetPressedModifierKeys() const;
|
||||
static ::Microsoft::Terminal::Core::ControlKeyStates _GetPressedModifierKeys() noexcept;
|
||||
bool _TryHandleKeyBinding(const WORD vkey, const WORD scanCode, ::Microsoft::Terminal::Core::ControlKeyStates modifiers) const;
|
||||
void _ClearKeyboardState(const WORD vkey, const WORD scanCode) const noexcept;
|
||||
static void _ClearKeyboardState(const WORD vkey, const WORD scanCode) noexcept;
|
||||
bool _TrySendKeyEvent(const WORD vkey, const WORD scanCode, ::Microsoft::Terminal::Core::ControlKeyStates modifiers, const bool keyDown);
|
||||
|
||||
const til::point _toTerminalOrigin(winrt::Windows::Foundation::Point cursorPosition);
|
||||
|
|
|
@ -40,13 +40,10 @@ namespace Microsoft::Terminal::Core
|
|||
virtual bool WarningBell() noexcept = 0;
|
||||
virtual bool SetWindowTitle(std::wstring_view title) noexcept = 0;
|
||||
|
||||
virtual bool SetColorTableEntry(const size_t tableIndex, const DWORD color) noexcept = 0;
|
||||
virtual COLORREF GetColorTableEntry(const size_t tableIndex) const noexcept = 0;
|
||||
virtual bool SetColorTableEntry(const size_t tableIndex, const COLORREF color) noexcept = 0;
|
||||
|
||||
virtual bool SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle) noexcept = 0;
|
||||
virtual bool SetCursorColor(const DWORD color) noexcept = 0;
|
||||
|
||||
virtual bool SetDefaultForeground(const DWORD color) noexcept = 0;
|
||||
virtual bool SetDefaultBackground(const DWORD color) noexcept = 0;
|
||||
|
||||
virtual bool SetInputMode(const ::Microsoft::Console::VirtualTerminal::TerminalInput::Mode mode, const bool enabled) noexcept = 0;
|
||||
|
||||
|
|
|
@ -41,8 +41,6 @@ Terminal::Terminal() :
|
|||
_mutableViewport{ Viewport::Empty() },
|
||||
_title{},
|
||||
_colorTable{},
|
||||
_defaultFg{ RGB(255, 255, 255) },
|
||||
_defaultBg{ ARGB(0, 0, 0, 0) },
|
||||
_screenReversed{ false },
|
||||
_pfnWriteInput{ nullptr },
|
||||
_scrollOffset{ 0 },
|
||||
|
@ -61,6 +59,14 @@ Terminal::Terminal() :
|
|||
|
||||
_stateMachine = std::make_unique<StateMachine>(std::move(engine));
|
||||
|
||||
// Until we have a true pass-through mode (GH#1173), the decision as to
|
||||
// whether C1 controls are interpreted or not is made at the conhost level.
|
||||
// If they are being filtered out, then we will simply never receive them.
|
||||
// But if they are being accepted by conhost, there's a chance they may get
|
||||
// passed through in some situations, so it's important that our state
|
||||
// machine is always prepared to accept them.
|
||||
_stateMachine->SetParserMode(StateMachine::Mode::AcceptC1, true);
|
||||
|
||||
auto passAlongInput = [&](std::deque<std::unique_ptr<IInputEvent>>& inEventsToWrite) {
|
||||
if (!_pfnWriteInput)
|
||||
{
|
||||
|
@ -73,6 +79,10 @@ Terminal::Terminal() :
|
|||
_terminalInput = std::make_unique<TerminalInput>(passAlongInput);
|
||||
|
||||
_InitializeColorTable();
|
||||
|
||||
_colorTable.at(TextColor::DEFAULT_FOREGROUND) = RGB(255, 255, 255);
|
||||
_colorTable.at(TextColor::DEFAULT_BACKGROUND) = ARGB(0, 0, 0, 0);
|
||||
_colorTable.at(TextColor::CURSOR_COLOR) = INVALID_COLOR;
|
||||
}
|
||||
|
||||
void Terminal::Create(COORD viewportSize, SHORT scrollbackLines, IRenderTarget& renderTarget)
|
||||
|
@ -172,9 +182,13 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance)
|
|||
{
|
||||
// Set the default background as transparent to prevent the
|
||||
// DX layer from overwriting the background image or acrylic effect
|
||||
til::color newBackgroundColor{ appearance.DefaultBackground() };
|
||||
_defaultBg = newBackgroundColor.with_alpha(0);
|
||||
_defaultFg = appearance.DefaultForeground();
|
||||
const til::color newBackgroundColor{ appearance.DefaultBackground() };
|
||||
_colorTable.at(TextColor::DEFAULT_BACKGROUND) = newBackgroundColor.with_alpha(0);
|
||||
const til::color newForegroundColor{ appearance.DefaultForeground() };
|
||||
_colorTable.at(TextColor::DEFAULT_FOREGROUND) = newForegroundColor;
|
||||
const til::color newCursorColor{ appearance.CursorColor() };
|
||||
_colorTable.at(TextColor::CURSOR_COLOR) = newCursorColor;
|
||||
|
||||
_intenseIsBright = appearance.IntenseIsBright();
|
||||
_adjustIndistinguishableColors = appearance.AdjustIndistinguishableColors();
|
||||
|
||||
|
@ -213,9 +227,7 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance)
|
|||
|
||||
if (_buffer)
|
||||
{
|
||||
_buffer->GetCursor().SetStyle(appearance.CursorHeight(),
|
||||
til::color{ appearance.CursorColor() },
|
||||
cursorShape);
|
||||
_buffer->GetCursor().SetStyle(appearance.CursorHeight(), cursorShape);
|
||||
}
|
||||
|
||||
_defaultCursorShape = cursorShape;
|
||||
|
|
|
@ -106,11 +106,9 @@ public:
|
|||
bool EraseInDisplay(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::EraseType eraseType) noexcept override;
|
||||
bool WarningBell() noexcept override;
|
||||
bool SetWindowTitle(std::wstring_view title) noexcept override;
|
||||
COLORREF GetColorTableEntry(const size_t tableIndex) const noexcept override;
|
||||
bool SetColorTableEntry(const size_t tableIndex, const COLORREF color) noexcept override;
|
||||
bool SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle) noexcept override;
|
||||
bool SetCursorColor(const COLORREF color) noexcept override;
|
||||
bool SetDefaultForeground(const COLORREF color) noexcept override;
|
||||
bool SetDefaultBackground(const COLORREF color) noexcept override;
|
||||
|
||||
bool SetInputMode(const ::Microsoft::Console::VirtualTerminal::TerminalInput::Mode mode, const bool enabled) noexcept override;
|
||||
|
||||
|
@ -212,7 +210,6 @@ public:
|
|||
void ClearPatternTree() noexcept;
|
||||
|
||||
const std::optional<til::color> GetTabColor() const noexcept;
|
||||
til::color GetDefaultBackground() const noexcept;
|
||||
|
||||
Microsoft::Console::Render::BlinkingState& GetBlinkingState() const noexcept;
|
||||
|
||||
|
@ -281,9 +278,7 @@ private:
|
|||
std::optional<til::color> _startingTabColor;
|
||||
|
||||
// This is still stored as a COLORREF because it interacts with some code in ConTypes
|
||||
std::array<COLORREF, XTERM_COLOR_TABLE_SIZE> _colorTable;
|
||||
til::color _defaultFg;
|
||||
til::color _defaultBg;
|
||||
std::array<COLORREF, TextColor::TABLE_SIZE> _colorTable;
|
||||
CursorType _defaultCursorShape;
|
||||
bool _screenReversed;
|
||||
mutable Microsoft::Console::Render::BlinkingState _blinkingState;
|
||||
|
|
|
@ -69,14 +69,6 @@ COORD Terminal::GetCursorPosition() noexcept
|
|||
return newPos;
|
||||
}
|
||||
|
||||
bool Terminal::SetCursorColor(const COLORREF color) noexcept
|
||||
try
|
||||
{
|
||||
_buffer->GetCursor().SetColor(color);
|
||||
return true;
|
||||
}
|
||||
CATCH_RETURN_FALSE()
|
||||
|
||||
// Method Description:
|
||||
// - Moves the cursor down one line, and possibly also to the leftmost column.
|
||||
// Arguments:
|
||||
|
@ -370,6 +362,22 @@ try
|
|||
}
|
||||
CATCH_RETURN_FALSE()
|
||||
|
||||
// Method Description:
|
||||
// - Retrieves the value in the colortable at the specified index.
|
||||
// Arguments:
|
||||
// - tableIndex: the index of the color table to retrieve.
|
||||
// Return Value:
|
||||
// - the COLORREF value for the color at that index in the table.
|
||||
COLORREF Terminal::GetColorTableEntry(const size_t tableIndex) const noexcept
|
||||
try
|
||||
{
|
||||
return _colorTable.at(tableIndex);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return INVALID_COLOR;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Updates the value in the colortable at index tableIndex to the new color
|
||||
// color. color is a COLORREF, format 0x00BBGGRR.
|
||||
|
@ -383,6 +391,11 @@ try
|
|||
{
|
||||
_colorTable.at(tableIndex) = color;
|
||||
|
||||
if (tableIndex == TextColor::DEFAULT_BACKGROUND)
|
||||
{
|
||||
_pfnBackgroundColorChanged(color);
|
||||
}
|
||||
|
||||
// Repaint everything - the colors might have changed
|
||||
_buffer->GetRenderTarget().TriggerRedrawAll();
|
||||
return true;
|
||||
|
@ -442,46 +455,6 @@ bool Terminal::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle) noex
|
|||
return true;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Updates the default foreground color from a COLORREF, format 0x00BBGGRR.
|
||||
// Arguments:
|
||||
// - color: the new COLORREF to use as the default foreground color
|
||||
// Return Value:
|
||||
// - true
|
||||
bool Terminal::SetDefaultForeground(const COLORREF color) noexcept
|
||||
try
|
||||
{
|
||||
_defaultFg = color;
|
||||
|
||||
// Repaint everything - the colors might have changed
|
||||
_buffer->GetRenderTarget().TriggerRedrawAll();
|
||||
return true;
|
||||
}
|
||||
CATCH_RETURN_FALSE()
|
||||
|
||||
// Method Description:
|
||||
// - Updates the default background color from a COLORREF, format 0x00BBGGRR.
|
||||
// Arguments:
|
||||
// - color: the new COLORREF to use as the default background color
|
||||
// Return Value:
|
||||
// - true
|
||||
bool Terminal::SetDefaultBackground(const COLORREF color) noexcept
|
||||
try
|
||||
{
|
||||
_defaultBg = color;
|
||||
_pfnBackgroundColorChanged(color);
|
||||
|
||||
// Repaint everything - the colors might have changed
|
||||
_buffer->GetRenderTarget().TriggerRedrawAll();
|
||||
return true;
|
||||
}
|
||||
CATCH_RETURN_FALSE()
|
||||
|
||||
til::color Terminal::GetDefaultBackground() const noexcept
|
||||
{
|
||||
return _defaultBg;
|
||||
}
|
||||
|
||||
bool Terminal::SetInputMode(const TerminalInput::Mode mode, const bool enabled) noexcept
|
||||
try
|
||||
{
|
||||
|
|
|
@ -227,7 +227,7 @@ CATCH_LOG_RETURN_FALSE()
|
|||
bool TerminalDispatch::SetCursorColor(const DWORD color) noexcept
|
||||
try
|
||||
{
|
||||
return _terminalApi.SetCursorColor(color);
|
||||
return _terminalApi.SetColorTableEntry(TextColor::CURSOR_COLOR, color);
|
||||
}
|
||||
CATCH_LOG_RETURN_FALSE()
|
||||
|
||||
|
@ -247,7 +247,7 @@ CATCH_LOG_RETURN_FALSE()
|
|||
bool TerminalDispatch::SetDefaultForeground(const DWORD color) noexcept
|
||||
try
|
||||
{
|
||||
return _terminalApi.SetDefaultForeground(color);
|
||||
return _terminalApi.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, color);
|
||||
}
|
||||
CATCH_LOG_RETURN_FALSE()
|
||||
|
||||
|
@ -260,7 +260,7 @@ CATCH_LOG_RETURN_FALSE()
|
|||
bool TerminalDispatch::SetDefaultBackground(const DWORD color) noexcept
|
||||
try
|
||||
{
|
||||
return _terminalApi.SetDefaultBackground(color);
|
||||
return _terminalApi.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, color);
|
||||
}
|
||||
CATCH_LOG_RETURN_FALSE()
|
||||
|
||||
|
|
|
@ -73,19 +73,19 @@ std::pair<COLORREF, COLORREF> Terminal::GetAttributeColors(const TextAttribute&
|
|||
if (attr.IsReverseVideo() ^ _screenReversed)
|
||||
{
|
||||
colors.first = _adjustedForegroundColors[fgIndex][bgIndex];
|
||||
colors.second = fgTextColor.GetColor(_colorTable, _defaultFg);
|
||||
colors.second = fgTextColor.GetColor(_colorTable, TextColor::DEFAULT_FOREGROUND);
|
||||
}
|
||||
else
|
||||
{
|
||||
colors.first = _adjustedForegroundColors[bgIndex][fgIndex];
|
||||
colors.second = bgTextColor.GetColor(_colorTable, _defaultBg);
|
||||
colors.second = bgTextColor.GetColor(_colorTable, TextColor::DEFAULT_BACKGROUND);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
colors = attr.CalculateRgbColors(_colorTable,
|
||||
_defaultFg,
|
||||
_defaultBg,
|
||||
TextColor::DEFAULT_FOREGROUND,
|
||||
TextColor::DEFAULT_BACKGROUND,
|
||||
_screenReversed,
|
||||
_blinkingState.IsBlinkingFaint(),
|
||||
_intenseIsBright);
|
||||
|
@ -135,7 +135,7 @@ CursorType Terminal::GetCursorStyle() const noexcept
|
|||
|
||||
COLORREF Terminal::GetCursorColor() const noexcept
|
||||
{
|
||||
return _buffer->GetCursor().GetColor();
|
||||
return _colorTable.at(TextColor::CURSOR_COLOR);
|
||||
}
|
||||
|
||||
bool Terminal::IsCursorDoubleWidth() const
|
||||
|
@ -312,8 +312,8 @@ void Terminal::_MakeAdjustedColorArray()
|
|||
// to include the default background and default foreground colors
|
||||
std::array<COLORREF, 18> colorTableWithDefaults;
|
||||
std::copy_n(std::begin(_colorTable), 16, std::begin(colorTableWithDefaults));
|
||||
colorTableWithDefaults[DefaultBgIndex] = _defaultBg;
|
||||
colorTableWithDefaults[DefaultFgIndex] = _defaultFg;
|
||||
colorTableWithDefaults[DefaultBgIndex] = _colorTable.at(TextColor::DEFAULT_BACKGROUND);
|
||||
colorTableWithDefaults[DefaultFgIndex] = _colorTable.at(TextColor::DEFAULT_FOREGROUND);
|
||||
for (auto fgIndex = 0; fgIndex < 18; ++fgIndex)
|
||||
{
|
||||
const auto fg = til::at(colorTableWithDefaults, fgIndex);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "pch.h"
|
||||
#include "Profiles.h"
|
||||
|
||||
#include "PreviewConnection.h"
|
||||
#include "Profiles.g.cpp"
|
||||
#include "EnumEntry.h"
|
||||
|
@ -10,6 +11,54 @@
|
|||
#include <LibraryResources.h>
|
||||
#include "..\WinRTUtils\inc\Utils.h"
|
||||
|
||||
// This function is a copy of DxFontInfo::_NearbyCollection() with
|
||||
// * the call to DxFontInfo::s_GetNearbyFonts() inlined
|
||||
// * checkForUpdates for GetSystemFontCollection() set to true
|
||||
static wil::com_ptr<IDWriteFontCollection1> NearbyCollection(IDWriteFactory* dwriteFactory)
|
||||
{
|
||||
// The convenience interfaces for loading fonts from files
|
||||
// are only available on Windows 10+.
|
||||
wil::com_ptr<IDWriteFactory6> factory6;
|
||||
// wil's query() facilities don't work inside WinRT land at the moment.
|
||||
// They produce a compilation error due to IUnknown and winrt::Windows::Foundation::IUnknown being ambiguous.
|
||||
if (!SUCCEEDED(dwriteFactory->QueryInterface(__uuidof(IDWriteFactory6), factory6.put_void())))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wil::com_ptr<IDWriteFontCollection1> systemFontCollection;
|
||||
THROW_IF_FAILED(factory6->GetSystemFontCollection(false, systemFontCollection.addressof(), true));
|
||||
|
||||
wil::com_ptr<IDWriteFontSet> systemFontSet;
|
||||
THROW_IF_FAILED(systemFontCollection->GetFontSet(systemFontSet.addressof()));
|
||||
|
||||
wil::com_ptr<IDWriteFontSetBuilder2> fontSetBuilder2;
|
||||
THROW_IF_FAILED(factory6->CreateFontSetBuilder(fontSetBuilder2.addressof()));
|
||||
|
||||
THROW_IF_FAILED(fontSetBuilder2->AddFontSet(systemFontSet.get()));
|
||||
|
||||
{
|
||||
const std::filesystem::path module{ wil::GetModuleFileNameW<std::wstring>(nullptr) };
|
||||
const auto folder{ module.parent_path() };
|
||||
|
||||
for (const auto& p : std::filesystem::directory_iterator(folder))
|
||||
{
|
||||
if (til::ends_with(p.path().native(), L".ttf"))
|
||||
{
|
||||
fontSetBuilder2->AddFontFile(p.path().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wil::com_ptr<IDWriteFontSet> fontSet;
|
||||
THROW_IF_FAILED(fontSetBuilder2->CreateFontSet(fontSet.addressof()));
|
||||
|
||||
wil::com_ptr<IDWriteFontCollection1> fontCollection;
|
||||
THROW_IF_FAILED(factory6->CreateFontCollectionFromFontSet(fontSet.get(), &fontCollection));
|
||||
|
||||
return fontCollection;
|
||||
}
|
||||
|
||||
using namespace winrt::Windows::UI::Text;
|
||||
using namespace winrt::Windows::UI::Xaml;
|
||||
using namespace winrt::Windows::UI::Xaml::Controls;
|
||||
|
@ -107,8 +156,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
reinterpret_cast<::IUnknown**>(factory.put())));
|
||||
|
||||
// get the font collection; subscribe to updates
|
||||
com_ptr<IDWriteFontCollection> fontCollection;
|
||||
THROW_IF_FAILED(factory->GetSystemFontCollection(fontCollection.put(), TRUE));
|
||||
const auto fontCollection = NearbyCollection(factory.get());
|
||||
|
||||
for (UINT32 i = 0; i < fontCollection->GetFontFamilyCount(); ++i)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
//
|
||||
// pch.h
|
||||
|
@ -51,8 +51,7 @@
|
|||
|
||||
#include <shlobj.h>
|
||||
#include <shobjidl_core.h>
|
||||
#include <dwrite.h>
|
||||
#include <dwrite_1.h>
|
||||
#include <dwrite_3.h>
|
||||
|
||||
// Manually include til after we include Windows.Foundation to give it winrt superpowers
|
||||
#include "til.h"
|
||||
|
|
|
@ -197,9 +197,29 @@
|
|||
<Project>{CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
|
||||
<!-- For whatever reason, we can't include the TerminalControl and
|
||||
TerminalSettings projects' winmds via project references. So we'll have to
|
||||
manually include the winmds as References below -->
|
||||
manually include the winmds as References below
|
||||
|
||||
BODGY: we do need to add a ProjectReference to TerminalControl.vcxproj,
|
||||
with Private=true, ReferenceOutputAssembly=false, so that Visual Studio's
|
||||
"Fast Up-to-date Check" will work with this project. If we don't, the Fast
|
||||
Up-to-date Check will look for the .xaml files from that project in our
|
||||
output, which won't actually be there.
|
||||
|
||||
We do still need to separately reference the winmds manually below, which is annoying.
|
||||
-->
|
||||
|
||||
<ProjectReference Include="$(OpenConsoleDir)src\cascadia\TerminalControl\dll\TerminalControl.vcxproj">
|
||||
<!-- Private:true and ReferenceOutputAssembly:false, in combination with
|
||||
the manual reference to TerminalControl.winmd below make sure that this
|
||||
project will compile correct, and that we won't roll up the TermControl
|
||||
xbf's into the packaging project twice. -->
|
||||
<Private>true</Private>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<!-- Manually add references to each of our dependent winmds. Mark them as
|
||||
|
@ -266,4 +286,5 @@
|
|||
</Target>
|
||||
<Import Project="$(SolutionDir)build\rules\CollectWildcardResources.targets" />
|
||||
<Import Project="..\..\..\packages\Microsoft.VisualStudio.Setup.Configuration.Native.2.3.2262\build\native\Microsoft.VisualStudio.Setup.Configuration.Native.targets" Condition="Exists('..\..\..\packages\Microsoft.VisualStudio.Setup.Configuration.Native.2.3.2262\build\native\Microsoft.VisualStudio.Setup.Configuration.Native.targets')" />
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
</ProjectReference>
|
||||
|
||||
<ProjectReference Include="$(OpenConsoleDir)src\cascadia\TerminalControl\dll\TerminalControl.vcxproj">
|
||||
<!-- Private:false and ReferenceOutputAssembly:false, in combination with
|
||||
<!-- Private:true and ReferenceOutputAssembly:false, in combination with
|
||||
the manual reference to TerminalControl.winmd below make sure that this
|
||||
project will compile correct, and that we won't roll up the TermControl
|
||||
xbf's into the packaging project twice. -->
|
||||
|
|
|
@ -96,9 +96,10 @@ class TerminalCoreUnitTests::ConptyRoundtripTests final
|
|||
auto& g = ServiceLocator::LocateGlobals();
|
||||
auto& gci = g.getConsoleInformation();
|
||||
|
||||
gci.SetDefaultForegroundColor(INVALID_COLOR);
|
||||
gci.SetDefaultBackgroundColor(INVALID_COLOR);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, INVALID_COLOR);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, INVALID_COLOR);
|
||||
gci.SetFillAttribute(0x07); // DARK_WHITE on DARK_BLACK
|
||||
gci.CalculateDefaultColorIndices();
|
||||
|
||||
m_state->PrepareNewTextBufferInfo(true, TerminalViewWidth, TerminalViewHeight);
|
||||
auto& currentBuffer = gci.GetActiveOutputBuffer();
|
||||
|
|
|
@ -59,7 +59,6 @@ void TerminalApiTest::SetColorTableEntry()
|
|||
VERIFY_IS_TRUE(term.SetColorTableEntry(128, 100));
|
||||
VERIFY_IS_TRUE(term.SetColorTableEntry(255, 100));
|
||||
|
||||
VERIFY_IS_FALSE(term.SetColorTableEntry(256, 100));
|
||||
VERIFY_IS_FALSE(term.SetColorTableEntry(512, 100));
|
||||
}
|
||||
|
||||
|
@ -271,7 +270,7 @@ void TerminalCoreUnitTests::TerminalApiTest::AddHyperlink()
|
|||
auto& stateMachine = *(term._stateMachine);
|
||||
|
||||
// Process the opening osc 8 sequence
|
||||
stateMachine.ProcessString(L"\x1b]8;;test.url\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]8;;test.url\x1b\\");
|
||||
VERIFY_IS_TRUE(tbi.GetCurrentAttributes().IsHyperlink());
|
||||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkUriFromId(tbi.GetCurrentAttributes().GetHyperlinkId()), L"test.url");
|
||||
|
||||
|
@ -281,7 +280,7 @@ void TerminalCoreUnitTests::TerminalApiTest::AddHyperlink()
|
|||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkUriFromId(tbi.GetCurrentAttributes().GetHyperlinkId()), L"test.url");
|
||||
|
||||
// Process the closing osc 8 sequences
|
||||
stateMachine.ProcessString(L"\x1b]8;;\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]8;;\x1b\\");
|
||||
VERIFY_IS_FALSE(tbi.GetCurrentAttributes().IsHyperlink());
|
||||
}
|
||||
|
||||
|
@ -297,7 +296,7 @@ void TerminalCoreUnitTests::TerminalApiTest::AddHyperlinkCustomId()
|
|||
auto& stateMachine = *(term._stateMachine);
|
||||
|
||||
// Process the opening osc 8 sequence
|
||||
stateMachine.ProcessString(L"\x1b]8;id=myId;test.url\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]8;id=myId;test.url\x1b\\");
|
||||
VERIFY_IS_TRUE(tbi.GetCurrentAttributes().IsHyperlink());
|
||||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkUriFromId(tbi.GetCurrentAttributes().GetHyperlinkId()), L"test.url");
|
||||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkId(L"test.url", L"myId"), tbi.GetCurrentAttributes().GetHyperlinkId());
|
||||
|
@ -309,7 +308,7 @@ void TerminalCoreUnitTests::TerminalApiTest::AddHyperlinkCustomId()
|
|||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkId(L"test.url", L"myId"), tbi.GetCurrentAttributes().GetHyperlinkId());
|
||||
|
||||
// Process the closing osc 8 sequences
|
||||
stateMachine.ProcessString(L"\x1b]8;;\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]8;;\x1b\\");
|
||||
VERIFY_IS_FALSE(tbi.GetCurrentAttributes().IsHyperlink());
|
||||
}
|
||||
|
||||
|
@ -325,7 +324,7 @@ void TerminalCoreUnitTests::TerminalApiTest::AddHyperlinkCustomIdDifferentUri()
|
|||
auto& stateMachine = *(term._stateMachine);
|
||||
|
||||
// Process the opening osc 8 sequence
|
||||
stateMachine.ProcessString(L"\x1b]8;id=myId;test.url\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]8;id=myId;test.url\x1b\\");
|
||||
VERIFY_IS_TRUE(tbi.GetCurrentAttributes().IsHyperlink());
|
||||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkUriFromId(tbi.GetCurrentAttributes().GetHyperlinkId()), L"test.url");
|
||||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkId(L"test.url", L"myId"), tbi.GetCurrentAttributes().GetHyperlinkId());
|
||||
|
@ -333,7 +332,7 @@ void TerminalCoreUnitTests::TerminalApiTest::AddHyperlinkCustomIdDifferentUri()
|
|||
const auto oldAttributes{ tbi.GetCurrentAttributes() };
|
||||
|
||||
// Send any other text
|
||||
stateMachine.ProcessString(L"\x1b]8;id=myId;other.url\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]8;id=myId;other.url\x1b\\");
|
||||
VERIFY_IS_TRUE(tbi.GetCurrentAttributes().IsHyperlink());
|
||||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkUriFromId(tbi.GetCurrentAttributes().GetHyperlinkId()), L"other.url");
|
||||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkId(L"other.url", L"myId"), tbi.GetCurrentAttributes().GetHyperlinkId());
|
||||
|
@ -356,58 +355,58 @@ void TerminalCoreUnitTests::TerminalApiTest::SetTaskbarProgress()
|
|||
VERIFY_ARE_EQUAL(term.GetTaskbarProgress(), gsl::narrow<size_t>(0));
|
||||
|
||||
// Set some values for taskbar state and progress through state machine
|
||||
stateMachine.ProcessString(L"\x1b]9;4;1;50\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;4;1;50\x1b\\");
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarState(), gsl::narrow<size_t>(1));
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarProgress(), gsl::narrow<size_t>(50));
|
||||
|
||||
// Reset to 0
|
||||
stateMachine.ProcessString(L"\x1b]9;4;0;0\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;4;0;0\x1b\\");
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarState(), gsl::narrow<size_t>(0));
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarProgress(), gsl::narrow<size_t>(0));
|
||||
|
||||
// Set an out of bounds value for state
|
||||
stateMachine.ProcessString(L"\x1b]9;4;5;50\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;4;5;50\x1b\\");
|
||||
// Nothing should have changed (dispatch should have returned false)
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarState(), gsl::narrow<size_t>(0));
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarProgress(), gsl::narrow<size_t>(0));
|
||||
|
||||
// Set an out of bounds value for progress
|
||||
stateMachine.ProcessString(L"\x1b]9;4;1;999\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;4;1;999\x1b\\");
|
||||
// Progress should have been clamped to 100
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarState(), gsl::narrow<size_t>(1));
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarProgress(), gsl::narrow<size_t>(100));
|
||||
|
||||
// Don't specify any params
|
||||
stateMachine.ProcessString(L"\x1b]9;4\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;4\x1b\\");
|
||||
// State and progress should both be reset to 0
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarState(), gsl::narrow<size_t>(0));
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarProgress(), gsl::narrow<size_t>(0));
|
||||
|
||||
// Specify additional params
|
||||
stateMachine.ProcessString(L"\x1b]9;4;1;80;123\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;4;1;80;123\x1b\\");
|
||||
// Additional params should be ignored, state and progress still set normally
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarState(), gsl::narrow<size_t>(1));
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarProgress(), gsl::narrow<size_t>(80));
|
||||
|
||||
// Edge cases + trailing semicolon testing
|
||||
stateMachine.ProcessString(L"\x1b]9;4;2;\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;4;2;\x1b\\");
|
||||
// String should be processed correctly despite the trailing semicolon,
|
||||
// taskbar progress should remain unchanged from previous value
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarState(), gsl::narrow<size_t>(2));
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarProgress(), gsl::narrow<size_t>(80));
|
||||
|
||||
stateMachine.ProcessString(L"\x1b]9;4;3;75\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;4;3;75\x1b\\");
|
||||
// Given progress value should be ignored because this is the indeterminate state,
|
||||
// so the progress value should remain unchanged
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarState(), gsl::narrow<size_t>(3));
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarProgress(), gsl::narrow<size_t>(80));
|
||||
|
||||
stateMachine.ProcessString(L"\x1b]9;4;0;50\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;4;0;50\x1b\\");
|
||||
// Taskbar progress should be 0 (the given value should be ignored)
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarState(), gsl::narrow<size_t>(0));
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarProgress(), gsl::narrow<size_t>(0));
|
||||
|
||||
stateMachine.ProcessString(L"\x1b]9;4;2;\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;4;2;\x1b\\");
|
||||
// String should be processed correctly despite the trailing semicolon,
|
||||
// taskbar progress should be set to a 'minimum', non-zero value
|
||||
VERIFY_ARE_EQUAL(term.GetTaskbarState(), gsl::narrow<size_t>(2));
|
||||
|
@ -427,45 +426,45 @@ void TerminalCoreUnitTests::TerminalApiTest::SetWorkingDirectory()
|
|||
VERIFY_IS_TRUE(term.GetWorkingDirectory().empty());
|
||||
|
||||
// Invalid sequences should not change CWD
|
||||
stateMachine.ProcessString(L"\x1b]9;9\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;9\x1b\\");
|
||||
VERIFY_IS_TRUE(term.GetWorkingDirectory().empty());
|
||||
|
||||
stateMachine.ProcessString(L"\x1b]9;9\"\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;9\"\x1b\\");
|
||||
VERIFY_IS_TRUE(term.GetWorkingDirectory().empty());
|
||||
|
||||
stateMachine.ProcessString(L"\x1b]9;9\"C:\\\"\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;9\"C:\\\"\x1b\\");
|
||||
VERIFY_IS_TRUE(term.GetWorkingDirectory().empty());
|
||||
|
||||
// Valid sequences should change CWD
|
||||
stateMachine.ProcessString(L"\x1b]9;9;\"C:\\\"\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;9;\"C:\\\"\x1b\\");
|
||||
VERIFY_ARE_EQUAL(term.GetWorkingDirectory(), L"C:\\");
|
||||
|
||||
stateMachine.ProcessString(L"\x1b]9;9;\"C:\\Program Files\"\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;9;\"C:\\Program Files\"\x1b\\");
|
||||
VERIFY_ARE_EQUAL(term.GetWorkingDirectory(), L"C:\\Program Files");
|
||||
|
||||
stateMachine.ProcessString(L"\x1b]9;9;\"D:\\中文\"\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;9;\"D:\\中文\"\x1b\\");
|
||||
VERIFY_ARE_EQUAL(term.GetWorkingDirectory(), L"D:\\中文");
|
||||
|
||||
// Test OSC 9;9 sequences without quotation marks
|
||||
stateMachine.ProcessString(L"\x1b]9;9;C:\\\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;9;C:\\\x1b\\");
|
||||
VERIFY_ARE_EQUAL(term.GetWorkingDirectory(), L"C:\\");
|
||||
|
||||
stateMachine.ProcessString(L"\x1b]9;9;C:\\Program Files\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;9;C:\\Program Files\x1b\\");
|
||||
VERIFY_ARE_EQUAL(term.GetWorkingDirectory(), L"C:\\Program Files");
|
||||
|
||||
stateMachine.ProcessString(L"\x1b]9;9;D:\\中文\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;9;D:\\中文\x1b\\");
|
||||
VERIFY_ARE_EQUAL(term.GetWorkingDirectory(), L"D:\\中文");
|
||||
|
||||
// These OSC 9;9 sequences will result in invalid CWD. We shouldn't crash on these.
|
||||
stateMachine.ProcessString(L"\x1b]9;9;\"\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;9;\"\x1b\\");
|
||||
VERIFY_ARE_EQUAL(term.GetWorkingDirectory(), L"\"");
|
||||
|
||||
stateMachine.ProcessString(L"\x1b]9;9;\"\"\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;9;\"\"\x1b\\");
|
||||
VERIFY_ARE_EQUAL(term.GetWorkingDirectory(), L"\"\"");
|
||||
|
||||
stateMachine.ProcessString(L"\x1b]9;9;\"\"\"\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;9;\"\"\"\x1b\\");
|
||||
VERIFY_ARE_EQUAL(term.GetWorkingDirectory(), L"\"");
|
||||
|
||||
stateMachine.ProcessString(L"\x1b]9;9;\"\"\"\"\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]9;9;\"\"\"\"\x1b\\");
|
||||
VERIFY_ARE_EQUAL(term.GetWorkingDirectory(), L"\"\"");
|
||||
}
|
||||
|
|
|
@ -115,6 +115,23 @@
|
|||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--
|
||||
BODGY
|
||||
|
||||
The wapproj `GetResolvedWinMD` target tries to get a winmd from every cppwinrt
|
||||
executable we put in the package. But we DON'T produce a winmd. This makes the
|
||||
FastUpToDate check fail every time, and leads to the whole wapproj build
|
||||
running even if you're just f5'ing the package. EVEN AFTER A SUCCESSFUL BUILD.
|
||||
|
||||
Setting GenerateWindowsMetadata=false is enough to tell the build system that
|
||||
we don't produce one, and get it off our backs.
|
||||
-->
|
||||
<ItemDefinitionGroup>
|
||||
<Link>
|
||||
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
<Import Project="$(OpenConsoleDir)src\cppwinrt.build.post.props" />
|
||||
|
||||
<Import Project="..\..\..\packages\Microsoft.UI.Xaml.2.7.0-prerelease.210913003\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\..\packages\Microsoft.UI.Xaml.2.7.0-prerelease.210913003\build\native\Microsoft.UI.Xaml.targets')" />
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.18362.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.18362.0" MaxVersionTested="10.0.22000.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.18362.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.18362.0" MaxVersionTested="10.0.22000.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<Description>TAEF Packaged Cwa FullTrust Application Host Process</Description>
|
||||
</Properties>
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.18362.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.18362.0" MaxVersionTested="10.0.22000.0" />
|
||||
<PackageDependency Name="Microsoft.VCLibs.140.00.Debug" MinVersion="14.0.27023.1" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
<PackageDependency Name="Microsoft.VCLibs.140.00.Debug.UWPDesktop" MinVersion="14.0.27027.1" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" />
|
||||
</Dependencies>
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Label="Globals">
|
||||
<WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)' == ''">10.0.19041.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)' == ''">10.0.22000.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformMinVersion Condition="'$(WindowsTargetPlatformMinVersion)' == ''">10.0.18362.0</WindowsTargetPlatformMinVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
@ -219,36 +219,6 @@ InputBuffer* const CONSOLE_INFORMATION::GetActiveInputBuffer() const
|
|||
return pInputBuffer;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Return the default foreground color of the console. If the settings are
|
||||
// configured to have a default foreground color (separate from the color
|
||||
// table), this will return that value. Otherwise it will return the value
|
||||
// from the colortable corresponding to our default attributes.
|
||||
// Arguments:
|
||||
// - <none>
|
||||
// Return Value:
|
||||
// - the default foreground color of the console.
|
||||
COLORREF CONSOLE_INFORMATION::GetDefaultForeground() const noexcept
|
||||
{
|
||||
const auto fg = GetDefaultForegroundColor();
|
||||
return fg != INVALID_COLOR ? fg : GetLegacyColorTableEntry(LOBYTE(GetFillAttribute()) & FG_ATTRS);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Return the default background color of the console. If the settings are
|
||||
// configured to have a default background color (separate from the color
|
||||
// table), this will return that value. Otherwise it will return the value
|
||||
// from the colortable corresponding to our default attributes.
|
||||
// Arguments:
|
||||
// - <none>
|
||||
// Return Value:
|
||||
// - the default background color of the console.
|
||||
COLORREF CONSOLE_INFORMATION::GetDefaultBackground() const noexcept
|
||||
{
|
||||
const auto bg = GetDefaultBackgroundColor();
|
||||
return bg != INVALID_COLOR ? bg : GetLegacyColorTableEntry((LOBYTE(GetFillAttribute()) & BG_ATTRS) >> 4);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Get the colors of a particular text attribute, using our color table,
|
||||
// and our configured default attributes.
|
||||
|
@ -257,26 +227,12 @@ COLORREF CONSOLE_INFORMATION::GetDefaultBackground() const noexcept
|
|||
// Return Value:
|
||||
// - The color values of the attribute's foreground and background.
|
||||
std::pair<COLORREF, COLORREF> CONSOLE_INFORMATION::LookupAttributeColors(const TextAttribute& attr) const noexcept
|
||||
{
|
||||
return LookupAttributeColors(attr, GetDefaultForeground(), GetDefaultBackground());
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Get the colors of a particular text attribute, using our color table,
|
||||
// and the given default color values.
|
||||
// Arguments:
|
||||
// - attr: the TextAttribute to retrieve the foreground and background color of.
|
||||
// - defaultFg: the COLORREF to use for a default foreground color.
|
||||
// - defaultBg: the COLORREF to use for a default background color.
|
||||
// Return Value:
|
||||
// - The color values of the attribute's foreground and background.
|
||||
std::pair<COLORREF, COLORREF> CONSOLE_INFORMATION::LookupAttributeColors(const TextAttribute& attr, const COLORREF defaultFg, const COLORREF defaultBg) const noexcept
|
||||
{
|
||||
_blinkingState.RecordBlinkingUsage(attr);
|
||||
return attr.CalculateRgbColors(
|
||||
GetColorTable(),
|
||||
defaultFg,
|
||||
defaultBg,
|
||||
GetDefaultForegroundIndex(),
|
||||
GetDefaultBackgroundIndex(),
|
||||
IsScreenReversed(),
|
||||
_blinkingState.IsBlinkingFaint());
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@
|
|||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy $(SolutionDir)\dep\WinAppDriver\* $(OutDir)\</PostBuildEvent>
|
||||
<PostBuildEvent>copy "$(SolutionDir)\dep\WinAppDriver\*" "$(OutDir)\"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\..\..\packages\Microsoft.Taef.10.60.210621002\build\Microsoft.Taef.targets" Condition="Exists('..\..\..\packages\Microsoft.Taef.10.60.210621002\build\Microsoft.Taef.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
@ -152,4 +152,4 @@
|
|||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\..\packages\Microsoft.Taef.10.60.210621002\build\Microsoft.Taef.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Taef.10.60.210621002\build\Microsoft.Taef.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -1499,12 +1499,6 @@ void DoSrvSetCursorStyle(SCREEN_INFORMATION& screenInfo,
|
|||
screenInfo.GetActiveBuffer().GetTextBuffer().GetCursor().SetType(cursorType);
|
||||
}
|
||||
|
||||
void DoSrvSetCursorColor(SCREEN_INFORMATION& screenInfo,
|
||||
const COLORREF cursorColor)
|
||||
{
|
||||
screenInfo.GetActiveBuffer().GetTextBuffer().GetCursor().SetColor(cursorColor);
|
||||
}
|
||||
|
||||
void DoSrvAddHyperlink(SCREEN_INFORMATION& screenInfo,
|
||||
const std::wstring_view uri,
|
||||
const std::wstring_view params)
|
||||
|
@ -1963,115 +1957,6 @@ void DoSrvPrivateMoveToBottom(SCREEN_INFORMATION& screenInfo)
|
|||
screenInfo.GetActiveBuffer().MoveToBottom();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Retrieve the color table value at the specified index.
|
||||
// Arguments:
|
||||
// - index: the index in the table to retrieve.
|
||||
// - value: receives the RGB value for the color at that index in the table.
|
||||
// Return Value:
|
||||
// - E_INVALIDARG if index is >= 256, else S_OK
|
||||
[[nodiscard]] HRESULT DoSrvPrivateGetColorTableEntry(const size_t index, COLORREF& value) noexcept
|
||||
{
|
||||
RETURN_HR_IF(E_INVALIDARG, index >= 256);
|
||||
try
|
||||
{
|
||||
Globals& g = ServiceLocator::LocateGlobals();
|
||||
CONSOLE_INFORMATION& gci = g.getConsoleInformation();
|
||||
|
||||
value = gci.GetColorTableEntry(index);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
CATCH_RETURN();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sets the color table value in index to the color specified in value.
|
||||
// Can be used to set the 256-color table as well as the 16-color table.
|
||||
// Arguments:
|
||||
// - index: the index in the table to change.
|
||||
// - value: the new RGB value to use for that index in the color table.
|
||||
// Return Value:
|
||||
// - E_INVALIDARG if index is >= 256, else S_OK
|
||||
// Notes:
|
||||
// Does not take a buffer parameter. The color table for a console and for
|
||||
// terminals as well is global, not per-screen-buffer.
|
||||
[[nodiscard]] HRESULT DoSrvPrivateSetColorTableEntry(const size_t index, const COLORREF value) noexcept
|
||||
{
|
||||
RETURN_HR_IF(E_INVALIDARG, index >= 256);
|
||||
try
|
||||
{
|
||||
Globals& g = ServiceLocator::LocateGlobals();
|
||||
CONSOLE_INFORMATION& gci = g.getConsoleInformation();
|
||||
|
||||
gci.SetColorTableEntry(index, value);
|
||||
|
||||
// Update the screen colors if we're not a pty
|
||||
// No need to force a redraw in pty mode.
|
||||
if (g.pRender && !gci.IsInVtIoMode())
|
||||
{
|
||||
g.pRender->TriggerRedrawAll();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
CATCH_RETURN();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sets the default foreground color to the color specified in value.
|
||||
// Arguments:
|
||||
// - value: the new RGB value to use, as a COLORREF, format 0x00BBGGRR.
|
||||
// Return Value:
|
||||
// - S_OK
|
||||
[[nodiscard]] HRESULT DoSrvPrivateSetDefaultForegroundColor(const COLORREF value) noexcept
|
||||
{
|
||||
try
|
||||
{
|
||||
Globals& g = ServiceLocator::LocateGlobals();
|
||||
CONSOLE_INFORMATION& gci = g.getConsoleInformation();
|
||||
|
||||
gci.SetDefaultForegroundColor(value);
|
||||
|
||||
// Update the screen colors if we're not a pty
|
||||
// No need to force a redraw in pty mode.
|
||||
if (g.pRender && !gci.IsInVtIoMode())
|
||||
{
|
||||
g.pRender->TriggerRedrawAll();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
CATCH_RETURN();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sets the default background color to the color specified in value.
|
||||
// Arguments:
|
||||
// - value: the new RGB value to use, as a COLORREF, format 0x00BBGGRR.
|
||||
// Return Value:
|
||||
// - S_OK
|
||||
[[nodiscard]] HRESULT DoSrvPrivateSetDefaultBackgroundColor(const COLORREF value) noexcept
|
||||
{
|
||||
try
|
||||
{
|
||||
Globals& g = ServiceLocator::LocateGlobals();
|
||||
CONSOLE_INFORMATION& gci = g.getConsoleInformation();
|
||||
|
||||
gci.SetDefaultBackgroundColor(value);
|
||||
|
||||
// Update the screen colors if we're not a pty
|
||||
// No need to force a redraw in pty mode.
|
||||
if (g.pRender && !gci.IsInVtIoMode())
|
||||
{
|
||||
g.pRender->TriggerRedrawAll();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
CATCH_RETURN();
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - A private API call for filling a region of the screen buffer.
|
||||
// Arguments:
|
||||
|
|
|
@ -36,8 +36,6 @@ void DoSrvPrivateUseMainScreenBuffer(SCREEN_INFORMATION& screenInfo);
|
|||
|
||||
void DoSrvSetCursorStyle(SCREEN_INFORMATION& screenInfo,
|
||||
const CursorType cursorType);
|
||||
void DoSrvSetCursorColor(SCREEN_INFORMATION& screenInfo,
|
||||
const COLORREF cursorColor);
|
||||
|
||||
void DoSrvAddHyperlink(SCREEN_INFORMATION& screenInfo,
|
||||
const std::wstring_view uri,
|
||||
|
@ -63,13 +61,6 @@ void DoSrvPrivateInsertLines(const size_t count);
|
|||
|
||||
void DoSrvPrivateMoveToBottom(SCREEN_INFORMATION& screenInfo);
|
||||
|
||||
[[nodiscard]] HRESULT DoSrvPrivateGetColorTableEntry(const size_t index, COLORREF& value) noexcept;
|
||||
[[nodiscard]] HRESULT DoSrvPrivateSetColorTableEntry(const size_t index, const COLORREF value) noexcept;
|
||||
|
||||
[[nodiscard]] HRESULT DoSrvPrivateSetDefaultForegroundColor(const COLORREF value) noexcept;
|
||||
|
||||
[[nodiscard]] HRESULT DoSrvPrivateSetDefaultBackgroundColor(const COLORREF value) noexcept;
|
||||
|
||||
[[nodiscard]] HRESULT DoSrvPrivateFillRegion(SCREEN_INFORMATION& screenInfo,
|
||||
const COORD startPosition,
|
||||
const size_t fillLength,
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
using namespace Microsoft::Console;
|
||||
using Microsoft::Console::Interactivity::ServiceLocator;
|
||||
using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
using Microsoft::Console::VirtualTerminal::TerminalInput;
|
||||
|
||||
WriteBuffer::WriteBuffer(_In_ Microsoft::Console::IIoProvider& io) :
|
||||
|
@ -263,22 +264,35 @@ bool ConhostInternalGetSet::SetInputMode(const TerminalInput::Mode mode, const b
|
|||
}
|
||||
|
||||
// Routine Description:
|
||||
// - Sets the terminal emulation mode to either ANSI-compatible or VT52.
|
||||
// PrivateSetAnsiMode is an internal-only "API" call that the vt commands can execute,
|
||||
// - Sets the various StateMachine parser modes.
|
||||
// SetParserMode is an internal-only "API" call that the vt commands can execute,
|
||||
// but it is not represented as a function call on out public API surface.
|
||||
// Arguments:
|
||||
// - ansiMode - set to true to enable the ANSI mode, false for VT52 mode.
|
||||
// - mode - the parser mode to change.
|
||||
// - enabled - set to true to enable the mode, false to disable it.
|
||||
// Return Value:
|
||||
// - true if successful. false otherwise.
|
||||
bool ConhostInternalGetSet::PrivateSetAnsiMode(const bool ansiMode)
|
||||
bool ConhostInternalGetSet::SetParserMode(const StateMachine::Mode mode, const bool enabled)
|
||||
{
|
||||
auto& stateMachine = _io.GetActiveOutputBuffer().GetStateMachine();
|
||||
stateMachine.SetAnsiMode(ansiMode);
|
||||
auto& terminalInput = _io.GetActiveInputBuffer()->GetTerminalInput();
|
||||
terminalInput.SetInputMode(TerminalInput::Mode::Ansi, ansiMode);
|
||||
stateMachine.SetParserMode(mode, enabled);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - Retrieves the various StateMachine parser modes.
|
||||
// GetParserMode is an internal-only "API" call that the vt commands can execute,
|
||||
// but it is not represented as a function call on out public API surface.
|
||||
// Arguments:
|
||||
// - mode - the parser mode to query.
|
||||
// Return Value:
|
||||
// - true if the mode is enabled. false if disabled.
|
||||
bool ConhostInternalGetSet::GetParserMode(const Microsoft::Console::VirtualTerminal::StateMachine::Mode mode) const
|
||||
{
|
||||
auto& stateMachine = _io.GetActiveOutputBuffer().GetStateMachine();
|
||||
return stateMachine.GetParserMode(mode);
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - Connects the PrivateSetScreenMode call directly into our Driver Message servicing call inside Conhost.exe
|
||||
// PrivateSetScreenMode is an internal-only "API" call that the vt commands can execute,
|
||||
|
@ -538,21 +552,6 @@ bool ConhostInternalGetSet::PrivateSuppressResizeRepaint()
|
|||
return SUCCEEDED(DoSrvPrivateSuppressResizeRepaint());
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - Connects the SetCursorStyle call directly into our Driver Message servicing call inside Conhost.exe
|
||||
// SetCursorStyle is an internal-only "API" call that the vt commands can execute,
|
||||
// but it is not represented as a function call on our public API surface.
|
||||
// Arguments:
|
||||
// - cursorColor: The color to change the cursor to. INVALID_COLOR will revert
|
||||
// it to the legacy inverting behavior.
|
||||
// Return Value:
|
||||
// - true if successful (see DoSrvSetCursorStyle). false otherwise.
|
||||
bool ConhostInternalGetSet::SetCursorColor(const COLORREF cursorColor)
|
||||
{
|
||||
DoSrvSetCursorColor(_io.GetActiveOutputBuffer(), cursorColor);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - Connects the IsConsolePty call directly into our Driver Message servicing call inside Conhost.exe
|
||||
// - NOTE: This ONE method behaves differently! The rest of the methods on this
|
||||
|
@ -594,54 +593,61 @@ bool ConhostInternalGetSet::MoveToBottom() const
|
|||
}
|
||||
|
||||
// Method Description:
|
||||
// - Connects the PrivateGetColorTableEntry call directly into our Driver Message servicing
|
||||
// call inside Conhost.exe
|
||||
// - Retrieves the value in the colortable at the specified index.
|
||||
// Arguments:
|
||||
// - index: the index in the table to retrieve.
|
||||
// - value: receives the RGB value for the color at that index in the table.
|
||||
// - tableIndex: the index of the color table to retrieve.
|
||||
// Return Value:
|
||||
// - true if successful (see DoSrvPrivateGetColorTableEntry). false otherwise.
|
||||
bool ConhostInternalGetSet::PrivateGetColorTableEntry(const size_t index, COLORREF& value) const noexcept
|
||||
// - the COLORREF value for the color at that index in the table.
|
||||
COLORREF ConhostInternalGetSet::GetColorTableEntry(const size_t tableIndex) const noexcept
|
||||
try
|
||||
{
|
||||
return SUCCEEDED(DoSrvPrivateGetColorTableEntry(index, value));
|
||||
auto& g = ServiceLocator::LocateGlobals();
|
||||
auto& gci = g.getConsoleInformation();
|
||||
|
||||
return gci.GetColorTableEntry(tableIndex);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return INVALID_COLOR;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Connects the PrivateSetColorTableEntry call directly into our Driver Message servicing
|
||||
// call inside Conhost.exe
|
||||
// - Updates the value in the colortable at index tableIndex to the new color
|
||||
// color. color is a COLORREF, format 0x00BBGGRR.
|
||||
// Arguments:
|
||||
// - index: the index in the table to change.
|
||||
// - value: the new RGB value to use for that index in the color table.
|
||||
// - tableIndex: the index of the color table to update.
|
||||
// - color: the new COLORREF to use as that color table value.
|
||||
// Return Value:
|
||||
// - true if successful (see DoSrvPrivateSetColorTableEntry). false otherwise.
|
||||
bool ConhostInternalGetSet::PrivateSetColorTableEntry(const size_t index, const COLORREF value) const noexcept
|
||||
// - true if successful. false otherwise.
|
||||
bool ConhostInternalGetSet::SetColorTableEntry(const size_t tableIndex, const COLORREF color) noexcept
|
||||
try
|
||||
{
|
||||
return SUCCEEDED(DoSrvPrivateSetColorTableEntry(index, value));
|
||||
}
|
||||
auto& g = ServiceLocator::LocateGlobals();
|
||||
auto& gci = g.getConsoleInformation();
|
||||
|
||||
// Method Description:
|
||||
// - Connects the PrivateSetDefaultForeground call directly into our Driver Message servicing
|
||||
// call inside Conhost.exe
|
||||
// Arguments:
|
||||
// - value: the new RGB value to use, as a COLORREF, format 0x00BBGGRR.
|
||||
// Return Value:
|
||||
// - true if successful (see DoSrvPrivateSetDefaultForegroundColor). false otherwise.
|
||||
bool ConhostInternalGetSet::PrivateSetDefaultForeground(const COLORREF value) const noexcept
|
||||
{
|
||||
return SUCCEEDED(DoSrvPrivateSetDefaultForegroundColor(value));
|
||||
}
|
||||
gci.SetColorTableEntry(tableIndex, color);
|
||||
|
||||
// Method Description:
|
||||
// - Connects the PrivateSetDefaultBackground call directly into our Driver Message servicing
|
||||
// call inside Conhost.exe
|
||||
// Arguments:
|
||||
// - value: the new RGB value to use, as a COLORREF, format 0x00BBGGRR.
|
||||
// Return Value:
|
||||
// - true if successful (see DoSrvPrivateSetDefaultBackgroundColor). false otherwise.
|
||||
bool ConhostInternalGetSet::PrivateSetDefaultBackground(const COLORREF value) const noexcept
|
||||
{
|
||||
return SUCCEEDED(DoSrvPrivateSetDefaultBackgroundColor(value));
|
||||
// If we're setting the default foreground or background colors
|
||||
// we need to make sure the index is correctly set as well.
|
||||
if (tableIndex == TextColor::DEFAULT_FOREGROUND)
|
||||
{
|
||||
gci.SetDefaultForegroundIndex(TextColor::DEFAULT_FOREGROUND);
|
||||
}
|
||||
if (tableIndex == TextColor::DEFAULT_BACKGROUND)
|
||||
{
|
||||
gci.SetDefaultBackgroundIndex(TextColor::DEFAULT_BACKGROUND);
|
||||
}
|
||||
|
||||
// Update the screen colors if we're not a pty
|
||||
// No need to force a redraw in pty mode.
|
||||
if (g.pRender && !gci.IsInVtIoMode())
|
||||
{
|
||||
g.pRender->TriggerRedrawAll();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
CATCH_RETURN_FALSE()
|
||||
|
||||
// Routine Description:
|
||||
// - Connects the PrivateFillRegion call directly into our Driver Message servicing
|
||||
|
|
|
@ -73,8 +73,9 @@ public:
|
|||
const SMALL_RECT& window) override;
|
||||
|
||||
bool SetInputMode(const Microsoft::Console::VirtualTerminal::TerminalInput::Mode mode, const bool enabled) override;
|
||||
bool SetParserMode(const Microsoft::Console::VirtualTerminal::StateMachine::Mode mode, const bool enabled) override;
|
||||
bool GetParserMode(const Microsoft::Console::VirtualTerminal::StateMachine::Mode mode) const override;
|
||||
|
||||
bool PrivateSetAnsiMode(const bool ansiMode) override;
|
||||
bool PrivateSetScreenMode(const bool reverseMode) override;
|
||||
bool PrivateSetAutoWrapMode(const bool wrapAtEOL) override;
|
||||
|
||||
|
@ -100,7 +101,6 @@ public:
|
|||
|
||||
bool GetUserDefaultCursorStyle(CursorType& style) override;
|
||||
bool SetCursorStyle(CursorType const style) override;
|
||||
bool SetCursorColor(COLORREF const color) override;
|
||||
|
||||
bool PrivateRefreshWindow() override;
|
||||
|
||||
|
@ -118,12 +118,8 @@ public:
|
|||
|
||||
bool MoveToBottom() const override;
|
||||
|
||||
bool PrivateGetColorTableEntry(const size_t index, COLORREF& value) const noexcept override;
|
||||
bool PrivateSetColorTableEntry(const size_t index, const COLORREF value) const noexcept override;
|
||||
|
||||
bool PrivateSetDefaultForeground(const COLORREF value) const noexcept override;
|
||||
|
||||
bool PrivateSetDefaultBackground(const COLORREF value) const noexcept override;
|
||||
COLORREF GetColorTableEntry(const size_t tableIndex) const noexcept override;
|
||||
bool SetColorTableEntry(const size_t tableIndex, const COLORREF color) noexcept override;
|
||||
|
||||
bool PrivateFillRegion(const COORD startPosition,
|
||||
const size_t fillLength,
|
||||
|
|
|
@ -110,8 +110,6 @@ void RenderData::UnlockConsole() noexcept
|
|||
const TextAttribute RenderData::GetDefaultBrushColors() noexcept
|
||||
{
|
||||
const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
_defaultForeground = gci.GetDefaultForeground();
|
||||
_defaultBackground = gci.GetDefaultBackground();
|
||||
return gci.GetActiveOutputBuffer().GetAttributes();
|
||||
}
|
||||
|
||||
|
@ -226,8 +224,7 @@ ULONG RenderData::GetCursorPixelWidth() const noexcept
|
|||
COLORREF RenderData::GetCursorColor() const noexcept
|
||||
{
|
||||
const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
const auto& cursor = gci.GetActiveOutputBuffer().GetTextBuffer().GetCursor();
|
||||
return cursor.GetColor();
|
||||
return gci.GetColorTableEntry(TextColor::CURSOR_COLOR);
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
|
@ -364,7 +361,7 @@ const std::vector<size_t> RenderData::GetPatternId(const COORD /*location*/) con
|
|||
std::pair<COLORREF, COLORREF> RenderData::GetAttributeColors(const TextAttribute& attr) const noexcept
|
||||
{
|
||||
const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
return gci.LookupAttributeColors(attr, _defaultForeground, _defaultBackground);
|
||||
return gci.LookupAttributeColors(attr);
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
|
|
|
@ -72,8 +72,4 @@ public:
|
|||
void ColorSelection(const COORD coordSelectionStart, const COORD coordSelectionEnd, const TextAttribute attr);
|
||||
const bool IsUiaDataInitialized() const noexcept override { return true; }
|
||||
#pragma endregion
|
||||
|
||||
private:
|
||||
COLORREF _defaultForeground = gsl::at(Microsoft::Console::Utils::CampbellColorTable(), 7);
|
||||
COLORREF _defaultBackground = gsl::at(Microsoft::Console::Utils::CampbellColorTable(), 0);
|
||||
};
|
||||
|
|
|
@ -123,7 +123,6 @@ SCREEN_INFORMATION::~SCREEN_INFORMATION()
|
|||
pScreen->_renderTarget);
|
||||
|
||||
const auto& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
pScreen->_textBuffer->GetCursor().SetColor(gci.GetCursorColor());
|
||||
pScreen->_textBuffer->GetCursor().SetType(gci.GetCursorType());
|
||||
|
||||
const NTSTATUS status = pScreen->_InitializeOutputStateMachine();
|
||||
|
@ -1630,29 +1629,6 @@ void SCREEN_INFORMATION::SetCursorInformation(const ULONG Size,
|
|||
}
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - This routine sets the cursor color. Also updates the cursor information of
|
||||
// this buffer's main buffer, if this buffer is an alt buffer.
|
||||
// Arguments:
|
||||
// - Color - The new color to set the cursor to
|
||||
// - setMain - If true, propagate change to main buffer as well.
|
||||
// Return Value:
|
||||
// - None
|
||||
void SCREEN_INFORMATION::SetCursorColor(const unsigned int Color, const bool setMain) noexcept
|
||||
{
|
||||
Cursor& cursor = _textBuffer->GetCursor();
|
||||
|
||||
cursor.SetColor(Color);
|
||||
|
||||
// If we're an alt buffer, DON'T propagate this setting up to the main buffer.
|
||||
// We don't want to pollute that buffer with this state,
|
||||
// UNLESS we're getting called from the propsheet, then we DO want to update this.
|
||||
if (_psiMainBuffer && setMain)
|
||||
{
|
||||
_psiMainBuffer->SetCursorColor(Color);
|
||||
}
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - This routine sets the cursor shape both in the data
|
||||
// structures and on the screen. Also updates the cursor information of
|
||||
|
@ -1908,7 +1884,7 @@ const SCREEN_INFORMATION& SCREEN_INFORMATION::GetMainBuffer() const
|
|||
auto& myCursor = GetTextBuffer().GetCursor();
|
||||
auto* const createdBuffer = *ppsiNewScreenBuffer;
|
||||
auto& altCursor = createdBuffer->GetTextBuffer().GetCursor();
|
||||
altCursor.SetStyle(myCursor.GetSize(), myCursor.GetColor(), myCursor.GetType());
|
||||
altCursor.SetStyle(myCursor.GetSize(), myCursor.GetType());
|
||||
altCursor.SetIsVisible(myCursor.IsVisible());
|
||||
altCursor.SetBlinkingAllowed(myCursor.IsBlinkingAllowed());
|
||||
// The new position should match the viewport-relative position of the main buffer.
|
||||
|
@ -2006,7 +1982,7 @@ void SCREEN_INFORMATION::UseMainScreenBuffer()
|
|||
// Copy the alt buffer's cursor style and visibility back to the main buffer.
|
||||
const auto& altCursor = psiAlt->GetTextBuffer().GetCursor();
|
||||
auto& mainCursor = psiMain->GetTextBuffer().GetCursor();
|
||||
mainCursor.SetStyle(altCursor.GetSize(), altCursor.GetColor(), altCursor.GetType());
|
||||
mainCursor.SetStyle(altCursor.GetSize(), altCursor.GetType());
|
||||
mainCursor.SetIsVisible(altCursor.IsVisible());
|
||||
mainCursor.SetBlinkingAllowed(altCursor.IsBlinkingAllowed());
|
||||
|
||||
|
|
|
@ -189,8 +189,6 @@ public:
|
|||
void SetCursorInformation(const ULONG Size,
|
||||
const bool Visible) noexcept;
|
||||
|
||||
void SetCursorColor(const unsigned int Color, const bool setMain = false) noexcept;
|
||||
|
||||
void SetCursorType(const CursorType Type, const bool setMain = false) noexcept;
|
||||
|
||||
void SetCursorDBMode(const bool DoubleCursor);
|
||||
|
|
|
@ -16,7 +16,6 @@ Selection::Selection() :
|
|||
_fSelectionVisible(false),
|
||||
_ulSavedCursorSize(0),
|
||||
_fSavedCursorVisible(false),
|
||||
_savedCursorColor(INVALID_COLOR),
|
||||
_savedCursorType(CursorType::Legacy),
|
||||
_dwSelectionFlags(0),
|
||||
_fLineSelection(true),
|
||||
|
|
|
@ -174,7 +174,6 @@ private:
|
|||
COORD _coordSavedCursorPosition;
|
||||
ULONG _ulSavedCursorSize;
|
||||
bool _fSavedCursorVisible;
|
||||
COLORREF _savedCursorColor;
|
||||
CursorType _savedCursorType;
|
||||
|
||||
#ifdef UNIT_TESTING
|
||||
|
|
|
@ -168,7 +168,6 @@ void Selection::_SaveCursorData(const Cursor& cursor) noexcept
|
|||
_coordSavedCursorPosition = cursor.GetPosition();
|
||||
_ulSavedCursorSize = cursor.GetSize();
|
||||
_fSavedCursorVisible = cursor.IsVisible();
|
||||
_savedCursorColor = cursor.GetColor();
|
||||
_savedCursorType = cursor.GetType();
|
||||
}
|
||||
|
||||
|
@ -182,7 +181,6 @@ void Selection::_RestoreDataToCursor(Cursor& cursor) noexcept
|
|||
{
|
||||
cursor.SetSize(_ulSavedCursorSize);
|
||||
cursor.SetIsVisible(_fSavedCursorVisible);
|
||||
cursor.SetColor(_savedCursorColor);
|
||||
cursor.SetType(_savedCursorType);
|
||||
cursor.SetIsOn(true);
|
||||
cursor.SetPosition(_coordSavedCursorPosition);
|
||||
|
|
|
@ -124,10 +124,7 @@ public:
|
|||
COOKED_READ_DATA& CookedReadData() noexcept;
|
||||
void SetCookedReadData(COOKED_READ_DATA* readData) noexcept;
|
||||
|
||||
COLORREF GetDefaultForeground() const noexcept;
|
||||
COLORREF GetDefaultBackground() const noexcept;
|
||||
std::pair<COLORREF, COLORREF> LookupAttributeColors(const TextAttribute& attr) const noexcept;
|
||||
std::pair<COLORREF, COLORREF> LookupAttributeColors(const TextAttribute& attr, const COLORREF defaultFg, const COLORREF defaultBg) const noexcept;
|
||||
|
||||
void SetTitle(const std::wstring_view newTitle);
|
||||
void SetTitlePrefix(const std::wstring_view newTitlePrefix);
|
||||
|
|
|
@ -56,8 +56,8 @@ Settings::Settings() :
|
|||
_fScreenReversed(false),
|
||||
// window size pixels initialized below
|
||||
_fInterceptCopyPaste(0),
|
||||
_DefaultForeground(INVALID_COLOR),
|
||||
_DefaultBackground(INVALID_COLOR),
|
||||
_defaultForegroundIndex(TextColor::DARK_WHITE),
|
||||
_defaultBackgroundIndex(TextColor::DARK_BLACK),
|
||||
_fUseDx(UseDx::Disabled),
|
||||
_fCopyColor(false)
|
||||
{
|
||||
|
@ -78,11 +78,14 @@ Settings::Settings() :
|
|||
ZeroMemory((void*)&_FaceName, sizeof(_FaceName));
|
||||
wcscpy_s(_FaceName, DEFAULT_TT_FONT_FACENAME);
|
||||
|
||||
_CursorColor = Cursor::s_InvertCursorColor;
|
||||
_CursorType = CursorType::Legacy;
|
||||
|
||||
gsl::span<COLORREF> tableView = { _colorTable.data(), _colorTable.size() };
|
||||
::Microsoft::Console::Utils::InitializeColorTable(tableView);
|
||||
|
||||
_colorTable.at(TextColor::DEFAULT_FOREGROUND) = INVALID_COLOR;
|
||||
_colorTable.at(TextColor::DEFAULT_BACKGROUND) = INVALID_COLOR;
|
||||
_colorTable.at(TextColor::CURSOR_COLOR) = INVALID_COLOR;
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
|
@ -229,11 +232,11 @@ void Settings::InitFromStateInfo(_In_ PCONSOLE_STATE_INFO pStateInfo)
|
|||
_fCtrlKeyShortcutsDisabled = pStateInfo->fCtrlKeyShortcutsDisabled;
|
||||
_bLineSelection = pStateInfo->fLineSelection;
|
||||
_bWindowAlpha = pStateInfo->bWindowTransparency;
|
||||
_CursorColor = pStateInfo->CursorColor;
|
||||
_CursorType = static_cast<CursorType>(pStateInfo->CursorType);
|
||||
_fInterceptCopyPaste = pStateInfo->InterceptCopyPaste;
|
||||
_DefaultForeground = pStateInfo->DefaultForeground;
|
||||
_DefaultBackground = pStateInfo->DefaultBackground;
|
||||
_colorTable.at(TextColor::DEFAULT_FOREGROUND) = pStateInfo->DefaultForeground;
|
||||
_colorTable.at(TextColor::DEFAULT_BACKGROUND) = pStateInfo->DefaultBackground;
|
||||
_colorTable.at(TextColor::CURSOR_COLOR) = pStateInfo->CursorColor;
|
||||
_TerminalScrolling = pStateInfo->TerminalScrolling;
|
||||
}
|
||||
|
||||
|
@ -274,11 +277,11 @@ CONSOLE_STATE_INFO Settings::CreateConsoleStateInfo() const
|
|||
csi.fCtrlKeyShortcutsDisabled = _fCtrlKeyShortcutsDisabled;
|
||||
csi.fLineSelection = _bLineSelection;
|
||||
csi.bWindowTransparency = _bWindowAlpha;
|
||||
csi.CursorColor = _CursorColor;
|
||||
csi.CursorType = static_cast<unsigned int>(_CursorType);
|
||||
csi.InterceptCopyPaste = _fInterceptCopyPaste;
|
||||
csi.DefaultForeground = _DefaultForeground;
|
||||
csi.DefaultBackground = _DefaultBackground;
|
||||
csi.DefaultForeground = _colorTable.at(TextColor::DEFAULT_FOREGROUND);
|
||||
csi.DefaultBackground = _colorTable.at(TextColor::DEFAULT_BACKGROUND);
|
||||
csi.CursorColor = _colorTable.at(TextColor::CURSOR_COLOR);
|
||||
csi.TerminalScrolling = _TerminalScrolling;
|
||||
return csi;
|
||||
}
|
||||
|
@ -330,16 +333,22 @@ void Settings::Validate()
|
|||
WI_ClearAllFlags(_wFillAttribute, ~(FG_ATTRS | BG_ATTRS));
|
||||
WI_ClearAllFlags(_wPopupFillAttribute, ~(FG_ATTRS | BG_ATTRS));
|
||||
|
||||
const auto defaultForeground = _colorTable.at(TextColor::DEFAULT_FOREGROUND);
|
||||
const auto defaultBackground = _colorTable.at(TextColor::DEFAULT_BACKGROUND);
|
||||
const auto cursorColor = _colorTable.at(TextColor::CURSOR_COLOR);
|
||||
|
||||
// If the extended color options are set to invalid values (all the same color), reset them.
|
||||
if (_CursorColor != Cursor::s_InvertCursorColor && _CursorColor == _DefaultBackground)
|
||||
if (cursorColor != INVALID_COLOR && cursorColor == defaultBackground)
|
||||
{
|
||||
_CursorColor = Cursor::s_InvertCursorColor;
|
||||
// INVALID_COLOR is used to represent "Invert Colors"
|
||||
_colorTable.at(TextColor::CURSOR_COLOR) = INVALID_COLOR;
|
||||
}
|
||||
|
||||
if (_DefaultForeground != INVALID_COLOR && _DefaultForeground == _DefaultBackground)
|
||||
if (defaultForeground != INVALID_COLOR && defaultForeground == defaultBackground)
|
||||
{
|
||||
// INVALID_COLOR is used as an "unset" sentinel in future attribute functions.
|
||||
_DefaultForeground = _DefaultBackground = INVALID_COLOR;
|
||||
_colorTable.at(TextColor::DEFAULT_FOREGROUND) = INVALID_COLOR;
|
||||
_colorTable.at(TextColor::DEFAULT_BACKGROUND) = INVALID_COLOR;
|
||||
// If the damaged settings _further_ propagated to the default fill attribute, fix it.
|
||||
if (_wFillAttribute == 0)
|
||||
{
|
||||
|
@ -351,6 +360,8 @@ void Settings::Validate()
|
|||
// At this point the default fill attributes are fully initialized
|
||||
// so we can pass on the final colors to the TextAttribute class.
|
||||
TextAttribute::SetLegacyDefaultAttributes(_wFillAttribute);
|
||||
// And calculate the position of the default colors in the color table.
|
||||
CalculateDefaultColorIndices();
|
||||
|
||||
FAIL_FAST_IF(!(_dwWindowSize.X > 0));
|
||||
FAIL_FAST_IF(!(_dwWindowSize.Y > 0));
|
||||
|
@ -760,21 +771,11 @@ COLORREF Settings::GetLegacyColorTableEntry(const size_t index) const
|
|||
return _colorTable.at(TextColor::TransposeLegacyIndex(index));
|
||||
}
|
||||
|
||||
COLORREF Settings::GetCursorColor() const noexcept
|
||||
{
|
||||
return _CursorColor;
|
||||
}
|
||||
|
||||
CursorType Settings::GetCursorType() const noexcept
|
||||
{
|
||||
return _CursorType;
|
||||
}
|
||||
|
||||
void Settings::SetCursorColor(const COLORREF CursorColor) noexcept
|
||||
{
|
||||
_CursorColor = CursorColor;
|
||||
}
|
||||
|
||||
void Settings::SetCursorType(const CursorType cursorType) noexcept
|
||||
{
|
||||
_CursorType = cursorType;
|
||||
|
@ -790,24 +791,35 @@ void Settings::SetInterceptCopyPaste(const bool interceptCopyPaste) noexcept
|
|||
_fInterceptCopyPaste = interceptCopyPaste;
|
||||
}
|
||||
|
||||
COLORREF Settings::GetDefaultForegroundColor() const noexcept
|
||||
void Settings::CalculateDefaultColorIndices() noexcept
|
||||
{
|
||||
return _DefaultForeground;
|
||||
const auto foregroundColor = _colorTable.at(TextColor::DEFAULT_FOREGROUND);
|
||||
const auto foregroundIndex = TextColor::TransposeLegacyIndex(_wFillAttribute & FG_ATTRS);
|
||||
_defaultForegroundIndex = foregroundColor != INVALID_COLOR ? TextColor::DEFAULT_FOREGROUND : foregroundIndex;
|
||||
|
||||
const auto backgroundColor = _colorTable.at(TextColor::DEFAULT_BACKGROUND);
|
||||
const auto backgroundIndex = TextColor::TransposeLegacyIndex((_wFillAttribute & BG_ATTRS) >> 4);
|
||||
_defaultBackgroundIndex = backgroundColor != INVALID_COLOR ? TextColor::DEFAULT_BACKGROUND : backgroundIndex;
|
||||
}
|
||||
|
||||
void Settings::SetDefaultForegroundColor(const COLORREF defaultForeground) noexcept
|
||||
size_t Settings::GetDefaultForegroundIndex() const noexcept
|
||||
{
|
||||
_DefaultForeground = defaultForeground;
|
||||
return _defaultForegroundIndex;
|
||||
}
|
||||
|
||||
COLORREF Settings::GetDefaultBackgroundColor() const noexcept
|
||||
void Settings::SetDefaultForegroundIndex(const size_t index) noexcept
|
||||
{
|
||||
return _DefaultBackground;
|
||||
_defaultForegroundIndex = index;
|
||||
}
|
||||
|
||||
void Settings::SetDefaultBackgroundColor(const COLORREF defaultBackground) noexcept
|
||||
size_t Settings::GetDefaultBackgroundIndex() const noexcept
|
||||
{
|
||||
_DefaultBackground = defaultBackground;
|
||||
return _defaultBackgroundIndex;
|
||||
}
|
||||
|
||||
void Settings::SetDefaultBackgroundIndex(const size_t index) noexcept
|
||||
{
|
||||
_defaultBackgroundIndex = index;
|
||||
}
|
||||
|
||||
bool Settings::IsTerminalScrolling() const noexcept
|
||||
|
|
|
@ -167,7 +167,7 @@ public:
|
|||
void SetHistoryNoDup(const bool fHistoryNoDup);
|
||||
|
||||
// The first 16 items of the color table are the same as the 16-color palette.
|
||||
inline const std::array<COLORREF, XTERM_COLOR_TABLE_SIZE>& GetColorTable() const noexcept
|
||||
inline const std::array<COLORREF, TextColor::TABLE_SIZE>& GetColorTable() const noexcept
|
||||
{
|
||||
return _colorTable;
|
||||
}
|
||||
|
@ -177,20 +177,17 @@ public:
|
|||
void SetLegacyColorTableEntry(const size_t index, const COLORREF ColorValue);
|
||||
COLORREF GetLegacyColorTableEntry(const size_t index) const;
|
||||
|
||||
COLORREF GetCursorColor() const noexcept;
|
||||
CursorType GetCursorType() const noexcept;
|
||||
|
||||
void SetCursorColor(const COLORREF CursorColor) noexcept;
|
||||
void SetCursorType(const CursorType cursorType) noexcept;
|
||||
|
||||
bool GetInterceptCopyPaste() const noexcept;
|
||||
void SetInterceptCopyPaste(const bool interceptCopyPaste) noexcept;
|
||||
|
||||
COLORREF GetDefaultForegroundColor() const noexcept;
|
||||
void SetDefaultForegroundColor(const COLORREF defaultForeground) noexcept;
|
||||
|
||||
COLORREF GetDefaultBackgroundColor() const noexcept;
|
||||
void SetDefaultBackgroundColor(const COLORREF defaultBackground) noexcept;
|
||||
void CalculateDefaultColorIndices() noexcept;
|
||||
size_t GetDefaultForegroundIndex() const noexcept;
|
||||
void SetDefaultForegroundIndex(const size_t index) noexcept;
|
||||
size_t GetDefaultBackgroundIndex() const noexcept;
|
||||
void SetDefaultBackgroundIndex(const size_t index) noexcept;
|
||||
|
||||
bool IsTerminalScrolling() const noexcept;
|
||||
void SetTerminalScrolling(const bool terminalScrollingEnabled) noexcept;
|
||||
|
@ -242,20 +239,19 @@ private:
|
|||
UseDx _fUseDx;
|
||||
bool _fCopyColor;
|
||||
|
||||
std::array<COLORREF, XTERM_COLOR_TABLE_SIZE> _colorTable;
|
||||
std::array<COLORREF, TextColor::TABLE_SIZE> _colorTable;
|
||||
|
||||
// this is used for the special STARTF_USESIZE mode.
|
||||
bool _fUseWindowSizePixels;
|
||||
COORD _dwWindowSizePixels;
|
||||
|
||||
// Technically a COLORREF, but using INVALID_COLOR as "Invert Colors"
|
||||
unsigned int _CursorColor;
|
||||
CursorType _CursorType;
|
||||
|
||||
bool _fInterceptCopyPaste;
|
||||
|
||||
COLORREF _DefaultForeground;
|
||||
COLORREF _DefaultBackground;
|
||||
size_t _defaultForegroundIndex;
|
||||
size_t _defaultBackgroundIndex;
|
||||
|
||||
bool _TerminalScrolling;
|
||||
friend class RegistrySerialization;
|
||||
};
|
||||
|
|
|
@ -67,9 +67,10 @@ class ConptyOutputTests
|
|||
// Set up some sane defaults
|
||||
auto& g = ServiceLocator::LocateGlobals();
|
||||
auto& gci = g.getConsoleInformation();
|
||||
gci.SetDefaultForegroundColor(INVALID_COLOR);
|
||||
gci.SetDefaultBackgroundColor(INVALID_COLOR);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, INVALID_COLOR);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, INVALID_COLOR);
|
||||
gci.SetFillAttribute(0x07); // DARK_WHITE on DARK_BLACK
|
||||
gci.CalculateDefaultColorIndices();
|
||||
|
||||
m_state->PrepareNewTextBufferInfo(true, TerminalViewWidth, TerminalViewHeight);
|
||||
auto& currentBuffer = gci.GetActiveOutputBuffer();
|
||||
|
|
|
@ -59,9 +59,10 @@ class ScreenBufferTests
|
|||
{
|
||||
// Set up some sane defaults
|
||||
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
gci.SetDefaultForegroundColor(INVALID_COLOR);
|
||||
gci.SetDefaultBackgroundColor(INVALID_COLOR);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, INVALID_COLOR);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, INVALID_COLOR);
|
||||
gci.SetFillAttribute(0x07); // DARK_WHITE on DARK_BLACK
|
||||
gci.CalculateDefaultColorIndices();
|
||||
|
||||
m_state->PrepareNewTextBufferInfo();
|
||||
auto& currentBuffer = gci.GetActiveOutputBuffer();
|
||||
|
@ -359,12 +360,11 @@ void ScreenBufferTests::AlternateBufferCursorInheritanceTest()
|
|||
auto mainCursorPos = COORD{ 3, 5 };
|
||||
auto mainCursorVisible = false;
|
||||
auto mainCursorSize = 33u;
|
||||
auto mainCursorColor = RGB(1, 2, 3);
|
||||
auto mainCursorType = CursorType::DoubleUnderscore;
|
||||
auto mainCursorBlinking = false;
|
||||
mainCursor.SetPosition(mainCursorPos);
|
||||
mainCursor.SetIsVisible(mainCursorVisible);
|
||||
mainCursor.SetStyle(mainCursorSize, mainCursorColor, mainCursorType);
|
||||
mainCursor.SetStyle(mainCursorSize, mainCursorType);
|
||||
mainCursor.SetBlinkingAllowed(mainCursorBlinking);
|
||||
|
||||
Log::Comment(L"Switch to the alternate buffer.");
|
||||
|
@ -379,7 +379,6 @@ void ScreenBufferTests::AlternateBufferCursorInheritanceTest()
|
|||
VERIFY_ARE_EQUAL(mainCursorVisible, altCursor.IsVisible());
|
||||
Log::Comment(L"Confirm the cursor style is inherited from the main buffer.");
|
||||
VERIFY_ARE_EQUAL(mainCursorSize, altCursor.GetSize());
|
||||
VERIFY_ARE_EQUAL(mainCursorColor, altCursor.GetColor());
|
||||
VERIFY_ARE_EQUAL(mainCursorType, altCursor.GetType());
|
||||
VERIFY_ARE_EQUAL(mainCursorBlinking, altCursor.IsBlinkingAllowed());
|
||||
|
||||
|
@ -387,12 +386,11 @@ void ScreenBufferTests::AlternateBufferCursorInheritanceTest()
|
|||
auto altCursorPos = COORD{ 5, 3 };
|
||||
auto altCursorVisible = true;
|
||||
auto altCursorSize = 66u;
|
||||
auto altCursorColor = RGB(3, 2, 1);
|
||||
auto altCursorType = CursorType::EmptyBox;
|
||||
auto altCursorBlinking = true;
|
||||
altCursor.SetPosition(altCursorPos);
|
||||
altCursor.SetIsVisible(altCursorVisible);
|
||||
altCursor.SetStyle(altCursorSize, altCursorColor, altCursorType);
|
||||
altCursor.SetStyle(altCursorSize, altCursorType);
|
||||
altCursor.SetBlinkingAllowed(altCursorBlinking);
|
||||
|
||||
Log::Comment(L"Switch back to the main buffer.");
|
||||
|
@ -406,7 +404,6 @@ void ScreenBufferTests::AlternateBufferCursorInheritanceTest()
|
|||
VERIFY_ARE_EQUAL(altCursorVisible, mainCursor.IsVisible());
|
||||
Log::Comment(L"Confirm the cursor style is inherited from the alt buffer.");
|
||||
VERIFY_ARE_EQUAL(altCursorSize, mainCursor.GetSize());
|
||||
VERIFY_ARE_EQUAL(altCursorColor, mainCursor.GetColor());
|
||||
VERIFY_ARE_EQUAL(altCursorType, mainCursor.GetType());
|
||||
VERIFY_ARE_EQUAL(altCursorBlinking, mainCursor.IsBlinkingAllowed());
|
||||
}
|
||||
|
@ -1388,8 +1385,9 @@ void ScreenBufferTests::VtScrollMarginsNewlineColor()
|
|||
|
||||
const COLORREF yellow = RGB(255, 255, 0);
|
||||
const COLORREF magenta = RGB(255, 0, 255);
|
||||
gci.SetDefaultForegroundColor(yellow);
|
||||
gci.SetDefaultBackgroundColor(magenta);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, yellow);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, magenta);
|
||||
gci.CalculateDefaultColorIndices();
|
||||
const TextAttribute defaultAttrs = {};
|
||||
si.SetAttributes(defaultAttrs);
|
||||
|
||||
|
@ -1741,7 +1739,6 @@ void ScreenBufferTests::ResizeCursorUnchanged()
|
|||
// Get initial cursor values
|
||||
const CursorType initialType = initialCursor.GetType();
|
||||
const auto initialSize = initialCursor.GetSize();
|
||||
const COLORREF initialColor = initialCursor.GetColor();
|
||||
|
||||
// set our wrap mode accordingly - ResizeScreenBuffer will be smart enough
|
||||
// to call the appropriate implementation
|
||||
|
@ -1756,10 +1753,8 @@ void ScreenBufferTests::ResizeCursorUnchanged()
|
|||
const auto& finalCursor = si.GetTextBuffer().GetCursor();
|
||||
const CursorType finalType = finalCursor.GetType();
|
||||
const auto finalSize = finalCursor.GetSize();
|
||||
const COLORREF finalColor = finalCursor.GetColor();
|
||||
|
||||
VERIFY_ARE_EQUAL(initialType, finalType);
|
||||
VERIFY_ARE_EQUAL(initialColor, finalColor);
|
||||
VERIFY_ARE_EQUAL(initialSize, finalSize);
|
||||
}
|
||||
|
||||
|
@ -2122,7 +2117,6 @@ void ScreenBufferTests::TestAltBufferCursorState()
|
|||
// Validate that the cursor state was copied appropriately into the
|
||||
// alternate buffer
|
||||
VERIFY_ARE_EQUAL(mainCursor.GetSize(), altCursor.GetSize());
|
||||
VERIFY_ARE_EQUAL(mainCursor.GetColor(), altCursor.GetColor());
|
||||
VERIFY_ARE_EQUAL(mainCursor.GetType(), altCursor.GetType());
|
||||
}
|
||||
}
|
||||
|
@ -2259,8 +2253,9 @@ void ScreenBufferTests::SetDefaultsIndividuallyBothDefault()
|
|||
COLORREF brightGreen = gci.GetColorTableEntry(TextColor::BRIGHT_GREEN);
|
||||
COLORREF darkBlue = gci.GetColorTableEntry(TextColor::DARK_BLUE);
|
||||
|
||||
gci.SetDefaultForegroundColor(yellow);
|
||||
gci.SetDefaultBackgroundColor(magenta);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, yellow);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, magenta);
|
||||
gci.CalculateDefaultColorIndices();
|
||||
si.SetDefaultAttributes({}, TextAttribute{ gci.GetPopupFillAttribute() });
|
||||
|
||||
Log::Comment(NoThrowString().Format(L"Write 6 X's:"));
|
||||
|
@ -2361,8 +2356,9 @@ void ScreenBufferTests::SetDefaultsTogether()
|
|||
COLORREF yellow = RGB(255, 255, 0);
|
||||
COLORREF color250 = gci.GetColorTableEntry(250);
|
||||
|
||||
gci.SetDefaultForegroundColor(yellow);
|
||||
gci.SetDefaultBackgroundColor(magenta);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, yellow);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, magenta);
|
||||
gci.CalculateDefaultColorIndices();
|
||||
si.SetDefaultAttributes({}, TextAttribute{ gci.GetPopupFillAttribute() });
|
||||
|
||||
Log::Comment(NoThrowString().Format(L"Write 6 X's:"));
|
||||
|
@ -2432,8 +2428,9 @@ void ScreenBufferTests::ReverseResetWithDefaultBackground()
|
|||
|
||||
COLORREF magenta = RGB(255, 0, 255);
|
||||
|
||||
gci.SetDefaultForegroundColor(INVALID_COLOR);
|
||||
gci.SetDefaultBackgroundColor(magenta);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, INVALID_COLOR);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, magenta);
|
||||
gci.CalculateDefaultColorIndices();
|
||||
si.SetDefaultAttributes({}, TextAttribute{ gci.GetPopupFillAttribute() });
|
||||
|
||||
Log::Comment(NoThrowString().Format(L"Write 3 X's:"));
|
||||
|
@ -2501,7 +2498,8 @@ void ScreenBufferTests::BackspaceDefaultAttrs()
|
|||
|
||||
COLORREF magenta = RGB(255, 0, 255);
|
||||
|
||||
gci.SetDefaultBackgroundColor(magenta);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, magenta);
|
||||
gci.CalculateDefaultColorIndices();
|
||||
si.SetDefaultAttributes({}, TextAttribute{ gci.GetPopupFillAttribute() });
|
||||
|
||||
Log::Comment(NoThrowString().Format(L"Write 2 X's, then backspace one."));
|
||||
|
@ -2564,7 +2562,8 @@ void ScreenBufferTests::BackspaceDefaultAttrsWriteCharsLegacy()
|
|||
|
||||
COLORREF magenta = RGB(255, 0, 255);
|
||||
|
||||
gci.SetDefaultBackgroundColor(magenta);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, magenta);
|
||||
gci.CalculateDefaultColorIndices();
|
||||
si.SetDefaultAttributes({}, TextAttribute{ gci.GetPopupFillAttribute() });
|
||||
|
||||
Log::Comment(NoThrowString().Format(L"Write 2 X's, then backspace one."));
|
||||
|
@ -2632,7 +2631,8 @@ void ScreenBufferTests::BackspaceDefaultAttrsInPrompt()
|
|||
|
||||
COLORREF magenta = RGB(255, 0, 255);
|
||||
|
||||
gci.SetDefaultBackgroundColor(magenta);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, magenta);
|
||||
gci.CalculateDefaultColorIndices();
|
||||
si.SetDefaultAttributes({}, TextAttribute{ gci.GetPopupFillAttribute() });
|
||||
TextAttribute expectedDefaults{};
|
||||
|
||||
|
@ -2889,15 +2889,15 @@ void ScreenBufferTests::SetDefaultForegroundColor()
|
|||
|
||||
StateMachine& stateMachine = mainBuffer.GetStateMachine();
|
||||
|
||||
COLORREF originalColor = gci.GetDefaultForegroundColor();
|
||||
COLORREF newColor = gci.GetDefaultForegroundColor();
|
||||
COLORREF originalColor = gci.GetColorTableEntry(TextColor::DEFAULT_FOREGROUND);
|
||||
COLORREF newColor = gci.GetColorTableEntry(TextColor::DEFAULT_FOREGROUND);
|
||||
COLORREF testColor = RGB(0x33, 0x66, 0x99);
|
||||
VERIFY_ARE_NOT_EQUAL(originalColor, testColor);
|
||||
|
||||
Log::Comment(L"Valid Hexadecimal Notation");
|
||||
stateMachine.ProcessString(L"\x1b]10;rgb:33/66/99\x1b\\");
|
||||
|
||||
newColor = gci.GetDefaultForegroundColor();
|
||||
newColor = gci.GetColorTableEntry(TextColor::DEFAULT_FOREGROUND);
|
||||
VERIFY_ARE_EQUAL(testColor, newColor);
|
||||
|
||||
Log::Comment(L"Valid Hexadecimal Notation");
|
||||
|
@ -2905,7 +2905,7 @@ void ScreenBufferTests::SetDefaultForegroundColor()
|
|||
testColor = RGB(0xff, 0xff, 0xff);
|
||||
stateMachine.ProcessString(L"\x1b]10;rgb:ff/ff/ff\x1b\\");
|
||||
|
||||
newColor = gci.GetDefaultForegroundColor();
|
||||
newColor = gci.GetColorTableEntry(TextColor::DEFAULT_FOREGROUND);
|
||||
VERIFY_ARE_EQUAL(testColor, newColor);
|
||||
|
||||
Log::Comment(L"Invalid syntax");
|
||||
|
@ -2913,7 +2913,7 @@ void ScreenBufferTests::SetDefaultForegroundColor()
|
|||
testColor = RGB(153, 102, 51);
|
||||
stateMachine.ProcessString(L"\x1b]10;99/66/33\x1b\\");
|
||||
|
||||
newColor = gci.GetDefaultForegroundColor();
|
||||
newColor = gci.GetColorTableEntry(TextColor::DEFAULT_FOREGROUND);
|
||||
VERIFY_ARE_NOT_EQUAL(testColor, newColor);
|
||||
// it will, in fact leave the color the way it was
|
||||
VERIFY_ARE_EQUAL(originalColor, newColor);
|
||||
|
@ -2934,15 +2934,15 @@ void ScreenBufferTests::SetDefaultBackgroundColor()
|
|||
|
||||
StateMachine& stateMachine = mainBuffer.GetStateMachine();
|
||||
|
||||
COLORREF originalColor = gci.GetDefaultBackgroundColor();
|
||||
COLORREF newColor = gci.GetDefaultBackgroundColor();
|
||||
COLORREF originalColor = gci.GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
COLORREF newColor = gci.GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
COLORREF testColor = RGB(0x33, 0x66, 0x99);
|
||||
VERIFY_ARE_NOT_EQUAL(originalColor, testColor);
|
||||
|
||||
Log::Comment(L"Valid Hexadecimal Notation");
|
||||
stateMachine.ProcessString(L"\x1b]11;rgb:33/66/99\x1b\\");
|
||||
|
||||
newColor = gci.GetDefaultBackgroundColor();
|
||||
newColor = gci.GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
VERIFY_ARE_EQUAL(testColor, newColor);
|
||||
|
||||
Log::Comment(L"Valid Hexadecimal Notation");
|
||||
|
@ -2950,7 +2950,7 @@ void ScreenBufferTests::SetDefaultBackgroundColor()
|
|||
testColor = RGB(0xff, 0xff, 0xff);
|
||||
stateMachine.ProcessString(L"\x1b]11;rgb:ff/ff/ff\x1b\\");
|
||||
|
||||
newColor = gci.GetDefaultBackgroundColor();
|
||||
newColor = gci.GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
VERIFY_ARE_EQUAL(testColor, newColor);
|
||||
|
||||
Log::Comment(L"Invalid Syntax");
|
||||
|
@ -2958,7 +2958,7 @@ void ScreenBufferTests::SetDefaultBackgroundColor()
|
|||
testColor = RGB(153, 102, 51);
|
||||
stateMachine.ProcessString(L"\x1b]11;99/66/33\x1b\\");
|
||||
|
||||
newColor = gci.GetDefaultBackgroundColor();
|
||||
newColor = gci.GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
VERIFY_ARE_NOT_EQUAL(testColor, newColor);
|
||||
// it will, in fact leave the color the way it was
|
||||
VERIFY_ARE_EQUAL(originalColor, newColor);
|
||||
|
@ -5978,7 +5978,7 @@ void ScreenBufferTests::TestAddHyperlink()
|
|||
auto& stateMachine = si.GetStateMachine();
|
||||
|
||||
// Process the opening osc 8 sequence with no custom id
|
||||
stateMachine.ProcessString(L"\x1b]8;;test.url\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]8;;test.url\x1b\\");
|
||||
VERIFY_IS_TRUE(tbi.GetCurrentAttributes().IsHyperlink());
|
||||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkUriFromId(tbi.GetCurrentAttributes().GetHyperlinkId()), L"test.url");
|
||||
|
||||
|
@ -5988,7 +5988,7 @@ void ScreenBufferTests::TestAddHyperlink()
|
|||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkUriFromId(tbi.GetCurrentAttributes().GetHyperlinkId()), L"test.url");
|
||||
|
||||
// Process the closing osc 8 sequences
|
||||
stateMachine.ProcessString(L"\x1b]8;;\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]8;;\x1b\\");
|
||||
VERIFY_IS_FALSE(tbi.GetCurrentAttributes().IsHyperlink());
|
||||
}
|
||||
|
||||
|
@ -6001,7 +6001,7 @@ void ScreenBufferTests::TestAddHyperlinkCustomId()
|
|||
auto& stateMachine = si.GetStateMachine();
|
||||
|
||||
// Process the opening osc 8 sequence with a custom id
|
||||
stateMachine.ProcessString(L"\x1b]8;id=myId;test.url\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]8;id=myId;test.url\x1b\\");
|
||||
VERIFY_IS_TRUE(tbi.GetCurrentAttributes().IsHyperlink());
|
||||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkUriFromId(tbi.GetCurrentAttributes().GetHyperlinkId()), L"test.url");
|
||||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkId(L"test.url", L"myId"), tbi.GetCurrentAttributes().GetHyperlinkId());
|
||||
|
@ -6013,7 +6013,7 @@ void ScreenBufferTests::TestAddHyperlinkCustomId()
|
|||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkId(L"test.url", L"myId"), tbi.GetCurrentAttributes().GetHyperlinkId());
|
||||
|
||||
// Process the closing osc 8 sequences
|
||||
stateMachine.ProcessString(L"\x1b]8;;\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]8;;\x1b\\");
|
||||
VERIFY_IS_FALSE(tbi.GetCurrentAttributes().IsHyperlink());
|
||||
}
|
||||
|
||||
|
@ -6026,7 +6026,7 @@ void ScreenBufferTests::TestAddHyperlinkCustomIdDifferentUri()
|
|||
auto& stateMachine = si.GetStateMachine();
|
||||
|
||||
// Process the opening osc 8 sequence with a custom id
|
||||
stateMachine.ProcessString(L"\x1b]8;id=myId;test.url\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]8;id=myId;test.url\x1b\\");
|
||||
VERIFY_IS_TRUE(tbi.GetCurrentAttributes().IsHyperlink());
|
||||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkUriFromId(tbi.GetCurrentAttributes().GetHyperlinkId()), L"test.url");
|
||||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkId(L"test.url", L"myId"), tbi.GetCurrentAttributes().GetHyperlinkId());
|
||||
|
@ -6034,7 +6034,7 @@ void ScreenBufferTests::TestAddHyperlinkCustomIdDifferentUri()
|
|||
const auto oldAttributes{ tbi.GetCurrentAttributes() };
|
||||
|
||||
// Send any other text
|
||||
stateMachine.ProcessString(L"\x1b]8;id=myId;other.url\x9c");
|
||||
stateMachine.ProcessString(L"\x1b]8;id=myId;other.url\x1b\\");
|
||||
VERIFY_IS_TRUE(tbi.GetCurrentAttributes().IsHyperlink());
|
||||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkUriFromId(tbi.GetCurrentAttributes().GetHyperlinkId()), L"other.url");
|
||||
VERIFY_ARE_EQUAL(tbi.GetHyperlinkId(L"other.url", L"myId"), tbi.GetCurrentAttributes().GetHyperlinkId());
|
||||
|
|
|
@ -37,4 +37,3 @@ enum class CursorType : unsigned int
|
|||
constexpr COLORREF INVALID_COLOR = 0xffffffff;
|
||||
|
||||
constexpr WORD COLOR_TABLE_SIZE = 16;
|
||||
constexpr WORD XTERM_COLOR_TABLE_SIZE = 256;
|
||||
|
|
|
@ -37,23 +37,3 @@ constexpr bool operator!=(const SMALL_RECT& a, const SMALL_RECT& b) noexcept
|
|||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
constexpr bool operator==(const std::wstring& wstr, const std::wstring_view& wstrView)
|
||||
{
|
||||
return (wstrView == std::wstring_view{ wstr.c_str(), wstr.size() });
|
||||
}
|
||||
|
||||
constexpr bool operator==(const std::wstring_view& wstrView, const std::wstring& wstr)
|
||||
{
|
||||
return (wstr == wstrView);
|
||||
}
|
||||
|
||||
constexpr bool operator!=(const std::wstring& wstr, const std::wstring_view& wstrView)
|
||||
{
|
||||
return !(wstr == wstrView);
|
||||
}
|
||||
|
||||
constexpr bool operator!=(const std::wstring_view& wstrView, const std::wstring& wstr)
|
||||
{
|
||||
return !(wstr == wstrView);
|
||||
}
|
||||
|
|
|
@ -3,130 +3,136 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <bitset>
|
||||
#ifdef __cpp_concepts
|
||||
#define TIL_ENUMSET_VARARG template<std::same_as<T>... Args>
|
||||
#else
|
||||
#define TIL_ENUMSET_VARARG template<typename... Args, typename = std::enable_if_t<std::conjunction_v<std::is_same<T, Args>...>>>
|
||||
#endif
|
||||
|
||||
namespace til // Terminal Implementation Library. Also: "Today I Learned"
|
||||
{
|
||||
// By design, this class hides several methods in the std::bitset class
|
||||
// so they can be called with an enum parameter instead of a size_t, so
|
||||
// we need to disable the "hides a non-virtual function" warning.
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 26434)
|
||||
|
||||
// til::enumset is a subclass of std::bitset, storing a fixed size array of
|
||||
// boolean elements, the positions in the array being identified by values
|
||||
// from a given enumerated type. By default it holds the same number of
|
||||
// bits as a size_t value.
|
||||
template<typename Type, size_t Bits = std::numeric_limits<size_t>::digits>
|
||||
class enumset : public std::bitset<Bits>
|
||||
// til::enumset stores a fixed size array of boolean elements, the positions
|
||||
// in the array being identified by values from a given enumerated type.
|
||||
// Position N corresponds to bit 1<<N in the UnderlyingType integer.
|
||||
//
|
||||
// If you only need 32 positions for your T, UnderlyingType can be set uint32_t.
|
||||
// It defaults to uintptr_t allowing you to set as many positions as a pointer has bits.
|
||||
// This class doesn't statically assert that your given position fits into UnderlyingType.
|
||||
template<typename T, typename UnderlyingType = uintptr_t>
|
||||
class enumset
|
||||
{
|
||||
using _base = std::bitset<Bits>;
|
||||
static_assert(std::is_unsigned_v<UnderlyingType>);
|
||||
|
||||
public:
|
||||
using reference = typename _base::reference;
|
||||
|
||||
enumset() = default;
|
||||
|
||||
// Method Description:
|
||||
// - Constructs a new bitset with the given list of positions set to true.
|
||||
template<typename... Args, typename = std::enable_if_t<std::conjunction_v<std::is_same<Type, Args>...>>>
|
||||
constexpr enumset(const Args... positions) noexcept :
|
||||
_base((... | (1ULL << static_cast<size_t>(positions))))
|
||||
TIL_ENUMSET_VARARG
|
||||
constexpr enumset(Args... positions) noexcept :
|
||||
_data{ to_underlying(positions...) }
|
||||
{
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Returns the value of the bit at the given position.
|
||||
constexpr bool operator[](const Type pos) const
|
||||
// - Returns the underlying bit positions as a copy.
|
||||
constexpr UnderlyingType bits() const noexcept
|
||||
{
|
||||
return _base::operator[](static_cast<size_t>(pos));
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Returns a reference to the bit at the given position.
|
||||
reference operator[](const Type pos)
|
||||
{
|
||||
return _base::operator[](static_cast<size_t>(pos));
|
||||
return _data;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Returns the value of the bit at the given position.
|
||||
// Throws std::out_of_range if it is not a valid position
|
||||
// in the bitset.
|
||||
bool test(const Type pos) const
|
||||
constexpr bool test(const T pos) const noexcept
|
||||
{
|
||||
return _base::test(static_cast<size_t>(pos));
|
||||
const auto mask = to_underlying(pos);
|
||||
return (_data & mask) != 0;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Returns true if any of the bits are set to true.
|
||||
bool any() const noexcept
|
||||
constexpr bool any() const noexcept
|
||||
{
|
||||
return _base::any();
|
||||
return _data != 0;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Returns true if any of the bits in the given positions are true.
|
||||
template<typename... Args, typename = std::enable_if_t<std::conjunction_v<std::is_same<Type, Args>...>>>
|
||||
bool any(const Args... positions) const noexcept
|
||||
TIL_ENUMSET_VARARG
|
||||
constexpr bool any(Args... positions) const noexcept
|
||||
{
|
||||
return (enumset{ positions... } & *this) != 0;
|
||||
const auto mask = to_underlying(positions...);
|
||||
return (_data & mask) != 0;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Returns true if all of the bits are set to true.
|
||||
bool all() const noexcept
|
||||
constexpr bool all() const noexcept
|
||||
{
|
||||
return _base::all();
|
||||
return _data == ~UnderlyingType{ 0 };
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Returns true if all of the bits in the given positions are true.
|
||||
template<typename... Args, typename = std::enable_if_t<std::conjunction_v<std::is_same<Type, Args>...>>>
|
||||
bool all(const Args... positions) const noexcept
|
||||
TIL_ENUMSET_VARARG
|
||||
constexpr bool all(Args... positions) const noexcept
|
||||
{
|
||||
return (enumset{ positions... } & *this) == enumset{ positions... };
|
||||
const auto mask = to_underlying(positions...);
|
||||
return (_data & mask) == mask;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sets the bit in the given position to the specified value.
|
||||
enumset& set(const Type pos, const bool val = true)
|
||||
// - Sets all of the bits in the given positions to true.
|
||||
TIL_ENUMSET_VARARG
|
||||
constexpr enumset& set(Args... positions) noexcept
|
||||
{
|
||||
_base::set(static_cast<size_t>(pos), val);
|
||||
_data |= to_underlying(positions...);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Resets the bit in the given position to false.
|
||||
enumset& reset(const Type pos)
|
||||
// - Sets the bit in the given position to the specified value.
|
||||
constexpr enumset& set(const T pos, const bool val) noexcept
|
||||
{
|
||||
_base::reset(static_cast<size_t>(pos));
|
||||
const auto mask = to_underlying(pos);
|
||||
// false == 0 --> UnderlyingType(-0) == 0b0000...
|
||||
// true == 1 --> UnderlyingType(-1) == 0b1111...
|
||||
#pragma warning(suppress : 4804) // '-': unsafe use of type 'bool' in operation
|
||||
_data = (_data & ~mask) | (-val & mask);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Resets all of the bits in the given positions to false.
|
||||
TIL_ENUMSET_VARARG
|
||||
constexpr enumset& reset(Args... positions) noexcept
|
||||
{
|
||||
_data &= ~to_underlying(positions...);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Flips the bit at the given position.
|
||||
enumset& flip(const Type pos)
|
||||
TIL_ENUMSET_VARARG
|
||||
constexpr enumset& flip(Args... positions) noexcept
|
||||
{
|
||||
_base::flip(static_cast<size_t>(pos));
|
||||
_data ^= to_underlying(positions...);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sets all of the bits in the given positions to true.
|
||||
private:
|
||||
template<typename... Args>
|
||||
enumset& set_all(const Args... positions)
|
||||
static constexpr UnderlyingType to_underlying(Args... positions) noexcept
|
||||
{
|
||||
return (..., set(positions));
|
||||
return ((UnderlyingType{ 1 } << static_cast<UnderlyingType>(positions)) | ...);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Resets all of the bits in the given positions to false.
|
||||
template<typename... Args>
|
||||
enumset& reset_all(const Args... positions)
|
||||
template<>
|
||||
static constexpr UnderlyingType to_underlying() noexcept
|
||||
{
|
||||
return (..., reset(positions));
|
||||
return 0;
|
||||
}
|
||||
|
||||
UnderlyingType _data{};
|
||||
};
|
||||
#pragma warning(pop)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#pragma once
|
||||
|
@ -34,10 +34,7 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
|
|||
template<typename T, typename Traits>
|
||||
constexpr bool starts_with(const std::basic_string_view<T, Traits>& str, const std::basic_string_view<T, Traits>& prefix) noexcept
|
||||
{
|
||||
#ifdef __cpp_lib_starts_ends_with
|
||||
#error This code can be replaced in C++20, which natively supports .starts_with().
|
||||
#endif
|
||||
return str.size() >= prefix.size() && Traits::compare(str.data(), prefix.data(), prefix.size()) == 0;
|
||||
return str.size() >= prefix.size() && __builtin_memcmp(str.data(), prefix.data(), prefix.size() * sizeof(T)) == 0;
|
||||
}
|
||||
|
||||
constexpr bool starts_with(const std::string_view& str, const std::string_view& prefix) noexcept
|
||||
|
@ -52,15 +49,10 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
|
|||
|
||||
// std::string_view::ends_with support for C++17.
|
||||
template<typename T, typename Traits>
|
||||
constexpr bool ends_with(const std::basic_string_view<T, Traits>& str, const std::basic_string_view<T, Traits>& prefix) noexcept
|
||||
constexpr bool ends_with(const std::basic_string_view<T, Traits>& str, const std::basic_string_view<T, Traits>& suffix) noexcept
|
||||
{
|
||||
#ifdef __cpp_lib_ends_ends_with
|
||||
#error This code can be replaced in C++20, which natively supports .ends_with().
|
||||
#endif
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 26481) // Don't use pointer arithmetic. Use span instead (bounds.1).
|
||||
return str.size() >= prefix.size() && Traits::compare(str.data() + (str.size() - prefix.size()), prefix.data(), prefix.size()) == 0;
|
||||
#pragma warning(pop)
|
||||
#pragma warning(suppress : 26481) // Don't use pointer arithmetic. Use span instead (bounds.1).
|
||||
return str.size() >= suffix.size() && __builtin_memcmp(str.data() + (str.size() - suffix.size()), suffix.data(), suffix.size() * sizeof(T)) == 0;
|
||||
}
|
||||
|
||||
constexpr bool ends_with(const std::string_view& str, const std::string_view& prefix) noexcept
|
||||
|
@ -168,6 +160,20 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
|
|||
return c;
|
||||
}
|
||||
|
||||
// Just like std::wstring_view::operator==().
|
||||
//
|
||||
// At the time of writing wmemcmp() is not an intrinsic for MSVC,
|
||||
// but the STL uses it to implement wide string comparisons.
|
||||
// This produces 3x the assembly _per_ comparison and increases
|
||||
// runtime by 2-3x for strings of medium length (16 characters)
|
||||
// and 5x or more for long strings (128 characters or more).
|
||||
// See: https://github.com/microsoft/STL/issues/2289
|
||||
template<typename T, typename Traits>
|
||||
bool equals(const std::basic_string_view<T, Traits>& str1, const std::basic_string_view<T, Traits>& str2) noexcept
|
||||
{
|
||||
return lhs.size() == rhs.size() && __builtin_memcmp(lhs.data(), rhs.data(), lhs.size() * sizeof(T)) == 0;
|
||||
}
|
||||
|
||||
// Just like _memicmp, but without annoying locales.
|
||||
template<typename T, typename Traits>
|
||||
bool equals_insensitive_ascii(const std::basic_string_view<T, Traits>& str1, const std::basic_string_view<T, Traits>& str2) noexcept
|
||||
|
@ -205,6 +211,39 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
|
|||
return equals_insensitive_ascii<>(str1, str2);
|
||||
}
|
||||
|
||||
template<typename T, typename Traits>
|
||||
constexpr bool starts_with_insensitive_ascii(const std::basic_string_view<T, Traits>& str, const std::basic_string_view<T, Traits>& prefix) noexcept
|
||||
{
|
||||
return str.size() >= prefix.size() && equals_insensitive_ascii<>({ str.data(), prefix.size() }, prefix);
|
||||
}
|
||||
|
||||
constexpr bool starts_with_insensitive_ascii(const std::string_view& str, const std::string_view& prefix) noexcept
|
||||
{
|
||||
return starts_with_insensitive_ascii<>(str, prefix);
|
||||
}
|
||||
|
||||
constexpr bool starts_with_insensitive_ascii(const std::wstring_view& str, const std::wstring_view& prefix) noexcept
|
||||
{
|
||||
return starts_with_insensitive_ascii<>(str, prefix);
|
||||
}
|
||||
|
||||
template<typename T, typename Traits>
|
||||
constexpr bool ends_with_insensitive_ascii(const std::basic_string_view<T, Traits>& str, const std::basic_string_view<T, Traits>& suffix) noexcept
|
||||
{
|
||||
#pragma warning(suppress : 26481) // Don't use pointer arithmetic. Use span instead (bounds.1).
|
||||
return str.size() >= suffix.size() && equals_insensitive_ascii<>({ str.data() - suffix.size(), suffix.size() }, suffix);
|
||||
}
|
||||
|
||||
constexpr bool ends_with_insensitive_ascii(const std::string_view& str, const std::string_view& prefix) noexcept
|
||||
{
|
||||
return ends_with_insensitive_ascii<>(str, prefix);
|
||||
}
|
||||
|
||||
constexpr bool ends_with_insensitive_ascii(const std::wstring_view& str, const std::wstring_view& prefix) noexcept
|
||||
{
|
||||
return ends_with<>(str, prefix);
|
||||
}
|
||||
|
||||
// Give the arguments ("foo bar baz", " "), this method will
|
||||
// * modify the first argument to "bar baz"
|
||||
// * return "foo"
|
||||
|
|
|
@ -208,10 +208,8 @@ void Clipboard::StoreSelectionToClipboard(bool const copyFormatting)
|
|||
const auto& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
const auto& buffer = gci.GetActiveOutputBuffer().GetTextBuffer();
|
||||
|
||||
const auto defaultForeground = gci.GetDefaultForeground();
|
||||
const auto defaultBackground = gci.GetDefaultBackground();
|
||||
const auto GetAttributeColors = [=, &gci](const auto& attr) {
|
||||
return gci.LookupAttributeColors(attr, defaultForeground, defaultBackground);
|
||||
return gci.LookupAttributeColors(attr);
|
||||
};
|
||||
|
||||
bool includeCRLF, trimTrailingWhitespace;
|
||||
|
@ -276,9 +274,10 @@ void Clipboard::CopyTextToSystemClipboard(const TextBuffer::TextAndColor& rows,
|
|||
|
||||
if (fAlsoCopyFormatting)
|
||||
{
|
||||
const auto& fontData = ServiceLocator::LocateGlobals().getConsoleInformation().GetActiveOutputBuffer().GetCurrentFont();
|
||||
const auto& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
const auto& fontData = gci.GetActiveOutputBuffer().GetCurrentFont();
|
||||
int const iFontHeightPoints = fontData.GetUnscaledSize().Y * 72 / ServiceLocator::LocateGlobals().dpi;
|
||||
const COLORREF bgColor = ServiceLocator::LocateGlobals().getConsoleInformation().GetDefaultBackground();
|
||||
const COLORREF bgColor = gci.GetColorTableEntry(gci.GetDefaultBackgroundIndex());
|
||||
|
||||
std::string HTMLToPlaceOnClip = TextBuffer::GenHTML(rows, iFontHeightPoints, fontData.GetFaceName(), bgColor);
|
||||
CopyToSystemClipboard(HTMLToPlaceOnClip, L"HTML Format");
|
||||
|
|
|
@ -315,7 +315,7 @@ void Menu::s_ShowPropertiesDialog(HWND const hwnd, BOOL const Defaults)
|
|||
|
||||
const Cursor& cursor = ScreenInfo.GetTextBuffer().GetCursor();
|
||||
pStateInfo->CursorSize = cursor.GetSize();
|
||||
pStateInfo->CursorColor = cursor.GetColor();
|
||||
pStateInfo->CursorColor = gci.GetColorTableEntry(TextColor::CURSOR_COLOR);
|
||||
pStateInfo->CursorType = static_cast<unsigned int>(cursor.GetType());
|
||||
|
||||
// Retrieve small icon for use in displaying the dialog
|
||||
|
@ -376,8 +376,8 @@ void Menu::s_ShowPropertiesDialog(HWND const hwnd, BOOL const Defaults)
|
|||
pStateInfo->InterceptCopyPaste = gci.GetInterceptCopyPaste();
|
||||
|
||||
// Get the properties from the settings
|
||||
pStateInfo->DefaultForeground = gci.GetDefaultForegroundColor();
|
||||
pStateInfo->DefaultBackground = gci.GetDefaultBackgroundColor();
|
||||
pStateInfo->DefaultForeground = gci.GetColorTableEntry(TextColor::DEFAULT_FOREGROUND);
|
||||
pStateInfo->DefaultBackground = gci.GetColorTableEntry(TextColor::DEFAULT_BACKGROUND);
|
||||
|
||||
pStateInfo->TerminalScrolling = gci.IsTerminalScrolling();
|
||||
// end console v2 properties
|
||||
|
@ -461,13 +461,12 @@ void Menu::s_PropertiesUpdate(PCONSOLE_STATE_INFO pStateInfo)
|
|||
|
||||
// Set the cursor properties in the Settings
|
||||
const auto cursorType = static_cast<CursorType>(pStateInfo->CursorType);
|
||||
gci.SetCursorColor(pStateInfo->CursorColor);
|
||||
gci.SetCursorType(cursorType);
|
||||
gci.SetColorTableEntry(TextColor::CURSOR_COLOR, pStateInfo->CursorColor);
|
||||
|
||||
// Then also apply them to the buffer's cursor
|
||||
ScreenInfo.SetCursorInformation(pStateInfo->CursorSize,
|
||||
ScreenInfo.GetTextBuffer().GetCursor().IsVisible());
|
||||
ScreenInfo.SetCursorColor(pStateInfo->CursorColor, true);
|
||||
ScreenInfo.SetCursorType(cursorType, true);
|
||||
|
||||
gci.SetTerminalScrolling(pStateInfo->TerminalScrolling);
|
||||
|
@ -579,11 +578,13 @@ void Menu::s_PropertiesUpdate(PCONSOLE_STATE_INFO pStateInfo)
|
|||
gci.SetFillAttribute(pStateInfo->ScreenAttributes);
|
||||
gci.SetPopupFillAttribute(pStateInfo->PopupAttributes);
|
||||
// Store our updated Default Color values
|
||||
gci.SetDefaultForegroundColor(pStateInfo->DefaultForeground);
|
||||
gci.SetDefaultBackgroundColor(pStateInfo->DefaultBackground);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, pStateInfo->DefaultForeground);
|
||||
gci.SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, pStateInfo->DefaultBackground);
|
||||
|
||||
// Make sure the updated fill attributes are passed on to the TextAttribute class.
|
||||
TextAttribute::SetLegacyDefaultAttributes(pStateInfo->ScreenAttributes);
|
||||
// And recalculate the position of the default colors in the color table.
|
||||
gci.CalculateDefaultColorIndices();
|
||||
|
||||
// Set the screen info's default text attributes to defaults -
|
||||
ScreenInfo.SetDefaultAttributes({}, TextAttribute{ gci.GetPopupFillAttribute() });
|
||||
|
|
|
@ -574,6 +574,10 @@ using namespace Microsoft::Console::Types;
|
|||
{
|
||||
Menu::s_ShowPropertiesDialog(hWnd, TRUE);
|
||||
}
|
||||
else if (wParam == SC_RESTORE && _fIsInFullscreen)
|
||||
{
|
||||
SetIsFullscreen(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
goto CallDefWin;
|
||||
|
|
|
@ -78,8 +78,10 @@
|
|||
<AdditionalIncludeDirectories>$(IntermediateOutputPath);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<!-- If you don't include a '.' at the end of the $(IntermediateOutputPath),
|
||||
mc.exe will get confused by the trailing slash. -->
|
||||
<Target Name="MessageCompile" Inputs="@(MessageCompile)" Outputs="$(IntermediateOutputPath)\%(MessageCompile.Filename).h" BeforeTargets="ClCompile">
|
||||
<Exec Command="mc.exe /h $(IntermediateOutputPath) /r $(IntermediateOutputPath) @(MessageCompile)" />
|
||||
<Exec Command="mc.exe /h "$(IntermediateOutputPath)." /r "$(IntermediateOutputPath)." @(MessageCompile)" />
|
||||
</Target>
|
||||
<!-- Careful reordering these. Some default props (contained in these files) are order sensitive. -->
|
||||
<Import Project="..\common.build.post.props" />
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma hdrstop
|
||||
|
||||
#define SET_FIELD_AND_SIZE(x) FIELD_OFFSET(Settings, x), RTL_FIELD_SIZE(Settings, x)
|
||||
#define SET_FIELD_AND_SIZE(x) UFIELD_OFFSET(Settings, x), RTL_FIELD_SIZE(Settings, x)
|
||||
|
||||
#define NT_TESTNULL(var) (((var) == nullptr) ? STATUS_NO_MEMORY : STATUS_SUCCESS)
|
||||
|
||||
|
@ -57,14 +57,14 @@ const RegistrySerialization::_RegPropertyMap RegistrySerialization::s_PropertyMa
|
|||
{ _RegPropertyType::Boolean, CONSOLE_REGISTRY_TRIMZEROHEADINGS, SET_FIELD_AND_SIZE(_fTrimLeadingZeros) },
|
||||
{ _RegPropertyType::Boolean, CONSOLE_REGISTRY_ENABLE_COLOR_SELECTION, SET_FIELD_AND_SIZE(_fEnableColorSelection) },
|
||||
{ _RegPropertyType::Coordinate, CONSOLE_REGISTRY_WINDOWPOS, SET_FIELD_AND_SIZE(_dwWindowOrigin) },
|
||||
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_CURSORCOLOR, SET_FIELD_AND_SIZE(_CursorColor) },
|
||||
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_CURSORTYPE, SET_FIELD_AND_SIZE(_CursorType) },
|
||||
{ _RegPropertyType::Boolean, CONSOLE_REGISTRY_INTERCEPTCOPYPASTE, SET_FIELD_AND_SIZE(_fInterceptCopyPaste) },
|
||||
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_DEFAULTFOREGROUND, SET_FIELD_AND_SIZE(_DefaultForeground) },
|
||||
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_DEFAULTBACKGROUND, SET_FIELD_AND_SIZE(_DefaultBackground) },
|
||||
{ _RegPropertyType::Boolean, CONSOLE_REGISTRY_TERMINALSCROLLING, SET_FIELD_AND_SIZE(_TerminalScrolling) },
|
||||
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_USEDX, SET_FIELD_AND_SIZE(_fUseDx) },
|
||||
{ _RegPropertyType::Boolean, CONSOLE_REGISTRY_COPYCOLOR, SET_FIELD_AND_SIZE(_fCopyColor) }
|
||||
{ _RegPropertyType::Boolean, CONSOLE_REGISTRY_COPYCOLOR, SET_FIELD_AND_SIZE(_fCopyColor) },
|
||||
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_DEFAULTFOREGROUND, SET_FIELD_AND_SIZE(_colorTable[TextColor::DEFAULT_FOREGROUND]) },
|
||||
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_DEFAULTBACKGROUND, SET_FIELD_AND_SIZE(_colorTable[TextColor::DEFAULT_BACKGROUND]) },
|
||||
{ _RegPropertyType::Dword, CONSOLE_REGISTRY_CURSORCOLOR, SET_FIELD_AND_SIZE(_colorTable[TextColor::CURSOR_COLOR]) }
|
||||
|
||||
};
|
||||
const size_t RegistrySerialization::s_PropertyMappingsSize = ARRAYSIZE(s_PropertyMappings);
|
||||
|
|
|
@ -96,6 +96,11 @@ bool DxFontInfo::GetFallback() const noexcept
|
|||
return _didFallback;
|
||||
}
|
||||
|
||||
IDWriteFontCollection* DxFontInfo::GetNearbyCollection() const noexcept
|
||||
{
|
||||
return _nearbyCollection.Get();
|
||||
}
|
||||
|
||||
void DxFontInfo::SetFromEngine(const std::wstring_view familyName,
|
||||
const DWRITE_FONT_WEIGHT weight,
|
||||
const DWRITE_FONT_STYLE style,
|
||||
|
@ -223,13 +228,11 @@ void DxFontInfo::SetFromEngine(const std::wstring_view familyName,
|
|||
// If the system collection missed, try the files sitting next to our binary.
|
||||
if (withNearbyLookup && !familyExists)
|
||||
{
|
||||
auto&& nearbyCollection = _NearbyCollection(dwriteFactory);
|
||||
|
||||
// May be null on OS below Windows 10. If null, just skip the attempt.
|
||||
if (nearbyCollection)
|
||||
if (const auto nearbyCollection = _NearbyCollection(dwriteFactory))
|
||||
{
|
||||
nearbyCollection.As(&fontCollection);
|
||||
THROW_IF_FAILED(fontCollection->FindFamilyName(_familyName.data(), &familyIndex, &familyExists));
|
||||
THROW_IF_FAILED(nearbyCollection->FindFamilyName(_familyName.data(), &familyIndex, &familyExists));
|
||||
fontCollection = nearbyCollection;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -332,42 +335,48 @@ void DxFontInfo::SetFromEngine(const std::wstring_view familyName,
|
|||
// - dwriteFactory - The DWrite factory to use
|
||||
// Return Value:
|
||||
// - DirectWrite font collection. May be null if one cannot be created.
|
||||
[[nodiscard]] const Microsoft::WRL::ComPtr<IDWriteFontCollection1>& DxFontInfo::_NearbyCollection(gsl::not_null<IDWriteFactory1*> dwriteFactory) const
|
||||
[[nodiscard]] IDWriteFontCollection* DxFontInfo::_NearbyCollection(gsl::not_null<IDWriteFactory1*> dwriteFactory)
|
||||
{
|
||||
// Magic static so we only attempt to grovel the hard disk once no matter how many instances
|
||||
// of the font collection itself we require.
|
||||
static const auto knownPaths = s_GetNearbyFonts();
|
||||
if (_nearbyCollection)
|
||||
{
|
||||
return _nearbyCollection.Get();
|
||||
}
|
||||
|
||||
// The convenience interfaces for loading fonts from files
|
||||
// are only available on Windows 10+.
|
||||
// Don't try to look up if below that OS version.
|
||||
static const bool s_isWindows10OrGreater = IsWindows10OrGreater();
|
||||
|
||||
if (s_isWindows10OrGreater && !_nearbyCollection)
|
||||
::Microsoft::WRL::ComPtr<IDWriteFactory6> factory6;
|
||||
if (FAILED(dwriteFactory->QueryInterface<IDWriteFactory6>(&factory6)))
|
||||
{
|
||||
// Factory3 has a convenience to get us a font set builder.
|
||||
::Microsoft::WRL::ComPtr<IDWriteFactory3> factory3;
|
||||
THROW_IF_FAILED(dwriteFactory->QueryInterface<IDWriteFactory3>(&factory3));
|
||||
|
||||
::Microsoft::WRL::ComPtr<IDWriteFontSetBuilder> fontSetBuilder;
|
||||
THROW_IF_FAILED(factory3->CreateFontSetBuilder(&fontSetBuilder));
|
||||
|
||||
// Builder2 has a convenience to just feed in paths to font files.
|
||||
::Microsoft::WRL::ComPtr<IDWriteFontSetBuilder2> fontSetBuilder2;
|
||||
THROW_IF_FAILED(fontSetBuilder.As(&fontSetBuilder2));
|
||||
|
||||
for (auto& p : knownPaths)
|
||||
{
|
||||
fontSetBuilder2->AddFontFile(p.c_str());
|
||||
}
|
||||
|
||||
::Microsoft::WRL::ComPtr<IDWriteFontSet> fontSet;
|
||||
THROW_IF_FAILED(fontSetBuilder2->CreateFontSet(&fontSet));
|
||||
|
||||
THROW_IF_FAILED(factory3->CreateFontCollectionFromFontSet(fontSet.Get(), &_nearbyCollection));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return _nearbyCollection;
|
||||
::Microsoft::WRL::ComPtr<IDWriteFontCollection1> systemFontCollection;
|
||||
THROW_IF_FAILED(factory6->GetSystemFontCollection(false, &systemFontCollection, 0));
|
||||
|
||||
::Microsoft::WRL::ComPtr<IDWriteFontSet> systemFontSet;
|
||||
THROW_IF_FAILED(systemFontCollection->GetFontSet(&systemFontSet));
|
||||
|
||||
::Microsoft::WRL::ComPtr<IDWriteFontSetBuilder2> fontSetBuilder2;
|
||||
THROW_IF_FAILED(factory6->CreateFontSetBuilder(&fontSetBuilder2));
|
||||
|
||||
THROW_IF_FAILED(fontSetBuilder2->AddFontSet(systemFontSet.Get()));
|
||||
|
||||
// Magic static so we only attempt to grovel the hard disk once no matter how many instances
|
||||
// of the font collection itself we require.
|
||||
static const auto knownPaths = s_GetNearbyFonts();
|
||||
for (auto& p : knownPaths)
|
||||
{
|
||||
fontSetBuilder2->AddFontFile(p.c_str());
|
||||
}
|
||||
|
||||
::Microsoft::WRL::ComPtr<IDWriteFontSet> fontSet;
|
||||
THROW_IF_FAILED(fontSetBuilder2->CreateFontSet(&fontSet));
|
||||
|
||||
::Microsoft::WRL::ComPtr<IDWriteFontCollection1> fontCollection;
|
||||
THROW_IF_FAILED(factory6->CreateFontCollectionFromFontSet(fontSet.Get(), &fontCollection));
|
||||
|
||||
_nearbyCollection = fontCollection;
|
||||
return _nearbyCollection.Get();
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
|
@ -386,18 +395,11 @@ void DxFontInfo::SetFromEngine(const std::wstring_view familyName,
|
|||
const std::filesystem::path module{ wil::GetModuleFileNameW<std::wstring>(nullptr) };
|
||||
const auto folder{ module.parent_path() };
|
||||
|
||||
for (auto& p : std::filesystem::directory_iterator(folder))
|
||||
for (const auto& p : std::filesystem::directory_iterator(folder))
|
||||
{
|
||||
if (p.is_regular_file())
|
||||
if (til::ends_with(p.path().native(), L".ttf"))
|
||||
{
|
||||
auto extension = p.path().extension().wstring();
|
||||
std::transform(extension.begin(), extension.end(), extension.begin(), std::towlower);
|
||||
|
||||
static constexpr std::wstring_view ttfExtension{ L".ttf" };
|
||||
if (ttfExtension == extension)
|
||||
{
|
||||
paths.push_back(p);
|
||||
}
|
||||
paths.push_back(p.path());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ namespace Microsoft::Console::Render
|
|||
|
||||
bool GetFallback() const noexcept;
|
||||
|
||||
IDWriteFontCollection* GetNearbyCollection() const noexcept;
|
||||
|
||||
void SetFromEngine(const std::wstring_view familyName,
|
||||
const DWRITE_FONT_WEIGHT weight,
|
||||
const DWRITE_FONT_STYLE style,
|
||||
|
@ -57,11 +59,11 @@ namespace Microsoft::Console::Render
|
|||
[[nodiscard]] std::wstring _GetFontFamilyName(gsl::not_null<IDWriteFontFamily*> const fontFamily,
|
||||
std::wstring& localeName);
|
||||
|
||||
[[nodiscard]] const Microsoft::WRL::ComPtr<IDWriteFontCollection1>& _NearbyCollection(gsl::not_null<IDWriteFactory1*> dwriteFactory) const;
|
||||
[[nodiscard]] IDWriteFontCollection* _NearbyCollection(gsl::not_null<IDWriteFactory1*> dwriteFactory);
|
||||
|
||||
[[nodiscard]] static std::vector<std::filesystem::path> s_GetNearbyFonts();
|
||||
|
||||
mutable ::Microsoft::WRL::ComPtr<IDWriteFontCollection1> _nearbyCollection;
|
||||
::Microsoft::WRL::ComPtr<IDWriteFontCollection> _nearbyCollection;
|
||||
|
||||
// The font name we should be looking for
|
||||
std::wstring _familyName;
|
||||
|
|
|
@ -894,11 +894,11 @@ void DxFontRenderData::_BuildFontRenderData(const FontInfoDesired& desired, Font
|
|||
_glyphCell = actual.GetSize();
|
||||
}
|
||||
|
||||
Microsoft::WRL::ComPtr<IDWriteTextFormat> DxFontRenderData::_BuildTextFormat(const DxFontInfo fontInfo, const std::wstring_view localeName)
|
||||
Microsoft::WRL::ComPtr<IDWriteTextFormat> DxFontRenderData::_BuildTextFormat(const DxFontInfo& fontInfo, const std::wstring_view localeName)
|
||||
{
|
||||
Microsoft::WRL::ComPtr<IDWriteTextFormat> format;
|
||||
THROW_IF_FAILED(_dwriteFactory->CreateTextFormat(fontInfo.GetFamilyName().data(),
|
||||
nullptr,
|
||||
fontInfo.GetNearbyCollection(),
|
||||
fontInfo.GetWeight(),
|
||||
fontInfo.GetStyle(),
|
||||
fontInfo.GetStretch(),
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace Microsoft::Console::Render
|
|||
float _FontStretchToWidthAxisValue(DWRITE_FONT_STRETCH fontStretch) noexcept;
|
||||
float _FontStyleToSlantFixedAxisValue(DWRITE_FONT_STYLE fontStyle) noexcept;
|
||||
void _BuildFontRenderData(const FontInfoDesired& desired, FontInfo& actual, const int dpi);
|
||||
Microsoft::WRL::ComPtr<IDWriteTextFormat> _BuildTextFormat(const DxFontInfo fontInfo, const std::wstring_view localeName);
|
||||
Microsoft::WRL::ComPtr<IDWriteTextFormat> _BuildTextFormat(const DxFontInfo& fontInfo, const std::wstring_view localeName);
|
||||
|
||||
std::unordered_map<FontAttributeMapKey, ::Microsoft::WRL::ComPtr<IDWriteTextFormat>> _textFormatMap;
|
||||
std::unordered_map<FontAttributeMapKey, ::Microsoft::WRL::ComPtr<IDWriteFontFace1>> _fontFaceMap;
|
||||
|
|
|
@ -18,21 +18,21 @@
|
|||
<ClCompile Include="..\BoxDrawingEffect.cpp" />
|
||||
<ClCompile Include="..\CustomTextLayout.cpp" />
|
||||
<ClCompile Include="..\CustomTextRenderer.cpp" />
|
||||
<ClCompile Include="..\precomp.cpp">
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\DxFontInfo.cpp" />
|
||||
<ClCompile Include="..\DxFontRenderData.cpp" />
|
||||
<ClCompile Include="..\DxRenderer.cpp" />
|
||||
<ClCompile Include="..\precomp.cpp">
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\BoxDrawingEffect.h" />
|
||||
<ClInclude Include="..\CustomTextLayout.h" />
|
||||
<ClInclude Include="..\CustomTextRenderer.h" />
|
||||
<ClInclude Include="..\precomp.h" />
|
||||
<ClInclude Include="..\DxRenderer.hpp" />
|
||||
<ClInclude Include="..\DxFontInfo.h" />
|
||||
<ClInclude Include="..\DxFontRenderData.h" />
|
||||
<ClInclude Include="..\DxRenderer.hpp" />
|
||||
<ClInclude Include="..\precomp.h" />
|
||||
<ClInclude Include="..\ScreenPixelShader.h" />
|
||||
<ClInclude Include="..\ScreenVertexShader.h" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -4,24 +4,26 @@
|
|||
<Natvis Include="$(SolutionDir)tools\ConsoleTypes.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\BoxDrawingEffect.cpp" />
|
||||
<ClCompile Include="..\CustomTextLayout.cpp" />
|
||||
<ClCompile Include="..\CustomTextRenderer.cpp" />
|
||||
<ClCompile Include="..\precomp.cpp" />
|
||||
<ClCompile Include="..\DxFontInfo.cpp" />
|
||||
<ClCompile Include="..\DxFontRenderData.cpp" />
|
||||
<ClCompile Include="..\DxRenderer.cpp" />
|
||||
<ClCompile Include="..\BoxDrawingEffect.cpp" />
|
||||
<ClCompile Include="..\precomp.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\BoxDrawingEffect.h" />
|
||||
<ClInclude Include="..\CustomTextLayout.h" />
|
||||
<ClInclude Include="..\CustomTextRenderer.h" />
|
||||
<ClInclude Include="..\precomp.h" />
|
||||
<ClInclude Include="..\DxFontRenderData.h"/>
|
||||
<ClInclude Include="..\DxFontInfo.h" />
|
||||
<ClInclude Include="..\DxFontRenderData.h" />
|
||||
<ClInclude Include="..\DxRenderer.hpp" />
|
||||
<ClInclude Include="..\precomp.h" />
|
||||
<ClInclude Include="..\ScreenPixelShader.h" />
|
||||
<ClInclude Include="..\ScreenVertexShader.h" />
|
||||
<ClInclude Include="..\BoxDrawingEffect.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Midl Include="..\IBoxDrawingEffect.idl" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -113,6 +113,7 @@ public:
|
|||
virtual bool LockingShift(const size_t gsetNumber) = 0; // LS0, LS1, LS2, LS3
|
||||
virtual bool LockingShiftRight(const size_t gsetNumber) = 0; // LS1R, LS2R, LS3R
|
||||
virtual bool SingleShift(const size_t gsetNumber) = 0; // SS2, SS3
|
||||
virtual bool AcceptC1Controls(const bool enabled) = 0; // DECAC1
|
||||
|
||||
virtual bool SoftReset() = 0; // DECSTR
|
||||
virtual bool HardReset() = 0; // RIS
|
||||
|
|
|
@ -344,6 +344,7 @@ bool AdaptDispatch::CursorSaveState()
|
|||
savedCursorState.IsOriginModeRelative = _isOriginModeRelative;
|
||||
savedCursorState.Attributes = attributes;
|
||||
savedCursorState.TermOutput = _termOutput;
|
||||
savedCursorState.C1ControlsAccepted = _pConApi->GetParserMode(StateMachine::Mode::AcceptC1);
|
||||
_pConApi->GetConsoleOutputCP(savedCursorState.CodePage);
|
||||
}
|
||||
|
||||
|
@ -386,6 +387,9 @@ bool AdaptDispatch::CursorRestoreState()
|
|||
// Restore designated character set.
|
||||
_termOutput = savedCursorState.TermOutput;
|
||||
|
||||
// Restore the parsing state of C1 control codes.
|
||||
AcceptC1Controls(savedCursorState.C1ControlsAccepted);
|
||||
|
||||
// Restore the code page if it was previously saved.
|
||||
if (savedCursorState.CodePage != 0)
|
||||
{
|
||||
|
@ -1243,7 +1247,12 @@ bool AdaptDispatch::SetAnsiMode(const bool ansiMode)
|
|||
// need to be reset to defaults, even if the mode doesn't actually change.
|
||||
_termOutput = {};
|
||||
|
||||
return _pConApi->PrivateSetAnsiMode(ansiMode);
|
||||
_pConApi->SetParserMode(StateMachine::Mode::Ansi, ansiMode);
|
||||
_pConApi->SetInputMode(TerminalInput::Mode::Ansi, ansiMode);
|
||||
|
||||
// We don't check the SetInputMode return value, because we'll never want
|
||||
// to forward a DECANM mode change over conpty.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
|
@ -1687,9 +1696,10 @@ void AdaptDispatch::_InitTabStopsForWidth(const size_t width)
|
|||
|
||||
//Routine Description:
|
||||
// DOCS - Selects the coding system through which character sets are activated.
|
||||
// When ISO2022 is selected, the code page is set to ISO-8859-1, and both
|
||||
// GL and GR areas of the code table can be remapped. When UTF8 is selected,
|
||||
// the code page is set to UTF-8, and only the GL area can be remapped.
|
||||
// When ISO2022 is selected, the code page is set to ISO-8859-1, C1 control
|
||||
// codes are accepted, and both GL and GR areas of the code table can be
|
||||
// remapped. When UTF8 is selected, the code page is set to UTF-8, the C1
|
||||
// control codes are disabled, and only the GL area can be remapped.
|
||||
//Arguments:
|
||||
// - codingSystem - The coding system that will be selected.
|
||||
// Return value:
|
||||
|
@ -1712,6 +1722,7 @@ bool AdaptDispatch::DesignateCodingSystem(const VTID codingSystem)
|
|||
success = _pConApi->SetConsoleOutputCP(28591);
|
||||
if (success)
|
||||
{
|
||||
AcceptC1Controls(true);
|
||||
_termOutput.EnableGrTranslation(true);
|
||||
}
|
||||
break;
|
||||
|
@ -1719,6 +1730,7 @@ bool AdaptDispatch::DesignateCodingSystem(const VTID codingSystem)
|
|||
success = _pConApi->SetConsoleOutputCP(CP_UTF8);
|
||||
if (success)
|
||||
{
|
||||
AcceptC1Controls(false);
|
||||
_termOutput.EnableGrTranslation(false);
|
||||
}
|
||||
break;
|
||||
|
@ -1792,6 +1804,17 @@ bool AdaptDispatch::SingleShift(const size_t gsetNumber)
|
|||
return _termOutput.SingleShift(gsetNumber);
|
||||
}
|
||||
|
||||
//Routine Description:
|
||||
// DECAC1 - Enable or disable the reception of C1 control codes in the parser.
|
||||
//Arguments:
|
||||
// - enabled - true to allow C1 controls to be used, false to disallow.
|
||||
// Return value:
|
||||
// True if handled successfully. False otherwise.
|
||||
bool AdaptDispatch::AcceptC1Controls(const bool enabled)
|
||||
{
|
||||
return _pConApi->SetParserMode(StateMachine::Mode::AcceptC1, enabled);
|
||||
}
|
||||
|
||||
//Routine Description:
|
||||
// Soft Reset - Perform a soft reset. See http://www.vt100.net/docs/vt510-rm/DECSTR.html
|
||||
// The following table lists everything that should be done, 'X's indicate the ones that
|
||||
|
@ -1840,6 +1863,8 @@ bool AdaptDispatch::SoftReset()
|
|||
// Restore initial code page if previously changed by a DOCS sequence.
|
||||
success = _pConApi->SetConsoleOutputCP(_initialCodePage.value()) && success;
|
||||
}
|
||||
// Disable parsing of C1 control codes.
|
||||
success = AcceptC1Controls(false) && success;
|
||||
|
||||
success = SetGraphicsRendition({}) && success; // Normal rendition.
|
||||
|
||||
|
@ -2225,7 +2250,7 @@ bool AdaptDispatch::SetCursorColor(const COLORREF cursorColor)
|
|||
return false;
|
||||
}
|
||||
|
||||
return _pConApi->SetCursorColor(cursorColor);
|
||||
return _pConApi->SetColorTableEntry(TextColor::CURSOR_COLOR, cursorColor);
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
|
@ -2248,7 +2273,7 @@ bool AdaptDispatch::SetClipboard(const std::wstring_view /*content*/) noexcept
|
|||
// True if handled successfully. False otherwise.
|
||||
bool AdaptDispatch::SetColorTableEntry(const size_t tableIndex, const DWORD dwColor)
|
||||
{
|
||||
const bool success = _pConApi->PrivateSetColorTableEntry(tableIndex, dwColor);
|
||||
const bool success = _pConApi->SetColorTableEntry(tableIndex, dwColor);
|
||||
|
||||
// If we're a conpty, always return false, so that we send the updated color
|
||||
// value to the terminal. Still handle the sequence so apps that use
|
||||
|
@ -2268,10 +2293,10 @@ bool AdaptDispatch::SetColorTableEntry(const size_t tableIndex, const DWORD dwCo
|
|||
// - dwColor: The new RGB color value to use, as a COLORREF, format 0x00BBGGRR.
|
||||
// Return Value:
|
||||
// True if handled successfully. False otherwise.
|
||||
bool Microsoft::Console::VirtualTerminal::AdaptDispatch::SetDefaultForeground(const DWORD dwColor)
|
||||
bool AdaptDispatch::SetDefaultForeground(const DWORD dwColor)
|
||||
{
|
||||
bool success = true;
|
||||
success = _pConApi->PrivateSetDefaultForeground(dwColor);
|
||||
success = _pConApi->SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, dwColor);
|
||||
|
||||
// If we're a conpty, always return false, so that we send the updated color
|
||||
// value to the terminal. Still handle the sequence so apps that use
|
||||
|
@ -2291,10 +2316,10 @@ bool Microsoft::Console::VirtualTerminal::AdaptDispatch::SetDefaultForeground(co
|
|||
// - dwColor: The new RGB color value to use, as a COLORREF, format 0x00BBGGRR.
|
||||
// Return Value:
|
||||
// True if handled successfully. False otherwise.
|
||||
bool Microsoft::Console::VirtualTerminal::AdaptDispatch::SetDefaultBackground(const DWORD dwColor)
|
||||
bool AdaptDispatch::SetDefaultBackground(const DWORD dwColor)
|
||||
{
|
||||
bool success = true;
|
||||
success = _pConApi->PrivateSetDefaultBackground(dwColor);
|
||||
success = _pConApi->SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, dwColor);
|
||||
|
||||
// If we're a conpty, always return false, so that we send the updated color
|
||||
// value to the terminal. Still handle the sequence so apps that use
|
||||
|
|
|
@ -101,6 +101,7 @@ namespace Microsoft::Console::VirtualTerminal
|
|||
bool LockingShift(const size_t gsetNumber) override; // LS0, LS1, LS2, LS3
|
||||
bool LockingShiftRight(const size_t gsetNumber) override; // LS1R, LS2R, LS3R
|
||||
bool SingleShift(const size_t gsetNumber) override; // SS2, SS3
|
||||
bool AcceptC1Controls(const bool enabled) override; // DECAC1
|
||||
bool SoftReset() override; // DECSTR
|
||||
bool HardReset() override; // RIS
|
||||
bool ScreenAlignmentPattern() override; // DECALN
|
||||
|
@ -155,6 +156,7 @@ namespace Microsoft::Console::VirtualTerminal
|
|||
bool IsOriginModeRelative = false;
|
||||
TextAttribute Attributes = {};
|
||||
TerminalOutput TermOutput = {};
|
||||
bool C1ControlsAccepted = false;
|
||||
unsigned int CodePage = 0;
|
||||
};
|
||||
struct Offset
|
||||
|
|
|
@ -16,6 +16,7 @@ Author(s):
|
|||
#pragma once
|
||||
|
||||
#include "../input/terminalInput.hpp"
|
||||
#include "../parser/stateMachine.hpp"
|
||||
#include "../../types/inc/IInputEvent.hpp"
|
||||
#include "../../buffer/out/LineRendition.hpp"
|
||||
#include "../../buffer/out/TextAttribute.hpp"
|
||||
|
@ -49,8 +50,9 @@ namespace Microsoft::Console::VirtualTerminal
|
|||
const SMALL_RECT& window) = 0;
|
||||
|
||||
virtual bool SetInputMode(const TerminalInput::Mode mode, const bool enabled) = 0;
|
||||
virtual bool SetParserMode(const StateMachine::Mode mode, const bool enabled) = 0;
|
||||
virtual bool GetParserMode(const StateMachine::Mode mode) const = 0;
|
||||
|
||||
virtual bool PrivateSetAnsiMode(const bool ansiMode) = 0;
|
||||
virtual bool PrivateSetScreenMode(const bool reverseMode) = 0;
|
||||
virtual bool PrivateSetAutoWrapMode(const bool wrapAtEOL) = 0;
|
||||
|
||||
|
@ -70,7 +72,6 @@ namespace Microsoft::Console::VirtualTerminal
|
|||
virtual bool PrivateClearBuffer() = 0;
|
||||
virtual bool GetUserDefaultCursorStyle(CursorType& style) = 0;
|
||||
virtual bool SetCursorStyle(const CursorType style) = 0;
|
||||
virtual bool SetCursorColor(const COLORREF color) = 0;
|
||||
virtual bool PrivateWriteConsoleControlInput(const KeyEvent key) = 0;
|
||||
virtual bool PrivateRefreshWindow() = 0;
|
||||
|
||||
|
@ -85,10 +86,8 @@ namespace Microsoft::Console::VirtualTerminal
|
|||
|
||||
virtual bool MoveToBottom() const = 0;
|
||||
|
||||
virtual bool PrivateGetColorTableEntry(const size_t index, COLORREF& value) const = 0;
|
||||
virtual bool PrivateSetColorTableEntry(const size_t index, const COLORREF value) const = 0;
|
||||
virtual bool PrivateSetDefaultForeground(const COLORREF value) const = 0;
|
||||
virtual bool PrivateSetDefaultBackground(const COLORREF value) const = 0;
|
||||
virtual COLORREF GetColorTableEntry(const size_t tableIndex) const = 0;
|
||||
virtual bool SetColorTableEntry(const size_t tableIndex, const COLORREF color) = 0;
|
||||
|
||||
virtual bool PrivateFillRegion(const COORD startPosition,
|
||||
const size_t fillLength,
|
||||
|
|
|
@ -104,6 +104,7 @@ public:
|
|||
bool LockingShift(const size_t /*gsetNumber*/) noexcept override { return false; } // LS0, LS1, LS2, LS3
|
||||
bool LockingShiftRight(const size_t /*gsetNumber*/) noexcept override { return false; } // LS1R, LS2R, LS3R
|
||||
bool SingleShift(const size_t /*gsetNumber*/) noexcept override { return false; } // SS2, SS3
|
||||
bool AcceptC1Controls(const bool /*enabled*/) noexcept override { return false; } // DECAC1
|
||||
|
||||
bool SoftReset() noexcept override { return false; } // DECSTR
|
||||
bool HardReset() noexcept override { return false; } // RIS
|
||||
|
|
|
@ -125,16 +125,24 @@ public:
|
|||
return _setInputModeResult;
|
||||
}
|
||||
|
||||
bool PrivateSetAnsiMode(const bool ansiMode) override
|
||||
bool SetParserMode(const StateMachine::Mode mode, const bool enabled) override
|
||||
{
|
||||
Log::Comment(L"PrivateSetAnsiMode MOCK called...");
|
||||
Log::Comment(L"SetParserMode MOCK called...");
|
||||
|
||||
if (_privateSetAnsiModeResult)
|
||||
if (_setParserModeResult)
|
||||
{
|
||||
VERIFY_ARE_EQUAL(_expectedAnsiMode, ansiMode);
|
||||
VERIFY_ARE_EQUAL(_expectedParserMode, mode);
|
||||
VERIFY_ARE_EQUAL(_expectedParserModeEnabled, enabled);
|
||||
}
|
||||
|
||||
return _privateSetAnsiModeResult;
|
||||
return _setParserModeResult;
|
||||
}
|
||||
|
||||
bool GetParserMode(const StateMachine::Mode /*mode*/) const override
|
||||
{
|
||||
Log::Comment(L"GetParserMode MOCK called...");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PrivateSetScreenMode(const bool /*reverseMode*/) override
|
||||
|
@ -362,16 +370,6 @@ public:
|
|||
return _setCursorStyleResult;
|
||||
}
|
||||
|
||||
bool SetCursorColor(const COLORREF cursorColor) override
|
||||
{
|
||||
Log::Comment(L"SetCursorColor MOCK called...");
|
||||
if (_setCursorColorResult)
|
||||
{
|
||||
VERIFY_ARE_EQUAL(_expectedCursorColor, cursorColor);
|
||||
}
|
||||
return _setCursorColorResult;
|
||||
}
|
||||
|
||||
bool PrivateRefreshWindow() override
|
||||
{
|
||||
Log::Comment(L"PrivateRefreshWindow MOCK called...");
|
||||
|
@ -386,10 +384,14 @@ public:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
bool SetConsoleOutputCP(const unsigned int /*codepage*/) override
|
||||
bool SetConsoleOutputCP(const unsigned int codepage) override
|
||||
{
|
||||
Log::Comment(L"SetConsoleOutputCP MOCK called...");
|
||||
return TRUE;
|
||||
if (_setConsoleOutputCPResult)
|
||||
{
|
||||
VERIFY_ARE_EQUAL(_expectedOutputCP, codepage);
|
||||
}
|
||||
return _setConsoleOutputCPResult;
|
||||
}
|
||||
|
||||
bool GetConsoleOutputCP(unsigned int& codepage) override
|
||||
|
@ -426,53 +428,31 @@ public:
|
|||
return _moveToBottomResult;
|
||||
}
|
||||
|
||||
bool PrivateGetColorTableEntry(const size_t index, COLORREF& value) const noexcept override
|
||||
COLORREF GetColorTableEntry(const size_t tableIndex) const noexcept override
|
||||
{
|
||||
Log::Comment(L"PrivateGetColorTableEntry MOCK called...");
|
||||
Log::Comment(L"GetColorTableEntry MOCK called...");
|
||||
|
||||
if (_privateGetColorTableEntryResult)
|
||||
if (_getColorTableEntryResult)
|
||||
{
|
||||
VERIFY_ARE_EQUAL(_expectedColorTableIndex, index);
|
||||
VERIFY_ARE_EQUAL(_expectedColorTableIndex, tableIndex);
|
||||
// Simply returning the index as the color value makes it easy for
|
||||
// tests to confirm that they've received the color they expected.
|
||||
value = gsl::narrow_cast<COLORREF>(index);
|
||||
return gsl::narrow_cast<COLORREF>(tableIndex);
|
||||
}
|
||||
|
||||
return _privateGetColorTableEntryResult;
|
||||
return INVALID_COLOR;
|
||||
}
|
||||
|
||||
bool PrivateSetColorTableEntry(const size_t index, const COLORREF value) const noexcept override
|
||||
bool SetColorTableEntry(const size_t tableIndex, const COLORREF color) noexcept override
|
||||
{
|
||||
Log::Comment(L"PrivateSetColorTableEntry MOCK called...");
|
||||
if (_privateSetColorTableEntryResult)
|
||||
Log::Comment(L"SetColorTableEntry MOCK called...");
|
||||
if (_setColorTableEntryResult)
|
||||
{
|
||||
VERIFY_ARE_EQUAL(_expectedColorTableIndex, index);
|
||||
VERIFY_ARE_EQUAL(_expectedColorValue, value);
|
||||
VERIFY_ARE_EQUAL(_expectedColorTableIndex, tableIndex);
|
||||
VERIFY_ARE_EQUAL(_expectedColorValue, color);
|
||||
}
|
||||
|
||||
return _privateSetColorTableEntryResult;
|
||||
}
|
||||
|
||||
bool PrivateSetDefaultForeground(const COLORREF value) const noexcept override
|
||||
{
|
||||
Log::Comment(L"PrivateSetDefaultForeground MOCK called...");
|
||||
if (_privateSetDefaultForegroundResult)
|
||||
{
|
||||
VERIFY_ARE_EQUAL(_expectedDefaultForegroundColorValue, value);
|
||||
}
|
||||
|
||||
return _privateSetDefaultForegroundResult;
|
||||
}
|
||||
|
||||
bool PrivateSetDefaultBackground(const COLORREF value) const noexcept override
|
||||
{
|
||||
Log::Comment(L"PrivateSetDefaultForeground MOCK called...");
|
||||
if (_privateSetDefaultBackgroundResult)
|
||||
{
|
||||
VERIFY_ARE_EQUAL(_expectedDefaultBackgroundColorValue, value);
|
||||
}
|
||||
|
||||
return _privateSetDefaultBackgroundResult;
|
||||
return _setColorTableEntryResult;
|
||||
}
|
||||
|
||||
bool PrivateFillRegion(const COORD /*startPosition*/,
|
||||
|
@ -712,8 +692,9 @@ public:
|
|||
bool _setInputModeResult = false;
|
||||
TerminalInput::Mode _expectedInputMode;
|
||||
bool _expectedInputModeEnabled = false;
|
||||
bool _privateSetAnsiModeResult = false;
|
||||
bool _expectedAnsiMode = false;
|
||||
bool _setParserModeResult = false;
|
||||
StateMachine::Mode _expectedParserMode;
|
||||
bool _expectedParserModeEnabled = false;
|
||||
bool _privateAllowCursorBlinkingResult = false;
|
||||
bool _enable = false; // for cursor blinking
|
||||
bool _privateSetScrollingRegionResult = false;
|
||||
|
@ -726,22 +707,15 @@ public:
|
|||
std::wstring_view _expectedWindowTitle{};
|
||||
bool _setCursorStyleResult = false;
|
||||
CursorType _expectedCursorStyle;
|
||||
bool _setCursorColorResult = false;
|
||||
COLORREF _expectedCursorColor = 0;
|
||||
bool _setConsoleOutputCPResult = false;
|
||||
bool _getConsoleOutputCPResult = false;
|
||||
bool _moveToBottomResult = false;
|
||||
|
||||
bool _privateGetColorTableEntryResult = false;
|
||||
bool _privateSetColorTableEntryResult = false;
|
||||
bool _getColorTableEntryResult = false;
|
||||
bool _setColorTableEntryResult = false;
|
||||
size_t _expectedColorTableIndex = SIZE_MAX;
|
||||
COLORREF _expectedColorValue = INVALID_COLOR;
|
||||
|
||||
bool _privateSetDefaultForegroundResult = false;
|
||||
COLORREF _expectedDefaultForegroundColorValue = INVALID_COLOR;
|
||||
|
||||
bool _privateSetDefaultBackgroundResult = false;
|
||||
COLORREF _expectedDefaultBackgroundColorValue = INVALID_COLOR;
|
||||
|
||||
SIZE _expectedCellSize = {};
|
||||
|
||||
private:
|
||||
|
@ -2057,15 +2031,17 @@ public:
|
|||
// success cases
|
||||
// set ansi mode = true
|
||||
Log::Comment(L"Test 1: ansi mode = true");
|
||||
_testGetSet->_privateSetAnsiModeResult = true;
|
||||
_testGetSet->_expectedAnsiMode = true;
|
||||
_testGetSet->_setParserModeResult = true;
|
||||
_testGetSet->_expectedParserMode = StateMachine::Mode::Ansi;
|
||||
_testGetSet->_expectedParserModeEnabled = true;
|
||||
|
||||
VERIFY_IS_TRUE(_pDispatch.get()->SetAnsiMode(true));
|
||||
|
||||
// set ansi mode = false
|
||||
Log::Comment(L"Test 2: ansi mode = false.");
|
||||
_testGetSet->_privateSetAnsiModeResult = true;
|
||||
_testGetSet->_expectedAnsiMode = false;
|
||||
_testGetSet->_setParserModeResult = true;
|
||||
_testGetSet->_expectedParserMode = StateMachine::Mode::Ansi;
|
||||
_testGetSet->_expectedParserModeEnabled = false;
|
||||
|
||||
VERIFY_IS_TRUE(_pDispatch.get()->SetAnsiMode(false));
|
||||
}
|
||||
|
@ -2290,7 +2266,7 @@ public:
|
|||
VTParameter rgOptions[16];
|
||||
size_t cOptions = 3;
|
||||
|
||||
_testGetSet->_privateGetColorTableEntryResult = true;
|
||||
_testGetSet->_getColorTableEntryResult = true;
|
||||
_testGetSet->_expectedAttribute = _testGetSet->_attribute;
|
||||
|
||||
Log::Comment(L"Test 1: Change Foreground");
|
||||
|
@ -2340,7 +2316,7 @@ public:
|
|||
|
||||
VTParameter rgOptions[16];
|
||||
|
||||
_testGetSet->_privateGetColorTableEntryResult = true;
|
||||
_testGetSet->_getColorTableEntryResult = true;
|
||||
_testGetSet->_expectedAttribute = _testGetSet->_attribute;
|
||||
|
||||
Log::Comment(L"Test 1: Change Indexed Foreground with missing index parameter");
|
||||
|
@ -2383,7 +2359,7 @@ public:
|
|||
{
|
||||
_testGetSet->PrepData();
|
||||
|
||||
_testGetSet->_privateSetColorTableEntryResult = true;
|
||||
_testGetSet->_setColorTableEntryResult = true;
|
||||
const auto testColor = RGB(1, 2, 3);
|
||||
_testGetSet->_expectedColorValue = testColor;
|
||||
|
||||
|
@ -2393,7 +2369,7 @@ public:
|
|||
VERIFY_IS_TRUE(_pDispatch.get()->SetColorTableEntry(i, testColor));
|
||||
}
|
||||
|
||||
// Test in pty mode - we should fail, but PrivateSetColorTableEntry should still be called
|
||||
// Test in pty mode - we should fail, but SetColorTableEntry should still be called
|
||||
_testGetSet->_isPty = true;
|
||||
|
||||
_testGetSet->_expectedColorTableIndex = 15; // Windows BRIGHT_WHITE
|
||||
|
@ -2623,6 +2599,39 @@ public:
|
|||
VERIFY_IS_TRUE(decdld(CellMatrix::Default, 0, FontSet::Size132x24, FontUsage::FullCell, bitmapOf6x18));
|
||||
}
|
||||
|
||||
TEST_METHOD(TogglingC1ParserMode)
|
||||
{
|
||||
Log::Comment(L"1. Accept C1 controls");
|
||||
_testGetSet->_setParserModeResult = true;
|
||||
_testGetSet->_expectedParserMode = StateMachine::Mode::AcceptC1;
|
||||
_testGetSet->_expectedParserModeEnabled = true;
|
||||
VERIFY_IS_TRUE(_pDispatch.get()->AcceptC1Controls(true));
|
||||
|
||||
Log::Comment(L"2. Don't accept C1 controls");
|
||||
_testGetSet->_setParserModeResult = true;
|
||||
_testGetSet->_expectedParserMode = StateMachine::Mode::AcceptC1;
|
||||
_testGetSet->_expectedParserModeEnabled = false;
|
||||
VERIFY_IS_TRUE(_pDispatch.get()->AcceptC1Controls(false));
|
||||
|
||||
Log::Comment(L"3. Designate ISO-2022 coding system");
|
||||
// Code page should be set to ISO-8859-1 and C1 parsing enabled
|
||||
_testGetSet->_setConsoleOutputCPResult = true;
|
||||
_testGetSet->_expectedOutputCP = 28591;
|
||||
_testGetSet->_setParserModeResult = true;
|
||||
_testGetSet->_expectedParserMode = StateMachine::Mode::AcceptC1;
|
||||
_testGetSet->_expectedParserModeEnabled = true;
|
||||
VERIFY_IS_TRUE(_pDispatch.get()->DesignateCodingSystem(DispatchTypes::CodingSystem::ISO2022));
|
||||
|
||||
Log::Comment(L"4. Designate UTF-8 coding system");
|
||||
// Code page should be set to UTF-8 and C1 parsing disabled
|
||||
_testGetSet->_setConsoleOutputCPResult = true;
|
||||
_testGetSet->_expectedOutputCP = CP_UTF8;
|
||||
_testGetSet->_setParserModeResult = true;
|
||||
_testGetSet->_expectedParserMode = StateMachine::Mode::AcceptC1;
|
||||
_testGetSet->_expectedParserModeEnabled = false;
|
||||
VERIFY_IS_TRUE(_pDispatch.get()->DesignateCodingSystem(DispatchTypes::CodingSystem::UTF8));
|
||||
}
|
||||
|
||||
private:
|
||||
TestGetSet* _testGetSet; // non-ownership pointer
|
||||
std::unique_ptr<AdaptDispatch> _pDispatch;
|
||||
|
|
|
@ -542,7 +542,7 @@ std::wstring TerminalInput::_GenerateSGRSequence(const COORD position,
|
|||
// - delta: The scroll wheel delta of the input event
|
||||
// Return value:
|
||||
// True iff the alternate buffer is active and alternate scroll mode is enabled and the event is a mouse wheel event.
|
||||
bool TerminalInput::_ShouldSendAlternateScroll(const unsigned int button, const short delta) const
|
||||
bool TerminalInput::_ShouldSendAlternateScroll(const unsigned int button, const short delta) const noexcept
|
||||
{
|
||||
return _mouseInputState.inAlternateBuffer &&
|
||||
_inputMode.test(Mode::AlternateScroll) &&
|
||||
|
@ -555,7 +555,7 @@ bool TerminalInput::_ShouldSendAlternateScroll(const unsigned int button, const
|
|||
// - delta: The scroll wheel delta of the input event
|
||||
// Return value:
|
||||
// True iff the input sequence was sent successfully.
|
||||
bool TerminalInput::_SendAlternateScroll(const short delta) const
|
||||
bool TerminalInput::_SendAlternateScroll(const short delta) const noexcept
|
||||
{
|
||||
if (delta > 0)
|
||||
{
|
||||
|
|
|
@ -250,13 +250,13 @@ const wchar_t* const CTRL_QUESTIONMARK_SEQUENCE = L"\x7F";
|
|||
const wchar_t* const CTRL_ALT_SLASH_SEQUENCE = L"\x1b\x1f";
|
||||
const wchar_t* const CTRL_ALT_QUESTIONMARK_SEQUENCE = L"\x1b\x7F";
|
||||
|
||||
void TerminalInput::SetInputMode(const Mode mode, const bool enabled)
|
||||
void TerminalInput::SetInputMode(const Mode mode, const bool enabled) noexcept
|
||||
{
|
||||
// If we're changing a tracking mode, we always clear other tracking modes first.
|
||||
// We also clear out the last saved mouse position & button.
|
||||
if (mode == Mode::DefaultMouseTracking || mode == Mode::ButtonEventMouseTracking || mode == Mode::AnyEventMouseTracking)
|
||||
{
|
||||
_inputMode.reset_all(Mode::DefaultMouseTracking, Mode::ButtonEventMouseTracking, Mode::AnyEventMouseTracking);
|
||||
_inputMode.reset(Mode::DefaultMouseTracking, Mode::ButtonEventMouseTracking, Mode::AnyEventMouseTracking);
|
||||
_mouseInputState.lastPos = { -1, -1 };
|
||||
_mouseInputState.lastButton = 0;
|
||||
}
|
||||
|
@ -265,13 +265,13 @@ void TerminalInput::SetInputMode(const Mode mode, const bool enabled)
|
|||
// when enabling a new encoding - not when disabling.
|
||||
if ((mode == Mode::Utf8MouseEncoding || mode == Mode::SgrMouseEncoding) && enabled)
|
||||
{
|
||||
_inputMode.reset_all(Mode::Utf8MouseEncoding, Mode::SgrMouseEncoding);
|
||||
_inputMode.reset(Mode::Utf8MouseEncoding, Mode::SgrMouseEncoding);
|
||||
}
|
||||
|
||||
_inputMode.set(mode, enabled);
|
||||
}
|
||||
|
||||
bool TerminalInput::GetInputMode(const Mode mode) const
|
||||
bool TerminalInput::GetInputMode(const Mode mode) const noexcept
|
||||
{
|
||||
return _inputMode.test(mode);
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ namespace Microsoft::Console::VirtualTerminal
|
|||
AlternateScroll
|
||||
};
|
||||
|
||||
void SetInputMode(const Mode mode, const bool enabled);
|
||||
bool GetInputMode(const Mode mode) const;
|
||||
void SetInputMode(const Mode mode, const bool enabled) noexcept;
|
||||
bool GetInputMode(const Mode mode) const noexcept;
|
||||
void ForceDisableWin32InputMode(const bool win32InputMode) noexcept;
|
||||
|
||||
#pragma region MouseInput
|
||||
|
@ -127,8 +127,8 @@ namespace Microsoft::Console::VirtualTerminal
|
|||
const short modifierKeyState,
|
||||
const short delta);
|
||||
|
||||
bool _ShouldSendAlternateScroll(const unsigned int button, const short delta) const;
|
||||
bool _SendAlternateScroll(const short delta) const;
|
||||
bool _ShouldSendAlternateScroll(const unsigned int button, const short delta) const noexcept;
|
||||
bool _SendAlternateScroll(const short delta) const noexcept;
|
||||
|
||||
static constexpr unsigned int s_GetPressedButton(const MouseButtonState state) noexcept;
|
||||
#pragma endregion
|
||||
|
|
|
@ -265,6 +265,10 @@ bool OutputStateMachineEngine::ActionEscDispatch(const VTID id)
|
|||
success = _dispatch->LockingShiftRight(3);
|
||||
TermTelemetry::Instance().Log(TermTelemetry::Codes::LS3R);
|
||||
break;
|
||||
case EscActionCodes::DECAC1_AcceptC1Controls:
|
||||
success = _dispatch->AcceptC1Controls(true);
|
||||
TermTelemetry::Instance().Log(TermTelemetry::Codes::DECAC1);
|
||||
break;
|
||||
case EscActionCodes::DECDHL_DoubleHeightLineTop:
|
||||
_dispatch->SetLineRendition(LineRendition::DoubleHeightTop);
|
||||
TermTelemetry::Instance().Log(TermTelemetry::Codes::DECDHL);
|
||||
|
|
|
@ -88,6 +88,7 @@ namespace Microsoft::Console::VirtualTerminal
|
|||
LS1R_LockingShift = VTID("~"),
|
||||
LS2R_LockingShift = VTID("}"),
|
||||
LS3R_LockingShift = VTID("|"),
|
||||
DECAC1_AcceptC1Controls = VTID(" 7"),
|
||||
DECDHL_DoubleHeightLineTop = VTID("#3"),
|
||||
DECDHL_DoubleHeightLineBottom = VTID("#4"),
|
||||
DECSWL_SingleWidthLine = VTID("#5"),
|
||||
|
|
|
@ -14,7 +14,6 @@ StateMachine::StateMachine(std::unique_ptr<IStateMachineEngine> engine) :
|
|||
_engine(std::move(engine)),
|
||||
_state(VTStates::Ground),
|
||||
_trace(Microsoft::Console::VirtualTerminal::ParserTracing()),
|
||||
_isInAnsiMode(true),
|
||||
_parameters{},
|
||||
_parameterLimitReached(false),
|
||||
_oscString{},
|
||||
|
@ -24,9 +23,14 @@ StateMachine::StateMachine(std::unique_ptr<IStateMachineEngine> engine) :
|
|||
_ActionClear();
|
||||
}
|
||||
|
||||
void StateMachine::SetAnsiMode(bool ansiMode) noexcept
|
||||
void StateMachine::SetParserMode(const Mode mode, const bool enabled) noexcept
|
||||
{
|
||||
_isInAnsiMode = ansiMode;
|
||||
_parserMode.set(mode, enabled);
|
||||
}
|
||||
|
||||
bool StateMachine::GetParserMode(const Mode mode) const noexcept
|
||||
{
|
||||
return _parserMode.test(mode);
|
||||
}
|
||||
|
||||
const IStateMachineEngine& StateMachine::Engine() const noexcept
|
||||
|
@ -1064,7 +1068,7 @@ void StateMachine::_EventEscape(const wchar_t wch)
|
|||
_EnterEscapeIntermediate();
|
||||
}
|
||||
}
|
||||
else if (_isInAnsiMode)
|
||||
else if (_parserMode.test(Mode::Ansi))
|
||||
{
|
||||
if (_isCsiIndicator(wch))
|
||||
{
|
||||
|
@ -1129,7 +1133,7 @@ void StateMachine::_EventEscapeIntermediate(const wchar_t wch)
|
|||
{
|
||||
_ActionIgnore();
|
||||
}
|
||||
else if (_isInAnsiMode)
|
||||
else if (_parserMode.test(Mode::Ansi))
|
||||
{
|
||||
_ActionEscDispatch(wch);
|
||||
_EnterGround();
|
||||
|
@ -1729,8 +1733,16 @@ void StateMachine::ProcessCharacter(const wchar_t wch)
|
|||
// Preprocess C1 control characters and treat them as ESC + their 7-bit equivalent.
|
||||
else if (_isC1ControlCharacter(wch))
|
||||
{
|
||||
ProcessCharacter(AsciiChars::ESC);
|
||||
ProcessCharacter(_c1To7Bit(wch));
|
||||
// But note that we only do this if C1 control code parsing has been
|
||||
// explicitly requested, since there are some code pages with "unmapped"
|
||||
// code points that get translated as C1 controls when that is not their
|
||||
// intended use. In order to avoid them triggering unintentional escape
|
||||
// sequences, we ignore these characters by default.
|
||||
if (_parserMode.test(Mode::AcceptC1))
|
||||
{
|
||||
ProcessCharacter(AsciiChars::ESC);
|
||||
ProcessCharacter(_c1To7Bit(wch));
|
||||
}
|
||||
}
|
||||
// Don't go to escape from the OSC string state - ESC can be used to terminate OSC strings.
|
||||
else if (_isEscape(wch) && _state != VTStates::OscString)
|
||||
|
|
|
@ -42,7 +42,14 @@ namespace Microsoft::Console::VirtualTerminal
|
|||
public:
|
||||
StateMachine(std::unique_ptr<IStateMachineEngine> engine);
|
||||
|
||||
void SetAnsiMode(bool ansiMode) noexcept;
|
||||
enum class Mode : size_t
|
||||
{
|
||||
AcceptC1,
|
||||
Ansi,
|
||||
};
|
||||
|
||||
void SetParserMode(const Mode mode, const bool enabled) noexcept;
|
||||
bool GetParserMode(const Mode mode) const noexcept;
|
||||
|
||||
void ProcessCharacter(const wchar_t wch);
|
||||
void ProcessString(const std::wstring_view string);
|
||||
|
@ -144,7 +151,7 @@ namespace Microsoft::Console::VirtualTerminal
|
|||
|
||||
VTStates _state;
|
||||
|
||||
bool _isInAnsiMode;
|
||||
til::enumset<Mode> _parserMode{ Mode::Ansi };
|
||||
|
||||
std::wstring_view _currentString;
|
||||
size_t _runOffset;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue