Compare commits

...

24 Commits

Author SHA1 Message Date
Dustin Howett
00db8704b6 HACK: Add Version to the propsheet 2019-05-30 17:59:26 -07:00
Ian Frosst
71e19cd825 "Color scheme" is two words (#1054)
* Update ColorTool comments

* Update profile key

* Add ability to load settings from old key
2019-05-30 13:32:05 -05:00
Nicholas Baron
dadd74c3c6 Improvements to TerminalInput (#690)
* Specified the destructor of TerminalInput as default

* Simplified GetKeymappingLength

* Simplified GetKeyMapping

* Removed a redundant assignment

* Added auto deduction to some variables

* Merged the public sections of TerminalInput

* Implied the destructor for TerminalInput

* Removed GetKeyMappingLength and GetKeyMapping from public interface

Rearranged public section to be above private.

* Deleted or defaulted all six special member functions.

* Removed extraneous newlines

* Deleted all move and copy operations.

The default constructor is also deleted.
The destructor is defaulted.

* Converted tabs to 4 spaces
2019-05-30 11:15:37 -07:00
MelulekiDube
1c16b2c06b Removed using namespace directive from header files (#955)
* Removed using namespace directive from header files and put these in cpp files where they are used

* Fixed tabbing issues by replacing them with spaces.
Also regrouped the using directives.

* Update src/host/exemain.cpp

Co-Authored-By: Mike Griese <migrie@microsoft.com>

* Update src/interactivity/win32/find.cpp

Co-Authored-By: Mike Griese <migrie@microsoft.com>
2019-05-30 11:14:21 -07:00
fghzxm
c3e32eb1ca Highlight the default profile in new-tab flyout (#888)
* Highlight the default profile in new-tab flyout

This commit makes the default profile in the new-tab flyout to show up
at the top and gives it bold text.
2019-05-30 09:24:34 -07:00
Shawn Walker-Salas
e52170e2cf Apply [[nodiscard]] to functions returning error codes (#953)
* Apply [[nodiscard]] to functions returning error codes

- applied [[nodiscard]] for all HRESULT, LRESULT, and NTSTATUS functions
- fixed IntelliSense declaration complaints leading to function not
  implemented warnings
- deleted declared but never implemented functions
- fixed unused parameter warnings

How verified:
- bcz dbg
- opencon
- testcon
- VS2019 debug build

* - use LOG_IF_FAILED where applicable
- remove use of goto
- make MakeAltRasterFont return void

* - add missing [[nodiscard]]
- remove vestigal function declarations
- fix inconsistent function declaration
2019-05-30 16:20:42 +00:00
Kyle Sabo
3d7160d731 Use a ComPtr to avoid leaking font. (#1063)
Fixes #768
2019-05-30 15:54:46 +00:00
Michael Ratanapintha
d24d647c0d Turn on Text Buffer unit tests in Azure DevOps CI build (#1057)
* rename TextBuffer.UnitTests.dll -> TextBuffer.Unit.Tests.dll

* renamed the project file as well
2019-05-29 19:51:17 -07:00
Flo56958
e2b5fecd48 Some Typo-Fixes in Comments (#1049)
* Typo fixes
2019-05-29 14:27:30 -07:00
d-bingham
097f7d32a6 Background image support (#853)
* Initial code check in for background images

* Cleaning up whitespace

* Whitespace cleanup

* Added/fixed comments

* Fixing tabs

* Reverting erroneous file add

* Removing custom enum for image stretching mode and using Windows::UI::Xaml::Media::Stretch instead.

* Removing now-superfluous static_cast when setting stretch mode.

* Updating code to use wstring_view (per #925)

* One last set of wstring -> wstring_view changes

* Split off brush-intialization function from TermControl::_BackgroundColorChanged and added code to prevent flicker on resetting acrylic or image backgrounds.
2019-05-29 13:35:46 -05:00
Michael Ratanapintha
2f88c46350 Allow tools\razzle & nuget restore to work with NuGet 5 and later (#1046)
Since version 5.0.2, NuGet has used the PATH environment variable
to find MSBuild.exe before looking in other file paths.
See NuGet change
21f2b07f2c
(https://github.com/NuGet/NuGet.Client/pull/2687 ).

Unfortunately, in PR
https://github.com/microsoft/terminal/pull/606 ,
`tools\razzle.cmd` was changed to add the MSBuild.exe folder path
in _quotes_ to the PATH environment variable.
Windows itself is fine with this (you can type `msbuild` and
MSBuild runs), but some tools are not, including NuGet itself,
so you would get errors like this:

```
D:\GitHub\metathinker\console> where nuget
C:\ProgramData\chocolatey\bin\nuget.exe
D:\GitHub\metathinker\console\dep\nuget\nuget.exe

D:\GitHub\metathinker\console> nuget restore OpenConsole.sln
Illegal characters in path.
```

`razzle.cmd` runs NuGet itself, but does so before adding
the MSBuild folder to the PATH, so it was not affected by this
problem.

This change fixes the issue by dequotifying the PATH,
so that if you already had a newer version of NuGet on your PATH
before running `tools\razzle.cmd`, that version will continue
to work should you need to run `nuget restore` again
(such as after a `git clean -dx`).
2019-05-29 10:02:48 -07:00
Michael Niksa
8baba4b46c Guard try_query calls with a null check on the pointer we're QI-ing from (#1044)
Even wil::com_ptr_nothrow can still inadvertantly throw an 'access violation exception' when null pointer deref-ing (WIL won't check if it's null before attempting, CComQIPtr apparently didn't care.
2019-05-28 16:03:22 -07:00
Summon528
cfc72cee5d Make sure cursor blinks after opening new tab (#1030) 2019-05-28 11:18:28 -07:00
Michael Ratanapintha
9ad2544033 Fix #936: misuse of uninitialized objects causes AppVerifier breaks on Windows Terminal startup (#1015)
* move the render thread init up; gets rid of verifier stops

* s/INVALID_HANDLE_VALUE/NULL/g since CreateEvent() and CreateThread() return a NULL HANDLE on failure; resolves another cause of AppVerifier breaks
2019-05-28 16:56:36 +00:00
nathan-castlehow
5f938a0465 Update Terminal.cpp (#1034) 2019-05-28 16:53:03 +00:00
subhasan
4c47631bf4 Cleanup - termDispatch.hpp & adaptDispatch.hpp overrides (#1004)
* Fix for https://github.com/microsoft/terminal/issues/896

* Fixing spaces

* Base Class destructor is virtual, derived class destructor shouldn't be declared vitual or override

* Update src/terminal/adapter/termDispatch.hpp

nit: remove space

Co-Authored-By: Mike Griese <migrie@microsoft.com>
2019-05-24 15:29:12 -07:00
adiviness
cc30475955 add audit mode to ci (#948)
* add audit mode to ci
2019-05-24 14:48:10 -07:00
Mike Griese
80f107965d Fix the bell sound when Alt+key is pressed. (#1006) 2019-05-24 16:43:46 -05:00
Mike Griese
42e87ed3e3 fix build break from using await instead of co_await (#1009) 2019-05-24 21:27:45 +00:00
Michael Niksa
40b557a4b6 Update manifest to correct 1903 version, unref param fix (#1008)
* Update manifest to correct 1903 version

While messing around with building with VS2019/14.2/etc, I noticed that the version we're using in the compatibility manifest doesn't match guidance for XAML Islands. This puts the version information from the public guidance into the manifest and leaves a link back to the page where I got this idea from.

* comment out unused params in IslandWindow::OnResize
2019-05-24 14:26:40 -07:00
Mike Griese
0f62ec81d8 Eat all tap keypresses no matter what. (#985)
Fixes #744
2019-05-24 15:04:00 -05:00
Dustin L. Howett (MSFT)
ce0eaab9ac inbox: Merge accumulated build fixes from RS_ONECORE_DEP_ACIOSS (#1002)
* Merged PR 3302855

[Git2Git] Git Train: Merge of building/rs_onecore_dep_acioss/190523-1700 into official/rs_onecore_dep_acioss Retrieved from official/rs_onecore_dep_acioss 3fceea90bee761aa93d91c0184a7217d1e2d404b

Related work items: #18974333
2019-05-24 12:28:30 -07:00
Benjamin Staneck
1c50968333 add .editorconfig file (#585)
* add .editorconfig file

* drop charset from editorconfig

* Update .editorconfig

Co-Authored-By: Michael Niksa <miniksa@microsoft.com>
2019-05-24 18:20:17 +00:00
Joel Bennett
efd69990c6 Add support for OSC 10 and 11 to set the default colors (#891)
* Support OSC to set default background and foreground colors

* Update the Terminal theme when the background changes

* Fix whitespace per code-review

* Add Documentation Comments

Also fix a few outdated comments and whitespace

* Update Telemetry codes per code review

* Add Unit Tests for OSC ForegroundColor and BackgroundColor

* Add a couple additional test cases

* Minor doc and whitespace change per PR review

* Update comment help per code review

* Add another OSC 10 & 11 test case, improve output

* Comments and syntax cleanup per code reviews
2019-05-24 09:53:00 -07:00
200 changed files with 1732 additions and 610 deletions

13
.editorconfig Normal file
View File

@@ -0,0 +1,13 @@
root = true
[*]
trim_trailing_whitespace = true
insert_final_newline = true
[{*.cpp,*.c,*.hpp,*.h,*.cs}]
indent_style = space
indent_size = 4
[*.json]
indent_style = space
indent_size = 2

1
.gitignore vendored
View File

@@ -18,7 +18,6 @@
x64/
x86/
ARM64/
build/
bld/
[Bb]in/
[Oo]bj/

View File

@@ -71,7 +71,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Host.Tests.Unit", "src\host
{06EC74CB-9A12-429C-B551-8562EC954747} = {06EC74CB-9A12-429C-B551-8562EC954747}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TextBuffer.UnitTests", "src\buffer\out\ut_textbuffer\TextBuffer.UnitTests.vcxproj", "{531C23E7-4B76-4C08-8BBD-04164CB628C9}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TextBuffer.Unit.Tests", "src\buffer\out\ut_textbuffer\TextBuffer.Unit.Tests.vcxproj", "{531C23E7-4B76-4C08-8BBD-04164CB628C9}"
ProjectSection(ProjectDependencies) = postProject
{0CF235BD-2DA0-407E-90EE-C467E8BBC714} = {0CF235BD-2DA0-407E-90EE-C467E8BBC714}
EndProjectSection

View File

@@ -19,6 +19,10 @@ pr:
name: 0.0.$(Date:yyMM).$(Date:dd)$(Rev:rr)
jobs:
- template: ./templates/build-console-audit-job.yml
parameters:
platform: x64
- template: ./templates/build-console-ci.yml
parameters:
platform: x64

View File

@@ -16,6 +16,10 @@ variables:
name: 'Terminal_$(date:yyMM).$(date:dd)$(rev:rrr)'
jobs:
- template: ./templates/build-console-audit-job.yml
parameters:
platform: x64
- template: ./templates/build-console-int.yml
parameters:
platform: x64

View File

@@ -0,0 +1,53 @@
parameters:
platform: ''
additionalBuildArguments: ''
jobs:
- job: Build${{ parameters.platform }}AuditMode
displayName: Static Analysis Build ${{ parameters.platform }}
variables:
BuildConfiguration: AuditMode
BuildPlatform: ${{ parameters.platform }}
pool: { vmImage: vs2017-win2016 }
steps:
- checkout: self
submodules: true
clean: true
- task: NuGetToolInstaller@0
displayName: Ensure NuGet 4.8.1
inputs:
versionSpec: 4.8.1
# In the Microsoft Azure DevOps tenant, NuGetCommand is ambiguous.
# This should be `task: NuGetCommand@2`
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: Restore NuGet packages
inputs:
command: restore
feedsToUse: config
configPath: NuGet.config
restoreSolution: OpenConsole.sln
restoreDirectory: '$(Build.SourcesDirectory)\packages'
- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: 'NuGet restore packages for CI'
inputs:
command: restore
restoreSolution: build/.nuget/packages.config
feedsToUse: config
externalFeedCredentials: 'TAEF NuGet Feed'
nugetConfigPath: build/config/NuGet.config
restoreDirectory: '$(Build.SourcesDirectory)/packages'
- task: VSBuild@1
displayName: 'Build solution **\OpenConsole.sln'
inputs:
solution: '**\OpenConsole.sln'
vsVersion: 15.0
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
msbuildArgs: ${{ parameters.additionalBuildArguments }}
clean: true
maximumCpuCount: true

View File

@@ -4,8 +4,8 @@ parameters:
additionalBuildArguments: ''
jobs:
- job: Build${{ parameters.platform }}
displayName: Build ${{ parameters.platform }}
- job: Build${{ parameters.platform }}${{ parameters.configuration }}
displayName: Build ${{ parameters.platform }} ${{ parameters.configuration }}
variables:
BuildConfiguration: ${{ parameters.configuration }}
BuildPlatform: ${{ parameters.platform }}

View File

@@ -4,8 +4,8 @@ parameters:
additionalBuildArguments: ''
jobs:
- job: Build${{ parameters.platform }}
displayName: Build ${{ parameters.platform }}
- job: Build${{ parameters.platform }}${{ parameters.configuration }}
displayName: Build ${{ parameters.platform }} ${{ parameters.configuration }}
variables:
BuildConfiguration: ${{ parameters.configuration }}
BuildPlatform: ${{ parameters.platform }}

View File

@@ -6,16 +6,18 @@ jobs:
displayName: Sign and Deploy for ${{ parameters.configuration }}
dependsOn:
- Buildx64
- Buildx86
- Buildarm64
- Buildx64AuditMode
- Buildx64Release
- Buildx86Release
- Buildarm64Release
condition: |
and
(
in(dependencies.Buildx64.result, 'Succeeded', 'SucceededWithIssues', 'Skipped'),
in(dependencies.Buildx86.result, 'Succeeded', 'SucceededWithIssues', 'Skipped'),
in(dependencies.Buildarm64.result, 'Succeeded', 'SucceededWithIssues', 'Skipped')
)
in(dependencies.Buildx64AuditMode.result, 'Succeeded', 'SucceededWithIssues', 'Skipped'),
in(dependencies.Buildx64Release.result, 'Succeeded', 'SucceededWithIssues', 'Skipped'),
in(dependencies.Buildx86Release.result, 'Succeeded', 'SucceededWithIssues', 'Skipped'),
in(dependencies.Buildarm64Release.result, 'Succeeded', 'SucceededWithIssues', 'Skipped')
)
variables:
BuildConfiguration: ${{ parameters.configuration }}

View File

@@ -586,6 +586,8 @@ typedef struct _CONSOLE_STATE_INFO {
COLORREF DefaultForeground;
COLORREF DefaultBackground;
BOOL TerminalScrolling;
LPWSTR VersionString;
/* END V2 CONSOLE_STATE_INFO */
} CONSOLE_STATE_INFO, *PCONSOLE_STATE_INFO;

View File

@@ -1,5 +1,5 @@
// EchoCon.cpp : Entry point for the EchoCon Pseudo-Consle sample application.
// Copyright © 2018, Microsoft
// EchoCon.cpp : Entry point for the EchoCon Pseudo-Console sample application.
// Copyright © 2018, Microsoft
#include "stdafx.h"
#include <Windows.h>

View File

@@ -1,4 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Console Rules" Description="These rules enforce static analysis on console code." ToolsVersion="15.0">
<Include Path="cppcorecheckrules.ruleset" Action="Default" />
<Rules AnalyzerId="Microsoft.Analyzers.NativeCodeAnalysis" RuleNamespace="Microsoft.Rules.Native">
<Rule Id="C6001" Action="Error" />
<Rule Id="C6011" Action="Error" />
</Rules>
</RuleSet>

View File

@@ -21,7 +21,6 @@ Abstract:
#include "LibraryIncludes.h"
#pragma warning(push)
#pragma warning(disable: ALL_CPPCORECHECK_WARNINGS)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#endif

View File

@@ -21,8 +21,8 @@
<ProjectGuid>{531C23E7-4B76-4C08-8BBD-04164CB628C9}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>TextBufferUnitTests</RootNamespace>
<ProjectName>TextBuffer.UnitTests</ProjectName>
<TargetName>TextBuffer.UnitTests</TargetName>
<ProjectName>TextBuffer.Unit.Tests</ProjectName>
<TargetName>TextBuffer.Unit.Tests</TargetName>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>

View File

@@ -12,6 +12,7 @@
using namespace winrt::Windows::ApplicationModel::DataTransfer;
using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::UI::Text;
using namespace winrt::Windows::UI::Core;
using namespace winrt::Windows::System;
using namespace winrt::Microsoft::Terminal;
@@ -211,7 +212,7 @@ namespace winrt::TerminalApp::implementation
_root.Children().Append(dialog);
// Display the dialog.
Controls::ContentDialogResult result = await dialog.ShowAsync(Controls::ContentDialogPlacement::Popup);
Controls::ContentDialogResult result = co_await dialog.ShowAsync(Controls::ContentDialogPlacement::Popup);
// After the dialog is dismissed, the dialog lock (held by `lock`) will
// be released so another can be shown.
@@ -285,6 +286,7 @@ namespace winrt::TerminalApp::implementation
auto newTabFlyout = Controls::MenuFlyout{};
auto keyBindings = _settings->GetKeybindings();
const GUID defaultProfileGuid = _settings->GlobalSettings().GetDefaultProfile();
for (int profileIndex = 0; profileIndex < _settings->GetProfiles().size(); profileIndex++)
{
const auto& profile = _settings->GetProfiles()[profileIndex];
@@ -295,12 +297,12 @@ namespace winrt::TerminalApp::implementation
{
// enum value for ShortcutAction::NewTabProfileX; 0==NewTabProfile0
auto profileKeyChord = keyBindings.GetKeyBinding(static_cast<ShortcutAction>(profileIndex + static_cast<int>(ShortcutAction::NewTabProfile0)));
// make sure we find one to display
if (profileKeyChord)
{
_SetAcceleratorForMenuItem(profileMenuItem, profileKeyChord);
}
}
}
auto profileName = profile.GetName();
@@ -314,6 +316,12 @@ namespace winrt::TerminalApp::implementation
profileMenuItem.Icon(_GetIconFromProfile(profile));
}
if (profile.GetGuid() == defaultProfileGuid)
{
// Contrast the default profile with others in font weight.
profileMenuItem.FontWeight(FontWeights::Bold());
}
profileMenuItem.Click([this, profileIndex](auto&&, auto&&){
this->_OpenNewTab({ profileIndex });
});

View File

@@ -8,8 +8,6 @@
#include "App.g.h"
#include "../../cascadia/inc/cppwinrt_utils.h"
#include <wil/filesystem.h>
#include <winrt/Microsoft.Terminal.TerminalControl.h>
#include <winrt/Microsoft.UI.Xaml.Controls.h>

View File

@@ -6,8 +6,6 @@
#include "CascadiaSettings.h"
#include "../../types/inc/utils.hpp"
#include <appmodel.h>
#include <wil/com.h>
#include <wil/filesystem.h>
#include <shlobj.h>
using namespace ::TerminalApp;

View File

@@ -12,10 +12,10 @@ using namespace winrt::TerminalApp;
using namespace winrt::Windows::Data::Json;
using namespace ::Microsoft::Console;
static constexpr std::wstring_view NAME_KEY{ L"name" };
static constexpr std::wstring_view GUID_KEY{ L"guid" };
static constexpr std::wstring_view COLORSCHEME_KEY{ L"colorscheme" };
static constexpr std::wstring_view COLORSCHEME_KEY{ L"colorScheme" };
static constexpr std::wstring_view COLORSCHEME_KEY_OLD{ L"colorscheme" };
static constexpr std::wstring_view FOREGROUND_KEY{ L"foreground" };
static constexpr std::wstring_view BACKGROUND_KEY{ L"background" };
@@ -36,6 +36,9 @@ static constexpr std::wstring_view CLOSEONEXIT_KEY{ L"closeOnExit" };
static constexpr std::wstring_view PADDING_KEY{ L"padding" };
static constexpr std::wstring_view STARTINGDIRECTORY_KEY{ L"startingDirectory" };
static constexpr std::wstring_view ICON_KEY{ L"icon" };
static constexpr std::wstring_view BACKGROUNDIMAGE_KEY{ L"backgroundImage" };
static constexpr std::wstring_view BACKGROUNDIMAGEOPACITY_KEY{ L"backgroundImageOpacity" };
static constexpr std::wstring_view BACKGROUNDIMAGESTRETCHMODE_KEY{ L"backgroundImageStretchMode" };
// Possible values for Scrollbar state
static constexpr std::wstring_view ALWAYS_VISIBLE{ L"visible" };
@@ -48,6 +51,12 @@ static constexpr std::wstring_view CURSORSHAPE_UNDERSCORE{ L"underscore" };
static constexpr std::wstring_view CURSORSHAPE_FILLEDBOX{ L"filledBox" };
static constexpr std::wstring_view CURSORSHAPE_EMPTYBOX{ L"emptyBox" };
// Possible values for Image Stretch Mode
static constexpr std::wstring_view IMAGESTRETCHMODE_NONE{ L"none" };
static constexpr std::wstring_view IMAGESTRETCHMODE_FILL{ L"fill" };
static constexpr std::wstring_view IMAGESTRETCHMODE_UNIFORM{ L"uniform" };
static constexpr std::wstring_view IMAGESTRETCHMODE_UNIFORMTOFILL{ L"uniformToFill" };
Profile::Profile() :
Profile(Utils::CreateGuid())
{
@@ -76,7 +85,10 @@ Profile::Profile(const winrt::guid& guid):
_scrollbarState{ },
_closeOnExit{ true },
_padding{ DEFAULT_PADDING },
_icon{ }
_icon{ },
_backgroundImage{ },
_backgroundImageOpacity{ },
_backgroundImageStretchMode{ }
{
}
@@ -113,7 +125,7 @@ const ColorScheme* _FindScheme(const std::vector<ColorScheme>& schemes,
// Method Description:
// - Create a TerminalSettings from this object. Apply our settings, as well as
// any colors from our colorscheme, if we have one.
// any colors from our color scheme, if we have one.
// Arguments:
// - schemes: a list of schemes to look for our color scheme in, if we have one.
// Return Value:
@@ -173,6 +185,21 @@ TerminalSettings Profile::CreateTerminalSettings(const std::vector<ColorScheme>&
terminalSettings.ScrollState(result);
}
if (_backgroundImage)
{
terminalSettings.BackgroundImage(_backgroundImage.value());
}
if (_backgroundImageOpacity)
{
terminalSettings.BackgroundImageOpacity(_backgroundImageOpacity.value());
}
if (_backgroundImageStretchMode)
{
terminalSettings.BackgroundImageStretchMode(_backgroundImageStretchMode.value());
}
return terminalSettings;
}
@@ -274,6 +301,25 @@ JsonObject Profile::ToJson() const
jsonObject.Insert(ICON_KEY, icon);
}
if (_backgroundImage)
{
const auto backgroundImage = JsonValue::CreateStringValue(_backgroundImage.value());
jsonObject.Insert(BACKGROUNDIMAGE_KEY, backgroundImage);
}
if (_backgroundImageOpacity)
{
const auto opacity = JsonValue::CreateNumberValue(_backgroundImageOpacity.value());
jsonObject.Insert(BACKGROUNDIMAGEOPACITY_KEY, opacity);
}
if (_backgroundImageStretchMode)
{
const auto imageStretchMode = JsonValue::CreateStringValue(
SerializeImageStretchMode(_backgroundImageStretchMode.value()));
jsonObject.Insert(BACKGROUNDIMAGESTRETCHMODE_KEY, imageStretchMode);
}
return jsonObject;
}
@@ -319,23 +365,25 @@ Profile Profile::FromJson(winrt::Windows::Data::Json::JsonObject json)
{
result._schemeName = json.GetNamedString(COLORSCHEME_KEY);
}
else
else if (json.HasKey(COLORSCHEME_KEY_OLD))
{
if (json.HasKey(COLORTABLE_KEY))
// TODO: deprecate old settings key
result._schemeName = json.GetNamedString(COLORSCHEME_KEY_OLD);
}
else if (json.HasKey(COLORTABLE_KEY))
{
const auto table = json.GetNamedArray(COLORTABLE_KEY);
int i = 0;
for (auto v : table)
{
const auto table = json.GetNamedArray(COLORTABLE_KEY);
int i = 0;
for (auto v : table)
if (v.ValueType() == JsonValueType::String)
{
if (v.ValueType() == JsonValueType::String)
{
const auto str = v.GetString();
// TODO: MSFT:20737698 - if this fails, display an approriate error
const auto color = Utils::ColorFromHexString(str.c_str());
result._colorTable[i] = color;
}
i++;
const auto str = v.GetString();
// TODO: MSFT:20737698 - if this fails, display an approriate error
const auto color = Utils::ColorFromHexString(str.c_str());
result._colorTable[i] = color;
}
i++;
}
}
if (json.HasKey(HISTORYSIZE_KEY))
@@ -405,6 +453,19 @@ Profile Profile::FromJson(winrt::Windows::Data::Json::JsonObject json)
{
result._icon = json.GetNamedString(ICON_KEY);
}
if (json.HasKey(BACKGROUNDIMAGE_KEY))
{
result._backgroundImage = json.GetNamedString(BACKGROUNDIMAGE_KEY);
}
if (json.HasKey(BACKGROUNDIMAGEOPACITY_KEY))
{
result._backgroundImageOpacity = json.GetNamedNumber(BACKGROUNDIMAGEOPACITY_KEY);
}
if (json.HasKey(BACKGROUNDIMAGESTRETCHMODE_KEY))
{
const auto stretchMode = json.GetNamedString(BACKGROUNDIMAGESTRETCHMODE_KEY);
result._backgroundImageStretchMode = ParseImageStretchMode(stretchMode.c_str());
}
return result;
}
@@ -551,6 +612,58 @@ ScrollbarState Profile::ParseScrollbarState(const std::wstring& scrollbarState)
}
}
// Method Description:
// - Helper function for converting a user-specified image stretch mode
// to the appropriate enum value
// Arguments:
// - The value from the profiles.json file
// Return Value:
// - The corresponding enum value which maps to the string provided by the user
winrt::Windows::UI::Xaml::Media::Stretch Profile::ParseImageStretchMode(const std::wstring& imageStretchMode)
{
if (imageStretchMode == IMAGESTRETCHMODE_NONE)
{
return winrt::Windows::UI::Xaml::Media::Stretch::None;
}
else if (imageStretchMode == IMAGESTRETCHMODE_FILL)
{
return winrt::Windows::UI::Xaml::Media::Stretch::Fill;
}
else if (imageStretchMode == IMAGESTRETCHMODE_UNIFORM)
{
return winrt::Windows::UI::Xaml::Media::Stretch::Uniform;
}
else // Fall through to default behavior
{
return winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill;
}
}
// Method Description:
// - Helper function for converting an ImageStretchMode to the
// correct string value.
// Arguments:
// - imageStretchMode: The enum value to convert to a string.
// Return Value:
// - The string value for the given ImageStretchMode
std::wstring_view Profile::SerializeImageStretchMode(const winrt::Windows::UI::Xaml::Media::Stretch imageStretchMode)
{
switch (imageStretchMode)
{
case winrt::Windows::UI::Xaml::Media::Stretch::None:
return IMAGESTRETCHMODE_NONE;
case winrt::Windows::UI::Xaml::Media::Stretch::Fill:
return IMAGESTRETCHMODE_FILL;
case winrt::Windows::UI::Xaml::Media::Stretch::Uniform:
return IMAGESTRETCHMODE_UNIFORM;
default:
case winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill:
return IMAGESTRETCHMODE_UNIFORMTOFILL;
}
}
// Method Description:
// - Helper function for converting a user-specified cursor style corresponding
// CursorStyle enum value

View File

@@ -59,6 +59,8 @@ private:
static std::wstring EvaluateStartingDirectory(const std::wstring& directory);
static winrt::Microsoft::Terminal::Settings::ScrollbarState ParseScrollbarState(const std::wstring& scrollbarState);
static winrt::Windows::UI::Xaml::Media::Stretch ParseImageStretchMode(const std::wstring& imageStretchMode);
static std::wstring_view SerializeImageStretchMode(const winrt::Windows::UI::Xaml::Media::Stretch imageStretchMode);
static winrt::Microsoft::Terminal::Settings::CursorStyle _ParseCursorShape(const std::wstring& cursorShapeString);
static std::wstring_view _SerializeCursorStyle(const winrt::Microsoft::Terminal::Settings::CursorStyle cursorShape);
@@ -84,6 +86,10 @@ private:
double _acrylicTransparency;
bool _useAcrylic;
std::optional<std::wstring> _backgroundImage;
std::optional<double> _backgroundImageOpacity;
std::optional<winrt::Windows::UI::Xaml::Media::Stretch> _backgroundImageStretchMode;
std::optional<std::wstring> _scrollbarState;
bool _closeOnExit;
std::wstring _padding;

View File

@@ -29,6 +29,7 @@
#include <winrt/Windows.Data.Json.h>
#include <winrt/windows.ui.core.h>
#include <winrt/Windows.ui.input.h>
#include <winrt/Windows.UI.Text.h>
#include <winrt/Windows.UI.Xaml.Controls.h>
#include <winrt/Windows.UI.Xaml.Controls.Primitives.h>
#include <winrt/Windows.ui.xaml.media.h>

View File

@@ -14,4 +14,3 @@
#include "winrt/Windows.Foundation.h"
#include <Windows.h>
#include <wil/result.h>

View File

@@ -158,8 +158,9 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// - Style our UI elements based on the values in our _settings, and set up
// other control-specific settings. This method will be called whenever
// the settings are reloaded.
// * Sets up the background of the control with the provided BG color,
// acrylic or not, and if acrylic, then uses the opacity from _settings.
// * Calls _InitializeBackgroundBrush to set up the Xaml brush responsible
// for the control's background
// * Calls _BackgroundColorChanged to style the background of the control
// - Core settings will be passed to the terminal in _InitializeTerminal
// Arguments:
// - <none>
@@ -167,37 +168,10 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// - <none>
void TermControl::_ApplyUISettings()
{
winrt::Windows::UI::Color bgColor{};
_InitializeBackgroundBrush();
uint32_t bg = _settings.DefaultBackground();
const auto R = GetRValue(bg);
const auto G = GetGValue(bg);
const auto B = GetBValue(bg);
bgColor.R = R;
bgColor.G = G;
bgColor.B = B;
bgColor.A = 255;
if (_settings.UseAcrylic())
{
Media::AcrylicBrush acrylic{};
acrylic.BackgroundSource(Media::AcrylicBackgroundSource::HostBackdrop);
acrylic.FallbackColor(bgColor);
acrylic.TintColor(bgColor);
acrylic.TintOpacity(_settings.TintOpacity());
_root.Background(acrylic);
// If we're acrylic, we want to make sure that the default BG color
// is transparent, so we can see the acrylic effect on text with the
// default BG color.
_settings.DefaultBackground(ARGB(0, R, G, B));
}
else
{
Media::SolidColorBrush solidColor{};
solidColor.Color(bgColor);
_root.Background(solidColor);
_settings.DefaultBackground(RGB(R, G, B));
}
_BackgroundColorChanged(bg);
// Apply padding to the root Grid
auto thickness = _ParseThicknessFromPadding(_settings.Padding());
@@ -216,6 +190,147 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
_desiredFont = { _actualFont };
}
// Method Description:
// - Set up the brush used to display the control's background.
// - Respects the settings for acrylic, background image and opacity from
// _settings.
// * Prioritizes the acrylic background if chosen, respecting acrylicOpacity
// from _settings.
// * If acrylic is not enabled and a backgroundImage is present, it is used,
// respecting the opacity and stretch mode settings from _settings.
// * Falls back to a solid color background from _settings if acrylic is not
// enabled and no background image is present.
// - Avoids image flickering and acrylic brush redraw if settings are changed
// but the appropriate brush is still in place.
// - Does not apply background color; _BackgroundColorChanged must be called
// to do so.
// Arguments:
// - <none>
// Return Value:
// - <none>
void TermControl::_InitializeBackgroundBrush()
{
if (_settings.UseAcrylic())
{
// See if we've already got an acrylic background brush
// to avoid the flicker when setting up a new one
auto acrylic = _root.Background().try_as<Media::AcrylicBrush>();
// Instantiate a brush if there's not already one there
if (acrylic == nullptr)
{
acrylic = Media::AcrylicBrush{};
acrylic.BackgroundSource(Media::AcrylicBackgroundSource::HostBackdrop);
}
// Apply brush settings
acrylic.TintOpacity(_settings.TintOpacity());
// Apply brush to control if it's not already there
if (_root.Background() != acrylic)
{
_root.Background(acrylic);
}
}
else if (!_settings.BackgroundImage().empty())
{
Windows::Foundation::Uri imageUri{ _settings.BackgroundImage() };
// Check if the existing brush is an image brush, and if not
// construct a new one
auto brush = _root.Background().try_as<Media::ImageBrush>();
if (brush == nullptr)
{
brush = Media::ImageBrush{};
}
// Check if the image brush is already pointing to the image
// in the modified settings; if it isn't (or isn't there),
// set a new image source for the brush
auto imageSource = brush.ImageSource().try_as<Media::Imaging::BitmapImage>();
if (imageSource == nullptr || imageSource.UriSource() == nullptr
|| imageSource.UriSource().RawUri() != imageUri.RawUri())
{
// Note that BitmapImage handles the image load asynchronously,
// which is especially important since the image
// may well be both large and somewhere out on the
// internet.
Media::Imaging::BitmapImage image(imageUri);
brush.ImageSource(image);
}
// Apply stretch and opacity settings
brush.Stretch(_settings.BackgroundImageStretchMode());
brush.Opacity(_settings.BackgroundImageOpacity());
// Apply brush if it isn't already there
if (_root.Background() != brush)
{
_root.Background(brush);
}
}
else
{
Media::SolidColorBrush solidColor{};
_root.Background(solidColor);
}
}
// Method Description:
// - Style the background of the control with the provided background color
// Arguments:
// - color: The background color to use as a uint32 (aka DWORD COLORREF)
// Return Value:
// - <none>
void TermControl::_BackgroundColorChanged(const uint32_t color)
{
_root.Dispatcher().RunAsync(CoreDispatcherPriority::Normal, [this, color]() {
const auto R = GetRValue(color);
const auto G = GetGValue(color);
const auto B = GetBValue(color);
winrt::Windows::UI::Color bgColor{};
bgColor.R = R;
bgColor.G = G;
bgColor.B = B;
bgColor.A = 255;
if (_settings.UseAcrylic())
{
if (auto acrylic = _root.Background().try_as<Media::AcrylicBrush>())
{
acrylic.FallbackColor(bgColor);
acrylic.TintColor(bgColor);
}
// If we're acrylic, we want to make sure that the default BG color
// is transparent, so we can see the acrylic effect on text with the
// default BG color.
_settings.DefaultBackground(ARGB(0, R, G, B));
}
else if (!_settings.BackgroundImage().empty())
{
// This currently applies no changes to the image background
// brush itself.
// Set the default background as transparent to prevent the
// DX layer from overwriting the background image
_settings.DefaultBackground(ARGB(0, R, G, B));
}
else
{
if (auto solidColor = _root.Background().try_as<Media::SolidColorBrush>())
{
solidColor.Color(bgColor);
}
_settings.DefaultBackground(RGB(R, G, B));
}
});
}
// Method Description:
// - Create a connection based on the values in our settings object.
// * Gets the commandline and working directory out of the _settings and
@@ -283,13 +398,19 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
_terminal = std::make_unique<::Microsoft::Terminal::Core::Terminal>();
// First create the render thread.
// Then stash a local pointer to the render thread so we can initialize it and enable it
// to paint itself *after* we hand off its ownership to the renderer.
// We split up construction and initialization of the render thread object this way
// because the renderer and render thread have circular references to each other.
auto renderThread = std::make_unique<::Microsoft::Console::Render::RenderThread>();
// Stash a local pointer to the render thread, so we can enable it after
// we hand off ownership to the renderer.
auto* const localPointerToThread = renderThread.get();
// Now create the renderer and initialize the render thread.
_renderer = std::make_unique<::Microsoft::Console::Render::Renderer>(_terminal.get(), nullptr, 0, std::move(renderThread));
::Microsoft::Console::Render::IRenderTarget& renderTarget = *_renderer;
THROW_IF_FAILED(localPointerToThread->Initialize(_renderer.get()));
// Set up the DX Engine
auto dxEngine = std::make_unique<::Microsoft::Console::Render::DxEngine>();
_renderer->AddRenderEngine(dxEngine.get());
@@ -336,8 +457,6 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
auto inputFn = std::bind(&TermControl::_SendInputToConnection, this, std::placeholders::_1);
_terminal->SetWriteInputCallback(inputFn);
THROW_IF_FAILED(localPointerToThread->Initialize(_renderer.get()));
auto chain = _renderEngine->GetSwapChain();
_swapChainPanel.Dispatcher().RunAsync(CoreDispatcherPriority::High, [this, chain]()
{
@@ -406,6 +525,9 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
auto pfnTitleChanged = std::bind(&TermControl::_TerminalTitleChanged, this, std::placeholders::_1);
_terminal->SetTitleChangedCallback(pfnTitleChanged);
auto pfnBackgroundColorChanged = std::bind(&TermControl::_BackgroundColorChanged, this, std::placeholders::_1);
_terminal->SetBackgroundCallback(pfnBackgroundColorChanged);
auto pfnScrollPositionChanged = std::bind(&TermControl::_TerminalScrollPositionChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
_terminal->SetScrollPositionChangedCallback(pfnScrollPositionChanged);
@@ -417,6 +539,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
_cursorTimer = std::make_optional(DispatcherTimer());
_cursorTimer.value().Interval(std::chrono::milliseconds(blinkTime));
_cursorTimer.value().Tick({ this, &TermControl::_BlinkCursor });
_cursorTimer.value().Start();
}
else
{
@@ -535,6 +658,14 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
}
}
// Manually prevent keyboard navigation with tab. We want to send tab to
// the terminal, and we don't want to be able to escape focus of the
// control with tab.
if (e.OriginalKey() == VirtualKey::Tab)
{
handled = true;
}
e.Handled(handled);
}
@@ -830,7 +961,9 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
_focused = true;
if (_cursorTimer.has_value())
{
_cursorTimer.value().Start();
}
}
// Method Description:

View File

@@ -95,6 +95,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
void _Create();
void _ApplyUISettings();
void _InitializeBackgroundBrush();
void _BackgroundColorChanged(const uint32_t color);
void _ApplyConnectionSettings();
void _InitializeTerminal();
void _UpdateFont();

View File

@@ -26,6 +26,7 @@
#include <winrt/Windows.UI.Xaml.Controls.h>
#include <winrt/Windows.UI.Xaml.Controls.Primitives.h>
#include <winrt/Windows.ui.xaml.media.h>
#include <winrt/Windows.ui.xaml.media.imaging.h>
#include <winrt/Windows.ui.xaml.input.h>
#include <windows.ui.xaml.media.dxinterop.h>

View File

@@ -31,5 +31,8 @@ namespace Microsoft::Terminal::Core
virtual bool SetColorTableEntry(const size_t tableIndex, const DWORD dwColor) = 0;
virtual bool SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle) = 0;
virtual bool SetDefaultForeground(const DWORD dwColor) = 0;
virtual bool SetDefaultBackground(const DWORD dwColor) = 0;
};
}

View File

@@ -77,7 +77,7 @@ void Terminal::Create(COORD viewportSize, SHORT scrollbackLines, IRenderTarget&
}
// Method Description:
// - Initializes the Temrinal from the given set of settings.
// - Initializes the Terminal from the given set of settings.
// Arguments:
// - settings: the set of CoreSettings we need to use to initialize the terminal
// - renderTarget: A render target the terminal can use for paint invalidation.
@@ -442,6 +442,15 @@ void Terminal::SetScrollPositionChangedCallback(std::function<void(const int, co
_pfnScrollPositionChanged = pfn;
}
// Method Description:
// - Allows setting a callback for when the background color is changed
// Arguments:
// - pfn: a function callback that takes a uint32 (DWORD COLORREF) color in the format 0x00BBGGRR
void Terminal::SetBackgroundCallback(std::function<void(const uint32_t)> pfn) noexcept
{
_pfnBackgroundColorChanged = pfn;
}
// Method Description:
// - Checks if selection is active
// Return Value:

View File

@@ -70,8 +70,10 @@ public:
COORD GetCursorPosition() override;
bool EraseCharacters(const unsigned int numChars) override;
bool SetWindowTitle(std::wstring_view title) override;
bool SetColorTableEntry(const size_t tableIndex, const DWORD dwColor) override;
bool SetColorTableEntry(const size_t tableIndex, const COLORREF dwColor) override;
bool SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle) override;
bool SetDefaultForeground(const COLORREF dwColor) override;
bool SetDefaultBackground(const COLORREF dwColor) override;
#pragma endregion
#pragma region ITerminalInput
@@ -113,6 +115,7 @@ public:
void SetWriteInputCallback(std::function<void(std::wstring&)> pfn) noexcept;
void SetTitleChangedCallback(std::function<void(const std::wstring_view&)> pfn) noexcept;
void SetScrollPositionChangedCallback(std::function<void(const int, const int, const int)> pfn) noexcept;
void SetBackgroundCallback(std::function<void(const uint32_t)> pfn) noexcept;
void SetCursorVisible(const bool isVisible) noexcept;
bool IsCursorBlinkingAllowed() const noexcept;
@@ -131,6 +134,7 @@ public:
std::function<void(std::wstring&)> _pfnWriteInput;
std::function<void(const std::wstring_view&)> _pfnTitleChanged;
std::function<void(const int, const int, const int)> _pfnScrollPositionChanged;
std::function<void(const uint32_t)> _pfnBackgroundColorChanged;
std::unique_ptr<::Microsoft::Console::VirtualTerminal::StateMachine> _stateMachine;
std::unique_ptr<::Microsoft::Console::VirtualTerminal::TerminalInput> _terminalInput;

View File

@@ -157,7 +157,7 @@ bool Terminal::SetWindowTitle(std::wstring_view title)
// - dwColor: the new COLORREF to use as that color table value.
// Return Value:
// - true iff we successfully updated the color table entry.
bool Terminal::SetColorTableEntry(const size_t tableIndex, const DWORD dwColor)
bool Terminal::SetColorTableEntry(const size_t tableIndex, const COLORREF dwColor)
{
if (tableIndex > _colorTable.size())
{
@@ -219,3 +219,34 @@ bool Terminal::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle)
return true;
}
// Method Description:
// - Updates the default foreground color from a COLORREF, format 0x00BBGGRR.
// Arguments:
// - dwColor: the new COLORREF to use as the default foreground color
// Return Value:
// - true
bool Terminal::SetDefaultForeground(const COLORREF dwColor)
{
_defaultFg = dwColor;
// Repaint everything - the colors might have changed
_buffer->GetRenderTarget().TriggerRedrawAll();
return true;
}
// Method Description:
// - Updates the default background color from a COLORREF, format 0x00BBGGRR.
// Arguments:
// - dwColor: the new COLORREF to use as the default background color
// Return Value:
// - true
bool Terminal::SetDefaultBackground(const COLORREF dwColor)
{
_defaultBg = dwColor;
_pfnBackgroundColorChanged(dwColor);
// Repaint everything - the colors might have changed
_buffer->GetRenderTarget().TriggerRedrawAll();
return true;
}

View File

@@ -64,7 +64,7 @@ bool TerminalDispatch::SetWindowTitle(std::wstring_view title)
// - tableIndex: The VT color table index
// - dwColor: The new RGB color value to use.
// Return Value:
// True if handled successfully. False othewise.
// True if handled successfully. False otherwise.
bool TerminalDispatch::SetColorTableEntry(const size_t tableIndex,
const DWORD dwColor)
{
@@ -75,3 +75,25 @@ bool TerminalDispatch::SetCursorStyle(const DispatchTypes::CursorStyle cursorSty
{
return _terminalApi.SetCursorStyle(cursorStyle);
}
// Method Description:
// - Sets the default foreground color to a new value
// Arguments:
// - dwColor: The new RGB color value to use, in 0x00BBGGRR form
// Return Value:
// True if handled successfully. False otherwise.
bool TerminalDispatch::SetDefaultForeground(const DWORD dwColor)
{
return _terminalApi.SetDefaultForeground(dwColor);
}
// Method Description:
// - Sets the default background color to a new value
// Arguments:
// - dwColor: The new RGB color value to use, in 0x00BBGGRR form
// Return Value:
// True if handled successfully. False otherwise.
bool TerminalDispatch::SetDefaultBackground(const DWORD dwColor)
{
return _terminalApi.SetDefaultBackground(dwColor);
}

View File

@@ -27,6 +27,9 @@ public:
bool SetColorTableEntry(const size_t tableIndex, const DWORD dwColor) override;
bool SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle) override;
bool SetDefaultForeground(const DWORD dwColor) override;
bool SetDefaultBackground(const DWORD dwColor) override;
private:
::Microsoft::Terminal::Core::ITerminalApi& _terminalApi;

View File

@@ -34,5 +34,8 @@ namespace Microsoft.Terminal.Settings
String StartingDirectory;
String EnvironmentVariables;
String BackgroundImage;
Double BackgroundImageOpacity;
Windows.UI.Xaml.Media.Stretch BackgroundImageStretchMode;
};
}

View File

@@ -26,6 +26,9 @@ namespace winrt::Microsoft::Terminal::Settings::implementation
_padding{ DEFAULT_PADDING },
_fontFace{ DEFAULT_FONT_FACE },
_fontSize{ DEFAULT_FONT_SIZE },
_backgroundImage{},
_backgroundImageOpacity{ 1.0 },
_backgroundImageStretchMode{ winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill },
_keyBindings{ nullptr },
_scrollbarState{ ScrollbarState::Visible }
{
@@ -193,6 +196,36 @@ namespace winrt::Microsoft::Terminal::Settings::implementation
_fontSize = value;
}
void TerminalSettings::BackgroundImage(hstring const& value)
{
_backgroundImage = value;
}
hstring TerminalSettings::BackgroundImage()
{
return _backgroundImage;
}
void TerminalSettings::BackgroundImageOpacity(double value)
{
_backgroundImageOpacity = value;
}
double TerminalSettings::BackgroundImageOpacity()
{
return _backgroundImageOpacity;
}
winrt::Windows::UI::Xaml::Media::Stretch TerminalSettings::BackgroundImageStretchMode()
{
return _backgroundImageStretchMode;
}
void TerminalSettings::BackgroundImageStretchMode(winrt::Windows::UI::Xaml::Media::Stretch value)
{
_backgroundImageStretchMode = value;
}
Settings::IKeyBindings TerminalSettings::KeyBindings()
{
return _keyBindings;

View File

@@ -61,6 +61,13 @@ namespace winrt::Microsoft::Terminal::Settings::implementation
int32_t FontSize();
void FontSize(int32_t value);
hstring BackgroundImage();
void BackgroundImage(hstring const& value);
double BackgroundImageOpacity();
void BackgroundImageOpacity(double value);
winrt::Windows::UI::Xaml::Media::Stretch BackgroundImageStretchMode();
void BackgroundImageStretchMode(winrt::Windows::UI::Xaml::Media::Stretch value);
winrt::Microsoft::Terminal::Settings::IKeyBindings KeyBindings();
void KeyBindings(winrt::Microsoft::Terminal::Settings::IKeyBindings const& value);
@@ -94,6 +101,9 @@ namespace winrt::Microsoft::Terminal::Settings::implementation
hstring _fontFace;
int32_t _fontSize;
hstring _padding;
hstring _backgroundImage;
double _backgroundImageOpacity;
winrt::Windows::UI::Xaml::Media::Stretch _backgroundImageStretchMode;
hstring _commandline;
hstring _startingDir;
hstring _envVars;

View File

@@ -16,6 +16,7 @@ public:
return reinterpret_cast<T *>(GetWindowLongPtr(window, GWLP_USERDATA));
}
[[nodiscard]]
static LRESULT __stdcall WndProc(HWND const window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept
{
WINRT_ASSERT(window);
@@ -40,6 +41,7 @@ public:
return DefWindowProc(window, message, wparam, lparam);
}
[[nodiscard]]
virtual LRESULT MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept
{
switch (message) {
@@ -98,6 +100,7 @@ public:
}
// DPI Change handler. on WM_DPICHANGE resize the window
[[nodiscard]]
LRESULT HandleDpiChange(const HWND hWnd, const WPARAM wParam, const LPARAM lParam)
{
_inDpiChange = true;

View File

@@ -144,6 +144,7 @@ void IslandWindow::OnSize()
}
}
[[nodiscard]]
LRESULT IslandWindow::MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept
{
switch (message) {
@@ -162,6 +163,13 @@ LRESULT IslandWindow::MessageHandler(UINT const message, WPARAM const wparam, LP
return 0; // eat the message
}
}
case WM_MENUCHAR:
{
// GH#891: return this LRESULT here to prevent the app from making a
// bell when alt+key is pressed. A menu is active and the user presses a
// key that does not correspond to any mnemonic or accelerator key,
return MAKELRESULT(0, MNC_CLOSE);
}
}
// TODO: handle messages here...
@@ -173,7 +181,7 @@ LRESULT IslandWindow::MessageHandler(UINT const message, WPARAM const wparam, LP
// Arguments:
// - width: the new width of the window _in pixels_
// - height: the new height of the window _in pixels_
void IslandWindow::OnResize(const UINT width, const UINT height)
void IslandWindow::OnResize(const UINT /*width*/, const UINT /*height*/)
{
OnSize();
}

View File

@@ -16,6 +16,7 @@ public:
void Close();
virtual void OnSize();
[[nodiscard]]
virtual LRESULT MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept override;
void OnResize(const UINT width, const UINT height) override;
void OnMinimize() override;

View File

@@ -209,6 +209,7 @@ void NonClientIslandWindow::OnSize()
// NOTE:
// Largely taken from code on:
// https://docs.microsoft.com/en-us/windows/desktop/dwm/customframe
[[nodiscard]]
LRESULT NonClientIslandWindow::HitTestNCA(POINT ptMouse) const noexcept
{
// Get the window rectangle.
@@ -284,6 +285,7 @@ MARGINS NonClientIslandWindow::GetFrameMargins() const noexcept
// - <none>
// Return Value:
// - the HRESULT returned by DwmExtendFrameIntoClientArea.
[[nodiscard]]
HRESULT NonClientIslandWindow::_UpdateFrameMargins() const noexcept
{
// Get the size of the borders we want to use. The sides and bottom will
@@ -387,6 +389,7 @@ RECT NonClientIslandWindow::GetMaxWindowRectInPixels(const RECT * const prcSugge
// Return Value:
// - The return value is the result of the message processing and depends on the
// message sent.
[[nodiscard]]
LRESULT NonClientIslandWindow::MessageHandler(UINT const message,
WPARAM const wParam,
LPARAM const lParam) noexcept
@@ -489,7 +492,7 @@ void NonClientIslandWindow::_HandleActivateWindow()
// _titlebarUnscaledContentHeight is set with SetNonClientHeight by the app
// hosting us.
_UpdateFrameMargins();
THROW_IF_FAILED(_UpdateFrameMargins());
}
// Method Description:
@@ -633,7 +636,7 @@ bool NonClientIslandWindow::_HandleWindowPosChanging(WINDOWPOS* const windowPos)
_maximizedMargins.cyBottomHeight = -offset;
_isMaximized = true;
_UpdateFrameMargins();
THROW_IF_FAILED(_UpdateFrameMargins());
}
}
else
@@ -647,7 +650,7 @@ bool NonClientIslandWindow::_HandleWindowPosChanging(WINDOWPOS* const windowPos)
// keep this here _in general_ for dragging across DPI boundaries.
if (!_isMaximized)
{
_UpdateFrameMargins();
THROW_IF_FAILED(_UpdateFrameMargins());
}
_isMaximized = false;

View File

@@ -31,6 +31,7 @@ public:
virtual void OnSize() override;
[[nodiscard]]
virtual LRESULT MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept override;
void SetNonClientContent(winrt::Windows::UI::Xaml::UIElement content);
@@ -62,7 +63,10 @@ private:
MARGINS _maximizedMargins;
bool _isMaximized;
[[nodiscard]]
LRESULT HitTestNCA(POINT ptMouse) const noexcept;
[[nodiscard]]
HRESULT _UpdateFrameMargins() const noexcept;
void _HandleActivateWindow();

View File

@@ -2,7 +2,10 @@
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<maxversiontested Id="10.0.18295.0"/>
<!-- Windows 10 1903 -->
<!-- See https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/xaml-islands -->
<maxversiontested Id="10.0.18362.0"/>
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>

View File

@@ -6,7 +6,7 @@
</ClCompile>
<Link>
<ProgramDatabaseFile>$(OutDir)$(TargetName)FullPDB.pdb</ProgramDatabaseFile>
<AdditionalDependencies>onecore_apiset.lib;dwrite.lib;dxgi.lib;d2d1.lib;d3d11.lib;shcore.lib;uxtheme.lib;dwmapi.lib;winmm.lib;pathcch.lib;propsys.lib;uiautomationcore.lib;Shlwapi.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>onecore_apiset.lib;version.lib;dwrite.lib;dxgi.lib;d2d1.lib;d3d11.lib;shcore.lib;uxtheme.lib;dwmapi.lib;winmm.lib;pathcch.lib;propsys.lib;uiautomationcore.lib;Shlwapi.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
<!--
There's a property that dictates which libraries are linked by default: MinimalCoreWin.
When it's enabled, only a sparing few libraries are injected into Link.AdditionalDependencies.

View File

@@ -25,4 +25,9 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<!-- Exclude our dependencies from static analysis. CAExcludePath can only be
set after we've imported Microsoft.Cpp.targets -->
<PropertyGroup>
<CAExcludePath>$(SolutionDir)\dep\;$(CAExcludePath)</CAExcludePath>
</PropertyGroup>
</Project>

View File

@@ -113,8 +113,8 @@
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<!-- For our Audit mode -->
<PropertyGroup Condition="'$(Configuration)'=='AuditMode'">
<!-- For our Audit mode -->
<PropertyGroup Condition="'$(Configuration)'=='AuditMode'">
<CodeAnalysisRuleSet>$(SolutionDir)\src\StaticAnalysis.ruleset</CodeAnalysisRuleSet>
<EnableCppCoreCheck>true</EnableCppCoreCheck>
<RunCodeAnalysis>true</RunCodeAnalysis>

View File

@@ -345,7 +345,7 @@ void CommandListPopup::_drawList()
WriteCoord.Y += 1i16;
}
auto& api = ServiceLocator::LocateGlobals().api;
auto& api = Microsoft::Console::Interactivity::ServiceLocator::LocateGlobals().api;
WriteCoord.Y = _region.Top + 1i16;
SHORT i = std::max(gsl::narrow<SHORT>(_bottomIndex - Height() + 1), 0i16);
@@ -515,7 +515,7 @@ void CommandListPopup::_update(const SHORT originalDelta, const bool wrap)
}
// Routine Description:
// - Adjusts the highligted line in a list of commands
// - Adjusts the highlighted line in a list of commands
// Arguments:
// - OldCurrentCommand - The previous command highlighted
// - NewCurrentCommand - The new command to be highlighted.

View File

@@ -102,7 +102,7 @@ void ConsoleArguments::s_ConsumeArg(_Inout_ std::vector<std::wstring>& args, _In
// args: A collection of wstrings representing command-line arguments
// index: the index of the argument of which to get the value for. The value
// should be at (index+1). index will be decremented by one on success.
// pSetting: recieves the string at index+1
// pSetting: receives the string at index+1
// Return Value:
// S_OK if we parsed the string successfully, otherwise E_INVALIDARG indicating
// failure.
@@ -132,7 +132,7 @@ HRESULT ConsoleArguments::s_GetArgumentValue(_Inout_ std::vector<std::wstring>&
// args: A collection of wstrings representing command-line arguments
// index: the index of the argument of which to get the value for. The value
// should be at (index+1). index will be decremented by one on success.
// pSetting: recieves the string at index+1
// pSetting: receives the string at index+1
// Return Value:
// S_OK if we parsed the string successfully, otherwise E_INVALIDARG indicating
// failure.
@@ -163,7 +163,7 @@ HRESULT ConsoleArguments::s_HandleFeatureValue(_Inout_ std::vector<std::wstring>
// args: A collection of wstrings representing command-line arguments
// index: the index of the argument of which to get the value for. The value
// should be at (index+1). index will be decremented by one on success.
// pSetting: recieves the short at index+1
// pSetting: receives the short at index+1
// Return Value:
// S_OK if we parsed the short successfully, otherwise E_INVALIDARG indicating
// failure. This could be the case for non-numeric arguments, or for >SHORT_MAX args.
@@ -420,7 +420,7 @@ HRESULT ConsoleArguments::ParseCommandline()
}
// TODO: handle the rest of the possible params (MSFT:13271366, MSFT:13631640)
// TODO: handle invalid args
// eg "conhost --foo bar" should not make the clientCommandline "--foo bar"
// e.g. "conhost --foo bar" should not make the clientCommandline "--foo bar"
else
{
// If we encounter something that doesn't match one of our other
@@ -547,7 +547,7 @@ bool ConsoleArguments::GetInheritCursor() const
// Method Description:
// - Tell us to use a different size than the one parsed as the size of the
// console. This is called by the PtySignalInputThread when it recieves a
// console. This is called by the PtySignalInputThread when it receives a
// resize before the first client has connected. Because there's no client,
// there's also no buffer yet, so it has nothing to resize.
// However, we shouldn't just discard that first resize message. Instead,

View File

@@ -32,7 +32,6 @@ public:
[[nodiscard]]
HRESULT ParseCommandline();
bool IsUsingVtPipe() const;
bool HasVtHandles() const;
bool InConptyMode() const noexcept;
bool IsHeadless() const;

View File

@@ -5,7 +5,9 @@
#include "../host/scrolling.hpp"
#include "../interactivity/inc/ServiceLocator.hpp"
#pragma hdrstop
using namespace Microsoft::Console;
using namespace Microsoft::Console::Interactivity;
CursorBlinker::CursorBlinker() :
_hCaretBlinkTimer(INVALID_HANDLE_VALUE),

View File

@@ -20,6 +20,7 @@ struct PTY_SIGNAL_RESIZE
using namespace Microsoft::Console;
using namespace Microsoft::Console::Interactivity;
using namespace Microsoft::Console::VirtualTerminal;
// Constructor Description:
// - Creates the PTY Signal Input Thread.

View File

@@ -5,6 +5,7 @@
#include "ScreenBufferRenderTarget.hpp"
#include "../interactivity/inc/ServiceLocator.hpp"
using Microsoft::Console::Interactivity::ServiceLocator;
ScreenBufferRenderTarget::ScreenBufferRenderTarget(SCREEN_INFORMATION& owner) :
_owner{ owner }
{
@@ -12,6 +13,7 @@ ScreenBufferRenderTarget::ScreenBufferRenderTarget(SCREEN_INFORMATION& owner) :
void ScreenBufferRenderTarget::TriggerRedraw(const Microsoft::Console::Types::Viewport& region)
{
auto* pRenderer = ServiceLocator::LocateGlobals().pRender;
const auto* pActive = &ServiceLocator::LocateGlobals().getConsoleInformation().GetActiveOutputBuffer().GetActiveBuffer();
if (pRenderer != nullptr && pActive == &_owner)

View File

@@ -16,7 +16,8 @@
#include "handle.h"
using namespace Microsoft::Console;
using namespace Microsoft::Console::Interactivity;
using namespace Microsoft::Console::VirtualTerminal;
// Constructor Description:
// - Creates the VT Input Thread.
// Arguments:

View File

@@ -41,7 +41,7 @@ namespace Microsoft::Console
bool _exitRequested;
HRESULT _exitResult;
std::unique_ptr<StateMachine> _pInputStateMachine;
std::unique_ptr<Microsoft::Console::VirtualTerminal::StateMachine> _pInputStateMachine;
Utf8ToWideCharParser _utf8Parser;
};
}

View File

@@ -15,9 +15,11 @@
#include "output.h" // CloseConsoleProcessState
using namespace Microsoft::Console;
using namespace Microsoft::Console::Render;
using namespace Microsoft::Console::VirtualTerminal;
using namespace Microsoft::Console::Types;
using namespace Microsoft::Console::Utils;
using namespace Microsoft::Console::Interactivity;
VtIo::VtIo() :
_initialized(false),
@@ -105,7 +107,7 @@ HRESULT VtIo::Initialize(const ConsoleArguments * const pArgs)
// S_OK if we initialized successfully, otherwise an appropriate HRESULT
// indicating failure.
[[nodiscard]]
HRESULT VtIo::_Initialize(const HANDLE InHandle, const HANDLE OutHandle, const std::wstring& VtMode, const HANDLE SignalHandle)
HRESULT VtIo::_Initialize(const HANDLE InHandle, const HANDLE OutHandle, const std::wstring& VtMode, _In_opt_ const HANDLE SignalHandle)
{
FAIL_FAST_IF_MSG(_initialized, "Someone attempted to double-_Initialize VtIo");

View File

@@ -63,9 +63,7 @@ namespace Microsoft::Console::VirtualTerminal
std::unique_ptr<Microsoft::Console::PtySignalInputThread> _pPtySignalInputThread;
[[nodiscard]]
HRESULT _Initialize(const HANDLE InHandle, const HANDLE OutHandle, const std::wstring& VtMode);
[[nodiscard]]
HRESULT _Initialize(const HANDLE InHandle, const HANDLE OutHandle, const std::wstring& VtMode, _In_opt_ HANDLE SignalHandle);
HRESULT _Initialize(const HANDLE InHandle, const HANDLE OutHandle, const std::wstring& VtMode, _In_opt_ const HANDLE SignalHandle);
void _ShutdownIfNeeded();

View File

@@ -22,6 +22,7 @@
#pragma hdrstop
using namespace Microsoft::Console::Types;
using Microsoft::Console::Interactivity::ServiceLocator;
// Routine Description:
// - This routine writes a screen buffer region to the screen.

View File

@@ -24,7 +24,8 @@
#pragma hdrstop
using namespace Microsoft::Console::Types;
using Microsoft::Console::Interactivity::ServiceLocator;
using Microsoft::Console::VirtualTerminal::StateMachine;
// Used by WriteCharsLegacy.
#define IS_GLYPH_CHAR(wch) (((wch) < L' ') || ((wch) == 0x007F))

View File

@@ -22,6 +22,8 @@
#pragma hdrstop
using Microsoft::Console::Interactivity::ServiceLocator;
struct case_insensitive_hash
{
std::size_t operator()(const std::wstring& key) const
@@ -294,7 +296,7 @@ HRESULT ApiRoutines::GetConsoleAliasWImpl(const std::wstring_view source,
CATCH_RETURN();
}
// These variables define the seperator character and the length of the string.
// These variables define the separator character and the length of the string.
// They will be used to as the joiner between source and target strings when returning alias data in list form.
static std::wstring aliasesSeparator(L"=");
@@ -325,11 +327,11 @@ HRESULT GetConsoleAliasesLengthWImplHelper(const std::wstring_view exeName,
size_t cchNeeded = 0;
// Each of the aliases will be made up of the source, a seperator, the target, then a null character.
// Each of the aliases will be made up of the source, a separator, the target, then a null character.
// They are of the form "Source=Target" when returned.
size_t const cchNull = 1;
size_t cchSeperator = aliasesSeparator.size();
// If we're counting how much multibyte space will be needed, trial convert the seperator before we add.
// If we're counting how much multibyte space will be needed, trial convert the separator before we add.
if (!countInUnicode)
{
cchSeperator = GetALengthFromW(codepage, aliasesSeparator);
@@ -465,7 +467,7 @@ HRESULT GetConsoleAliasesWImplHelper(const std::wstring_view exeName,
LPWSTR AliasesBufferPtrW = aliasBuffer.has_value() ? aliasBuffer.value().data() : nullptr;
size_t cchTotalLength = 0; // accumulate the characters we need/have copied as we walk the list
// Each of the alises will be made up of the source, a seperator, the target, then a null character.
// Each of the alises will be made up of the source, a separator, the target, then a null character.
// They are of the form "Source=Target" when returned.
size_t const cchNull = 1;

View File

@@ -25,7 +25,7 @@
#include "..\interactivity\inc\ServiceLocator.hpp"
#pragma hdrstop
using Microsoft::Console::Interactivity::ServiceLocator;
// Routine Description:
// - This routine is called when the user changes the screen/popup colors.
// - It goes through the popup structures and changes the saved contents to reflect the new screen/popup colors.
@@ -720,7 +720,7 @@ COORD CommandLine::_moveCursorLeftByWord(COOKED_READ_DATA& cookedReadData) noexc
// LastWord is currently pointing to the last character
// of the previous word, unless it backed up to the beginning
// of the buffer.
// Let's increment LastWord so that it points to the expeced
// Let's increment LastWord so that it points to the expected
// insertion point.
++LastWord;
}

View File

@@ -158,7 +158,7 @@ void RedrawCommandLine(COOKED_READ_DATA& cookedReadData);
#define WC_DELAY_EOL_WRAP 0x80
// Word delimiters
bool IsWordDelim(const WCHAR wch);
bool IsWordDelim(const wchar_t wch);
bool IsWordDelim(const std::wstring_view charData);
[[nodiscard]]

View File

@@ -13,6 +13,7 @@
#pragma hdrstop
using namespace Microsoft::Console::Types;
using Microsoft::Console::Interactivity::ServiceLocator;
ConversionAreaBufferInfo::ConversionAreaBufferInfo(const COORD coordBufferSize) :
coordCaBuffer(coordBufferSize),

View File

@@ -32,7 +32,7 @@ struct _HSL
const auto diff = max - min;
const auto sum = max + min;
// Luminence
// Luminance
l = max / 255.0;
// Saturation
@@ -147,7 +147,7 @@ WORD Xterm256ToWindowsIndex(const size_t xtermTableEntry) noexcept
}
// Function Description:
// - Converts the value of a pair of xterm color table indicies to the legacy attr equivalent.
// - Converts the value of a pair of xterm color table indices to the legacy attr equivalent.
// Arguments:
// - xtermForeground: the xterm color table foreground index
// - xtermBackground: the xterm color table background index
@@ -190,7 +190,7 @@ bool FindTableIndex(const COLORREF Color,
// - Get a COLORREF for the foreground component of the given legacy attributes.
// Arguments:
// - wLegacyAttrs - The legacy attributes to get the foreground color from.
// - ColorTable - The array of colors to to get the color from.
// - ColorTable - The array of colors to get the color from.
// - cColorTable - The number of elements in ColorTable
// Return Value:
// - the COLORREF for the foreground component
@@ -209,7 +209,7 @@ COLORREF ForegroundColor(const WORD wLegacyAttrs,
// - Get a COLORREF for the background component of the given legacy attributes.
// Arguments:
// - wLegacyAttrs - The legacy attributes to get the background color from.
// - ColorTable - The array of colors to to get the color from.
// - ColorTable - The array of colors to get the color from.
// - cColorTable - The number of elements in ColorTable
// Return Value:
// - the COLORREF for the background component

View File

@@ -16,6 +16,8 @@
// Attributes flags:
#define COMMON_LVB_GRID_SINGLEFLAG 0x2000 // DBCS: Grid attribute: use for ime cursor.
using Microsoft::Console::Interactivity::ServiceLocator;
ConsoleImeInfo::ConsoleImeInfo() :
_isSavedCursorVisible(false)
{

View File

@@ -11,6 +11,9 @@
#include "..\interactivity\inc\ServiceLocator.hpp"
#include "..\types\inc\convert.hpp"
using Microsoft::Console::Interactivity::ServiceLocator;
using Microsoft::Console::VirtualTerminal::VtIo;
CONSOLE_INFORMATION::CONSOLE_INFORMATION() :
// ProcessHandleList initializes itself
pInputBuffer(nullptr),
@@ -270,7 +273,7 @@ void CONSOLE_INFORMATION::SetTitle(const std::wstring_view newTitle)
// Method Description:
// - Set the console title's prefix, and trigger a renderer update of the title.
// This is the part of the title shuch as "Mark", "Select", or "Scroll"
// This is the part of the title such as "Mark", "Select", or "Scroll"
// Arguments:
// - newTitlePrefix: The new value to use for the title prefix
// Return Value:

View File

@@ -10,6 +10,7 @@
#pragma hdrstop
using namespace Microsoft::Console::Types;
using Microsoft::Console::Interactivity::ServiceLocator;
bool IsValidSmallRect(_In_ PSMALL_RECT const Rect)
{

View File

@@ -12,6 +12,7 @@
#pragma hdrstop
using Microsoft::Console::Interactivity::ServiceLocator;
// Routine Description:
// - This routine check bisected on Ascii string end.
// Arguments:
@@ -109,7 +110,7 @@ bool IsDBCSLeadByteConsole(const CHAR ch, const CPINFO * const pCPInfo)
unsigned char const uchComparison = (unsigned char)ch;
int i = 0;
// this is ok because the the array is guaranteed to have 2
// this is ok because the array is guaranteed to have 2
// null bytes at the end.
while (pCPInfo->LeadByte[i])
{

View File

@@ -23,6 +23,7 @@
#pragma hdrstop
using namespace Microsoft::Console::Types;
using Microsoft::Console::Interactivity::ServiceLocator;
class CONSOLE_INFORMATION;
@@ -571,7 +572,7 @@ HRESULT DoSrvPrivatePrependConsoleInput(_Inout_ InputBuffer* const pInputBuffer,
// Arguments:
// - pInputBuffer - the input buffer to write to. Currently unused, as
// HandleGenericKeyEvent just gets the global input buffer, but all
// ConGetSet API's require a input or output object.
// ConGetSet API's require an input or output object.
// - key - The keyevent to send to the console.
// Return Value:
// - HRESULT indicating success or failure
@@ -865,7 +866,7 @@ static HRESULT _ReadConsoleOutputWImplHelper(const SCREEN_INFORMATION& context,
auto sourceIter = storageBuffer.GetCellDataAt(sourcePoint, clippedRequestRectangle);
// Walk through every cell of the target, advancing the buffer.
// Validate that we always still have a valid iterator to the backgin store,
// Validate that we always still have a valid iterator to the backing store,
// that we always are writing inside the user's buffer (before the end)
// and we're always targeting the user's buffer inside its original bounds.
while (sourceIter && targetIter < targetBuffer.end())

View File

@@ -80,7 +80,7 @@
</ClCompile>
<Link>
<AllowIsolation>true</AllowIsolation>
<AdditionalManifestDependencies>type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'</AdditionalManifestDependencies>
<!--AdditionalManifestDependencies>type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'</AdditionalManifestDependencies-->
</Link>
</ItemDefinitionGroup>
<!-- Careful reordering these. Some default props (contained in these files) are order sensitive. -->

View File

@@ -152,7 +152,7 @@ int CALLBACK wWinMain(
_In_ PWSTR /*pwszCmdLine*/,
_In_ int /*nCmdShow*/)
{
ServiceLocator::LocateGlobals().hInstance = hInstance;
Microsoft::Console::Interactivity::ServiceLocator::LocateGlobals().hInstance = hInstance;
ConsoleCheckDebug();

View File

@@ -28,6 +28,9 @@
// This class is intended to test:
// GetConsoleAlias
using namespace WEX::TestExecution;
using namespace WEX::Common;
using WEX::Logging::Log;
class AliasTests
{

View File

@@ -1,3 +1,4 @@
#include "Common.hpp"
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
@@ -72,11 +73,11 @@ void TestGetConsoleAliasHelper(TCH* ptszSourceGiven,
{
case 0:
ptszSource = nullptr;
Log::Comment(L"Using null source arg.");
WEX::Logging::Log::Comment(L"Using null source arg.");
break;
case 1:
ptszSource = ptszSourceGiven;
Log::Comment(String().Format(L"Using source arg: '" TSTRFORMAT "'", ptszSource));
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"Using source arg: '" TSTRFORMAT "'", ptszSource));
break;
default:
VERIFY_FAIL(L"Unknown type.");
@@ -86,11 +87,11 @@ void TestGetConsoleAliasHelper(TCH* ptszSourceGiven,
{
case 0:
ptszExeName = nullptr;
Log::Comment(L"Using null exe name.");
WEX::Logging::Log::Comment(L"Using null exe name.");
break;
case 1:
ptszExeName = ptszExeNameGiven;
Log::Comment(String().Format(L"Using exe name arg: '" TSTRFORMAT "'", ptszExeName));
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"Using exe name arg: '" TSTRFORMAT "'", ptszExeName));
break;
default:
VERIFY_FAIL(L"Unknown type.");
@@ -143,7 +144,7 @@ void TestGetConsoleAliasHelper(TCH* ptszSourceGiven,
}
});
Log::Comment(String().Format(L"Using target buffer size: '%d'", cbTargetBuffer));
WEX::Logging::Log::Comment(WEX::Common::String().Format(L"Using target buffer size: '%d'", cbTargetBuffer));
// Set the alias if we're supposed to and prepare for cleanup later.
if (bSetFirst)
@@ -245,12 +246,12 @@ void TestGetConsoleAliasHelper(TCH* ptszSourceGiven,
VERIFY_ARE_EQUAL(dwExpectedResult, dwActualResult, L"Ensure result code/return value matches expected.");
VERIFY_ARE_EQUAL(dwExpectedLastError, dwActualLastError, L"Ensure last error code matches expected.");
Log::Comment(L"Compare target buffer character by character...");
WEX::Logging::Log::Comment(L"Compare target buffer character by character...");
for (size_t i = 0; i < (cbTargetBuffer / sizeof(TCH)); i++)
{
if (ptchExpectedTarget[i] != ptchTargetBuffer[i])
{
VERIFY_FAIL(String().Format(L"Target mismatch at %d. Expected: '" TCHFORMAT "' Actual: '" TCHFORMAT "'", i, ptchExpectedTarget[i], ptchTargetBuffer[i]));
VERIFY_FAIL(WEX::Common::String().Format(L"Target mismatch at %d. Expected: '" TCHFORMAT "' Actual: '" TCHFORMAT "'", i, ptchExpectedTarget[i], ptchTargetBuffer[i]));
}
}
}

View File

@@ -5,6 +5,9 @@
extern "C" IMAGE_DOS_HEADER __ImageBase;
using WEX::Logging::Log;
using namespace WEX::Common;
// This class is intended to test boundary conditions for:
// SetConsoleActiveScreenBuffer
class BufferTests
@@ -38,7 +41,7 @@ void BufferTests::TestSetConsoleActiveScreenBufferInvalid()
void BufferTests::TestWritingInactiveScreenBuffer()
{
bool useVtOutput;
VERIFY_SUCCEEDED_RETURN(TestData::TryGetValue(L"UseVtOutput", useVtOutput), L"Get whether this test should check VT output mode.");
VERIFY_SUCCEEDED_RETURN(WEX::TestExecution::TestData::TryGetValue(L"UseVtOutput", useVtOutput), L"Get whether this test should check VT output mode.");
const std::wstring primary(L"You should see me");
const std::wstring alternative(L"You should NOT see me!");

View File

@@ -46,6 +46,7 @@ bool CursorTests::TestCleanup()
void CursorTests::TestGetSetConsoleCursorInfo()
{
using namespace WEX::TestExecution;
DWORD dwSize;
bool bVisible;

View File

@@ -3,6 +3,10 @@
#include "precomp.h"
using namespace WEX::TestExecution;
using WEX::Logging::Log;
using namespace WEX::Common;
// This class is intended to test:
// GetConsoleScreenBufferInfo
// GetConsoleScreenBufferInfoEx

View File

@@ -7,6 +7,10 @@
#include <future>
using WEX::TestExecution::TestData;
using WEX::Logging::Log;
using namespace WEX::Common;
// This class is intended to test:
// WriteFile

View File

@@ -3,6 +3,10 @@
#include "precomp.h"
using namespace WEX::TestExecution;
using namespace WEX::Common;
using WEX::Logging::Log;
static const COORD c_coordZero = {0,0};
static const PCWSTR pwszLongFontPath = L"%WINDIR%\\Fonts\\ltype.ttf";

View File

@@ -11,6 +11,9 @@
#define NUMBER_OF_SCENARIO_INPUTS 10
#define READ_BATCH 3
using WEX::Logging::Log;
using namespace WEX::Common;
// This class is intended to test:
// FlushConsoleInputBuffer
// PeekConsoleInput
@@ -61,7 +64,7 @@ class InputTests
void VerifyNumberOfInputRecords(const HANDLE hConsoleInput, _In_ DWORD nInputs)
{
SetVerifyOutput verifySettings(VerifyOutputSettings::LogOnlyFailures);
WEX::TestExecution::SetVerifyOutput verifySettings(WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
DWORD nInputEvents = (DWORD)-1;
VERIFY_WIN32_BOOL_SUCCEEDED(GetNumberOfConsoleInputEvents(hConsoleInput, &nInputEvents));
VERIFY_ARE_EQUAL(nInputEvents,

View File

@@ -3,6 +3,8 @@
#include "precomp.h"
using namespace WEX::Logging;
// This class is intended to test:
// GetConsoleMode
// SetConsoleMode

View File

@@ -10,6 +10,9 @@
#include <algorithm>
using namespace Microsoft::Console::Types;
using namespace WEX::TestExecution;
using WEX::Logging::Log;
using namespace WEX::Common;
class OutputTests
{

View File

@@ -3,6 +3,8 @@
#include "precomp.h"
using WEX::Logging::Log;
// This class is intended to test restrictions placed on APIs from within a UWP application context
class PolicyTests
{

View File

@@ -3,6 +3,8 @@
#include "precomp.h"
using namespace WEX::Common;
HANDLE g_hOut = INVALID_HANDLE_VALUE;
CONSOLE_SCREEN_BUFFER_INFOEX g_sbiex_backup = { 0 };
COORD g_cWriteSize = {16, 16};

View File

@@ -3,6 +3,9 @@
#include "precomp.h"
using WEX::Logging::Log;
using namespace WEX::Common;
// This class is intended to test:
// GetConsoleTitle
class TitleTests

View File

@@ -10,6 +10,10 @@
#define ENGLISH_US_CP 437u
#define JAPANESE_CP 932u
using WEX::TestExecution::TestData;
using WEX::Logging::Log;
using namespace WEX::Common;
namespace DbcsWriteRead
{
enum WriteMode

View File

@@ -3,6 +3,9 @@
#include "precomp.h"
using WEX::Logging::Log;
using namespace WEX::Common;
// This class is intended to provide a canary (simple launch test)
// to ensure that activation of the console still works.
class CanaryTests

View File

@@ -3,6 +3,9 @@
#include "precomp.h"
using WEX::Logging::Log;
using namespace WEX::Common;
HANDLE Common::_hConsole = INVALID_HANDLE_VALUE;
void VerifySucceededGLE(BOOL bResult)

View File

@@ -3,6 +3,9 @@
#include "precomp.h"
using namespace WEX::TestExecution;
using namespace WEX::Common;
const DWORD _dwMaxMillisecondsToWaitOnStartup = 120 * 1000;
const DWORD _dwStartupWaitPollingIntervalInMilliseconds = 200;

View File

@@ -23,6 +23,10 @@
#define SLEEP_WAIT_TIME (2 * 1000)
#define GERMAN_KEYBOARD_LAYOUT (MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN))
using namespace WEX::TestExecution;
using namespace WEX::Common;
using WEX::Logging::Log;
class KeyPressTests
{
BEGIN_TEST_CLASS(KeyPressTests)

View File

@@ -9,10 +9,6 @@
#include "WexTestClass.h"
using namespace WEX::Common;
using namespace WEX::Logging;
using namespace WEX::TestExecution;
// This includes support libraries from the CRT, STL, WIL, and GSL
#include "LibraryIncludes.h"

View File

@@ -30,6 +30,7 @@
#define PRIVATE_MODES (ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE | ENABLE_AUTO_POSITION | ENABLE_EXTENDED_FLAGS)
using namespace Microsoft::Console::Types;
using namespace Microsoft::Console::Interactivity;
// Routine Description:
// - Retrieves the console input mode (settings that apply when manipulating the input buffer)
@@ -127,7 +128,7 @@ void ApiRoutines::GetConsoleScreenBufferInfoExImpl(const SCREEN_INFORMATION& con
&data.dwMaximumWindowSize,
&data.wPopupAttributes,
data.ColorTable);
// Callers of this function expect to recieve an exclusive rect, not an inclusive one.
// Callers of this function expect to receive an exclusive rect, not an inclusive one.
data.srWindow.Right += 1;
data.srWindow.Bottom += 1;
}
@@ -201,7 +202,7 @@ void ApiRoutines::GetNumberOfConsoleMouseButtonsImpl(ULONG& buttons) noexcept
}
// Routine Description:
// - Retrieves information about the a known font based on index
// - Retrieves information about a known font based on index
// Arguments:
// - context - The output buffer concerned
// - index - We only accept 0 now as we don't keep a list of fonts in memory.
@@ -837,7 +838,7 @@ HRESULT ApiRoutines::ScrollConsoleScreenBufferWImpl(SCREEN_INFORMATION& context,
// attributes, they likely wanted to use the full version of
// our current attributes, whether that be RGB or _default_ colored.
// This could create a scenario where someone emitted RGB with VT,
// THEN used the API to ScrollConsoleOutput with the legacy attrs,
// THEN used the API to ScrollConsoleOutput with the legacy attrs,
// and DIDN'T want the RGB color. As in FillConsoleOutputAttribute,
// this scenario is highly unlikely, and we can reasonably do this
// on their behalf.
@@ -1439,7 +1440,7 @@ HRESULT DoSrvMoveCursorVertically(SCREEN_INFORMATION& screenInfo, const short li
}
// Routine Description:
// - A private API call for swaping to the alternate screen buffer. In virtual terminals, there exists both a "main"
// - A private API call for swapping to the alternate screen buffer. In virtual terminals, there exists both a "main"
// screen buffer and an alternate. ASBSET creates a new alternate, and switches to it. If there is an already
// existing alternate, it is discarded.
// Parameters:
@@ -1470,7 +1471,7 @@ void DoSrvPrivateUseMainScreenBuffer(SCREEN_INFORMATION& screenInfo)
// Parameters:
// <none>
// Return value:
// - STATUS_SUCCESS if handled successfully. Otherwise, an approriate status code indicating the error.
// - STATUS_SUCCESS if handled successfully. Otherwise, an appropriate status code indicating the error.
[[nodiscard]]
NTSTATUS DoSrvPrivateHorizontalTabSet()
{
@@ -1490,12 +1491,12 @@ NTSTATUS DoSrvPrivateHorizontalTabSet()
}
// Routine Description:
// - A private helper for excecuting a number of tabs.
// - A private helper for executing a number of tabs.
// Parameters:
// sNumTabs - The number of tabs to execute
// fForward - whether to tab forward or backwards
// Return value:
// - STATUS_SUCCESS if handled successfully. Otherwise, an approriate status code indicating the error.
// - STATUS_SUCCESS if handled successfully. Otherwise, an appropriate status code indicating the error.
[[nodiscard]]
NTSTATUS DoPrivateTabHelper(const SHORT sNumTabs, _In_ bool fForward)
{
@@ -1524,7 +1525,7 @@ NTSTATUS DoPrivateTabHelper(const SHORT sNumTabs, _In_ bool fForward)
// Parameters:
// - sNumTabs - The number of tabs to perform.
// Return value:
// - STATUS_SUCCESS if handled successfully. Otherwise, an approriate status code indicating the error.
// - STATUS_SUCCESS if handled successfully. Otherwise, an appropriate status code indicating the error.
[[nodiscard]]
NTSTATUS DoSrvPrivateForwardTab(const SHORT sNumTabs)
{
@@ -1537,7 +1538,7 @@ NTSTATUS DoSrvPrivateForwardTab(const SHORT sNumTabs)
// Parameters:
// - sNumTabs - The number of tabs to perform.
// Return value:
// - STATUS_SUCCESS if handled successfully. Otherwise, an approriate status code indicating the error.
// - STATUS_SUCCESS if handled successfully. Otherwise, an appropriate status code indicating the error.
[[nodiscard]]
NTSTATUS DoSrvPrivateBackwardsTab(const SHORT sNumTabs)
{
@@ -1548,7 +1549,7 @@ NTSTATUS DoSrvPrivateBackwardsTab(const SHORT sNumTabs)
// - A private API call for clearing the VT tabs that have been set.
// Parameters:
// - fClearAll - If false, only clears the tab in the current column (if it exists)
// otherwise clears all set tabs. (and reverts to lecacy 8-char tabs behavior.)
// otherwise clears all set tabs. (and reverts to legacy 8-char tabs behavior.)
// Return value:
// - None
void DoSrvPrivateTabClear(const bool fClearAll)
@@ -2046,7 +2047,7 @@ NTSTATUS DoSrvPrivateSuppressResizeRepaint()
// Routine Description:
// - An API call for checking if the console host is acting as a pty.
// Parameters:
// - isPty: recieves the bool indicating whether or not we're in pty mode.
// - isPty: receives the bool indicating whether or not we're in pty mode.
// Return value:
// <none>
void DoSrvIsConsolePty(_Out_ bool* const pIsPty)
@@ -2145,7 +2146,7 @@ void DoSrvPrivateMoveToBottom(SCREEN_INFORMATION& screenInfo)
// Return Value:
// - E_INVALIDARG if index is >= 256, else S_OK
// Notes:
// Does not take a buffer paramenter. The color table for a console and for
// 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 short index, const COLORREF value) noexcept
@@ -2170,3 +2171,59 @@ HRESULT DoSrvPrivateSetColorTableEntry(const short index, const COLORREF value)
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();
}

View File

@@ -99,3 +99,9 @@ void DoSrvPrivateMoveToBottom(SCREEN_INFORMATION& screenInfo);
[[nodiscard]]
HRESULT DoSrvPrivateSetColorTableEntry(const short index, const COLORREF value) noexcept;
[[nodiscard]]
HRESULT DoSrvPrivateSetDefaultForegroundColor(const COLORREF value) noexcept;
[[nodiscard]]
HRESULT DoSrvPrivateSetDefaultBackgroundColor(const COLORREF value) noexcept;

View File

@@ -33,8 +33,6 @@ Revision History:
#include <winmeta.h>
TRACELOGGING_DECLARE_PROVIDER(g_hConhostV2EventTraceProvider);
using namespace Microsoft::Console::Render;
class Globals
{
public:
@@ -63,9 +61,9 @@ public:
std::vector<wchar_t> WordDelimiters;
IRenderer* pRender;
Microsoft::Console::Render::IRenderer* pRender;
IFontDefaultList* pFontDefaultList;
Microsoft::Console::Render::IFontDefaultList* pFontDefaultList;
bool IsHeadless() const;

View File

@@ -8,6 +8,8 @@
#pragma hdrstop
using Microsoft::Console::Interactivity::ServiceLocator;
void LockConsole()
{
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();

View File

@@ -22,6 +22,8 @@
#pragma hdrstop
using Microsoft::Console::Interactivity::ServiceLocator;
// I need to be a list because we rearrange elements inside to maintain a
// "least recently used" state. Doing many rearrangement operations with
// a list will maintain the iterator pointers as valid to the elements
@@ -760,7 +762,7 @@ HRESULT ApiRoutines::GetConsoleCommandHistoryLengthWImpl(const std::wstring_view
}
// Routine Description:
// - Retrieves a the full command history for a given EXE name known to the console.
// - Retrieves the full command history for a given EXE name known to the console.
// - It is permitted to call this function without having a target buffer. Use the result to allocate
// the appropriate amount of space and call again.
// - This behavior exists to allow the A version of the function to help allocate the right temp buffer for conversion of
@@ -835,7 +837,7 @@ HRESULT GetConsoleCommandHistoryWImplHelper(const std::wstring_view exeName,
}
// Routine Description:
// - Retrieves a the full command history for a given EXE name known to the console.
// - Retrieves the full command history for a given EXE name known to the console.
// - Converts inputs from A to W, calls the W version of this method, and then converts the resulting text W to A.
// Arguments:
// - exeName - The client EXE application attached to the host whose set we should check
@@ -899,7 +901,7 @@ HRESULT ApiRoutines::GetConsoleCommandHistoryAImpl(const std::string_view exeNam
}
// Routine Description:
// - Retrieves a the full command history for a given EXE name known to the console.
// - Retrieves the full command history for a given EXE name known to the console.
// - Converts inputs from A to W, calls the W version of this method, and then converts the resulting text W to A.
// Arguments:
// - exeName - The client EXE application attached to the host whose set we should check

View File

@@ -16,6 +16,8 @@
#define KEY_ENHANCED 0x01000000
using Microsoft::Console::Interactivity::ServiceLocator;
bool IsInProcessedInputMode()
{
const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();

View File

@@ -13,6 +13,9 @@
#define INPUT_BUFFER_DEFAULT_INPUT_MODE (ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT)
using Microsoft::Console::Interactivity::ServiceLocator;
using Microsoft::Console::VirtualTerminal::TerminalInput;
// Routine Description:
// - This method creates an input buffer.
// Arguments:

View File

@@ -15,6 +15,7 @@
#define CHAR_NULL ((char)0)
using Microsoft::Console::Interactivity::ServiceLocator;
WCHAR CharToWchar(_In_reads_(cch) const char * const pch, const UINT cch)
{

View File

@@ -15,7 +15,9 @@
#include "../types/inc/convert.hpp"
#pragma hdrstop
using namespace Microsoft::Console::Types;
using namespace Microsoft::Console::Interactivity;
// This routine figures out what parameters to pass to CreateScreenBuffer based on the data from STARTUPINFO and the
// registry defaults, and then calls CreateScreenBuffer.

View File

@@ -12,7 +12,9 @@
#include "../interactivity/inc/ServiceLocator.hpp"
#pragma hdrstop
using namespace Microsoft::Console;
using Microsoft::Console::Interactivity::ServiceLocator;
WriteBuffer::WriteBuffer(_In_ Microsoft::Console::IIoProvider& io) :
_io{ io },
@@ -761,3 +763,27 @@ BOOL ConhostInternalGetSet::PrivateSetColorTableEntry(const short index, const C
{
return SUCCEEDED(DoSrvPrivateSetColorTableEntry(index, value));
}
// 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));
}
// 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));
}

View File

@@ -157,6 +157,10 @@ public:
BOOL PrivateSetColorTableEntry(const short index, const COLORREF value) const noexcept override;
BOOL PrivateSetDefaultForeground(const COLORREF value) const noexcept override;
BOOL PrivateSetDefaultBackground(const COLORREF value) const noexcept override;
private:
Microsoft::Console::IIoProvider& _io;
};

View File

@@ -21,7 +21,7 @@
#pragma hdrstop
using namespace Microsoft::Console::Types;
using Microsoft::Console::Interactivity::ServiceLocator;
// Routine Description:
// - Creates an object representing an interactive popup overlay during cooked mode command line editing.
// - NOTE: Modifies global popup count (and adjusts cursor visibility as appropriate.)
@@ -333,6 +333,7 @@ void Popup::SetUserInputFunction(UserInputFunction function) noexcept
// - wch - on completion, the char read from the user
// Return Value:
// - relevant NTSTATUS
[[nodiscard]]
NTSTATUS Popup::_getUserInput(COOKED_READ_DATA& cookedReadData, bool& popupKey, DWORD& modifiers, wchar_t& wch) noexcept
{
return _userInputFunction(cookedReadData, popupKey, modifiers, wch);
@@ -346,6 +347,7 @@ NTSTATUS Popup::_getUserInput(COOKED_READ_DATA& cookedReadData, bool& popupKey,
// - wch - on completion, the char read from the user
// Return Value:
// - relevant NTSTATUS
[[nodiscard]]
NTSTATUS Popup::_getUserInputInternal(COOKED_READ_DATA& cookedReadData,
bool& popupKey,
DWORD& modifiers,

View File

@@ -66,6 +66,7 @@ protected:
friend class CommandListPopupTests;
#endif
[[nodiscard]]
NTSTATUS _getUserInput(COOKED_READ_DATA& cookedReadData, bool& popupKey, DWORD& modifiers, wchar_t& wch) noexcept;
void _DrawPrompt(const UINT id);
virtual void _DrawContent() = 0;
@@ -81,6 +82,7 @@ private:
void _DrawBorder();
[[nodiscard]]
static NTSTATUS _getUserInputInternal(COOKED_READ_DATA& cookedReadData,
bool& popupKey,
DWORD& modifiers,

View File

@@ -16,6 +16,8 @@
#define LINE_INPUT_BUFFER_SIZE (256 * sizeof(WCHAR))
using Microsoft::Console::Interactivity::ServiceLocator;
// Routine Description:
// - Constructs cooked read data class to hold context across key presses while a user is modifying their 'input line'.
// Arguments:

View File

@@ -75,7 +75,7 @@ bool DirectReadData::Notify(const WaitTerminationReason TerminationReason,
FAIL_FAST_IF(_pInputReadHandleData->GetReadCount() == 0);
const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
const CONSOLE_INFORMATION& gci = Microsoft::Console::Interactivity::ServiceLocator::LocateGlobals().getConsoleInformation();
FAIL_FAST_IF(!gci.IsConsoleLocked());
*pReplyStatus = STATUS_SUCCESS;

Some files were not shown because too many files have changed in this diff Show More