add clang-format conf to the project, format the c++ code (#1141)

This commit is contained in:
adiviness 2019-06-11 13:27:09 -07:00 committed by GitHub
parent 6fc0978ddb
commit 9b92986b49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
523 changed files with 11376 additions and 12481 deletions

93
.clang-format Normal file
View file

@ -0,0 +1,93 @@
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
#AllowAllArgumentsOnNextLine: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
#AllowAllConstructorInitializersOnNextLine: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
#AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
ColumnLimit: 0
CommentPragmas: "suppress"
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
FixNamespaceComments: false
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^.*(precomp|pch|stdafx)'
Priority: -1
- Regex: '^".*"'
Priority: 1
- Regex: '^<.*>'
Priority: 2
- Regex: '.*'
Priority: 3
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: "BEGIN_TEST_METHOD_PROPERTIES|BEGIN_MODULE|BEGIN_TEST_CLASS|BEGIN_TEST_METHOD"
MacroBlockEnd: "END_TEST_METHOD_PROPERTIES|END_MODULE|END_TEST_CLASS|END_TEST_METHOD"
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PointerAlignment: Left
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
#SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never

View file

@ -3,6 +3,8 @@
Openconsole can be built with Visual Studio or from the command line. There are build scripts for both cmd and powershell in /tools. Openconsole can be built with Visual Studio or from the command line. There are build scripts for both cmd and powershell in /tools.
When using Visual Studio, be sure to set up the path for code formatting. This can be done in Visual Studio by going to Tools > Options > Text Editor > C++ > Formatting and checking "Use custom clang-format.exe file" and choosing the clang-format.exe in the repository at /dep/llvm/clang-format.exe by clicking "browse" right under the check box.
## Building with cmd ## Building with cmd
The cmd scripts are set up to emulate a portion of the OS razzle build environment. razzle.cmd is the first script that should be run. bcz.cmd will build clean and bz.cmd should build incrementally. The cmd scripts are set up to emulate a portion of the OS razzle build environment. razzle.cmd is the first script that should be run. bcz.cmd will build clean and bz.cmd should build incrementally.
@ -11,6 +13,7 @@ There are also scripts for running the tests:
- `runut.cmd` - run the unit tests - `runut.cmd` - run the unit tests
- `runft.cmd` - run the feature tests - `runft.cmd` - run the feature tests
- `runuia.cmd` - run the UIA tests - `runuia.cmd` - run the UIA tests
- `runformat` - uses clang-format to format all c++ files to match our coding style.
## Build with Powershell ## Build with Powershell
@ -20,6 +23,7 @@ Openconsole.psm1 should be loaded with `Import-Module`. From there `Set-MsbuildD
- `Invoke-OpenConsoleTests` - runs the various tests. Will run the unit tests by default. - `Invoke-OpenConsoleTests` - runs the various tests. Will run the unit tests by default.
- `Start-OpenConsole` - starts Openconsole.exe from the output directory. x64 is run by default. - `Start-OpenConsole` - starts Openconsole.exe from the output directory. x64 is run by default.
- `Debug-OpenConsole` - starts Openconsole.exe and attaches it to the default debugger. x64 is run by default. - `Debug-OpenConsole` - starts Openconsole.exe and attaches it to the default debugger. x64 is run by default.
- `Invoke-CodeFormat` - uses clang-format to format all c++ files to match our coding style.
## Configuration Types ## Configuration Types

View file

@ -210,7 +210,6 @@ void ATTR_ROW::ReplaceLegacyAttrs(_In_ WORD wToBeReplacedAttr, _In_ WORD wReplac
ReplaceAttrs(ToBeReplaced, ReplaceWith); ReplaceAttrs(ToBeReplaced, ReplaceWith);
} }
// Method Description: // Method Description:
// - Replaces all runs in the row with the given toBeReplacedAttr with the new // - Replaces all runs in the row with the given toBeReplacedAttr with the new
// attribute replaceWith. // attribute replaceWith.
@ -230,7 +229,6 @@ void ATTR_ROW::ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAtt
} }
} }
// Routine Description: // Routine Description:
// - Takes a array of attribute runs, and inserts them into this row from startIndex to endIndex. // - Takes a array of attribute runs, and inserts them into this row from startIndex to endIndex.
// - For example, if the current row was was [{4, BLUE}], the merge string // - For example, if the current row was was [{4, BLUE}], the merge string
@ -245,8 +243,7 @@ void ATTR_ROW::ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAtt
// Return Value: // Return Value:
// - STATUS_NO_MEMORY if there wasn't enough memory to insert the runs // - STATUS_NO_MEMORY if there wasn't enough memory to insert the runs
// otherwise STATUS_SUCCESS if we were successful. // otherwise STATUS_SUCCESS if we were successful.
[[nodiscard]] [[nodiscard]] HRESULT ATTR_ROW::InsertAttrRuns(const std::basic_string_view<TextAttributeRun> newAttrs,
HRESULT ATTR_ROW::InsertAttrRuns(const std::basic_string_view<TextAttributeRun> newAttrs,
const size_t iStart, const size_t iStart,
const size_t iEnd, const size_t iEnd,
const size_t cBufferWidth) const size_t cBufferWidth)

View file

@ -47,8 +47,7 @@ public:
void Resize(const size_t newWidth); void Resize(const size_t newWidth);
[[nodiscard]] [[nodiscard]] HRESULT InsertAttrRuns(const std::basic_string_view<TextAttributeRun> newAttrs,
HRESULT InsertAttrRuns(const std::basic_string_view<TextAttributeRun> newAttrs,
const size_t iStart, const size_t iStart,
const size_t iEnd, const size_t iEnd,
const size_t cBufferWidth); const size_t cBufferWidth);
@ -65,12 +64,10 @@ public:
friend class AttrRowIterator; friend class AttrRowIterator;
private: private:
std::vector<TextAttributeRun> _list; std::vector<TextAttributeRun> _list;
size_t _cchRowWidth; size_t _cchRowWidth;
#ifdef UNIT_TESTING #ifdef UNIT_TESTING
friend class AttrRowTests; friend class AttrRowTests;
#endif #endif
}; };

View file

@ -13,7 +13,6 @@ Author(s):
- Austin Diviness (AustDi) 04-Jun-2018 - Austin Diviness (AustDi) 04-Jun-2018
--*/ --*/
#pragma once #pragma once
#include "TextAttribute.hpp" #include "TextAttribute.hpp"

View file

@ -101,8 +101,7 @@ void CharRow::Reset()
// - newSize - the new width of the character and attributes rows // - newSize - the new width of the character and attributes rows
// Return Value: // Return Value:
// - S_OK on success, otherwise relevant error code // - S_OK on success, otherwise relevant error code
[[nodiscard]] [[nodiscard]] HRESULT CharRow::Resize(const size_t newSize) noexcept
HRESULT CharRow::Resize(const size_t newSize) noexcept
{ {
try try
{ {

View file

@ -54,8 +54,7 @@ public:
bool WasDoubleBytePadded() const noexcept; bool WasDoubleBytePadded() const noexcept;
size_t size() const noexcept; size_t size() const noexcept;
void Reset(); void Reset();
[[nodiscard]] [[nodiscard]] HRESULT Resize(const size_t newSize) noexcept;
HRESULT Resize(const size_t newSize) noexcept;
size_t MeasureLeft() const; size_t MeasureLeft() const;
size_t MeasureRight() const noexcept; size_t MeasureRight() const noexcept;
void ClearCell(const size_t column); void ClearCell(const size_t column);
@ -116,8 +115,7 @@ void OverwriteColumns(InputIt1 startChars, InputIt1 endChars, InputIt2 startAttr
endChars, endChars,
startAttrs, startAttrs,
outIt, outIt,
[](const wchar_t wch, const DbcsAttribute attr) [](const wchar_t wch, const DbcsAttribute attr) {
{
return CharRow::value_type{ wch, attr }; return CharRow::value_type{ wch, attr };
}); });
} }

View file

@ -5,7 +5,6 @@
#include "CharRowCell.hpp" #include "CharRowCell.hpp"
#include "unicode.hpp" #include "unicode.hpp"
// default glyph value, used for reseting the character data portion of a cell // default glyph value, used for reseting the character data portion of a cell
static constexpr wchar_t DefaultValue = UNICODE_SPACE; static constexpr wchar_t DefaultValue = UNICODE_SPACE;

View file

@ -18,14 +18,12 @@ Author(s):
#include "DbcsAttribute.hpp" #include "DbcsAttribute.hpp"
#if (defined(_M_IX86) || defined(_M_AMD64)) #if (defined(_M_IX86) || defined(_M_AMD64))
// currently CharRowCell's fields use 3 bytes of memory, leaving the 4th byte in unused. this leads // currently CharRowCell's fields use 3 bytes of memory, leaving the 4th byte in unused. this leads
// to a rather large amount of useless memory allocated. so instead, pack CharRowCell by bytes instead of words. // to a rather large amount of useless memory allocated. so instead, pack CharRowCell by bytes instead of words.
#pragma pack(push, 1) #pragma pack(push, 1)
#endif #endif
class CharRowCell final class CharRowCell final
{ {
public: public:
@ -44,6 +42,7 @@ public:
const wchar_t& Char() const noexcept; const wchar_t& Char() const noexcept;
friend constexpr bool operator==(const CharRowCell& a, const CharRowCell& b) noexcept; friend constexpr bool operator==(const CharRowCell& a, const CharRowCell& b) noexcept;
private: private:
wchar_t _wch; wchar_t _wch;
DbcsAttribute _attr; DbcsAttribute _attr;

View file

@ -5,7 +5,6 @@
#include "UnicodeStorage.hpp" #include "UnicodeStorage.hpp"
#include "CharRow.hpp" #include "CharRow.hpp"
// Routine Description: // Routine Description:
// - assignment operator. will store extended glyph data in a separate storage location // - assignment operator. will store extended glyph data in a separate storage location
// Arguments: // Arguments:
@ -96,7 +95,6 @@ CharRowCellReference::const_iterator CharRowCellReference::end() const
{ {
if (_cellData().DbcsAttr().IsGlyphStored()) if (_cellData().DbcsAttr().IsGlyphStored())
{ {
const auto& chars = _parent.GetUnicodeStorage().GetText(_parent.GetStorageKey(_index)); const auto& chars = _parent.GetUnicodeStorage().GetText(_parent.GetStorageKey(_index));
return chars.data() + chars.size(); return chars.data() + chars.size();
} }

View file

@ -23,7 +23,6 @@ class CharRow;
class CharRowCellReference final class CharRowCellReference final
{ {
public: public:
using const_iterator = const wchar_t*; using const_iterator = const wchar_t*;
CharRowCellReference(CharRow& parent, const size_t index) : CharRowCellReference(CharRow& parent, const size_t index) :
@ -45,7 +44,6 @@ public:
const_iterator begin() const; const_iterator begin() const;
const_iterator end() const; const_iterator end() const;
friend bool operator==(const CharRowCellReference& ref, const std::vector<wchar_t>& glyph); friend bool operator==(const CharRowCellReference& ref, const std::vector<wchar_t>& glyph);
friend bool operator==(const std::vector<wchar_t>& glyph, const CharRowCellReference& ref); friend bool operator==(const std::vector<wchar_t>& glyph, const CharRowCellReference& ref);

View file

@ -140,4 +140,5 @@ constexpr bool operator==(const DbcsAttribute& a, const DbcsAttribute& b) noexce
} }
static_assert(sizeof(DbcsAttribute) == sizeof(BYTE), "DbcsAttribute should be one byte big. if this changes then it needs " static_assert(sizeof(DbcsAttribute) == sizeof(BYTE), "DbcsAttribute should be one byte big. if this changes then it needs "
" either an implicit conversion to a BYTE or an update to all places that assume it's a byte big"); "either an implicit conversion to a BYTE or an update to all places "
"that assume it's a byte big");

View file

@ -17,7 +17,6 @@ OutputCell::OutputCell() :
_textAttribute{ InvalidTextAttribute }, _textAttribute{ InvalidTextAttribute },
_behavior{ TextAttributeBehavior::Stored } _behavior{ TextAttributeBehavior::Stored }
{ {
} }
OutputCell::OutputCell(const std::wstring_view charData, OutputCell::OutputCell(const std::wstring_view charData,

View file

@ -26,7 +26,6 @@ OutputCellIterator::OutputCellIterator(const wchar_t& wch, const size_t fillLimi
_distance(0), _distance(0),
_fillLimit(fillLimit) _fillLimit(fillLimit)
{ {
} }
// Routine Description: // Routine Description:
@ -43,7 +42,6 @@ OutputCellIterator::OutputCellIterator(const TextAttribute& attr, const size_t f
_distance(0), _distance(0),
_fillLimit(fillLimit) _fillLimit(fillLimit)
{ {
} }
// Routine Description: // Routine Description:
@ -61,7 +59,6 @@ OutputCellIterator::OutputCellIterator(const wchar_t& wch, const TextAttribute&
_distance(0), _distance(0),
_fillLimit(fillLimit) _fillLimit(fillLimit)
{ {
} }
// Routine Description: // Routine Description:
@ -78,7 +75,6 @@ OutputCellIterator::OutputCellIterator(const CHAR_INFO& charInfo, const size_t f
_distance(0), _distance(0),
_fillLimit(fillLimit) _fillLimit(fillLimit)
{ {
} }
// Routine Description: // Routine Description:
@ -94,7 +90,6 @@ OutputCellIterator::OutputCellIterator(const std::wstring_view utf16Text) :
_distance(0), _distance(0),
_fillLimit(0) _fillLimit(0)
{ {
} }
// Routine Description: // Routine Description:
@ -111,7 +106,6 @@ OutputCellIterator::OutputCellIterator(const std::wstring_view utf16Text, const
_pos(0), _pos(0),
_fillLimit(0) _fillLimit(0)
{ {
} }
// Routine Description: // Routine Description:
@ -131,7 +125,6 @@ OutputCellIterator::OutputCellIterator(const std::basic_string_view<WORD> legacy
_pos(0), _pos(0),
_fillLimit(0) _fillLimit(0)
{ {
} }
// Routine Description: // Routine Description:
@ -147,7 +140,6 @@ OutputCellIterator::OutputCellIterator(const std::basic_string_view<CHAR_INFO> c
_pos(0), _pos(0),
_fillLimit(0) _fillLimit(0)
{ {
} }
// Routine Description: // Routine Description:
@ -163,7 +155,6 @@ OutputCellIterator::OutputCellIterator(const std::basic_string_view<OutputCell>
_pos(0), _pos(0),
_fillLimit(0) _fillLimit(0)
{ {
} }
// Routine Description: // Routine Description:

View file

@ -59,7 +59,6 @@ public:
const OutputCellView* operator->() const; const OutputCellView* operator->() const;
private: private:
enum class Mode enum class Mode
{ {
// Loose mode is where we're given text and attributes in a raw sort of form // Loose mode is where we're given text and attributes in a raw sort of form
@ -93,7 +92,8 @@ private:
std::wstring_view, std::wstring_view,
std::basic_string_view<CHAR_INFO>, std::basic_string_view<CHAR_INFO>,
std::basic_string_view<OutputCell>, std::basic_string_view<OutputCell>,
std::monostate> _run; std::monostate>
_run;
TextAttribute _attr; TextAttribute _attr;

View file

@ -11,7 +11,6 @@ OutputCellRect::OutputCellRect() :
_rows(0), _rows(0),
_cols(0) _cols(0)
{ {
} }
// Routine Description: // Routine Description:

View file

@ -21,7 +21,6 @@ OutputCellView::OutputCellView(const std::wstring_view view,
_textAttr(textAttr), _textAttr(textAttr),
_behavior(behavior) _behavior(behavior)
{ {
} }
// Routine Description: // Routine Description:

View file

@ -25,7 +25,6 @@ Revision History:
class OutputCellView class OutputCellView
{ {
public: public:
OutputCellView(const std::wstring_view view, OutputCellView(const std::wstring_view view,
const DbcsAttribute dbcsAttr, const DbcsAttribute dbcsAttr,
const TextAttribute textAttr, const TextAttribute textAttr,

View file

@ -87,8 +87,7 @@ bool ROW::Reset(const TextAttribute Attr)
// - width - the new width, in cells // - width - the new width, in cells
// Return Value: // Return Value:
// - S_OK if successful, otherwise relevant error // - S_OK if successful, otherwise relevant error
[[nodiscard]] [[nodiscard]] HRESULT ROW::Resize(const size_t width)
HRESULT ROW::Resize(const size_t width)
{ {
RETURN_IF_FAILED(_charRow.Resize(width)); RETURN_IF_FAILED(_charRow.Resize(width));
try try

View file

@ -46,8 +46,7 @@ public:
void SetId(const SHORT id) noexcept; void SetId(const SHORT id) noexcept;
bool Reset(const TextAttribute Attr); bool Reset(const TextAttribute Attr);
[[nodiscard]] [[nodiscard]] HRESULT Resize(const size_t width);
HRESULT Resize(const size_t width);
void ClearColumn(const size_t column); void ClearColumn(const size_t column);
std::wstring GetText() const; std::wstring GetText() const;

View file

@ -16,7 +16,6 @@ RowCellIterator::RowCellIterator(const ROW& row, const size_t start, const size_
_pos(start), _pos(start),
_view(s_GenerateView(row, start)) _view(s_GenerateView(row, start))
{ {
} }
RowCellIterator::operator bool() const noexcept RowCellIterator::operator bool() const noexcept

View file

@ -164,7 +164,8 @@ private:
#ifdef UNIT_TESTING #ifdef UNIT_TESTING
friend class TextBufferTests; friend class TextBufferTests;
friend class TextAttributeTests; friend class TextAttributeTests;
template<typename TextAttribute> friend class WEX::TestExecution::VerifyOutputTraits; template<typename TextAttribute>
friend class WEX::TestExecution::VerifyOutputTraits;
#endif #endif
}; };
@ -213,8 +214,10 @@ constexpr bool operator!=(const WORD& legacyAttr, const TextAttribute& attr) noe
#define LOG_ATTR(attr) (Log::Comment(NoThrowString().Format( \ #define LOG_ATTR(attr) (Log::Comment(NoThrowString().Format( \
L#attr L"=%s", VerifyOutputTraits<TextAttribute>::ToString(attr).GetBuffer()))) L#attr L"=%s", VerifyOutputTraits<TextAttribute>::ToString(attr).GetBuffer())))
namespace WEX { namespace WEX
namespace TestExecution { {
namespace TestExecution
{
template<> template<>
class VerifyOutputTraits<TextAttribute> class VerifyOutputTraits<TextAttribute>
{ {
@ -226,8 +229,7 @@ namespace WEX {
VerifyOutputTraits<TextColor>::ToString(attr._foreground).GetBuffer(), VerifyOutputTraits<TextColor>::ToString(attr._foreground).GetBuffer(),
VerifyOutputTraits<TextColor>::ToString(attr._background).GetBuffer(), VerifyOutputTraits<TextColor>::ToString(attr._background).GetBuffer(),
attr.IsBold(), attr.IsBold(),
attr._wAttrLegacy attr._wAttrLegacy);
);
} }
}; };
} }

View file

@ -86,7 +86,6 @@ COLORREF TextColor::GetColor(std::basic_string_view<COLORREF> colorTable,
return colorTable[i + 8]; return colorTable[i + 8];
} }
} }
} }
return defaultColor; return defaultColor;

View file

@ -49,7 +49,6 @@ enum class ColorType : BYTE
struct TextColor struct TextColor
{ {
public: public:
constexpr TextColor() noexcept : constexpr TextColor() noexcept :
_meta{ ColorType::IsDefault }, _meta{ ColorType::IsDefault },
_red{ 0 }, _red{ 0 },
@ -105,7 +104,6 @@ public:
return _index; return _index;
} }
private: private:
ColorType _meta : 2; ColorType _meta : 2;
union union
@ -119,7 +117,8 @@ private:
#ifdef UNIT_TESTING #ifdef UNIT_TESTING
friend class TextBufferTests; friend class TextBufferTests;
template<typename TextColor> friend class WEX::TestExecution::VerifyOutputTraits; template<typename TextColor>
friend class WEX::TestExecution::VerifyOutputTraits;
#endif #endif
}; };
@ -140,8 +139,10 @@ bool constexpr operator!=(const TextColor& a, const TextColor& b) noexcept
#ifdef UNIT_TESTING #ifdef UNIT_TESTING
namespace WEX { namespace WEX
namespace TestExecution { {
namespace TestExecution
{
template<> template<>
class VerifyOutputTraits<TextColor> class VerifyOutputTraits<TextColor>
{ {

View file

@ -24,7 +24,6 @@ namespace std
template<> template<>
struct hash<COORD> struct hash<COORD>
{ {
// Routine Description: // Routine Description:
// - hashes a coord. coord will be hashed by storing the x and y values consecutively in the lower // - hashes a coord. coord will be hashed by storing the x and y values consecutively in the lower
// bits of a size_t. // bits of a size_t.

View file

@ -26,7 +26,6 @@ class TextBuffer;
class Cursor final class Cursor final
{ {
public: public:
static const unsigned int s_InvertCursorColor = INVALID_COLOR; static const unsigned int s_InvertCursorColor = INVALID_COLOR;
Cursor(const ULONG ulSize, TextBuffer& parentBuffer); Cursor(const ULONG ulSize, TextBuffer& parentBuffer);

View file

@ -17,6 +17,8 @@ Abstract:
#pragma once #pragma once
// clang-format off
// This includes support libraries from the CRT, STL, WIL, and GSL // This includes support libraries from the CRT, STL, WIL, and GSL
#include "LibraryIncludes.h" #include "LibraryIncludes.h"
@ -33,3 +35,5 @@ Abstract:
#include "..\inc\operators.hpp" #include "..\inc\operators.hpp"
#include "..\inc\unicode.hpp" #include "..\inc\unicode.hpp"
#pragma warning(pop) #pragma warning(pop)
// clang-format on

View file

@ -748,8 +748,7 @@ const Cursor& TextBuffer::GetCursor() const
return _cursor; return _cursor;
} }
[[nodiscard]] [[nodiscard]] TextAttribute TextBuffer::GetCurrentAttributes() const noexcept
TextAttribute TextBuffer::GetCurrentAttributes() const noexcept
{ {
return _currentAttributes; return _currentAttributes;
} }
@ -779,8 +778,7 @@ void TextBuffer::Reset()
// - newSize - new size of screen. // - newSize - new size of screen.
// Return Value: // Return Value:
// - Success if successful. Invalid parameter if screen buffer size is unexpected. No memory if allocation failed. // - Success if successful. Invalid parameter if screen buffer size is unexpected. No memory if allocation failed.
[[nodiscard]] [[nodiscard]] NTSTATUS TextBuffer::ResizeTraditional(const COORD newSize) noexcept
NTSTATUS TextBuffer::ResizeTraditional(const COORD newSize) noexcept
{ {
RETURN_HR_IF(E_INVALIDARG, newSize.X < 0 || newSize.Y < 0); RETURN_HR_IF(E_INVALIDARG, newSize.X < 0 || newSize.Y < 0);
@ -822,7 +820,6 @@ NTSTATUS TextBuffer::ResizeTraditional(const COORD newSize) noexcept
// Also take advantage of the row ID refresh loop to resize the rows in the X dimension // Also take advantage of the row ID refresh loop to resize the rows in the X dimension
// and cleanup the UnicodeStorage characters that might fall outside the resized buffer. // and cleanup the UnicodeStorage characters that might fall outside the resized buffer.
_RefreshRowIDs(newSize.X); _RefreshRowIDs(newSize.X);
} }
CATCH_RETURN(); CATCH_RETURN();

View file

@ -117,15 +117,13 @@ public:
UINT TotalRowCount() const; UINT TotalRowCount() const;
[[nodiscard]] [[nodiscard]] TextAttribute GetCurrentAttributes() const noexcept;
TextAttribute GetCurrentAttributes() const noexcept;
void SetCurrentAttributes(const TextAttribute currentAttributes) noexcept; void SetCurrentAttributes(const TextAttribute currentAttributes) noexcept;
void Reset(); void Reset();
[[nodiscard]] [[nodiscard]] HRESULT ResizeTraditional(const COORD newSize) noexcept;
HRESULT ResizeTraditional(const COORD newSize) noexcept;
const UnicodeStorage& GetUnicodeStorage() const; const UnicodeStorage& GetUnicodeStorage() const;
UnicodeStorage& GetUnicodeStorage(); UnicodeStorage& GetUnicodeStorage();
@ -147,7 +145,6 @@ public:
std::function<COLORREF(TextAttribute&)> GetBackgroundColor) const; std::function<COLORREF(TextAttribute&)> GetBackgroundColor) const;
private: private:
std::deque<ROW> _storage; std::deque<ROW> _storage;
Cursor _cursor; Cursor _cursor;

View file

@ -50,7 +50,6 @@ public:
const OutputCellView* operator->() const noexcept; const OutputCellView* operator->() const noexcept;
protected: protected:
void _SetPos(const COORD newPos); void _SetPos(const COORD newPos);
void _GenerateView(); void _GenerateView();
static const ROW* s_GetRow(const TextBuffer& buffer, const COORD pos); static const ROW* s_GetRow(const TextBuffer& buffer, const COORD pos);
@ -70,4 +69,3 @@ protected:
friend class ApiRoutinesTests; friend class ApiRoutinesTests;
#endif #endif
}; };

View file

@ -38,4 +38,3 @@ const std::wstring_view* TextBufferTextIterator::operator->() const
{ {
return &_view.Chars(); return &_view.Chars();
} }

View file

@ -28,7 +28,6 @@ public:
const std::wstring_view* operator->() const; const std::wstring_view* operator->() const;
protected: protected:
#if UNIT_TESTING #if UNIT_TESTING
friend class TextBufferIteratorTests; friend class TextBufferIteratorTests;
#endif #endif

View file

@ -72,8 +72,7 @@ void TextAttributeTests::TestRoundtripLegacy()
void TextAttributeTests::TestRoundtripMetaBits() void TextAttributeTests::TestRoundtripMetaBits()
{ {
WORD metaFlags[] = WORD metaFlags[] = {
{
COMMON_LVB_GRID_HORIZONTAL, COMMON_LVB_GRID_HORIZONTAL,
COMMON_LVB_GRID_LVERTICAL, COMMON_LVB_GRID_LVERTICAL,
COMMON_LVB_GRID_RVERTICAL, COMMON_LVB_GRID_RVERTICAL,
@ -123,8 +122,7 @@ void TextAttributeTests::TestRoundtripExhaustive()
if (!(isLegacy && areEqual)) if (!(isLegacy && areEqual))
{ {
Log::Comment(NoThrowString().Format( Log::Comment(NoThrowString().Format(
L"Failed on wLegacy=0x%x", wLegacy L"Failed on wLegacy=0x%x", wLegacy));
));
VERIFY_IS_TRUE(attr.IsLegacy()); VERIFY_IS_TRUE(attr.IsLegacy());
VERIFY_ARE_EQUAL(wLegacy, attr.GetLegacyAttributes()); VERIFY_ARE_EQUAL(wLegacy, attr.GetLegacyAttributes());
} }

View file

@ -199,7 +199,6 @@ void TextColorTests::TestChangeColor()
color = rgbColor.GetColor(view, _defaultBg, true); color = rgbColor.GetColor(view, _defaultBg, true);
VERIFY_ARE_EQUAL(_colorTable[15], color); VERIFY_ARE_EQUAL(_colorTable[15], color);
rgbColor.SetIndex(15); rgbColor.SetIndex(15);
color = rgbColor.GetColor(view, _defaultFg, false); color = rgbColor.GetColor(view, _defaultFg, false);
VERIFY_ARE_EQUAL(_colorTable[15], color); VERIFY_ARE_EQUAL(_colorTable[15], color);

View file

@ -15,7 +15,6 @@ class UnicodeStorageTests
{ {
TEST_CLASS(UnicodeStorageTests); TEST_CLASS(UnicodeStorageTests);
TEST_METHOD(CanOverwriteEmoji) TEST_METHOD(CanOverwriteEmoji)
{ {
UnicodeStorage storage; UnicodeStorage storage;

View file

@ -17,6 +17,8 @@ Abstract:
#pragma once #pragma once
// clang-format off
// This includes support libraries from the CRT, STL, WIL, and GSL // This includes support libraries from the CRT, STL, WIL, and GSL
#include "LibraryIncludes.h" #include "LibraryIncludes.h"
@ -35,3 +37,5 @@ Abstract:
#include "..\inc\operators.hpp" #include "..\inc\operators.hpp"
#include "..\inc\unicode.hpp" #include "..\inc\unicode.hpp"
#pragma warning(pop) #pragma warning(pop)
// clang-format on

View file

@ -39,6 +39,7 @@ namespace winrt::Microsoft::UI::Xaml::Markup::factory_implementation
public: public:
XamlApplication(); XamlApplication();
~XamlApplication(); ~XamlApplication();
private: private:
std::vector<HMODULE> m_preloadInstances; std::vector<HMODULE> m_preloadInstances;
}; };

View file

@ -19,4 +19,3 @@
#include <unknwn.h> #include <unknwn.h>
#include <winrt/Windows.Foundation.h> #include <winrt/Windows.Foundation.h>

View file

@ -36,7 +36,6 @@ namespace winrt
namespace winrt::TerminalApp::implementation namespace winrt::TerminalApp::implementation
{ {
App::App() : App::App() :
App(winrt::TerminalApp::XamlMetaDataProvider()) App(winrt::TerminalApp::XamlMetaDataProvider())
{ {
@ -263,7 +262,6 @@ namespace winrt::TerminalApp::implementation
return TermControl::GetProposedDimensions(settings, dpi); return TermControl::GetProposedDimensions(settings, dpi);
} }
bool App::GetShowTabsInTitlebar() bool App::GetShowTabsInTitlebar()
{ {
if (!_loadedInitialSettings) if (!_loadedInitialSettings)
@ -440,8 +438,7 @@ namespace winrt::TerminalApp::implementation
// `CascadiaSettings::LoadAll` for details. // `CascadiaSettings::LoadAll` for details.
// Return Value: // Return Value:
// - S_OK if we successfully parsed the settings, otherwise an appropriate HRESULT. // - S_OK if we successfully parsed the settings, otherwise an appropriate HRESULT.
[[nodiscard]] [[nodiscard]] HRESULT App::_TryLoadSettings(const bool saveOnLoad) noexcept
HRESULT App::_TryLoadSettings(const bool saveOnLoad) noexcept
{ {
HRESULT hr = E_FAIL; HRESULT hr = E_FAIL;
@ -514,9 +511,10 @@ namespace winrt::TerminalApp::implementation
std::filesystem::path fileParser = localPathCopy.c_str(); std::filesystem::path fileParser = localPathCopy.c_str();
const auto folder = fileParser.parent_path(); const auto folder = fileParser.parent_path();
_reader.create(folder.c_str(), false, wil::FolderChangeEvents::All, _reader.create(folder.c_str(),
[this](wil::FolderChangeEvent event, PCWSTR fileModified) false,
{ wil::FolderChangeEvents::All,
[this](wil::FolderChangeEvent event, PCWSTR fileModified) {
// We want file modifications, AND when files are renamed to be // We want file modifications, AND when files are renamed to be
// profiles.json. This second case will oftentimes happen with text // profiles.json. This second case will oftentimes happen with text
// editors, who will write a temp file, then rename it to be the // editors, who will write a temp file, then rename it to be the
@ -600,7 +598,6 @@ namespace winrt::TerminalApp::implementation
// profile, which might have changed // profile, which might have changed
_CreateNewTabFlyout(); _CreateNewTabFlyout();
}); });
} }
// Method Description: // Method Description:
@ -801,8 +798,7 @@ namespace winrt::TerminalApp::implementation
_UpdateTitle(tab); _UpdateTitle(tab);
}); });
term.GetControl().GotFocus([this, weakTabPtr](auto&&, auto&&) term.GetControl().GotFocus([this, weakTabPtr](auto&&, auto&&) {
{
auto tab = weakTabPtr.lock(); auto tab = weakTabPtr.lock();
if (!tab) if (!tab)
{ {
@ -945,8 +941,7 @@ namespace winrt::TerminalApp::implementation
// we clamp the values to the range [0, tabCount) while still supporting moving // we clamp the values to the range [0, tabCount) while still supporting moving
// leftward from 0 to tabCount - 1. // leftward from 0 to tabCount - 1.
_SetFocusedTabIndex( _SetFocusedTabIndex(
static_cast<int>((tabCount + focusedTabIndex + (bMoveRight ? 1 : -1)) % tabCount) static_cast<int>((tabCount + focusedTabIndex + (bMoveRight ? 1 : -1)) % tabCount));
);
} }
// Method Description: // Method Description:

View file

@ -18,7 +18,6 @@
namespace winrt::TerminalApp::implementation namespace winrt::TerminalApp::implementation
{ {
// We dont use AppT as it does not provide access to protected constructors // We dont use AppT as it does not provide access to protected constructors
template<typename D, typename... I> template<typename D, typename... I>
using AppT_Override = App_base<D, I...>; using AppT_Override = App_base<D, I...>;
@ -75,8 +74,7 @@ namespace winrt::TerminalApp::implementation
fire_and_forget _ShowOkDialog(const winrt::hstring& titleKey, const winrt::hstring& contentKey); fire_and_forget _ShowOkDialog(const winrt::hstring& titleKey, const winrt::hstring& contentKey);
[[nodiscard]] [[nodiscard]] HRESULT _TryLoadSettings(const bool saveOnLoad) noexcept;
HRESULT _TryLoadSettings(const bool saveOnLoad) noexcept;
void _LoadSettings(); void _LoadSettings();
void _OpenSettings(); void _OpenSettings();
@ -92,7 +90,6 @@ namespace winrt::TerminalApp::implementation
void _UpdateTabIcon(std::shared_ptr<Tab> tab); void _UpdateTabIcon(std::shared_ptr<Tab> tab);
void _UpdateTitle(std::shared_ptr<Tab> tab); void _UpdateTitle(std::shared_ptr<Tab> tab);
void _RegisterTerminalEvents(Microsoft::Terminal::TerminalControl::TermControl term, std::shared_ptr<Tab> hostingTab); void _RegisterTerminalEvents(Microsoft::Terminal::TerminalControl::TermControl term, std::shared_ptr<Tab> hostingTab);
void _CreateNewTabFromSettings(GUID profileGuid, winrt::Microsoft::Terminal::Settings::TerminalSettings settings); void _CreateNewTabFromSettings(GUID profileGuid, winrt::Microsoft::Terminal::Settings::TerminalSettings settings);

View file

@ -23,7 +23,10 @@ namespace winrt::TerminalApp::implementation
{ {
for (auto& kv : _keyShortcuts) for (auto& kv : _keyShortcuts)
{ {
if (kv.second == action) return kv.first; if (kv.second == action)
{
return kv.first;
}
} }
return { nullptr }; return { nullptr };
} }
@ -208,6 +211,7 @@ namespace winrt::TerminalApp::implementation
} }
// -------------------------------- Events --------------------------------- // -------------------------------- Events ---------------------------------
// clang-format off
DEFINE_EVENT(AppKeyBindings, CopyText, _CopyTextHandlers, TerminalApp::CopyTextEventArgs); DEFINE_EVENT(AppKeyBindings, CopyText, _CopyTextHandlers, TerminalApp::CopyTextEventArgs);
DEFINE_EVENT(AppKeyBindings, PasteText, _PasteTextHandlers, TerminalApp::PasteTextEventArgs); DEFINE_EVENT(AppKeyBindings, PasteText, _PasteTextHandlers, TerminalApp::PasteTextEventArgs);
DEFINE_EVENT(AppKeyBindings, NewTab, _NewTabHandlers, TerminalApp::NewTabEventArgs); DEFINE_EVENT(AppKeyBindings, NewTab, _NewTabHandlers, TerminalApp::NewTabEventArgs);
@ -227,4 +231,5 @@ namespace winrt::TerminalApp::implementation
DEFINE_EVENT(AppKeyBindings, ScrollUpPage, _ScrollUpPageHandlers, TerminalApp::ScrollUpPageEventArgs); DEFINE_EVENT(AppKeyBindings, ScrollUpPage, _ScrollUpPageHandlers, TerminalApp::ScrollUpPageEventArgs);
DEFINE_EVENT(AppKeyBindings, ScrollDownPage, _ScrollDownPageHandlers, TerminalApp::ScrollDownPageEventArgs); DEFINE_EVENT(AppKeyBindings, ScrollDownPage, _ScrollDownPageHandlers, TerminalApp::ScrollDownPageEventArgs);
DEFINE_EVENT(AppKeyBindings, OpenSettings, _OpenSettingsHandlers, TerminalApp::OpenSettingsEventArgs); DEFINE_EVENT(AppKeyBindings, OpenSettings, _OpenSettingsHandlers, TerminalApp::OpenSettingsEventArgs);
// clang-format on
} }

View file

@ -39,6 +39,7 @@ namespace winrt::TerminalApp::implementation
static Windows::System::VirtualKeyModifiers ConvertVKModifiers(winrt::Microsoft::Terminal::Settings::KeyModifiers modifiers); static Windows::System::VirtualKeyModifiers ConvertVKModifiers(winrt::Microsoft::Terminal::Settings::KeyModifiers modifiers);
static winrt::hstring FormatOverrideShortcutText(winrt::Microsoft::Terminal::Settings::KeyModifiers modifiers); static winrt::hstring FormatOverrideShortcutText(winrt::Microsoft::Terminal::Settings::KeyModifiers modifiers);
// clang-format off
DECLARE_EVENT(CopyText, _CopyTextHandlers, TerminalApp::CopyTextEventArgs); DECLARE_EVENT(CopyText, _CopyTextHandlers, TerminalApp::CopyTextEventArgs);
DECLARE_EVENT(PasteText, _PasteTextHandlers, TerminalApp::PasteTextEventArgs); DECLARE_EVENT(PasteText, _PasteTextHandlers, TerminalApp::PasteTextEventArgs);
DECLARE_EVENT(NewTab, _NewTabHandlers, TerminalApp::NewTabEventArgs); DECLARE_EVENT(NewTab, _NewTabHandlers, TerminalApp::NewTabEventArgs);
@ -58,11 +59,11 @@ namespace winrt::TerminalApp::implementation
DECLARE_EVENT(ScrollUpPage, _ScrollUpPageHandlers, TerminalApp::ScrollUpPageEventArgs); DECLARE_EVENT(ScrollUpPage, _ScrollUpPageHandlers, TerminalApp::ScrollUpPageEventArgs);
DECLARE_EVENT(ScrollDownPage, _ScrollDownPageHandlers, TerminalApp::ScrollDownPageEventArgs); DECLARE_EVENT(ScrollDownPage, _ScrollDownPageHandlers, TerminalApp::ScrollDownPageEventArgs);
DECLARE_EVENT(OpenSettings, _OpenSettingsHandlers, TerminalApp::OpenSettingsEventArgs); DECLARE_EVENT(OpenSettings, _OpenSettingsHandlers, TerminalApp::OpenSettingsEventArgs);
// clang-format on
private: private:
std::unordered_map<winrt::Microsoft::Terminal::Settings::KeyChord, TerminalApp::ShortcutAction, KeyChordHash, KeyChordEquality> _keyShortcuts; std::unordered_map<winrt::Microsoft::Terminal::Settings::KeyChord, TerminalApp::ShortcutAction, KeyChordHash, KeyChordEquality> _keyShortcuts;
bool _DoAction(ShortcutAction action); bool _DoAction(ShortcutAction action);
}; };
} }

View file

@ -211,5 +211,4 @@ winrt::TerminalApp::AppKeyBindings AppKeyBindingsSerialization::FromJson(const J
} }
} }
return newBindings; return newBindings;
} }

View file

@ -18,8 +18,7 @@ using namespace Microsoft::Console;
// {2bde4a90-d05f-401c-9492-e40884ead1d8} // {2bde4a90-d05f-401c-9492-e40884ead1d8}
// uuidv5 properties: name format is UTF-16LE bytes // uuidv5 properties: name format is UTF-16LE bytes
static constexpr GUID TERMINAL_PROFILE_NAMESPACE_GUID = static constexpr GUID TERMINAL_PROFILE_NAMESPACE_GUID = { 0x2bde4a90, 0xd05f, 0x401c, { 0x94, 0x92, 0xe4, 0x8, 0x84, 0xea, 0xd1, 0xd8 } };
{ 0x2bde4a90, 0xd05f, 0x401c, { 0x94, 0x92, 0xe4, 0x8, 0x84, 0xea, 0xd1, 0xd8 } };
static constexpr std::wstring_view PACKAGED_PROFILE_ICON_PATH{ L"ms-appx:///ProfileIcons/" }; static constexpr std::wstring_view PACKAGED_PROFILE_ICON_PATH{ L"ms-appx:///ProfileIcons/" };
static constexpr std::wstring_view PACKAGED_PROFILE_ICON_EXTENSION{ L".png" }; static constexpr std::wstring_view PACKAGED_PROFILE_ICON_EXTENSION{ L".png" };
@ -29,12 +28,10 @@ CascadiaSettings::CascadiaSettings() :
_globals{}, _globals{},
_profiles{} _profiles{}
{ {
} }
CascadiaSettings::~CascadiaSettings() CascadiaSettings::~CascadiaSettings()
{ {
} }
ColorScheme _CreateCampbellScheme() ColorScheme _CreateCampbellScheme()
@ -50,6 +47,8 @@ ColorScheme _CreateCampbellScheme()
return campbellScheme; return campbellScheme;
} }
// clang-format off
ColorScheme _CreateOneHalfDarkScheme() ColorScheme _CreateOneHalfDarkScheme()
{ {
// First 8 dark colors per: https://github.com/sonph/onehalf/blob/master/putty/onehalf-dark.reg // First 8 dark colors per: https://github.com/sonph/onehalf/blob/master/putty/onehalf-dark.reg
@ -167,6 +166,8 @@ ColorScheme _CreateSolarizedLightScheme()
return solarizedLightScheme; return solarizedLightScheme;
} }
// clang-format on
// Method Description: // Method Description:
// - Create the set of schemes to use as the default schemes. Currently creates // - Create the set of schemes to use as the default schemes. Currently creates
// five default color schemes - Campbell (the new cmd color scheme), // five default color schemes - Campbell (the new cmd color scheme),
@ -498,8 +499,16 @@ void CascadiaSettings::_AppendWslProfiles(std::vector<TerminalApp::Profile>& pro
std::wstring command(systemPath.get()); std::wstring command(systemPath.get());
command += L"\\wsl.exe --list"; command += L"\\wsl.exe --list";
THROW_IF_WIN32_BOOL_FALSE(CreateProcessW(nullptr, const_cast<LPWSTR>(command.c_str()), nullptr, nullptr, THROW_IF_WIN32_BOOL_FALSE(CreateProcessW(nullptr,
TRUE, CREATE_NO_WINDOW, nullptr, nullptr, &si, &pi)); const_cast<LPWSTR>(command.c_str()),
nullptr,
nullptr,
TRUE,
CREATE_NO_WINDOW,
nullptr,
nullptr,
&si,
&pi));
switch (WaitForSingleObject(pi.hProcess, INFINITE)) switch (WaitForSingleObject(pi.hProcess, INFINITE))
{ {
case WAIT_OBJECT_0: case WAIT_OBJECT_0:
@ -524,7 +533,8 @@ void CascadiaSettings::_AppendWslProfiles(std::vector<TerminalApp::Profile>& pro
DWORD bytesAvailable; DWORD bytesAvailable;
THROW_IF_WIN32_BOOL_FALSE(PeekNamedPipe(readPipe.get(), nullptr, NULL, nullptr, &bytesAvailable, nullptr)); THROW_IF_WIN32_BOOL_FALSE(PeekNamedPipe(readPipe.get(), nullptr, NULL, nullptr, &bytesAvailable, nullptr));
std::wfstream pipe{ _wfdopen(_open_osfhandle((intptr_t)readPipe.get(), _O_WTEXT | _O_RDONLY), L"r") }; std::wfstream pipe{ _wfdopen(_open_osfhandle((intptr_t)readPipe.get(), _O_WTEXT | _O_RDONLY), L"r") };
//don't worry about the handle returned from wfdOpen, readPipe handle is already managed by wil and closing the file handle will cause an error. // don't worry about the handle returned from wfdOpen, readPipe handle is already managed by wil
// and closing the file handle will cause an error.
std::wstring wline; std::wstring wline;
std::getline(pipe, wline); // remove the header from the output. std::getline(pipe, wline); // remove the header from the output.
while (pipe.tellp() < bytesAvailable) while (pipe.tellp() < bytesAvailable)

View file

@ -20,7 +20,6 @@ Author(s):
#include "GlobalAppSettings.h" #include "GlobalAppSettings.h"
#include "Profile.h" #include "Profile.h"
namespace TerminalApp namespace TerminalApp
{ {
class CascadiaSettings; class CascadiaSettings;
@ -28,7 +27,6 @@ namespace TerminalApp
class TerminalApp::CascadiaSettings final class TerminalApp::CascadiaSettings final
{ {
public: public:
CascadiaSettings(); CascadiaSettings();
~CascadiaSettings(); ~CascadiaSettings();
@ -52,11 +50,11 @@ public:
const Profile* FindProfile(GUID profileGuid) const noexcept; const Profile* FindProfile(GUID profileGuid) const noexcept;
void CreateDefaults(); void CreateDefaults();
private: private:
GlobalAppSettings _globals; GlobalAppSettings _globals;
std::vector<Profile> _profiles; std::vector<Profile> _profiles;
void _CreateDefaultKeybindings(); void _CreateDefaultKeybindings();
void _CreateDefaultSchemes(); void _CreateDefaultSchemes();
void _CreateDefaultProfiles(); void _CreateDefaultProfiles();

View file

@ -40,7 +40,8 @@ std::unique_ptr<CascadiaSettings> CascadiaSettings::LoadAll(const bool saveOnLoa
{ {
std::unique_ptr<CascadiaSettings> resultPtr; std::unique_ptr<CascadiaSettings> resultPtr;
std::optional<std::string> fileData = _IsPackaged() ? std::optional<std::string> fileData = _IsPackaged() ?
_LoadAsPackagedApp() : _LoadAsUnpackagedApp(); _LoadAsPackagedApp() :
_LoadAsUnpackagedApp();
const bool foundFile = fileData.has_value(); const bool foundFile = fileData.has_value();
if (foundFile) if (foundFile)
@ -340,7 +341,6 @@ std::optional<std::string> CascadiaSettings::_LoadAsPackagedApp()
return { resultString }; return { resultString };
} }
// Method Description: // Method Description:
// - Reads the content in UTF-8 enconding of our settings file using the Win32 APIs // - Reads the content in UTF-8 enconding of our settings file using the Win32 APIs
// Arguments: // Arguments:

View file

@ -17,8 +17,7 @@ static constexpr std::string_view NameKey{ "name" };
static constexpr std::string_view TableKey{ "colors" }; static constexpr std::string_view TableKey{ "colors" };
static constexpr std::string_view ForegroundKey{ "foreground" }; static constexpr std::string_view ForegroundKey{ "foreground" };
static constexpr std::string_view BackgroundKey{ "background" }; static constexpr std::string_view BackgroundKey{ "background" };
static constexpr std::array<std::string_view, 16> TableColors = static constexpr std::array<std::string_view, 16> TableColors = {
{
"black", "black",
"red", "red",
"green", "green",
@ -43,7 +42,6 @@ ColorScheme::ColorScheme() :
_defaultForeground{ RGB(242, 242, 242) }, _defaultForeground{ RGB(242, 242, 242) },
_defaultBackground{ RGB(12, 12, 12) } _defaultBackground{ RGB(12, 12, 12) }
{ {
} }
ColorScheme::ColorScheme(std::wstring name, COLORREF defaultFg, COLORREF defaultBg) : ColorScheme::ColorScheme(std::wstring name, COLORREF defaultFg, COLORREF defaultBg) :
@ -52,12 +50,10 @@ ColorScheme::ColorScheme(std::wstring name, COLORREF defaultFg, COLORREF default
_defaultForeground{ defaultFg }, _defaultForeground{ defaultFg },
_defaultBackground{ defaultBg } _defaultBackground{ defaultBg }
{ {
} }
ColorScheme::~ColorScheme() ColorScheme::~ColorScheme()
{ {
} }
// Method Description: // Method Description:
@ -157,7 +153,6 @@ ColorScheme ColorScheme::FromJson(const Json::Value& json)
return result; return result;
} }
std::wstring_view ColorScheme::GetName() const noexcept std::wstring_view ColorScheme::GetName() const noexcept
{ {
return { _schemeName }; return { _schemeName };

View file

@ -27,7 +27,6 @@ namespace TerminalApp
class TerminalApp::ColorScheme class TerminalApp::ColorScheme
{ {
public: public:
ColorScheme(); ColorScheme();
ColorScheme(std::wstring name, COLORREF defaultFg, COLORREF defaultBg); ColorScheme(std::wstring name, COLORREF defaultFg, COLORREF defaultBg);

View file

@ -39,12 +39,10 @@ GlobalAppSettings::GlobalAppSettings() :
_showTabsInTitlebar{ true }, _showTabsInTitlebar{ true },
_requestedTheme{ ElementTheme::Default } _requestedTheme{ ElementTheme::Default }
{ {
} }
GlobalAppSettings::~GlobalAppSettings() GlobalAppSettings::~GlobalAppSettings()
{ {
} }
const std::vector<ColorScheme>& GlobalAppSettings::GetColorSchemes() const noexcept const std::vector<ColorScheme>& GlobalAppSettings::GetColorSchemes() const noexcept
@ -52,7 +50,6 @@ const std::vector<ColorScheme>& GlobalAppSettings::GetColorSchemes() const noexc
return _colorSchemes; return _colorSchemes;
} }
std::vector<ColorScheme>& GlobalAppSettings::GetColorSchemes() noexcept std::vector<ColorScheme>& GlobalAppSettings::GetColorSchemes() noexcept
{ {
return _colorSchemes; return _colorSchemes;
@ -207,7 +204,6 @@ GlobalAppSettings GlobalAppSettings::FromJson(const Json::Value& json)
return result; return result;
} }
// Method Description: // Method Description:
// - Helper function for converting a user-specified cursor style corresponding // - Helper function for converting a user-specified cursor style corresponding
// CursorStyle enum value // CursorStyle enum value

View file

@ -24,7 +24,6 @@ namespace TerminalApp
class TerminalApp::GlobalAppSettings final class TerminalApp::GlobalAppSettings final
{ {
public: public:
GlobalAppSettings(); GlobalAppSettings();
~GlobalAppSettings(); ~GlobalAppSettings();
@ -73,5 +72,4 @@ private:
static winrt::Windows::UI::Xaml::ElementTheme _ParseTheme(const std::wstring& themeString) noexcept; static winrt::Windows::UI::Xaml::ElementTheme _ParseTheme(const std::wstring& themeString) noexcept;
static std::wstring_view _SerializeTheme(const winrt::Windows::UI::Xaml::ElementTheme theme) noexcept; static std::wstring_view _SerializeTheme(const winrt::Windows::UI::Xaml::ElementTheme theme) noexcept;
}; };

View file

@ -12,6 +12,7 @@ static constexpr std::wstring_view ALT_KEY{ L"alt" };
static constexpr int MAX_CHORD_PARTS = 4; static constexpr int MAX_CHORD_PARTS = 4;
// clang-format off
static const std::unordered_map<int32_t, std::wstring_view> vkeyNamePairs { static const std::unordered_map<int32_t, std::wstring_view> vkeyNamePairs {
{ VK_BACK , L"backspace"}, { VK_BACK , L"backspace"},
{ VK_TAB , L"tab"}, { VK_TAB , L"tab"},
@ -83,6 +84,7 @@ static const std::unordered_map<int32_t, std::wstring_view> vkeyNamePairs {
// #define VK_OEM_6 0xDD // ']}' for US // #define VK_OEM_6 0xDD // ']}' for US
// #define VK_OEM_7 0xDE // ''"' for US // #define VK_OEM_7 0xDE // ''"' for US
}; };
// clang-format on
// Function Description: // Function Description:
// - Deserializes the given string into a new KeyChord instance. If this // - Deserializes the given string into a new KeyChord instance. If this

View file

@ -376,7 +376,6 @@ void Pane::_CloseChild(const bool closeFirst)
_root.Children().Append(_separatorRoot); _root.Children().Append(_separatorRoot);
_root.Children().Append(_secondChild->GetRootElement()); _root.Children().Append(_secondChild->GetRootElement());
// If the closed child was focused, transfer the focus to it's first sibling. // If the closed child was focused, transfer the focus to it's first sibling.
if (closedChild->_lastFocused) if (closedChild->_lastFocused)
{ {
@ -468,7 +467,6 @@ void Pane::_ApplySplitDefinitions()
Controls::Grid::SetColumn(_firstChild->GetRootElement(), 0); Controls::Grid::SetColumn(_firstChild->GetRootElement(), 0);
Controls::Grid::SetColumn(_separatorRoot, 1); Controls::Grid::SetColumn(_separatorRoot, 1);
Controls::Grid::SetColumn(_secondChild->GetRootElement(), 2); Controls::Grid::SetColumn(_secondChild->GetRootElement(), 2);
} }
else if (_splitState == SplitState::Horizontal) else if (_splitState == SplitState::Horizontal)
{ {
@ -478,7 +476,6 @@ void Pane::_ApplySplitDefinitions()
} }
} }
// Method Description: // Method Description:
// - Vertically split the focused pane in our tree of panes, and place the given // - Vertically split the focused pane in our tree of panes, and place the given
// TermControl into the newly created pane. If we're the focused pane, then // TermControl into the newly created pane. If we're the focused pane, then

View file

@ -18,16 +18,13 @@
// Author: // Author:
// - Mike Griese (zadjii-msft) 16-May-2019 // - Mike Griese (zadjii-msft) 16-May-2019
#pragma once #pragma once
#include <winrt/Microsoft.Terminal.TerminalControl.h> #include <winrt/Microsoft.Terminal.TerminalControl.h>
#include "../../cascadia/inc/cppwinrt_utils.h" #include "../../cascadia/inc/cppwinrt_utils.h"
class Pane : public std::enable_shared_from_this<Pane> class Pane : public std::enable_shared_from_this<Pane>
{ {
public: public:
enum class SplitState : int enum class SplitState : int
{ {
None = 0, None = 0,

View file

@ -95,7 +95,6 @@ Profile::Profile(const winrt::guid& guid):
Profile::~Profile() Profile::~Profile()
{ {
} }
GUID Profile::GetGuid() const noexcept GUID Profile::GetGuid() const noexcept

View file

@ -23,7 +23,6 @@ namespace TerminalApp
class TerminalApp::Profile final class TerminalApp::Profile final
{ {
public: public:
Profile(const winrt::guid& guid); Profile(const winrt::guid& guid);
Profile(); Profile();
@ -55,7 +54,6 @@ public:
bool GetCloseOnExit() const noexcept; bool GetCloseOnExit() const noexcept;
private: private:
static std::wstring EvaluateStartingDirectory(const std::wstring& directory); static std::wstring EvaluateStartingDirectory(const std::wstring& directory);
static winrt::Microsoft::Terminal::Settings::ScrollbarState ParseScrollbarState(const std::wstring& scrollbarState); static winrt::Microsoft::Terminal::Settings::ScrollbarState ParseScrollbarState(const std::wstring& scrollbarState);

View file

@ -7,7 +7,6 @@
class Tab class Tab
{ {
public: public:
Tab(const GUID& profile, const winrt::Microsoft::Terminal::TerminalControl::TermControl& control); Tab(const GUID& profile, const winrt::Microsoft::Terminal::TerminalControl::TermControl& control);
@ -32,7 +31,6 @@ public:
DECLARE_EVENT(Closed, _closedHandlers, winrt::Microsoft::Terminal::TerminalControl::ConnectionClosedEventArgs); DECLARE_EVENT(Closed, _closedHandlers, winrt::Microsoft::Terminal::TerminalControl::ConnectionClosedEventArgs);
private: private:
std::shared_ptr<Pane> _rootPane{ nullptr }; std::shared_ptr<Pane> _rootPane{ nullptr };
bool _focused{ false }; bool _focused{ false };

View file

@ -135,8 +135,14 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
void ConhostConnection::Close() void ConhostConnection::Close()
{ {
if (!_connected) return; if (!_connected)
if (_closing) return; {
return;
}
if (_closing)
{
return;
}
_closing = true; _closing = true;
// TODO: // TODO:
// terminate the output thread // terminate the output thread
@ -181,9 +187,11 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
_disconnectHandlers(); _disconnectHandlers();
return (DWORD)-1; return (DWORD)-1;
} }
} }
if (dwRead == 0) continue; if (dwRead == 0)
{
continue;
}
// Convert buffer to hstring // Convert buffer to hstring
char* pchStr = (char*)(buffer); char* pchStr = (char*)(buffer);
std::string str{ pchStr, dwRead }; std::string str{ pchStr, dwRead };

View file

@ -22,7 +22,6 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
_commandline = commandline; _commandline = commandline;
_initialRows = initialRows; _initialRows = initialRows;
_initialCols = initialCols; _initialCols = initialCols;
} }
winrt::event_token ConptyConnection::TerminalOutput(TerminalConnection::TerminalOutputEventArgs const& handler) winrt::event_token ConptyConnection::TerminalOutput(TerminalConnection::TerminalOutputEventArgs const& handler)
@ -97,7 +96,6 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
throw hresult_not_implemented(); throw hresult_not_implemented();
} }
// Function Description: // Function Description:
// - Sample function which combines the creation of some basic anonymous pipes // - Sample function which combines the creation of some basic anonymous pipes
// and passes them to CreatePseudoConsole. // and passes them to CreatePseudoConsole.
@ -196,7 +194,8 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
THROW_IF_FAILED(_AttachPseudoConsole(_hPC, siEx.lpAttributeList)); THROW_IF_FAILED(_AttachPseudoConsole(_hPC, siEx.lpAttributeList));
std::wstring realCommand = _commandline.c_str(); //winrt::to_string(_commandline); std::wstring realCommand = _commandline.c_str(); //winrt::to_string(_commandline);
if (realCommand == L""){ if (realCommand == L"")
{
realCommand = L"cmd.exe"; realCommand = L"cmd.exe";
} }
@ -221,7 +220,6 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
DeleteProcThreadAttributeList(siEx.lpAttributeList); DeleteProcThreadAttributeList(siEx.lpAttributeList);
} }
DWORD WINAPI ConptyConnection::StaticOutputThreadProc(LPVOID lpParameter) DWORD WINAPI ConptyConnection::StaticOutputThreadProc(LPVOID lpParameter)
{ {
ConptyConnection* const pInstance = (ConptyConnection*)lpParameter; ConptyConnection* const pInstance = (ConptyConnection*)lpParameter;

View file

@ -21,7 +21,6 @@ using namespace winrt::Microsoft::Terminal::Settings;
namespace winrt::Microsoft::Terminal::TerminalControl::implementation namespace winrt::Microsoft::Terminal::TerminalControl::implementation
{ {
TermControl::TermControl() : TermControl::TermControl() :
TermControl(Settings::TerminalSettings{}) TermControl(Settings::TerminalSettings{})
{ {
@ -262,8 +261,9 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// set a new image source for the brush // set a new image source for the brush
auto imageSource = brush.ImageSource().try_as<Media::Imaging::BitmapImage>(); auto imageSource = brush.ImageSource().try_as<Media::Imaging::BitmapImage>();
if (imageSource == nullptr || imageSource.UriSource() == nullptr if (imageSource == nullptr ||
|| imageSource.UriSource().RawUri() != imageUri.RawUri()) imageSource.UriSource() == nullptr ||
imageSource.UriSource().RawUri() != imageUri.RawUri())
{ {
// Note that BitmapImage handles the image load asynchronously, // Note that BitmapImage handles the image load asynchronously,
// which is especially important since the image // which is especially important since the image
@ -376,8 +376,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
} }
auto chain = _renderEngine->GetSwapChain(); auto chain = _renderEngine->GetSwapChain();
_swapChainPanel.Dispatcher().RunAsync(CoreDispatcherPriority::High, [=]() _swapChainPanel.Dispatcher().RunAsync(CoreDispatcherPriority::High, [=]() {
{
auto lock = _terminal->LockForWriting(); auto lock = _terminal->LockForWriting();
auto nativePanel = _swapChainPanel.as<ISwapChainPanelNative>(); auto nativePanel = _swapChainPanel.as<ISwapChainPanelNative>();
nativePanel->SetSwapChain(chain.Get()); nativePanel->SetSwapChain(chain.Get());
@ -457,8 +456,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
_terminal->SetWriteInputCallback(inputFn); _terminal->SetWriteInputCallback(inputFn);
auto chain = _renderEngine->GetSwapChain(); auto chain = _renderEngine->GetSwapChain();
_swapChainPanel.Dispatcher().RunAsync(CoreDispatcherPriority::High, [this, chain]() _swapChainPanel.Dispatcher().RunAsync(CoreDispatcherPriority::High, [this, chain]() {
{
_terminal->LockConsole(); _terminal->LockConsole();
auto nativePanel = _swapChainPanel.as<ISwapChainPanelNative>(); auto nativePanel = _swapChainPanel.as<ISwapChainPanelNative>();
nativePanel->SetSwapChain(chain.Get()); nativePanel->SetSwapChain(chain.Get());
@ -1008,7 +1006,6 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// TODO: MSFT:20895307 If the font doesn't exist, this doesn't // TODO: MSFT:20895307 If the font doesn't exist, this doesn't
// actually fail. We need a way to gracefully fallback. // actually fail. We need a way to gracefully fallback.
_renderer->TriggerFontChange(newDpi, _desiredFont, _actualFont); _renderer->TriggerFontChange(newDpi, _desiredFont, _actualFont);
} }
// Method Description: // Method Description:
@ -1147,7 +1144,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
hstring TermControl::Title() hstring TermControl::Title()
{ {
if (!_initializedTerminal) return L""; if (!_initializedTerminal)
return L"";
hstring hstr(_terminal->GetConsoleTitle()); hstring hstr(_terminal->GetConsoleTitle());
return hstr; return hstr;
@ -1357,11 +1355,15 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
switch (paddingPropIndex) switch (paddingPropIndex)
{ {
case 1: return ThicknessHelper::FromUniformLength(thicknessArr[0]); case 1:
case 2: return ThicknessHelper::FromLengths(thicknessArr[0], thicknessArr[1], thicknessArr[0], thicknessArr[1]); return ThicknessHelper::FromUniformLength(thicknessArr[0]);
case 2:
return ThicknessHelper::FromLengths(thicknessArr[0], thicknessArr[1], thicknessArr[0], thicknessArr[1]);
// No case for paddingPropIndex = 3, since it's not a norm to provide just Left, Top & Right padding values leaving out Bottom // No case for paddingPropIndex = 3, since it's not a norm to provide just Left, Top & Right padding values leaving out Bottom
case 4: return ThicknessHelper::FromLengths(thicknessArr[0], thicknessArr[1], thicknessArr[2], thicknessArr[3]); case 4:
default: return Thickness(); return ThicknessHelper::FromLengths(thicknessArr[0], thicknessArr[1], thicknessArr[2], thicknessArr[3]);
default:
return Thickness();
} }
} }
@ -1417,8 +1419,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
const COORD TermControl::_GetTerminalPosition(winrt::Windows::Foundation::Point cursorPosition) const COORD TermControl::_GetTerminalPosition(winrt::Windows::Foundation::Point cursorPosition)
{ {
// Exclude padding from cursor position calculation // Exclude padding from cursor position calculation
COORD terminalPosition = COORD terminalPosition = {
{
static_cast<SHORT>(cursorPosition.X - _root.Padding().Left), static_cast<SHORT>(cursorPosition.X - _root.Padding().Left),
static_cast<SHORT>(cursorPosition.Y - _root.Padding().Top) static_cast<SHORT>(cursorPosition.Y - _root.Padding().Top)
}; };
@ -1434,6 +1435,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
return terminalPosition; return terminalPosition;
} }
// clang-format off
// -------------------------------- WinRT Events --------------------------------- // -------------------------------- WinRT Events ---------------------------------
// Winrt events need a method for adding a callback to the event and removing the callback. // Winrt events need a method for adding a callback to the event and removing the callback.
// These macros will define them both for you. // These macros will define them both for you.
@ -1441,6 +1443,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
DEFINE_EVENT(TermControl, ConnectionClosed, _connectionClosedHandlers, TerminalControl::ConnectionClosedEventArgs); DEFINE_EVENT(TermControl, ConnectionClosed, _connectionClosedHandlers, TerminalControl::ConnectionClosedEventArgs);
DEFINE_EVENT(TermControl, CopyToClipboard, _clipboardCopyHandlers, TerminalControl::CopyToClipboardEventArgs); DEFINE_EVENT(TermControl, CopyToClipboard, _clipboardCopyHandlers, TerminalControl::CopyToClipboardEventArgs);
DEFINE_EVENT(TermControl, ScrollPositionChanged, _scrollPositionChangedHandlers, TerminalControl::ScrollPositionChangedEventArgs); DEFINE_EVENT(TermControl, ScrollPositionChanged, _scrollPositionChangedHandlers, TerminalControl::ScrollPositionChangedEventArgs);
// clang-format on
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TermControl, PasteFromClipboard, _clipboardPasteHandlers, TerminalControl::TermControl, TerminalControl::PasteFromClipboardEventArgs); DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TermControl, PasteFromClipboard, _clipboardPasteHandlers, TerminalControl::TermControl, TerminalControl::PasteFromClipboardEventArgs);
} }

View file

@ -18,7 +18,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
public PasteFromClipboardEventArgsT<PasteFromClipboardEventArgs> public PasteFromClipboardEventArgsT<PasteFromClipboardEventArgs>
{ {
public: public:
PasteFromClipboardEventArgs(std::function<void(std::wstring)> clipboardDataHandler) : m_clipboardDataHandler(clipboardDataHandler) { } PasteFromClipboardEventArgs(std::function<void(std::wstring)> clipboardDataHandler) :
m_clipboardDataHandler(clipboardDataHandler) {}
void HandleClipboardData(hstring value) void HandleClipboardData(hstring value)
{ {
@ -53,6 +54,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
static Windows::Foundation::Point GetProposedDimensions(Microsoft::Terminal::Settings::IControlSettings const& settings, const uint32_t dpi); static Windows::Foundation::Point GetProposedDimensions(Microsoft::Terminal::Settings::IControlSettings const& settings, const uint32_t dpi);
// clang-format off
// -------------------------------- WinRT Events --------------------------------- // -------------------------------- WinRT Events ---------------------------------
DECLARE_EVENT(TitleChanged, _titleChangedHandlers, TerminalControl::TitleChangedEventArgs); DECLARE_EVENT(TitleChanged, _titleChangedHandlers, TerminalControl::TitleChangedEventArgs);
DECLARE_EVENT(ConnectionClosed, _connectionClosedHandlers, TerminalControl::ConnectionClosedEventArgs); DECLARE_EVENT(ConnectionClosed, _connectionClosedHandlers, TerminalControl::ConnectionClosedEventArgs);
@ -60,6 +62,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
DECLARE_EVENT(CopyToClipboard, _clipboardCopyHandlers, TerminalControl::CopyToClipboardEventArgs); DECLARE_EVENT(CopyToClipboard, _clipboardCopyHandlers, TerminalControl::CopyToClipboardEventArgs);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(PasteFromClipboard, _clipboardPasteHandlers, TerminalControl::TermControl, TerminalControl::PasteFromClipboardEventArgs); DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(PasteFromClipboard, _clipboardPasteHandlers, TerminalControl::TermControl, TerminalControl::PasteFromClipboardEventArgs);
// clang-format on
private: private:
TerminalConnection::ITerminalConnection _connection; TerminalConnection::ITerminalConnection _connection;

View file

@ -30,4 +30,3 @@
#include <winrt/Windows.ui.xaml.input.h> #include <winrt/Windows.ui.xaml.input.h>
#include <windows.ui.xaml.media.dxinterop.h> #include <windows.ui.xaml.media.dxinterop.h>

View file

@ -12,10 +12,8 @@ namespace Microsoft::Terminal::Core
virtual bool SendKeyEvent(const WORD vkey, const bool ctrlPressed, const bool altPressed, const bool shiftPressed) = 0; virtual bool SendKeyEvent(const WORD vkey, const bool ctrlPressed, const bool altPressed, const bool shiftPressed) = 0;
// void SendMouseEvent(uint row, uint col, KeyModifiers modifiers); // void SendMouseEvent(uint row, uint col, KeyModifiers modifiers);
[[nodiscard]] [[nodiscard]] virtual HRESULT UserResize(const COORD size) noexcept = 0;
virtual HRESULT UserResize(const COORD size) noexcept = 0;
virtual void UserScrollViewport(const int viewTop) = 0; virtual void UserScrollViewport(const int viewTop) = 0;
virtual int GetScrollOffset() = 0; virtual int GetScrollOffset() = 0;
}; };
} }

View file

@ -50,9 +50,11 @@ Terminal::Terminal() :
{ {
_stateMachine = std::make_unique<StateMachine>(new OutputStateMachineEngine(new TerminalDispatch(*this))); _stateMachine = std::make_unique<StateMachine>(new OutputStateMachineEngine(new TerminalDispatch(*this)));
auto passAlongInput = [&](std::deque<std::unique_ptr<IInputEvent>>& inEventsToWrite) auto passAlongInput = [&](std::deque<std::unique_ptr<IInputEvent>>& inEventsToWrite) {
if (!_pfnWriteInput)
{ {
if(!_pfnWriteInput) return; return;
}
std::wstring wstr = _KeyEventsToText(inEventsToWrite); std::wstring wstr = _KeyEventsToText(inEventsToWrite);
_pfnWriteInput(wstr); _pfnWriteInput(wstr);
}; };
@ -146,8 +148,7 @@ void Terminal::UpdateSettings(winrt::Microsoft::Terminal::Settings::ICoreSetting
// - S_OK if we successfully resized the terminal, S_FALSE if there was // - S_OK if we successfully resized the terminal, S_FALSE if there was
// nothing to do (the viewportSize is the same as our current size), or an // nothing to do (the viewportSize is the same as our current size), or an
// appropriate HRESULT for failing to resize. // appropriate HRESULT for failing to resize.
[[nodiscard]] [[nodiscard]] HRESULT Terminal::UserResize(const COORD viewportSize) noexcept
HRESULT Terminal::UserResize(const COORD viewportSize) noexcept
{ {
const auto oldDimensions = _mutableViewport.Dimensions(); const auto oldDimensions = _mutableViewport.Dimensions();
if (viewportSize == oldDimensions) if (viewportSize == oldDimensions)
@ -212,11 +213,10 @@ bool Terminal::SendKeyEvent(const WORD vkey,
_NotifyScrollEvent(); _NotifyScrollEvent();
} }
DWORD modifiers = 0 DWORD modifiers = 0 |
| (ctrlPressed? LEFT_CTRL_PRESSED : 0) (ctrlPressed ? LEFT_CTRL_PRESSED : 0) |
| (altPressed? LEFT_ALT_PRESSED : 0) (altPressed ? LEFT_ALT_PRESSED : 0) |
| (shiftPressed? SHIFT_PRESSED : 0) (shiftPressed ? SHIFT_PRESSED : 0);
;
// Alt key sequences _require_ the char to be in the keyevent. If alt is // Alt key sequences _require_ the char to be in the keyevent. If alt is
// pressed, manually get the character that's being typed, and put it in the // pressed, manually get the character that's being typed, and put it in the
@ -252,8 +252,7 @@ bool Terminal::SendKeyEvent(const WORD vkey,
// Return Value: // Return Value:
// - a shared_lock which can be used to unlock the terminal. The shared_lock // - a shared_lock which can be used to unlock the terminal. The shared_lock
// will release this lock when it's destructed. // will release this lock when it's destructed.
[[nodiscard]] [[nodiscard]] std::shared_lock<std::shared_mutex> Terminal::LockForReading()
std::shared_lock<std::shared_mutex> Terminal::LockForReading()
{ {
return std::shared_lock<std::shared_mutex>(_readWriteLock); return std::shared_lock<std::shared_mutex>(_readWriteLock);
} }
@ -263,13 +262,11 @@ std::shared_lock<std::shared_mutex> Terminal::LockForReading()
// Return Value: // Return Value:
// - a unique_lock which can be used to unlock the terminal. The unique_lock // - a unique_lock which can be used to unlock the terminal. The unique_lock
// will release this lock when it's destructed. // will release this lock when it's destructed.
[[nodiscard]] [[nodiscard]] std::unique_lock<std::shared_mutex> Terminal::LockForWriting()
std::unique_lock<std::shared_mutex> Terminal::LockForWriting()
{ {
return std::unique_lock<std::shared_mutex>(_readWriteLock); return std::unique_lock<std::shared_mutex>(_readWriteLock);
} }
Viewport Terminal::_GetMutableViewport() const noexcept Viewport Terminal::_GetMutableViewport() const noexcept
{ {
return _mutableViewport; return _mutableViewport;
@ -527,8 +524,12 @@ std::vector<SMALL_RECT> Terminal::_GetSelectionRects() const
const COORD endSelectionPositionWithOffset = { _endSelectionPosition.X, temp2 }; const COORD endSelectionPositionWithOffset = { _endSelectionPosition.X, temp2 };
// NOTE: (0,0) is top-left so vertical comparison is inverted // NOTE: (0,0) is top-left so vertical comparison is inverted
const COORD &higherCoord = (selectionAnchorWithOffset.Y <= endSelectionPositionWithOffset.Y) ? selectionAnchorWithOffset : endSelectionPositionWithOffset; const COORD& higherCoord = (selectionAnchorWithOffset.Y <= endSelectionPositionWithOffset.Y) ?
const COORD &lowerCoord = (selectionAnchorWithOffset.Y > endSelectionPositionWithOffset.Y) ? selectionAnchorWithOffset : endSelectionPositionWithOffset; selectionAnchorWithOffset :
endSelectionPositionWithOffset;
const COORD& lowerCoord = (selectionAnchorWithOffset.Y > endSelectionPositionWithOffset.Y) ?
selectionAnchorWithOffset :
endSelectionPositionWithOffset;
selectionArea.reserve(lowerCoord.Y - higherCoord.Y + 1); selectionArea.reserve(lowerCoord.Y - higherCoord.Y + 1);
for (auto row = higherCoord.Y; row <= lowerCoord.Y; row++) for (auto row = higherCoord.Y; row <= lowerCoord.Y; row++)

View file

@ -48,10 +48,8 @@ public:
// Write goes through the parser // Write goes through the parser
void Write(std::wstring_view stringView); void Write(std::wstring_view stringView);
[[nodiscard]] [[nodiscard]] std::shared_lock<std::shared_mutex> LockForReading();
std::shared_lock<std::shared_mutex> LockForReading(); [[nodiscard]] std::unique_lock<std::shared_mutex> LockForWriting();
[[nodiscard]]
std::unique_lock<std::shared_mutex> LockForWriting();
short GetBufferHeight() const noexcept; short GetBufferHeight() const noexcept;
@ -82,8 +80,7 @@ public:
const bool ctrlPressed, const bool ctrlPressed,
const bool altPressed, const bool altPressed,
const bool shiftPressed) override; const bool shiftPressed) override;
[[nodiscard]] [[nodiscard]] HRESULT UserResize(const COORD viewportSize) noexcept override;
HRESULT UserResize(const COORD viewportSize) noexcept override;
void UserScrollViewport(const int viewTop) override; void UserScrollViewport(const int viewTop) override;
int GetScrollOffset() override; int GetScrollOffset() override;
#pragma endregion #pragma endregion
@ -193,4 +190,3 @@ public:
std::vector<SMALL_RECT> _GetSelectionRects() const; std::vector<SMALL_RECT> _GetSelectionRects() const;
}; };

View file

@ -13,7 +13,6 @@ using namespace ::Microsoft::Console::VirtualTerminal;
TerminalDispatch::TerminalDispatch(ITerminalApi& terminalApi) : TerminalDispatch::TerminalDispatch(ITerminalApi& terminalApi) :
_terminalApi{ terminalApi } _terminalApi{ terminalApi }
{ {
} }
void TerminalDispatch::Execute(const wchar_t wchControl) void TerminalDispatch::Execute(const wchar_t wchControl)

View file

@ -43,5 +43,4 @@ private:
bool _SetBoldColorHelper(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::GraphicsOptions option); bool _SetBoldColorHelper(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::GraphicsOptions option);
bool _SetDefaultColorHelper(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::GraphicsOptions option); bool _SetDefaultColorHelper(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::GraphicsOptions option);
void _SetGraphicsOptionHelper(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::GraphicsOptions opt); void _SetGraphicsOptionHelper(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::GraphicsOptions opt);
}; };

View file

@ -6,6 +6,7 @@
using namespace ::Microsoft::Terminal::Core; using namespace ::Microsoft::Terminal::Core;
using namespace ::Microsoft::Console::VirtualTerminal; using namespace ::Microsoft::Console::VirtualTerminal;
// clang-format off
const BYTE RED_ATTR = 0x01; const BYTE RED_ATTR = 0x01;
const BYTE GREEN_ATTR = 0x02; const BYTE GREEN_ATTR = 0x02;
const BYTE BLUE_ATTR = 0x04; const BYTE BLUE_ATTR = 0x04;
@ -26,6 +27,7 @@ const BYTE BRIGHT_BLUE = BRIGHT_ATTR | BLUE_ATTR;
const BYTE BRIGHT_MAGENTA = BRIGHT_ATTR | RED_ATTR | BLUE_ATTR; const BYTE BRIGHT_MAGENTA = BRIGHT_ATTR | RED_ATTR | BLUE_ATTR;
const BYTE BRIGHT_CYAN = BRIGHT_ATTR | GREEN_ATTR | BLUE_ATTR; const BYTE BRIGHT_CYAN = BRIGHT_ATTR | GREEN_ATTR | BLUE_ATTR;
const BYTE BRIGHT_WHITE = BRIGHT_ATTR | RED_ATTR | GREEN_ATTR | BLUE_ATTR; const BYTE BRIGHT_WHITE = BRIGHT_ATTR | RED_ATTR | GREEN_ATTR | BLUE_ATTR;
// clang-format on
// Routine Description: // Routine Description:
// Returns true if the GraphicsOption represents an extended color option. // Returns true if the GraphicsOption represents an extended color option.

View file

@ -32,7 +32,6 @@ namespace winrt::Microsoft::Terminal::Settings::implementation
_keyBindings{ nullptr }, _keyBindings{ nullptr },
_scrollbarState{ ScrollbarState::Visible } _scrollbarState{ ScrollbarState::Visible }
{ {
} }
uint32_t TerminalSettings::DefaultForeground() uint32_t TerminalSettings::DefaultForeground()

View file

@ -20,4 +20,3 @@
#include <unknwn.h> #include <unknwn.h>
#include <winrt/Windows.Foundation.h> #include <winrt/Windows.Foundation.h>

View file

@ -23,7 +23,8 @@ public:
_historySize(historySize), _historySize(historySize),
_initialRows(initialRows), _initialRows(initialRows),
_initialCols(initialCols) _initialCols(initialCols)
{ } {
}
// property getters - all implemented // property getters - all implemented
int32_t HistorySize() { return _historySize; } int32_t HistorySize() { return _historySize; }
@ -101,36 +102,31 @@ class ScreenSizeLimitsTest
auto noHistorySettings = winrt::make<MockTermSettings>(0, visibleRowCount, 100); auto noHistorySettings = winrt::make<MockTermSettings>(0, visibleRowCount, 100);
Terminal noHistoryTerminal; Terminal noHistoryTerminal;
noHistoryTerminal.CreateFromSettings(noHistorySettings, emptyRenderTarget); noHistoryTerminal.CreateFromSettings(noHistorySettings, emptyRenderTarget);
VERIFY_ARE_EQUAL(noHistoryTerminal.GetTextBuffer().TotalRowCount(), visibleRowCount, VERIFY_ARE_EQUAL(noHistoryTerminal.GetTextBuffer().TotalRowCount(), visibleRowCount, L"History size of 0 is accepted");
L"History size of 0 is accepted");
// Negative history sizes are clamped to zero. // Negative history sizes are clamped to zero.
auto negativeHistorySizeSettings = winrt::make<MockTermSettings>(-100, visibleRowCount, 100); auto negativeHistorySizeSettings = winrt::make<MockTermSettings>(-100, visibleRowCount, 100);
Terminal negativeHistorySizeTerminal; Terminal negativeHistorySizeTerminal;
negativeHistorySizeTerminal.CreateFromSettings(negativeHistorySizeSettings, emptyRenderTarget); negativeHistorySizeTerminal.CreateFromSettings(negativeHistorySizeSettings, emptyRenderTarget);
VERIFY_ARE_EQUAL(negativeHistorySizeTerminal.GetTextBuffer().TotalRowCount(), visibleRowCount, VERIFY_ARE_EQUAL(negativeHistorySizeTerminal.GetTextBuffer().TotalRowCount(), visibleRowCount, L"Negative history size is clamped to 0");
L"Negative history size is clamped to 0");
// History size + initial visible rows == SHRT_MAX is acceptable. // History size + initial visible rows == SHRT_MAX is acceptable.
auto maxHistorySizeSettings = winrt::make<MockTermSettings>(SHRT_MAX - visibleRowCount, visibleRowCount, 100); auto maxHistorySizeSettings = winrt::make<MockTermSettings>(SHRT_MAX - visibleRowCount, visibleRowCount, 100);
Terminal maxHistorySizeTerminal; Terminal maxHistorySizeTerminal;
maxHistorySizeTerminal.CreateFromSettings(maxHistorySizeSettings, emptyRenderTarget); maxHistorySizeTerminal.CreateFromSettings(maxHistorySizeSettings, emptyRenderTarget);
VERIFY_ARE_EQUAL(maxHistorySizeTerminal.GetTextBuffer().TotalRowCount(), static_cast<unsigned int>(SHRT_MAX), VERIFY_ARE_EQUAL(maxHistorySizeTerminal.GetTextBuffer().TotalRowCount(), static_cast<unsigned int>(SHRT_MAX), L"History size == SHRT_MAX - initial row count is accepted");
L"History size == SHRT_MAX - initial row count is accepted");
// History size + initial visible rows == SHRT_MAX + 1 will be clamped slightly. // History size + initial visible rows == SHRT_MAX + 1 will be clamped slightly.
auto justTooBigHistorySizeSettings = winrt::make<MockTermSettings>(SHRT_MAX - visibleRowCount + 1, visibleRowCount, 100); auto justTooBigHistorySizeSettings = winrt::make<MockTermSettings>(SHRT_MAX - visibleRowCount + 1, visibleRowCount, 100);
Terminal justTooBigHistorySizeTerminal; Terminal justTooBigHistorySizeTerminal;
justTooBigHistorySizeTerminal.CreateFromSettings(justTooBigHistorySizeSettings, emptyRenderTarget); justTooBigHistorySizeTerminal.CreateFromSettings(justTooBigHistorySizeSettings, emptyRenderTarget);
VERIFY_ARE_EQUAL(justTooBigHistorySizeTerminal.GetTextBuffer().TotalRowCount(), static_cast<unsigned int>(SHRT_MAX), VERIFY_ARE_EQUAL(justTooBigHistorySizeTerminal.GetTextBuffer().TotalRowCount(), static_cast<unsigned int>(SHRT_MAX), L"History size == 1 + SHRT_MAX - initial row count is clamped to SHRT_MAX - initial row count");
L"History size == 1 + SHRT_MAX - initial row count is clamped to SHRT_MAX - initial row count");
// Ridiculously large history sizes are also clamped. // Ridiculously large history sizes are also clamped.
auto farTooBigHistorySizeSettings = winrt::make<MockTermSettings>(99999999, visibleRowCount, 100); auto farTooBigHistorySizeSettings = winrt::make<MockTermSettings>(99999999, visibleRowCount, 100);
Terminal farTooBigHistorySizeTerminal; Terminal farTooBigHistorySizeTerminal;
farTooBigHistorySizeTerminal.CreateFromSettings(farTooBigHistorySizeSettings, emptyRenderTarget); farTooBigHistorySizeTerminal.CreateFromSettings(farTooBigHistorySizeSettings, emptyRenderTarget);
VERIFY_ARE_EQUAL(farTooBigHistorySizeTerminal.GetTextBuffer().TotalRowCount(), static_cast<unsigned int>(SHRT_MAX), VERIFY_ARE_EQUAL(farTooBigHistorySizeTerminal.GetTextBuffer().TotalRowCount(), static_cast<unsigned int>(SHRT_MAX), L"History size that is far too large is clamped to SHRT_MAX - initial row count");
L"History size that is far too large is clamped to SHRT_MAX - initial row count");
} }
}; };
} }

View file

@ -102,7 +102,8 @@ void AppHost::AppTitleChanged(winrt::hstring newTitle)
// - <none> // - <none>
// Return Value: // Return Value:
// - <none> // - <none>
void AppHost::LastTabClosed() { void AppHost::LastTabClosed()
{
_window->Close(); _window->Close();
} }
@ -140,7 +141,8 @@ void AppHost::_HandleCreateWindow(const HWND hwnd, const RECT proposedRect)
// Create a RECT from our requested client size // Create a RECT from our requested client size
auto nonClient = Viewport::FromDimensions({ _currentWidth, auto nonClient = Viewport::FromDimensions({ _currentWidth,
_currentHeight }).ToRect(); _currentHeight })
.ToRect();
// Get the size of a window we'd need to host that client rect. This will // Get the size of a window we'd need to host that client rect. This will
// add the titlebar space. // add the titlebar space.
@ -166,11 +168,11 @@ void AppHost::_HandleCreateWindow(const HWND hwnd, const RECT proposedRect)
// size of our window, which will be at least close. // size of our window, which will be at least close.
LOG_LAST_ERROR(); LOG_LAST_ERROR();
nonClient = Viewport::FromDimensions({ _currentWidth, nonClient = Viewport::FromDimensions({ _currentWidth,
_currentHeight }).ToRect(); _currentHeight })
.ToRect();
} }
} }
const auto adjustedHeight = nonClient.bottom - nonClient.top; const auto adjustedHeight = nonClient.bottom - nonClient.top;
const auto adjustedWidth = nonClient.right - nonClient.left; const auto adjustedWidth = nonClient.right - nonClient.left;
@ -181,7 +183,8 @@ void AppHost::_HandleCreateWindow(const HWND hwnd, const RECT proposedRect)
const auto newPos = Viewport::FromDimensions(origin, dimensions); const auto newPos = Viewport::FromDimensions(origin, dimensions);
bool succeeded = SetWindowPos(hwnd, nullptr, bool succeeded = SetWindowPos(hwnd,
nullptr,
newPos.Left(), newPos.Left(),
newPos.Top(), newPos.Top(),
newPos.Width(), newPos.Width(),
@ -191,6 +194,4 @@ void AppHost::_HandleCreateWindow(const HWND hwnd, const RECT proposedRect)
// If we can't resize the window, that's really okay. We can just go on with // If we can't resize the window, that's really okay. We can just go on with
// the originally proposed window size. // the originally proposed window size.
LOG_LAST_ERROR_IF(!succeeded); LOG_LAST_ERROR_IF(!succeeded);
} }

View file

@ -16,8 +16,7 @@ public:
return reinterpret_cast<T*>(GetWindowLongPtr(window, GWLP_USERDATA)); return reinterpret_cast<T*>(GetWindowLongPtr(window, GWLP_USERDATA));
} }
[[nodiscard]] [[nodiscard]] static LRESULT __stdcall WndProc(HWND const window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept
static LRESULT __stdcall WndProc(HWND const window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept
{ {
WINRT_ASSERT(window); WINRT_ASSERT(window);
@ -41,10 +40,10 @@ public:
return DefWindowProc(window, message, wparam, lparam); return DefWindowProc(window, message, wparam, lparam);
} }
[[nodiscard]] [[nodiscard]] virtual LRESULT MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept
virtual LRESULT MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept {
switch (message)
{ {
switch (message) {
case WM_DPICHANGED: case WM_DPICHANGED:
{ {
return HandleDpiChange(_window, wparam, lparam); return HandleDpiChange(_window, wparam, lparam);
@ -100,8 +99,7 @@ public:
} }
// DPI Change handler. on WM_DPICHANGE resize the window // DPI Change handler. on WM_DPICHANGE resize the window
[[nodiscard]] [[nodiscard]] LRESULT HandleDpiChange(const HWND hWnd, const WPARAM wParam, const LPARAM lParam)
LRESULT HandleDpiChange(const HWND hWnd, const WPARAM wParam, const LPARAM lParam)
{ {
_inDpiChange = true; _inDpiChange = true;
const HWND hWndStatic = GetWindow(hWnd, GW_CHILD); const HWND hWndStatic = GetWindow(hWnd, GW_CHILD);
@ -112,9 +110,7 @@ public:
// Resize the window // Resize the window
auto lprcNewScale = reinterpret_cast<RECT*>(lParam); auto lprcNewScale = reinterpret_cast<RECT*>(lParam);
SetWindowPos(hWnd, nullptr, lprcNewScale->left, lprcNewScale->top, SetWindowPos(hWnd, nullptr, lprcNewScale->left, lprcNewScale->top, lprcNewScale->right - lprcNewScale->left, lprcNewScale->bottom - lprcNewScale->top, SWP_NOZORDER | SWP_NOACTIVATE);
lprcNewScale->right - lprcNewScale->left, lprcNewScale->bottom - lprcNewScale->top,
SWP_NOZORDER | SWP_NOACTIVATE);
_currentDpi = uDpi; _currentDpi = uDpi;
} }
@ -203,4 +199,6 @@ protected:
}; };
template<typename T> template<typename T>
inline BaseWindow<T>::~BaseWindow() { } inline BaseWindow<T>::~BaseWindow()
{
}

View file

@ -51,11 +51,16 @@ void IslandWindow::MakeWindow() noexcept
WINRT_VERIFY(CreateWindow(wc.lpszClassName, WINRT_VERIFY(CreateWindow(wc.lpszClassName,
L"Windows Terminal", L"Windows Terminal",
WS_OVERLAPPEDWINDOW, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
nullptr, nullptr, wc.hInstance, this)); CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
nullptr,
nullptr,
wc.hInstance,
this));
WINRT_ASSERT(_window); WINRT_ASSERT(_window);
} }
// Method Description: // Method Description:
@ -144,11 +149,10 @@ void IslandWindow::OnSize()
} }
} }
[[nodiscard]] [[nodiscard]] LRESULT IslandWindow::MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept
LRESULT IslandWindow::MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept {
switch (message)
{ {
switch (message) {
case WM_CREATE: case WM_CREATE:
{ {
_HandleCreateWindow(wparam, lparam); _HandleCreateWindow(wparam, lparam);
@ -205,4 +209,3 @@ void IslandWindow::SetRootContent(winrt::Windows::UI::Xaml::UIElement content)
_rootGrid.Children().Clear(); _rootGrid.Children().Clear();
_rootGrid.Children().Append(content); _rootGrid.Children().Append(content);
} }

View file

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

View file

@ -71,7 +71,6 @@ void NonClientIslandWindow::SetNonClientContent(winrt::Windows::UI::Xaml::UIElem
_nonClientRootGrid.Children().Append(content); _nonClientRootGrid.Children().Append(content);
} }
// Method Description: // Method Description:
// - Set the height we expect to reserve for the non-client content. // - Set the height we expect to reserve for the non-client content.
// Arguments: // Arguments:
@ -104,7 +103,6 @@ Viewport NonClientIslandWindow::GetTitlebarContentArea() const noexcept
const auto titlebarHeight = titlebarContentHeight - (_titlebarMarginTop + _titlebarMarginBottom); const auto titlebarHeight = titlebarContentHeight - (_titlebarMarginTop + _titlebarMarginBottom);
COORD titlebarOrigin = { static_cast<short>(_windowMarginSides), COORD titlebarOrigin = { static_cast<short>(_windowMarginSides),
static_cast<short>(_titlebarMarginTop) }; static_cast<short>(_titlebarMarginTop) };
@ -172,7 +170,8 @@ void NonClientIslandWindow::OnSize()
auto titlebarArea = GetTitlebarContentArea(); auto titlebarArea = GetTitlebarContentArea();
// update the interop window size // update the interop window size
SetWindowPos(_interopWindowHandle, 0, SetWindowPos(_interopWindowHandle,
0,
clientArea.Left(), clientArea.Left(),
clientArea.Top(), clientArea.Top(),
clientArea.Width(), clientArea.Width(),
@ -188,7 +187,8 @@ void NonClientIslandWindow::OnSize()
} }
// update the interop window size // update the interop window size
SetWindowPos(_nonClientInteropWindowHandle, 0, SetWindowPos(_nonClientInteropWindowHandle,
0,
titlebarArea.Left(), titlebarArea.Left(),
titlebarArea.Top(), titlebarArea.Top(),
titlebarArea.Width(), titlebarArea.Width(),
@ -209,8 +209,7 @@ void NonClientIslandWindow::OnSize()
// NOTE: // NOTE:
// Largely taken from code on: // Largely taken from code on:
// https://docs.microsoft.com/en-us/windows/desktop/dwm/customframe // https://docs.microsoft.com/en-us/windows/desktop/dwm/customframe
[[nodiscard]] [[nodiscard]] LRESULT NonClientIslandWindow::HitTestNCA(POINT ptMouse) const noexcept
LRESULT NonClientIslandWindow::HitTestNCA(POINT ptMouse) const noexcept
{ {
// Get the window rectangle. // Get the window rectangle.
RECT rcWindow = BaseWindow::GetWindowRect(); RECT rcWindow = BaseWindow::GetWindowRect();
@ -249,13 +248,14 @@ LRESULT NonClientIslandWindow::HitTestNCA(POINT ptMouse) const noexcept
uCol = 2; // right side uCol = 2; // right side
} }
// clang-format off
// Hit test (HTTOPLEFT, ... HTBOTTOMRIGHT) // Hit test (HTTOPLEFT, ... HTBOTTOMRIGHT)
LRESULT hitTests[3][3] = LRESULT hitTests[3][3] = {
{
{ HTTOPLEFT, fOnResizeBorder ? HTTOP : HTCAPTION, HTTOPRIGHT }, { HTTOPLEFT, fOnResizeBorder ? HTTOP : HTCAPTION, HTTOPRIGHT },
{ HTLEFT, HTNOWHERE, HTRIGHT }, { HTLEFT, HTNOWHERE, HTRIGHT },
{ HTBOTTOMLEFT, HTBOTTOM, HTBOTTOMRIGHT }, { HTBOTTOMLEFT, HTBOTTOM, HTBOTTOMRIGHT },
}; };
// clang-format on
return hitTests[uRow][uCol]; return hitTests[uRow][uCol];
} }
@ -285,8 +285,7 @@ MARGINS NonClientIslandWindow::GetFrameMargins() const noexcept
// - <none> // - <none>
// Return Value: // Return Value:
// - the HRESULT returned by DwmExtendFrameIntoClientArea. // - the HRESULT returned by DwmExtendFrameIntoClientArea.
[[nodiscard]] [[nodiscard]] HRESULT NonClientIslandWindow::_UpdateFrameMargins() const noexcept
HRESULT NonClientIslandWindow::_UpdateFrameMargins() const noexcept
{ {
// Get the size of the borders we want to use. The sides and bottom will // Get the size of the borders we want to use. The sides and bottom will
// just be big enough for resizing, but the top will be as big as we need // just be big enough for resizing, but the top will be as big as we need
@ -389,8 +388,7 @@ RECT NonClientIslandWindow::GetMaxWindowRectInPixels(const RECT * const prcSugge
// Return Value: // Return Value:
// - The return value is the result of the message processing and depends on the // - The return value is the result of the message processing and depends on the
// message sent. // message sent.
[[nodiscard]] [[nodiscard]] LRESULT NonClientIslandWindow::MessageHandler(UINT const message,
LRESULT NonClientIslandWindow::MessageHandler(UINT const message,
WPARAM const wParam, WPARAM const wParam,
LPARAM const lParam) noexcept LPARAM const lParam) noexcept
{ {
@ -466,7 +464,6 @@ LRESULT NonClientIslandWindow::MessageHandler(UINT const message,
break; break;
} }
} }
} }
return IslandWindow::MessageHandler(message, wParam, lParam); return IslandWindow::MessageHandler(message, wParam, lParam);

View file

@ -31,8 +31,7 @@ public:
virtual void OnSize() override; virtual void OnSize() override;
[[nodiscard]] [[nodiscard]] virtual LRESULT MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept override;
virtual LRESULT MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept override;
void SetNonClientContent(winrt::Windows::UI::Xaml::UIElement content); void SetNonClientContent(winrt::Windows::UI::Xaml::UIElement content);
@ -43,7 +42,6 @@ public:
void SetNonClientHeight(const int contentHeight) noexcept; void SetNonClientHeight(const int contentHeight) noexcept;
private: private:
winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource _nonClientSource; winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource _nonClientSource;
HWND _nonClientInteropWindowHandle; HWND _nonClientInteropWindowHandle;
@ -63,11 +61,9 @@ private:
MARGINS _maximizedMargins; MARGINS _maximizedMargins;
bool _isMaximized; bool _isMaximized;
[[nodiscard]] [[nodiscard]] LRESULT HitTestNCA(POINT ptMouse) const noexcept;
LRESULT HitTestNCA(POINT ptMouse) const noexcept;
[[nodiscard]] [[nodiscard]] HRESULT _UpdateFrameMargins() const noexcept;
HRESULT _UpdateFrameMargins() const noexcept;
void _HandleActivateWindow(); void _HandleActivateWindow();
bool _HandleWindowPosChanging(WINDOWPOS* const windowPos); bool _HandleWindowPosChanging(WINDOWPOS* const windowPos);

View file

@ -24,6 +24,7 @@ Revision History:
public: \ public: \
winrt::event_token name(args const& handler); \ winrt::event_token name(args const& handler); \
void name(winrt::event_token const& token) noexcept; \ void name(winrt::event_token const& token) noexcept; \
\
private: \ private: \
winrt::event<args> eventHandler; winrt::event<args> eventHandler;
@ -43,6 +44,7 @@ Revision History:
public: \ public: \
winrt::event_token name(Windows::Foundation::TypedEventHandler<sender, args> const& handler); \ winrt::event_token name(Windows::Foundation::TypedEventHandler<sender, args> const& handler); \
void name(winrt::event_token const& token) noexcept; \ void name(winrt::event_token const& token) noexcept; \
\
private: \ private: \
winrt::event<Windows::Foundation::TypedEventHandler<sender, args>> eventHandler; winrt::event<Windows::Foundation::TypedEventHandler<sender, args>> eventHandler;

View file

@ -40,48 +40,40 @@ public:
void GetConsoleOutputModeImpl(SCREEN_INFORMATION& context, void GetConsoleOutputModeImpl(SCREEN_INFORMATION& context,
ULONG& mode) noexcept override; ULONG& mode) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleInputModeImpl(InputBuffer& context,
HRESULT SetConsoleInputModeImpl(InputBuffer& context,
const ULONG mode) noexcept override; const ULONG mode) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleOutputModeImpl(SCREEN_INFORMATION& context,
HRESULT SetConsoleOutputModeImpl(SCREEN_INFORMATION& context,
const ULONG Mode) noexcept override; const ULONG Mode) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetNumberOfConsoleInputEventsImpl(const InputBuffer& context,
HRESULT GetNumberOfConsoleInputEventsImpl(const InputBuffer& context,
ULONG& events) noexcept override; ULONG& events) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT PeekConsoleInputAImpl(IConsoleInputObject& context,
HRESULT PeekConsoleInputAImpl(IConsoleInputObject& context,
std::deque<std::unique_ptr<IInputEvent>>& outEvents, std::deque<std::unique_ptr<IInputEvent>>& outEvents,
const size_t eventsToRead, const size_t eventsToRead,
INPUT_READ_HANDLE_DATA& readHandleState, INPUT_READ_HANDLE_DATA& readHandleState,
std::unique_ptr<IWaitRoutine>& waiter) noexcept override; std::unique_ptr<IWaitRoutine>& waiter) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT PeekConsoleInputWImpl(IConsoleInputObject& context,
HRESULT PeekConsoleInputWImpl(IConsoleInputObject& context,
std::deque<std::unique_ptr<IInputEvent>>& outEvents, std::deque<std::unique_ptr<IInputEvent>>& outEvents,
const size_t eventsToRead, const size_t eventsToRead,
INPUT_READ_HANDLE_DATA& readHandleState, INPUT_READ_HANDLE_DATA& readHandleState,
std::unique_ptr<IWaitRoutine>& waiter) noexcept override; std::unique_ptr<IWaitRoutine>& waiter) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT ReadConsoleInputAImpl(IConsoleInputObject& context,
HRESULT ReadConsoleInputAImpl(IConsoleInputObject& context,
std::deque<std::unique_ptr<IInputEvent>>& outEvents, std::deque<std::unique_ptr<IInputEvent>>& outEvents,
const size_t eventsToRead, const size_t eventsToRead,
INPUT_READ_HANDLE_DATA& readHandleState, INPUT_READ_HANDLE_DATA& readHandleState,
std::unique_ptr<IWaitRoutine>& waiter) noexcept override; std::unique_ptr<IWaitRoutine>& waiter) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT ReadConsoleInputWImpl(IConsoleInputObject& context,
HRESULT ReadConsoleInputWImpl(IConsoleInputObject& context,
std::deque<std::unique_ptr<IInputEvent>>& outEvents, std::deque<std::unique_ptr<IInputEvent>>& outEvents,
const size_t eventsToRead, const size_t eventsToRead,
INPUT_READ_HANDLE_DATA& readHandleState, INPUT_READ_HANDLE_DATA& readHandleState,
std::unique_ptr<IWaitRoutine>& waiter) noexcept override; std::unique_ptr<IWaitRoutine>& waiter) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT ReadConsoleAImpl(IConsoleInputObject& context,
HRESULT ReadConsoleAImpl(IConsoleInputObject& context,
gsl::span<char> buffer, gsl::span<char> buffer,
size_t& written, size_t& written,
std::unique_ptr<IWaitRoutine>& waiter, std::unique_ptr<IWaitRoutine>& waiter,
@ -92,8 +84,7 @@ public:
const DWORD controlWakeupMask, const DWORD controlWakeupMask,
DWORD& controlKeyState) noexcept override; DWORD& controlKeyState) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT ReadConsoleWImpl(IConsoleInputObject& context,
HRESULT ReadConsoleWImpl(IConsoleInputObject& context,
gsl::span<char> buffer, gsl::span<char> buffer,
size_t& written, size_t& written,
std::unique_ptr<IWaitRoutine>& waiter, std::unique_ptr<IWaitRoutine>& waiter,
@ -104,43 +95,37 @@ public:
const DWORD controlWakeupMask, const DWORD controlWakeupMask,
DWORD& controlKeyState) noexcept override; DWORD& controlKeyState) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT WriteConsoleAImpl(IConsoleOutputObject& context,
HRESULT WriteConsoleAImpl(IConsoleOutputObject& context,
const std::string_view buffer, const std::string_view buffer,
size_t& read, size_t& read,
std::unique_ptr<IWaitRoutine>& waiter) noexcept override; std::unique_ptr<IWaitRoutine>& waiter) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT WriteConsoleWImpl(IConsoleOutputObject& context,
HRESULT WriteConsoleWImpl(IConsoleOutputObject& context,
const std::wstring_view buffer, const std::wstring_view buffer,
size_t& read, size_t& read,
std::unique_ptr<IWaitRoutine>& waiter) noexcept override; std::unique_ptr<IWaitRoutine>& waiter) noexcept override;
#pragma region ThreadCreationInfo #pragma region ThreadCreationInfo
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleLangIdImpl(LANGID& langId) noexcept override;
HRESULT GetConsoleLangIdImpl(LANGID& langId) noexcept override;
#pragma endregion #pragma endregion
#pragma endregion #pragma endregion
#pragma region L2 #pragma region L2
[[nodiscard]] [[nodiscard]] HRESULT FillConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
HRESULT FillConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
const WORD attribute, const WORD attribute,
const size_t lengthToWrite, const size_t lengthToWrite,
const COORD startingCoordinate, const COORD startingCoordinate,
size_t& cellsModified) noexcept override; size_t& cellsModified) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT FillConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
HRESULT FillConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
const char character, const char character,
const size_t lengthToWrite, const size_t lengthToWrite,
const COORD startingCoordinate, const COORD startingCoordinate,
size_t& cellsModified) noexcept override; size_t& cellsModified) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT FillConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
HRESULT FillConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
const wchar_t character, const wchar_t character,
const size_t lengthToWrite, const size_t lengthToWrite,
const COORD startingCoordinate, const COORD startingCoordinate,
@ -154,18 +139,15 @@ public:
void FlushConsoleInputBuffer(InputBuffer& context) noexcept override; void FlushConsoleInputBuffer(InputBuffer& context) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleInputCodePageImpl(const ULONG codepage) noexcept override;
HRESULT SetConsoleInputCodePageImpl(const ULONG codepage) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleOutputCodePageImpl(const ULONG codepage) noexcept override;
HRESULT SetConsoleOutputCodePageImpl(const ULONG codepage) noexcept override;
void GetConsoleCursorInfoImpl(const SCREEN_INFORMATION& context, void GetConsoleCursorInfoImpl(const SCREEN_INFORMATION& context,
ULONG& size, ULONG& size,
bool& isVisible) noexcept override; bool& isVisible) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleCursorInfoImpl(SCREEN_INFORMATION& context,
HRESULT SetConsoleCursorInfoImpl(SCREEN_INFORMATION& context,
const ULONG size, const ULONG size,
const bool isVisible) noexcept override; const bool isVisible) noexcept override;
@ -173,252 +155,204 @@ public:
void GetConsoleScreenBufferInfoExImpl(const SCREEN_INFORMATION& context, void GetConsoleScreenBufferInfoExImpl(const SCREEN_INFORMATION& context,
CONSOLE_SCREEN_BUFFER_INFOEX& data) noexcept override; CONSOLE_SCREEN_BUFFER_INFOEX& data) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleScreenBufferInfoExImpl(SCREEN_INFORMATION& context,
HRESULT SetConsoleScreenBufferInfoExImpl(SCREEN_INFORMATION& context,
const CONSOLE_SCREEN_BUFFER_INFOEX& data) noexcept override; const CONSOLE_SCREEN_BUFFER_INFOEX& data) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleScreenBufferSizeImpl(SCREEN_INFORMATION& context,
HRESULT SetConsoleScreenBufferSizeImpl(SCREEN_INFORMATION& context,
const COORD size) noexcept override; const COORD size) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleCursorPositionImpl(SCREEN_INFORMATION& context,
HRESULT SetConsoleCursorPositionImpl(SCREEN_INFORMATION& context,
const COORD position) noexcept override; const COORD position) noexcept override;
void GetLargestConsoleWindowSizeImpl(const SCREEN_INFORMATION& context, void GetLargestConsoleWindowSizeImpl(const SCREEN_INFORMATION& context,
COORD& size) noexcept override; COORD& size) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT ScrollConsoleScreenBufferAImpl(SCREEN_INFORMATION& context,
HRESULT ScrollConsoleScreenBufferAImpl(SCREEN_INFORMATION& context,
const SMALL_RECT& source, const SMALL_RECT& source,
const COORD target, const COORD target,
std::optional<SMALL_RECT> clip, std::optional<SMALL_RECT> clip,
const char fillCharacter, const char fillCharacter,
const WORD fillAttribute) noexcept override; const WORD fillAttribute) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT ScrollConsoleScreenBufferWImpl(SCREEN_INFORMATION& context,
HRESULT ScrollConsoleScreenBufferWImpl(SCREEN_INFORMATION& context,
const SMALL_RECT& source, const SMALL_RECT& source,
const COORD target, const COORD target,
std::optional<SMALL_RECT> clip, std::optional<SMALL_RECT> clip,
const wchar_t fillCharacter, const wchar_t fillCharacter,
const WORD fillAttribute) noexcept override; const WORD fillAttribute) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleTextAttributeImpl(SCREEN_INFORMATION& context,
HRESULT SetConsoleTextAttributeImpl(SCREEN_INFORMATION& context,
const WORD attribute) noexcept override; const WORD attribute) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleWindowInfoImpl(SCREEN_INFORMATION& context,
HRESULT SetConsoleWindowInfoImpl(SCREEN_INFORMATION& context,
const bool isAbsolute, const bool isAbsolute,
const SMALL_RECT& windowRect) noexcept override; const SMALL_RECT& windowRect) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT ReadConsoleOutputAttributeImpl(const SCREEN_INFORMATION& context,
HRESULT ReadConsoleOutputAttributeImpl(const SCREEN_INFORMATION& context,
const COORD origin, const COORD origin,
gsl::span<WORD> buffer, gsl::span<WORD> buffer,
size_t& written) noexcept override; size_t& written) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT ReadConsoleOutputCharacterAImpl(const SCREEN_INFORMATION& context,
HRESULT ReadConsoleOutputCharacterAImpl(const SCREEN_INFORMATION& context,
const COORD origin, const COORD origin,
gsl::span<char> buffer, gsl::span<char> buffer,
size_t& written) noexcept override; size_t& written) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT ReadConsoleOutputCharacterWImpl(const SCREEN_INFORMATION& context,
HRESULT ReadConsoleOutputCharacterWImpl(const SCREEN_INFORMATION& context,
const COORD origin, const COORD origin,
gsl::span<wchar_t> buffer, gsl::span<wchar_t> buffer,
size_t& written) noexcept override; size_t& written) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT WriteConsoleInputAImpl(InputBuffer& context,
HRESULT WriteConsoleInputAImpl(InputBuffer& context,
const std::basic_string_view<INPUT_RECORD> buffer, const std::basic_string_view<INPUT_RECORD> buffer,
size_t& written, size_t& written,
const bool append) noexcept override; const bool append) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT WriteConsoleInputWImpl(InputBuffer& context,
HRESULT WriteConsoleInputWImpl(InputBuffer& context,
const std::basic_string_view<INPUT_RECORD> buffer, const std::basic_string_view<INPUT_RECORD> buffer,
size_t& written, size_t& written,
const bool append) noexcept override; const bool append) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT WriteConsoleOutputAImpl(SCREEN_INFORMATION& context,
HRESULT WriteConsoleOutputAImpl(SCREEN_INFORMATION& context,
gsl::span<CHAR_INFO> buffer, gsl::span<CHAR_INFO> buffer,
const Microsoft::Console::Types::Viewport& requestRectangle, const Microsoft::Console::Types::Viewport& requestRectangle,
Microsoft::Console::Types::Viewport& writtenRectangle) noexcept override; Microsoft::Console::Types::Viewport& writtenRectangle) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT WriteConsoleOutputWImpl(SCREEN_INFORMATION& context,
HRESULT WriteConsoleOutputWImpl(SCREEN_INFORMATION& context,
gsl::span<CHAR_INFO> buffer, gsl::span<CHAR_INFO> buffer,
const Microsoft::Console::Types::Viewport& requestRectangle, const Microsoft::Console::Types::Viewport& requestRectangle,
Microsoft::Console::Types::Viewport& writtenRectangle) noexcept override; Microsoft::Console::Types::Viewport& writtenRectangle) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT WriteConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
HRESULT WriteConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
const std::basic_string_view<WORD> attrs, const std::basic_string_view<WORD> attrs,
const COORD target, const COORD target,
size_t& used) noexcept override; size_t& used) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT WriteConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
HRESULT WriteConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
const std::string_view text, const std::string_view text,
const COORD target, const COORD target,
size_t& used) noexcept override; size_t& used) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT WriteConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
HRESULT WriteConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
const std::wstring_view text, const std::wstring_view text,
const COORD target, const COORD target,
size_t& used) noexcept override; size_t& used) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT ReadConsoleOutputAImpl(const SCREEN_INFORMATION& context,
HRESULT ReadConsoleOutputAImpl(const SCREEN_INFORMATION& context,
gsl::span<CHAR_INFO> buffer, gsl::span<CHAR_INFO> buffer,
const Microsoft::Console::Types::Viewport& sourceRectangle, const Microsoft::Console::Types::Viewport& sourceRectangle,
Microsoft::Console::Types::Viewport& readRectangle) noexcept override; Microsoft::Console::Types::Viewport& readRectangle) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT ReadConsoleOutputWImpl(const SCREEN_INFORMATION& context,
HRESULT ReadConsoleOutputWImpl(const SCREEN_INFORMATION& context,
gsl::span<CHAR_INFO> buffer, gsl::span<CHAR_INFO> buffer,
const Microsoft::Console::Types::Viewport& sourceRectangle, const Microsoft::Console::Types::Viewport& sourceRectangle,
Microsoft::Console::Types::Viewport& readRectangle) noexcept override; Microsoft::Console::Types::Viewport& readRectangle) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleTitleAImpl(gsl::span<char> title,
HRESULT GetConsoleTitleAImpl(gsl::span<char> title,
size_t& written, size_t& written,
size_t& needed) noexcept override; size_t& needed) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleTitleWImpl(gsl::span<wchar_t> title,
HRESULT GetConsoleTitleWImpl(gsl::span<wchar_t> title,
size_t& written, size_t& written,
size_t& needed) noexcept override; size_t& needed) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleOriginalTitleAImpl(gsl::span<char> title,
HRESULT GetConsoleOriginalTitleAImpl(gsl::span<char> title,
size_t& written, size_t& written,
size_t& needed) noexcept override; size_t& needed) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleOriginalTitleWImpl(gsl::span<wchar_t> title,
HRESULT GetConsoleOriginalTitleWImpl(gsl::span<wchar_t> title,
size_t& written, size_t& written,
size_t& needed) noexcept override; size_t& needed) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleTitleAImpl(const std::string_view title) noexcept override;
HRESULT SetConsoleTitleAImpl(const std::string_view title) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleTitleWImpl(const std::wstring_view title) noexcept override;
HRESULT SetConsoleTitleWImpl(const std::wstring_view title) noexcept override;
#pragma endregion #pragma endregion
#pragma region L3 #pragma region L3
void GetNumberOfConsoleMouseButtonsImpl(ULONG& buttons) noexcept override; void GetNumberOfConsoleMouseButtonsImpl(ULONG& buttons) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleFontSizeImpl(const SCREEN_INFORMATION& context,
HRESULT GetConsoleFontSizeImpl(const SCREEN_INFORMATION& context,
const DWORD index, const DWORD index,
COORD& size) noexcept override; COORD& size) noexcept override;
//// driver will pare down for non-Ex method //// driver will pare down for non-Ex method
[[nodiscard]] [[nodiscard]] HRESULT GetCurrentConsoleFontExImpl(const SCREEN_INFORMATION& context,
HRESULT GetCurrentConsoleFontExImpl(const SCREEN_INFORMATION& context,
const bool isForMaximumWindowSize, const bool isForMaximumWindowSize,
CONSOLE_FONT_INFOEX& consoleFontInfoEx) noexcept override; CONSOLE_FONT_INFOEX& consoleFontInfoEx) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleDisplayModeImpl(SCREEN_INFORMATION& context,
HRESULT SetConsoleDisplayModeImpl(SCREEN_INFORMATION& context,
const ULONG flags, const ULONG flags,
COORD& newSize) noexcept override; COORD& newSize) noexcept override;
void GetConsoleDisplayModeImpl(ULONG& flags) noexcept override; void GetConsoleDisplayModeImpl(ULONG& flags) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT AddConsoleAliasAImpl(const std::string_view source,
HRESULT AddConsoleAliasAImpl(const std::string_view source,
const std::string_view target, const std::string_view target,
const std::string_view exeName) noexcept override; const std::string_view exeName) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT AddConsoleAliasWImpl(const std::wstring_view source,
HRESULT AddConsoleAliasWImpl(const std::wstring_view source,
const std::wstring_view target, const std::wstring_view target,
const std::wstring_view exeName) noexcept override; const std::wstring_view exeName) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasAImpl(const std::string_view source,
HRESULT GetConsoleAliasAImpl(const std::string_view source,
gsl::span<char> target, gsl::span<char> target,
size_t& written, size_t& written,
const std::string_view exeName) noexcept override; const std::string_view exeName) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasWImpl(const std::wstring_view source,
HRESULT GetConsoleAliasWImpl(const std::wstring_view source,
gsl::span<wchar_t> target, gsl::span<wchar_t> target,
size_t& written, size_t& written,
const std::wstring_view exeName) noexcept override; const std::wstring_view exeName) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasesLengthAImpl(const std::string_view exeName,
HRESULT GetConsoleAliasesLengthAImpl(const std::string_view exeName,
size_t& bufferRequired) noexcept override; size_t& bufferRequired) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasesLengthWImpl(const std::wstring_view exeName,
HRESULT GetConsoleAliasesLengthWImpl(const std::wstring_view exeName,
size_t& bufferRequired) noexcept override; size_t& bufferRequired) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasExesLengthAImpl(size_t& bufferRequired) noexcept override;
HRESULT GetConsoleAliasExesLengthAImpl(size_t& bufferRequired) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasExesLengthWImpl(size_t& bufferRequired) noexcept override;
HRESULT GetConsoleAliasExesLengthWImpl(size_t& bufferRequired) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasesAImpl(const std::string_view exeName,
HRESULT GetConsoleAliasesAImpl(const std::string_view exeName,
gsl::span<char> alias, gsl::span<char> alias,
size_t& written) noexcept override; size_t& written) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasesWImpl(const std::wstring_view exeName,
HRESULT GetConsoleAliasesWImpl(const std::wstring_view exeName,
gsl::span<wchar_t> alias, gsl::span<wchar_t> alias,
size_t& written) noexcept override; size_t& written) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasExesAImpl(gsl::span<char> aliasExes,
HRESULT GetConsoleAliasExesAImpl(gsl::span<char> aliasExes,
size_t& written) noexcept override; size_t& written) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasExesWImpl(gsl::span<wchar_t> aliasExes,
HRESULT GetConsoleAliasExesWImpl(gsl::span<wchar_t> aliasExes,
size_t& written) noexcept override; size_t& written) noexcept override;
#pragma region CMDext Private API #pragma region CMDext Private API
[[nodiscard]] [[nodiscard]] HRESULT ExpungeConsoleCommandHistoryAImpl(const std::string_view exeName) noexcept override;
HRESULT ExpungeConsoleCommandHistoryAImpl(const std::string_view exeName) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT ExpungeConsoleCommandHistoryWImpl(const std::wstring_view exeName) noexcept override;
HRESULT ExpungeConsoleCommandHistoryWImpl(const std::wstring_view exeName) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleNumberOfCommandsAImpl(const std::string_view exeName,
HRESULT SetConsoleNumberOfCommandsAImpl(const std::string_view exeName,
const size_t numberOfCommands) noexcept override; const size_t numberOfCommands) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleNumberOfCommandsWImpl(const std::wstring_view exeName,
HRESULT SetConsoleNumberOfCommandsWImpl(const std::wstring_view exeName,
const size_t numberOfCommands) noexcept override; const size_t numberOfCommands) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleCommandHistoryLengthAImpl(const std::string_view exeName,
HRESULT GetConsoleCommandHistoryLengthAImpl(const std::string_view exeName,
size_t& length) noexcept override; size_t& length) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleCommandHistoryLengthWImpl(const std::wstring_view exeName,
HRESULT GetConsoleCommandHistoryLengthWImpl(const std::wstring_view exeName,
size_t& length) noexcept override; size_t& length) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleCommandHistoryAImpl(const std::string_view exeName,
HRESULT GetConsoleCommandHistoryAImpl(const std::string_view exeName,
gsl::span<char> commandHistory, gsl::span<char> commandHistory,
size_t& written) noexcept override; size_t& written) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleCommandHistoryWImpl(const std::wstring_view exeName,
HRESULT GetConsoleCommandHistoryWImpl(const std::wstring_view exeName,
gsl::span<wchar_t> commandHistory, gsl::span<wchar_t> commandHistory,
size_t& written) noexcept override; size_t& written) noexcept override;
@ -430,11 +364,9 @@ public:
void GetConsoleHistoryInfoImpl(CONSOLE_HISTORY_INFO& consoleHistoryInfo) noexcept override; void GetConsoleHistoryInfoImpl(CONSOLE_HISTORY_INFO& consoleHistoryInfo) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetConsoleHistoryInfoImpl(const CONSOLE_HISTORY_INFO& consoleHistoryInfo) noexcept override;
HRESULT SetConsoleHistoryInfoImpl(const CONSOLE_HISTORY_INFO& consoleHistoryInfo) noexcept override;
[[nodiscard]] [[nodiscard]] HRESULT SetCurrentConsoleFontExImpl(IConsoleOutputObject& context,
HRESULT SetCurrentConsoleFontExImpl(IConsoleOutputObject& context,
const bool isForMaximumWindowSize, const bool isForMaximumWindowSize,
const CONSOLE_FONT_INFOEX& consoleFontInfoEx) noexcept override; const CONSOLE_FONT_INFOEX& consoleFontInfoEx) noexcept override;

View file

@ -59,8 +59,9 @@ CommandListPopup::CommandListPopup(SCREEN_INFORMATION& screenInfo, const Command
_setBottomIndex(); _setBottomIndex();
} }
[[nodiscard]] [[nodiscard]] NTSTATUS CommandListPopup::_handlePopupKeys(COOKED_READ_DATA& cookedReadData,
NTSTATUS CommandListPopup::_handlePopupKeys(COOKED_READ_DATA& cookedReadData, const wchar_t wch, const DWORD modifiers) noexcept const wchar_t wch,
const DWORD modifiers) noexcept
{ {
try try
{ {
@ -146,8 +147,7 @@ void CommandListPopup::_setBottomIndex()
} }
} }
[[nodiscard]] [[nodiscard]] NTSTATUS CommandListPopup::_deleteSelection(COOKED_READ_DATA& cookedReadData) noexcept
NTSTATUS CommandListPopup::_deleteSelection(COOKED_READ_DATA& cookedReadData) noexcept
{ {
try try
{ {
@ -176,8 +176,7 @@ NTSTATUS CommandListPopup::_deleteSelection(COOKED_READ_DATA& cookedReadData) no
// - moves the selected history item up in the history list // - moves the selected history item up in the history list
// Arguments: // Arguments:
// - cookedReadData - the read wait object to operate upon // - cookedReadData - the read wait object to operate upon
[[nodiscard]] [[nodiscard]] NTSTATUS CommandListPopup::_swapUp(COOKED_READ_DATA& cookedReadData) noexcept
NTSTATUS CommandListPopup::_swapUp(COOKED_READ_DATA& cookedReadData) noexcept
{ {
try try
{ {
@ -199,8 +198,7 @@ NTSTATUS CommandListPopup::_swapUp(COOKED_READ_DATA& cookedReadData) noexcept
// - moves the selected history item down in the history list // - moves the selected history item down in the history list
// Arguments: // Arguments:
// - cookedReadData - the read wait object to operate upon // - cookedReadData - the read wait object to operate upon
[[nodiscard]] [[nodiscard]] NTSTATUS CommandListPopup::_swapDown(COOKED_READ_DATA& cookedReadData) noexcept
NTSTATUS CommandListPopup::_swapDown(COOKED_READ_DATA& cookedReadData) noexcept
{ {
try try
{ {
@ -285,8 +283,7 @@ void CommandListPopup::_cycleSelectionToMatchingCommands(COOKED_READ_DATA& cooke
// Return Value: // Return Value:
// - CONSOLE_STATUS_WAIT - we ran out of input, so a wait block was created // - CONSOLE_STATUS_WAIT - we ran out of input, so a wait block was created
// - CONSOLE_STATUS_READ_COMPLETE - user hit return // - CONSOLE_STATUS_READ_COMPLETE - user hit return
[[nodiscard]] [[nodiscard]] NTSTATUS CommandListPopup::Process(COOKED_READ_DATA& cookedReadData) noexcept
NTSTATUS CommandListPopup::Process(COOKED_READ_DATA& cookedReadData) noexcept
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;

View file

@ -17,14 +17,12 @@ Author:
#include "popup.h" #include "popup.h"
class CommandListPopup : public Popup class CommandListPopup : public Popup
{ {
public: public:
CommandListPopup(SCREEN_INFORMATION& screenInfo, const CommandHistory& history); CommandListPopup(SCREEN_INFORMATION& screenInfo, const CommandHistory& history);
[[nodiscard]] [[nodiscard]] NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override;
NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override;
protected: protected:
void _DrawContent() override; void _DrawContent() override;
@ -37,14 +35,10 @@ private:
void _handleReturn(COOKED_READ_DATA& cookedReadData); void _handleReturn(COOKED_READ_DATA& cookedReadData);
void _cycleSelectionToMatchingCommands(COOKED_READ_DATA& cookedReadData, const wchar_t wch); void _cycleSelectionToMatchingCommands(COOKED_READ_DATA& cookedReadData, const wchar_t wch);
void _setBottomIndex(); void _setBottomIndex();
[[nodiscard]] [[nodiscard]] NTSTATUS _handlePopupKeys(COOKED_READ_DATA& cookedReadData, const wchar_t wch, const DWORD modifiers) noexcept;
NTSTATUS _handlePopupKeys(COOKED_READ_DATA& cookedReadData, const wchar_t wch, const DWORD modifiers) noexcept; [[nodiscard]] NTSTATUS _deleteSelection(COOKED_READ_DATA& cookedReadData) noexcept;
[[nodiscard]] [[nodiscard]] NTSTATUS _swapUp(COOKED_READ_DATA& cookedReadData) noexcept;
NTSTATUS _deleteSelection(COOKED_READ_DATA& cookedReadData) noexcept; [[nodiscard]] NTSTATUS _swapDown(COOKED_READ_DATA& cookedReadData) noexcept;
[[nodiscard]]
NTSTATUS _swapUp(COOKED_READ_DATA& cookedReadData) noexcept;
[[nodiscard]]
NTSTATUS _swapDown(COOKED_READ_DATA& cookedReadData) noexcept;
SHORT _currentCommand; SHORT _currentCommand;
SHORT _bottomIndex; // number of command displayed on last line of popup SHORT _bottomIndex; // number of command displayed on last line of popup

View file

@ -113,8 +113,7 @@ void CommandNumberPopup::_handleReturn(COOKED_READ_DATA& cookedReadData) noexcep
// Return Value: // Return Value:
// - CONSOLE_STATUS_WAIT - we ran out of input, so a wait block was created // - CONSOLE_STATUS_WAIT - we ran out of input, so a wait block was created
// - CONSOLE_STATUS_READ_COMPLETE - user hit return // - CONSOLE_STATUS_READ_COMPLETE - user hit return
[[nodiscard]] [[nodiscard]] NTSTATUS CommandNumberPopup::Process(COOKED_READ_DATA& cookedReadData) noexcept
NTSTATUS CommandNumberPopup::Process(COOKED_READ_DATA& cookedReadData) noexcept
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
WCHAR wch = UNICODE_NULL; WCHAR wch = UNICODE_NULL;

View file

@ -17,14 +17,12 @@ Author:
#include "popup.h" #include "popup.h"
class CommandNumberPopup final : public Popup class CommandNumberPopup final : public Popup
{ {
public: public:
CommandNumberPopup(SCREEN_INFORMATION& screenInfo); CommandNumberPopup(SCREEN_INFORMATION& screenInfo);
[[nodiscard]] [[nodiscard]] NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override;
NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override;
protected: protected:
void _DrawContent() override; void _DrawContent() override;

View file

@ -23,8 +23,8 @@ const std::wstring_view ConsoleArguments::FEATURE_PTY_ARG = L"pty";
ConsoleArguments::ConsoleArguments(const std::wstring& commandline, ConsoleArguments::ConsoleArguments(const std::wstring& commandline,
const HANDLE hStdIn, const HANDLE hStdIn,
const HANDLE hStdOut) const HANDLE hStdOut) :
: _commandline(commandline), _commandline(commandline),
_vtInHandle(hStdIn), _vtInHandle(hStdIn),
_vtOutHandle(hStdOut), _vtOutHandle(hStdOut),
_recievedEarlySizeChange{ false }, _recievedEarlySizeChange{ false },
@ -46,7 +46,6 @@ ConsoleArguments::ConsoleArguments(const std::wstring& commandline,
ConsoleArguments::ConsoleArguments() : ConsoleArguments::ConsoleArguments() :
ConsoleArguments(L"", nullptr, nullptr) ConsoleArguments(L"", nullptr, nullptr)
{ {
} }
ConsoleArguments& ConsoleArguments::operator=(const ConsoleArguments& other) ConsoleArguments& ConsoleArguments::operator=(const ConsoleArguments& other)
@ -106,8 +105,9 @@ void ConsoleArguments::s_ConsumeArg(_Inout_ std::vector<std::wstring>& args, _In
// Return Value: // Return Value:
// S_OK if we parsed the string successfully, otherwise E_INVALIDARG indicating // S_OK if we parsed the string successfully, otherwise E_INVALIDARG indicating
// failure. // failure.
[[nodiscard]] [[nodiscard]] HRESULT ConsoleArguments::s_GetArgumentValue(_Inout_ std::vector<std::wstring>& args,
HRESULT ConsoleArguments::s_GetArgumentValue(_Inout_ std::vector<std::wstring>& args, _Inout_ size_t& index, _Out_opt_ std::wstring* const pSetting) _Inout_ size_t& index,
_Out_opt_ std::wstring* const pSetting)
{ {
bool hasNext = (index + 1) < args.size(); bool hasNext = (index + 1) < args.size();
if (hasNext) if (hasNext)
@ -136,8 +136,7 @@ HRESULT ConsoleArguments::s_GetArgumentValue(_Inout_ std::vector<std::wstring>&
// Return Value: // Return Value:
// S_OK if we parsed the string successfully, otherwise E_INVALIDARG indicating // S_OK if we parsed the string successfully, otherwise E_INVALIDARG indicating
// failure. // failure.
[[nodiscard]] [[nodiscard]] HRESULT ConsoleArguments::s_HandleFeatureValue(_Inout_ std::vector<std::wstring>& args, _Inout_ size_t& index)
HRESULT ConsoleArguments::s_HandleFeatureValue(_Inout_ std::vector<std::wstring>& args, _Inout_ size_t& index)
{ {
HRESULT hr = E_INVALIDARG; HRESULT hr = E_INVALIDARG;
bool hasNext = (index + 1) < args.size(); bool hasNext = (index + 1) < args.size();
@ -167,8 +166,7 @@ HRESULT ConsoleArguments::s_HandleFeatureValue(_Inout_ std::vector<std::wstring>
// Return Value: // Return Value:
// S_OK if we parsed the short successfully, otherwise E_INVALIDARG indicating // 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. // failure. This could be the case for non-numeric arguments, or for >SHORT_MAX args.
[[nodiscard]] [[nodiscard]] HRESULT ConsoleArguments::s_GetArgumentValue(_Inout_ std::vector<std::wstring>& args,
HRESULT ConsoleArguments::s_GetArgumentValue(_Inout_ std::vector<std::wstring>& args,
_Inout_ size_t& index, _Inout_ size_t& index,
_Out_opt_ short* const pSetting) _Out_opt_ short* const pSetting)
{ {
@ -199,7 +197,6 @@ HRESULT ConsoleArguments::s_GetArgumentValue(_Inout_ std::vector<std::wstring>&
{ {
succeeded = false; succeeded = false;
} }
} }
s_ConsumeArg(args, index); s_ConsumeArg(args, index);
} }
@ -215,8 +212,7 @@ HRESULT ConsoleArguments::s_GetArgumentValue(_Inout_ std::vector<std::wstring>&
// - S_OK if we could successfully parse the given text and store it in the handle value location. // - S_OK if we could successfully parse the given text and store it in the handle value location.
// - E_INVALIDARG if we couldn't parse the text as a valid hex-encoded handle number OR // - E_INVALIDARG if we couldn't parse the text as a valid hex-encoded handle number OR
// if the handle value was already filled. // if the handle value was already filled.
[[nodiscard]] [[nodiscard]] HRESULT ConsoleArguments::s_ParseHandleArg(const std::wstring& handleAsText, _Inout_ DWORD& handleAsVal)
HRESULT ConsoleArguments::s_ParseHandleArg(const std::wstring& handleAsText, _Inout_ DWORD& handleAsVal)
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
@ -259,8 +255,7 @@ HRESULT ConsoleArguments::s_ParseHandleArg(const std::wstring& handleAsText, _In
// Return Value: // Return Value:
// S_OK if we parsed the string successfully, otherwise E_INVALIDARG indicating // S_OK if we parsed the string successfully, otherwise E_INVALIDARG indicating
// failure. // failure.
[[nodiscard]] [[nodiscard]] HRESULT ConsoleArguments::_GetClientCommandline(_Inout_ std::vector<std::wstring>& args, const size_t index, const bool skipFirst)
HRESULT ConsoleArguments::_GetClientCommandline(_Inout_ std::vector<std::wstring>& args, const size_t index, const bool skipFirst)
{ {
auto start = args.begin() + index; auto start = args.begin() + index;
@ -297,8 +292,7 @@ HRESULT ConsoleArguments::_GetClientCommandline(_Inout_ std::vector<std::wstring
// Return Value: // Return Value:
// S_OK if we parsed our _commandline successfully, otherwise E_INVALIDARG // S_OK if we parsed our _commandline successfully, otherwise E_INVALIDARG
// indicating failure. // indicating failure.
[[nodiscard]] [[nodiscard]] HRESULT ConsoleArguments::ParseCommandline()
HRESULT ConsoleArguments::ParseCommandline()
{ {
// If the commandline was empty, quick return. // If the commandline was empty, quick return.
if (_commandline.length() == 0) if (_commandline.length() == 0)

View file

@ -29,8 +29,7 @@ public:
ConsoleArguments& operator=(const ConsoleArguments& other); ConsoleArguments& operator=(const ConsoleArguments& other);
[[nodiscard]] [[nodiscard]] HRESULT ParseCommandline();
HRESULT ParseCommandline();
bool HasVtHandles() const; bool HasVtHandles() const;
bool InConptyMode() const noexcept; bool InConptyMode() const noexcept;
@ -101,7 +100,6 @@ private:
_originalWidth{ -1 }, _originalWidth{ -1 },
_originalHeight{ -1 } _originalHeight{ -1 }
{ {
} }
#endif #endif
@ -130,38 +128,34 @@ private:
short _originalWidth; short _originalWidth;
short _originalHeight; short _originalHeight;
[[nodiscard]] [[nodiscard]] HRESULT _GetClientCommandline(_Inout_ std::vector<std::wstring>& args,
HRESULT _GetClientCommandline(_Inout_ std::vector<std::wstring>& args,
const size_t index, const size_t index,
const bool skipFirst); const bool skipFirst);
static void s_ConsumeArg(_Inout_ std::vector<std::wstring>& args, static void s_ConsumeArg(_Inout_ std::vector<std::wstring>& args,
_In_ size_t& index); _In_ size_t& index);
[[nodiscard]] [[nodiscard]] static HRESULT s_GetArgumentValue(_Inout_ std::vector<std::wstring>& args,
static HRESULT s_GetArgumentValue(_Inout_ std::vector<std::wstring>& args,
_Inout_ size_t& index, _Inout_ size_t& index,
_Out_opt_ std::wstring* const pSetting); _Out_opt_ std::wstring* const pSetting);
[[nodiscard]] [[nodiscard]] static HRESULT s_GetArgumentValue(_Inout_ std::vector<std::wstring>& args,
static HRESULT s_GetArgumentValue(_Inout_ std::vector<std::wstring>& args,
_Inout_ size_t& index, _Inout_ size_t& index,
_Out_opt_ short* const pSetting); _Out_opt_ short* const pSetting);
[[nodiscard]] [[nodiscard]] static HRESULT s_HandleFeatureValue(_Inout_ std::vector<std::wstring>& args,
static HRESULT s_HandleFeatureValue(_Inout_ std::vector<std::wstring>& args,
_Inout_ size_t& index); _Inout_ size_t& index);
[[nodiscard]] [[nodiscard]] static HRESULT s_ParseHandleArg(const std::wstring& handleAsText,
static HRESULT s_ParseHandleArg(const std::wstring& handleAsText,
_Inout_ DWORD& handleAsVal); _Inout_ DWORD& handleAsVal);
#ifdef UNIT_TESTING #ifdef UNIT_TESTING
friend class ConsoleArgumentsTests; friend class ConsoleArgumentsTests;
#endif #endif
}; };
#ifdef UNIT_TESTING #ifdef UNIT_TESTING
namespace WEX { namespace WEX
namespace TestExecution { {
namespace TestExecution
{
template<> template<>
class VerifyOutputTraits<ConsoleArguments> class VerifyOutputTraits<ConsoleArguments>
{ {
@ -210,8 +204,7 @@ namespace WEX {
public: public:
static bool AreEqual(const ConsoleArguments& expected, const ConsoleArguments& actual) static bool AreEqual(const ConsoleArguments& expected, const ConsoleArguments& actual)
{ {
return return expected.GetClientCommandline() == actual.GetClientCommandline() &&
expected.GetClientCommandline() == actual.GetClientCommandline() &&
expected.HasVtHandles() == actual.HasVtHandles() && expected.HasVtHandles() == actual.HasVtHandles() &&
expected.GetVtInHandle() == actual.GetVtInHandle() && expected.GetVtInHandle() == actual.GetVtInHandle() &&
expected.GetVtOutHandle() == actual.GetVtOutHandle() && expected.GetVtOutHandle() == actual.GetVtOutHandle() &&
@ -238,8 +231,7 @@ namespace WEX {
static bool IsNull(const ConsoleArguments& object) static bool IsNull(const ConsoleArguments& object)
{ {
return return object.GetClientCommandline().empty() &&
object.GetClientCommandline().empty() &&
(object.GetVtInHandle() == 0 || object.GetVtInHandle() == INVALID_HANDLE_VALUE) && (object.GetVtInHandle() == 0 || object.GetVtInHandle() == INVALID_HANDLE_VALUE) &&
(object.GetVtOutHandle() == 0 || object.GetVtOutHandle() == INVALID_HANDLE_VALUE) && (object.GetVtOutHandle() == 0 || object.GetVtOutHandle() == INVALID_HANDLE_VALUE) &&
object.GetVtMode().empty() && object.GetVtMode().empty() &&

View file

@ -19,8 +19,7 @@ CopyFromCharPopup::CopyFromCharPopup(SCREEN_INFORMATION& screenInfo) :
// Return Value: // Return Value:
// - CONSOLE_STATUS_WAIT - we ran out of input, so a wait block was created // - CONSOLE_STATUS_WAIT - we ran out of input, so a wait block was created
// - CONSOLE_STATUS_READ_COMPLETE - user hit return // - CONSOLE_STATUS_READ_COMPLETE - user hit return
[[nodiscard]] [[nodiscard]] NTSTATUS CopyFromCharPopup::Process(COOKED_READ_DATA& cookedReadData) noexcept
NTSTATUS CopyFromCharPopup::Process(COOKED_READ_DATA& cookedReadData) noexcept
{ {
// get user input // get user input
WCHAR Char = UNICODE_NULL; WCHAR Char = UNICODE_NULL;

View file

@ -22,8 +22,7 @@ class CopyFromCharPopup final : public Popup
public: public:
CopyFromCharPopup(SCREEN_INFORMATION& screenInfo); CopyFromCharPopup(SCREEN_INFORMATION& screenInfo);
[[nodiscard]] [[nodiscard]] NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override;
NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override;
protected: protected:
void _DrawContent() override; void _DrawContent() override;

View file

@ -50,8 +50,7 @@ void CopyToCharPopup::_copyToChar(COOKED_READ_DATA& cookedReadData, const std::w
// Return Value: // Return Value:
// - CONSOLE_STATUS_WAIT - we ran out of input, so a wait block was created // - CONSOLE_STATUS_WAIT - we ran out of input, so a wait block was created
// - CONSOLE_STATUS_READ_COMPLETE - user hit return // - CONSOLE_STATUS_READ_COMPLETE - user hit return
[[nodiscard]] [[nodiscard]] NTSTATUS CopyToCharPopup::Process(COOKED_READ_DATA& cookedReadData) noexcept
NTSTATUS CopyToCharPopup::Process(COOKED_READ_DATA& cookedReadData) noexcept
{ {
wchar_t wch = UNICODE_NULL; wchar_t wch = UNICODE_NULL;
bool popupKey = false; bool popupKey = false;

View file

@ -22,8 +22,8 @@ class CopyToCharPopup final : public Popup
public: public:
CopyToCharPopup(SCREEN_INFORMATION& screenInfo); CopyToCharPopup(SCREEN_INFORMATION& screenInfo);
[[nodiscard]] [[nodiscard]] NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override;
NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override;
protected: protected:
void _DrawContent() override; void _DrawContent() override;

View file

@ -77,8 +77,7 @@ void PtySignalInputThread::ConnectConsole() noexcept
// Return Value: // Return Value:
// - S_OK if the thread runs to completion. // - S_OK if the thread runs to completion.
// - Otherwise it may cause an application termination another route and never return. // - Otherwise it may cause an application termination another route and never return.
[[nodiscard]] [[nodiscard]] HRESULT PtySignalInputThread::_InputThread()
HRESULT PtySignalInputThread::_InputThread()
{ {
unsigned short signalId; unsigned short signalId;
while (_GetData(&signalId, sizeof(signalId))) while (_GetData(&signalId, sizeof(signalId)))
@ -165,8 +164,7 @@ bool PtySignalInputThread::_GetData(_Out_writes_bytes_(cbBuffer) void* const pBu
// Method Description: // Method Description:
// - Starts the PTY Signal input thread. // - Starts the PTY Signal input thread.
[[nodiscard]] [[nodiscard]] HRESULT PtySignalInputThread::Start() noexcept
HRESULT PtySignalInputThread::Start() noexcept
{ {
RETURN_LAST_ERROR_IF(!_hFile); RETURN_LAST_ERROR_IF(!_hFile);

View file

@ -23,8 +23,7 @@ namespace Microsoft::Console
PtySignalInputThread(_In_ wil::unique_hfile hPipe); PtySignalInputThread(_In_ wil::unique_hfile hPipe);
~PtySignalInputThread(); ~PtySignalInputThread();
[[nodiscard]] [[nodiscard]] HRESULT Start() noexcept;
HRESULT Start() noexcept;
static DWORD WINAPI StaticThreadProc(_In_ LPVOID lpParameter); static DWORD WINAPI StaticThreadProc(_In_ LPVOID lpParameter);
// Prevent copying and assignment. // Prevent copying and assignment.
@ -34,8 +33,7 @@ namespace Microsoft::Console
void ConnectConsole() noexcept; void ConnectConsole() noexcept;
private: private:
[[nodiscard]] [[nodiscard]] HRESULT _InputThread();
HRESULT _InputThread();
bool _GetData(_Out_writes_bytes_(cbBuffer) void* const pBuffer, const DWORD cbBuffer); bool _GetData(_Out_writes_bytes_(cbBuffer) void* const pBuffer, const DWORD cbBuffer);
void _Shutdown(); void _Shutdown();

View file

@ -13,7 +13,6 @@ ScreenBufferRenderTarget::ScreenBufferRenderTarget(SCREEN_INFORMATION& owner) :
void ScreenBufferRenderTarget::TriggerRedraw(const Microsoft::Console::Types::Viewport& region) void ScreenBufferRenderTarget::TriggerRedraw(const Microsoft::Console::Types::Viewport& region)
{ {
auto* pRenderer = ServiceLocator::LocateGlobals().pRender; auto* pRenderer = ServiceLocator::LocateGlobals().pRender;
const auto* pActive = &ServiceLocator::LocateGlobals().getConsoleInformation().GetActiveOutputBuffer().GetActiveBuffer(); const auto* pActive = &ServiceLocator::LocateGlobals().getConsoleInformation().GetActiveOutputBuffer().GetActiveBuffer();
if (pRenderer != nullptr && pActive == &_owner) if (pRenderer != nullptr && pActive == &_owner)

View file

@ -42,5 +42,4 @@ public:
private: private:
SCREEN_INFORMATION& _owner; SCREEN_INFORMATION& _owner;
}; };

View file

@ -56,8 +56,7 @@ VtInputThread::VtInputThread(_In_ wil::unique_hfile hPipe,
// - cch - number of UTF-8 characters in charBuffer // - cch - number of UTF-8 characters in charBuffer
// Return Value: // Return Value:
// - S_OK on success, otherwise an appropriate failure. // - S_OK on success, otherwise an appropriate failure.
[[nodiscard]] [[nodiscard]] HRESULT VtInputThread::_HandleRunInput(_In_reads_(cch) const byte* const charBuffer, const int cch)
HRESULT VtInputThread::_HandleRunInput(_In_reads_(cch) const byte* const charBuffer, const int cch)
{ {
// Make sure to call the GLOBAL Lock/Unlock, not the gci's lock/unlock. // Make sure to call the GLOBAL Lock/Unlock, not the gci's lock/unlock.
// Only the global unlock attempts to dispatch ctrl events. If you use the // Only the global unlock attempts to dispatch ctrl events. If you use the
@ -157,8 +156,7 @@ DWORD VtInputThread::_InputThread()
// Method Description: // Method Description:
// - Starts the VT input thread. // - Starts the VT input thread.
[[nodiscard]] [[nodiscard]] HRESULT VtInputThread::Start()
HRESULT VtInputThread::Start()
{ {
RETURN_HR_IF(E_HANDLE, !_hFile); RETURN_HR_IF(E_HANDLE, !_hFile);

View file

@ -24,14 +24,12 @@ namespace Microsoft::Console
public: public:
VtInputThread(_In_ wil::unique_hfile hPipe, const bool inheritCursor); VtInputThread(_In_ wil::unique_hfile hPipe, const bool inheritCursor);
[[nodiscard]] [[nodiscard]] HRESULT Start();
HRESULT Start();
static DWORD WINAPI StaticVtInputThreadProc(_In_ LPVOID lpParameter); static DWORD WINAPI StaticVtInputThreadProc(_In_ LPVOID lpParameter);
void DoReadInput(const bool throwOnFail); void DoReadInput(const bool throwOnFail);
private: private:
[[nodiscard]] [[nodiscard]] HRESULT _HandleRunInput(_In_reads_(cch) const byte* const charBuffer, const int cch);
HRESULT _HandleRunInput(_In_reads_(cch) const byte* const charBuffer, const int cch);
DWORD _InputThread(); DWORD _InputThread();
wil::unique_hfile _hFile; wil::unique_hfile _hFile;

View file

@ -39,8 +39,7 @@ VtIo::VtIo() :
// IO mode string // IO mode string
// Return Value: // Return Value:
// S_OK if we parsed the string successfully, otherwise E_INVALIDARG indicating failure. // S_OK if we parsed the string successfully, otherwise E_INVALIDARG indicating failure.
[[nodiscard]] [[nodiscard]] HRESULT VtIo::ParseIoMode(const std::wstring& VtMode, _Out_ VtIoMode& ioMode)
HRESULT VtIo::ParseIoMode(const std::wstring& VtMode, _Out_ VtIoMode& ioMode)
{ {
ioMode = VtIoMode::INVALID; ioMode = VtIoMode::INVALID;
@ -71,8 +70,7 @@ HRESULT VtIo::ParseIoMode(const std::wstring& VtMode, _Out_ VtIoMode& ioMode)
return S_OK; return S_OK;
} }
[[nodiscard]] [[nodiscard]] HRESULT VtIo::Initialize(const ConsoleArguments* const pArgs)
HRESULT VtIo::Initialize(const ConsoleArguments * const pArgs)
{ {
_lookingForCursorPosition = pArgs->GetInheritCursor(); _lookingForCursorPosition = pArgs->GetInheritCursor();
@ -106,8 +104,10 @@ HRESULT VtIo::Initialize(const ConsoleArguments * const pArgs)
// Return Value: // Return Value:
// S_OK if we initialized successfully, otherwise an appropriate HRESULT // S_OK if we initialized successfully, otherwise an appropriate HRESULT
// indicating failure. // indicating failure.
[[nodiscard]] [[nodiscard]] HRESULT VtIo::_Initialize(const HANDLE InHandle,
HRESULT VtIo::_Initialize(const HANDLE InHandle, const HANDLE OutHandle, const std::wstring& VtMode, _In_opt_ const HANDLE SignalHandle) const HANDLE OutHandle,
const std::wstring& VtMode,
_In_opt_ const HANDLE SignalHandle)
{ {
FAIL_FAST_IF_MSG(_initialized, "Someone attempted to double-_Initialize VtIo"); FAIL_FAST_IF_MSG(_initialized, "Someone attempted to double-_Initialize VtIo");
@ -133,8 +133,7 @@ HRESULT VtIo::_Initialize(const HANDLE InHandle, const HANDLE OutHandle, const s
// S_OK if we initialized successfully, // S_OK if we initialized successfully,
// S_FALSE if VtIo hasn't been initialized (or we're not in conpty mode) // S_FALSE if VtIo hasn't been initialized (or we're not in conpty mode)
// otherwise an appropriate HRESULT indicating failure. // otherwise an appropriate HRESULT indicating failure.
[[nodiscard]] [[nodiscard]] HRESULT VtIo::CreateIoHandlers() noexcept
HRESULT VtIo::CreateIoHandlers() noexcept
{ {
if (!_initialized) if (!_initialized)
{ {
@ -217,8 +216,7 @@ bool VtIo::IsUsingVt() const
// Return Value: // Return Value:
// S_OK if we started successfully or had nothing to start, otherwise an // S_OK if we started successfully or had nothing to start, otherwise an
// appropriate HRESULT indicating failure. // appropriate HRESULT indicating failure.
[[nodiscard]] [[nodiscard]] HRESULT VtIo::StartIfNeeded()
HRESULT VtIo::StartIfNeeded()
{ {
// If we haven't been set up, do nothing (because there's nothing to start) // If we haven't been set up, do nothing (because there's nothing to start)
if (!_objectsCreated) if (!_objectsCreated)
@ -283,8 +281,7 @@ HRESULT VtIo::StartIfNeeded()
// - S_FALSE if we're not in VtIo mode, // - S_FALSE if we're not in VtIo mode,
// S_OK if we succeeded, // S_OK if we succeeded,
// otherwise an appropriate HRESULT indicating failure. // otherwise an appropriate HRESULT indicating failure.
[[nodiscard]] [[nodiscard]] HRESULT VtIo::CreateAndStartSignalThread() noexcept
HRESULT VtIo::CreateAndStartSignalThread() noexcept
{ {
if (!_initialized) if (!_initialized)
{ {
@ -315,8 +312,7 @@ HRESULT VtIo::CreateAndStartSignalThread() noexcept
// Return Value: // Return Value:
// - S_OK if the renderer successfully suppressed the next repaint, otherwise an // - S_OK if the renderer successfully suppressed the next repaint, otherwise an
// appropriate HRESULT indicating failure. // appropriate HRESULT indicating failure.
[[nodiscard]] [[nodiscard]] HRESULT VtIo::SuppressResizeRepaint()
HRESULT VtIo::SuppressResizeRepaint()
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
if (_pVtRenderEngine) if (_pVtRenderEngine)
@ -334,8 +330,7 @@ HRESULT VtIo::SuppressResizeRepaint()
// Return Value: // Return Value:
// - S_OK if we successfully inherited the cursor or did nothing, else an // - S_OK if we successfully inherited the cursor or did nothing, else an
// appropriate HRESULT // appropriate HRESULT
[[nodiscard]] [[nodiscard]] HRESULT VtIo::SetCursorPosition(const COORD coordCursor)
HRESULT VtIo::SetCursorPosition(const COORD coordCursor)
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
if (_lookingForCursorPosition) if (_lookingForCursorPosition)
@ -377,7 +372,6 @@ void VtIo::CloseOutput()
_ShutdownIfNeeded(); _ShutdownIfNeeded();
} }
void VtIo::_ShutdownIfNeeded() void VtIo::_ShutdownIfNeeded()
{ {
// The callers should have both accquired the _shutdownLock at this point - // The callers should have both accquired the _shutdownLock at this point -

View file

@ -19,27 +19,19 @@ namespace Microsoft::Console::VirtualTerminal
VtIo(); VtIo();
virtual ~VtIo() override = default; virtual ~VtIo() override = default;
[[nodiscard]] [[nodiscard]] HRESULT Initialize(const ConsoleArguments* const pArgs);
HRESULT Initialize(const ConsoleArguments* const pArgs);
[[nodiscard]] HRESULT CreateAndStartSignalThread() noexcept;
[[nodiscard]] [[nodiscard]] HRESULT CreateIoHandlers() noexcept;
HRESULT CreateAndStartSignalThread() noexcept;
[[nodiscard]]
HRESULT CreateIoHandlers() noexcept;
bool IsUsingVt() const; bool IsUsingVt() const;
[[nodiscard]] [[nodiscard]] HRESULT StartIfNeeded();
HRESULT StartIfNeeded();
[[nodiscard]] [[nodiscard]] static HRESULT ParseIoMode(const std::wstring& VtMode, _Out_ VtIoMode& ioMode);
static HRESULT ParseIoMode(const std::wstring& VtMode, _Out_ VtIoMode& ioMode);
[[nodiscard]] [[nodiscard]] HRESULT SuppressResizeRepaint();
HRESULT SuppressResizeRepaint(); [[nodiscard]] HRESULT SetCursorPosition(const COORD coordCursor);
[[nodiscard]]
HRESULT SetCursorPosition(const COORD coordCursor);
void CloseInput() override; void CloseInput() override;
void CloseOutput() override; void CloseOutput() override;
@ -62,8 +54,7 @@ namespace Microsoft::Console::VirtualTerminal
std::unique_ptr<Microsoft::Console::VtInputThread> _pVtInputThread; std::unique_ptr<Microsoft::Console::VtInputThread> _pVtInputThread;
std::unique_ptr<Microsoft::Console::PtySignalInputThread> _pPtySignalInputThread; std::unique_ptr<Microsoft::Console::PtySignalInputThread> _pPtySignalInputThread;
[[nodiscard]] [[nodiscard]] HRESULT _Initialize(const HANDLE InHandle, const HANDLE OutHandle, const std::wstring& VtMode, _In_opt_ const HANDLE SignalHandle);
HRESULT _Initialize(const HANDLE InHandle, const HANDLE OutHandle, const std::wstring& VtMode, _In_opt_ const HANDLE SignalHandle);
void _ShutdownIfNeeded(); void _ShutdownIfNeeded();

View file

@ -68,8 +68,7 @@ void WriteToScreen(SCREEN_INFORMATION& screenInfo, const Viewport& region)
// - used - number of elements written // - used - number of elements written
// Return Value: // Return Value:
// - S_OK, E_INVALIDARG or similar HRESULT error. // - S_OK, E_INVALIDARG or similar HRESULT error.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::WriteConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
HRESULT ApiRoutines::WriteConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
const std::basic_string_view<WORD> attrs, const std::basic_string_view<WORD> attrs,
const COORD target, const COORD target,
size_t& used) noexcept size_t& used) noexcept
@ -109,8 +108,7 @@ HRESULT ApiRoutines::WriteConsoleOutputAttributeImpl(IConsoleOutputObject& OutCo
// - used - number of elements written // - used - number of elements written
// Return Value: // Return Value:
// - S_OK, E_INVALIDARG or similar HRESULT error. // - S_OK, E_INVALIDARG or similar HRESULT error.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::WriteConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
HRESULT ApiRoutines::WriteConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
const std::wstring_view chars, const std::wstring_view chars,
const COORD target, const COORD target,
size_t& used) noexcept size_t& used) noexcept
@ -153,8 +151,7 @@ HRESULT ApiRoutines::WriteConsoleOutputCharacterWImpl(IConsoleOutputObject& OutC
// - used - number of elements written // - used - number of elements written
// Return Value: // Return Value:
// - S_OK, E_INVALIDARG or similar HRESULT error. // - S_OK, E_INVALIDARG or similar HRESULT error.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::WriteConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
HRESULT ApiRoutines::WriteConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
const std::string_view chars, const std::string_view chars,
const COORD target, const COORD target,
size_t& used) noexcept size_t& used) noexcept
@ -195,8 +192,7 @@ HRESULT ApiRoutines::WriteConsoleOutputCharacterAImpl(IConsoleOutputObject& OutC
// - cellsModified - the number of elements written // - cellsModified - the number of elements written
// Return Value: // Return Value:
// - S_OK or suitable HRESULT code from failure to write (memory issues, invalid arg, etc.) // - S_OK or suitable HRESULT code from failure to write (memory issues, invalid arg, etc.)
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::FillConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
HRESULT ApiRoutines::FillConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
const WORD attribute, const WORD attribute,
const size_t lengthToWrite, const size_t lengthToWrite,
const COORD startingCoordinate, const COORD startingCoordinate,
@ -239,7 +235,6 @@ HRESULT ApiRoutines::FillConsoleOutputAttributeImpl(IConsoleOutputObject& OutCon
{ {
useThisAttr = TextAttribute(screenBuffer.GetAttributes()); useThisAttr = TextAttribute(screenBuffer.GetAttributes());
} }
} }
const OutputCellIterator it(useThisAttr, lengthToWrite); const OutputCellIterator it(useThisAttr, lengthToWrite);
@ -267,8 +262,7 @@ HRESULT ApiRoutines::FillConsoleOutputAttributeImpl(IConsoleOutputObject& OutCon
// - cellsModified - the number of elements written // - cellsModified - the number of elements written
// Return Value: // Return Value:
// - S_OK or suitable HRESULT code from failure to write (memory issues, invalid arg, etc.) // - S_OK or suitable HRESULT code from failure to write (memory issues, invalid arg, etc.)
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::FillConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
HRESULT ApiRoutines::FillConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
const wchar_t character, const wchar_t character,
const size_t lengthToWrite, const size_t lengthToWrite,
const COORD startingCoordinate, const COORD startingCoordinate,
@ -319,8 +313,7 @@ HRESULT ApiRoutines::FillConsoleOutputCharacterWImpl(IConsoleOutputObject& OutCo
// - cellsModified - the number of elements written // - cellsModified - the number of elements written
// Return Value: // Return Value:
// - S_OK or suitable HRESULT code from failure to write (memory issues, invalid arg, etc.) // - S_OK or suitable HRESULT code from failure to write (memory issues, invalid arg, etc.)
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::FillConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
HRESULT ApiRoutines::FillConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
const char character, const char character,
const size_t lengthToWrite, const size_t lengthToWrite,
const COORD startingCoordinate, const COORD startingCoordinate,

View file

@ -40,8 +40,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
// - coordCursor - New location of cursor. // - coordCursor - New location of cursor.
// - fKeepCursorVisible - TRUE if changing window origin desirable when hit right edge // - fKeepCursorVisible - TRUE if changing window origin desirable when hit right edge
// Return Value: // Return Value:
[[nodiscard]] [[nodiscard]] NTSTATUS AdjustCursorPosition(SCREEN_INFORMATION& screenInfo,
NTSTATUS AdjustCursorPosition(SCREEN_INFORMATION& screenInfo,
_In_ COORD coordCursor, _In_ COORD coordCursor,
const BOOL fKeepCursorVisible, const BOOL fKeepCursorVisible,
_Inout_opt_ PSHORT psScrollY) _Inout_opt_ PSHORT psScrollY)
@ -300,8 +299,7 @@ NTSTATUS AdjustCursorPosition(SCREEN_INFORMATION& screenInfo,
// Return Value: // Return Value:
// Note: // Note:
// - This routine does not process tabs and backspace properly. That code will be implemented as part of the line editing services. // - This routine does not process tabs and backspace properly. That code will be implemented as part of the line editing services.
[[nodiscard]] [[nodiscard]] NTSTATUS WriteCharsLegacy(SCREEN_INFORMATION& screenInfo,
NTSTATUS WriteCharsLegacy(SCREEN_INFORMATION& screenInfo,
_In_range_(<=, pwchBuffer) const wchar_t* const pwchBufferBackupLimit, _In_range_(<=, pwchBuffer) const wchar_t* const pwchBufferBackupLimit,
_In_ const wchar_t* pwchBuffer, _In_ const wchar_t* pwchBuffer,
_In_reads_bytes_(*pcb) const wchar_t* pwchRealUnicode, _In_reads_bytes_(*pcb) const wchar_t* pwchRealUnicode,
@ -491,7 +489,6 @@ NTSTATUS WriteCharsLegacy(SCREEN_INFORMATION& screenInfo,
// if char is ctrl char, write ^char. // if char is ctrl char, write ^char.
if ((dwFlags & WC_ECHO) && (IS_CONTROL_CHAR(RealUnicodeChar))) if ((dwFlags & WC_ECHO) && (IS_CONTROL_CHAR(RealUnicodeChar)))
{ {
CtrlChar: CtrlChar:
if (i < (LOCAL_BUFFER_SIZE - 1)) if (i < (LOCAL_BUFFER_SIZE - 1))
{ {
@ -563,8 +560,7 @@ NTSTATUS WriteCharsLegacy(SCREEN_INFORMATION& screenInfo,
const auto itEnd = screenInfo.Write(it); const auto itEnd = screenInfo.Write(it);
// Notify accessibility // Notify accessibility
screenInfo.NotifyAccessibilityEventing(CursorPosition.X, CursorPosition.Y, screenInfo.NotifyAccessibilityEventing(CursorPosition.X, CursorPosition.Y, CursorPosition.X + gsl::narrow<SHORT>(i - 1), CursorPosition.Y);
CursorPosition.X + gsl::narrow<SHORT>(i - 1), CursorPosition.Y);
// The number of "spaces" or "cells" we have consumed needs to be reported and stored for later // The number of "spaces" or "cells" we have consumed needs to be reported and stored for later
// when/if we need to erase the command line. // when/if we need to erase the command line.
@ -641,7 +637,8 @@ NTSTATUS WriteCharsLegacy(SCREEN_INFORMATION& screenInfo,
} }
for (i = 0, Tmp2 = buffer.get(), Tmp = pwchBufferBackupLimit; for (i = 0, Tmp2 = buffer.get(), Tmp = pwchBufferBackupLimit;
i < bufferSize; i++, Tmp++) i < bufferSize;
i++, Tmp++)
{ {
// see 18120085, these two need to be seperate if statements // see 18120085, these two need to be seperate if statements
if (*Tmp == UNICODE_BACKSPACE) if (*Tmp == UNICODE_BACKSPACE)
@ -669,7 +666,6 @@ NTSTATUS WriteCharsLegacy(SCREEN_INFORMATION& screenInfo,
LastChar = *(Tmp2 - 1); LastChar = *(Tmp2 - 1);
} }
if (LastChar == UNICODE_TAB) if (LastChar == UNICODE_TAB)
{ {
CursorPosition.X -= (SHORT)(RetrieveNumberOfSpaces(sOriginalXPosition, CursorPosition.X -= (SHORT)(RetrieveNumberOfSpaces(sOriginalXPosition,
@ -810,7 +806,6 @@ NTSTATUS WriteCharsLegacy(SCREEN_INFORMATION& screenInfo,
} }
CATCH_LOG(); CATCH_LOG();
} }
} }
Status = AdjustCursorPosition(screenInfo, CursorPosition, (dwFlags & WC_KEEP_CURSOR_VISIBLE) != 0, psScrollY); Status = AdjustCursorPosition(screenInfo, CursorPosition, (dwFlags & WC_KEEP_CURSOR_VISIBLE) != 0, psScrollY);
break; break;
@ -936,8 +931,7 @@ NTSTATUS WriteCharsLegacy(SCREEN_INFORMATION& screenInfo,
// Return Value: // Return Value:
// Note: // Note:
// - This routine does not process tabs and backspace properly. That code will be implemented as part of the line editing services. // - This routine does not process tabs and backspace properly. That code will be implemented as part of the line editing services.
[[nodiscard]] [[nodiscard]] NTSTATUS WriteChars(SCREEN_INFORMATION& screenInfo,
NTSTATUS WriteChars(SCREEN_INFORMATION& screenInfo,
_In_range_(<=, pwchBuffer) const wchar_t* const pwchBufferBackupLimit, _In_range_(<=, pwchBuffer) const wchar_t* const pwchBufferBackupLimit,
_In_ const wchar_t* pwchBuffer, _In_ const wchar_t* pwchBuffer,
_In_reads_bytes_(*pcb) const wchar_t* pwchRealUnicode, _In_reads_bytes_(*pcb) const wchar_t* pwchRealUnicode,
@ -1011,8 +1005,7 @@ NTSTATUS WriteChars(SCREEN_INFORMATION& screenInfo,
// - STATUS_SUCCESS if OK. // - STATUS_SUCCESS if OK.
// - CONSOLE_STATUS_WAIT if we couldn't finish now and need to be called back later (see ppWaiter). // - CONSOLE_STATUS_WAIT if we couldn't finish now and need to be called back later (see ppWaiter).
// - Or a suitable NTSTATUS format error code for memory/string/math failures. // - Or a suitable NTSTATUS format error code for memory/string/math failures.
[[nodiscard]] [[nodiscard]] NTSTATUS DoWriteConsole(_In_reads_bytes_(*pcbBuffer) PWCHAR pwchBuffer,
NTSTATUS DoWriteConsole(_In_reads_bytes_(*pcbBuffer) PWCHAR pwchBuffer,
_Inout_ size_t* const pcbBuffer, _Inout_ size_t* const pcbBuffer,
SCREEN_INFORMATION& screenInfo, SCREEN_INFORMATION& screenInfo,
std::unique_ptr<WriteData>& waiter) std::unique_ptr<WriteData>& waiter)
@ -1061,8 +1054,7 @@ NTSTATUS DoWriteConsole(_In_reads_bytes_(*pcbBuffer) PWCHAR pwchBuffer,
// - S_OK if successful. // - S_OK if successful.
// - S_OK if we need to wait (check if ppWaiter is not nullptr). // - S_OK if we need to wait (check if ppWaiter is not nullptr).
// - Or a suitable HRESULT code for math/string/memory failures. // - Or a suitable HRESULT code for math/string/memory failures.
[[nodiscard]] [[nodiscard]] HRESULT WriteConsoleWImplHelper(IConsoleOutputObject& context,
HRESULT WriteConsoleWImplHelper(IConsoleOutputObject& context,
const std::wstring_view buffer, const std::wstring_view buffer,
size_t& read, size_t& read,
std::unique_ptr<WriteData>& waiter) noexcept std::unique_ptr<WriteData>& waiter) noexcept
@ -1107,8 +1099,7 @@ HRESULT WriteConsoleWImplHelper(IConsoleOutputObject& context,
// - S_OK if successful. // - S_OK if successful.
// - S_OK if we need to wait (check if ppWaiter is not nullptr). // - S_OK if we need to wait (check if ppWaiter is not nullptr).
// - Or a suitable HRESULT code for math/string/memory failures. // - Or a suitable HRESULT code for math/string/memory failures.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::WriteConsoleAImpl(IConsoleOutputObject& context,
HRESULT ApiRoutines::WriteConsoleAImpl(IConsoleOutputObject& context,
const std::string_view buffer, const std::string_view buffer,
size_t& read, size_t& read,
std::unique_ptr<IWaitRoutine>& waiter) noexcept std::unique_ptr<IWaitRoutine>& waiter) noexcept
@ -1354,8 +1345,7 @@ HRESULT ApiRoutines::WriteConsoleAImpl(IConsoleOutputObject& context,
// - S_OK if successful. // - S_OK if successful.
// - S_OK if we need to wait (check if ppWaiter is not nullptr). // - S_OK if we need to wait (check if ppWaiter is not nullptr).
// - Or a suitable HRESULT code for math/string/memory failures. // - Or a suitable HRESULT code for math/string/memory failures.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::WriteConsoleWImpl(IConsoleOutputObject& context,
HRESULT ApiRoutines::WriteConsoleWImpl(IConsoleOutputObject& context,
const std::wstring_view buffer, const std::wstring_view buffer,
size_t& read, size_t& read,
std::unique_ptr<IWaitRoutine>& waiter) noexcept std::unique_ptr<IWaitRoutine>& waiter) noexcept

View file

@ -35,15 +35,13 @@ Arguments:
Return Value: Return Value:
--*/ --*/
[[nodiscard]] [[nodiscard]] NTSTATUS AdjustCursorPosition(SCREEN_INFORMATION& screenInfo,
NTSTATUS AdjustCursorPosition(SCREEN_INFORMATION& screenInfo,
_In_ COORD coordCursor, _In_ COORD coordCursor,
const BOOL fKeepCursorVisible, const BOOL fKeepCursorVisible,
_Inout_opt_ PSHORT psScrollY); _Inout_opt_ PSHORT psScrollY);
#define LOCAL_BUFFER_SIZE 100 #define LOCAL_BUFFER_SIZE 100
/*++ /*++
Routine Description: Routine Description:
This routine writes a string to the screen, processing any embedded This routine writes a string to the screen, processing any embedded
@ -71,8 +69,7 @@ Note:
This routine does not process tabs and backspace properly. That code This routine does not process tabs and backspace properly. That code
will be implemented as part of the line editing services. will be implemented as part of the line editing services.
--*/ --*/
[[nodiscard]] [[nodiscard]] NTSTATUS WriteCharsLegacy(SCREEN_INFORMATION& screenInfo,
NTSTATUS WriteCharsLegacy(SCREEN_INFORMATION& screenInfo,
_In_range_(<=, pwchBuffer) const wchar_t* const pwchBufferBackupLimit, _In_range_(<=, pwchBuffer) const wchar_t* const pwchBufferBackupLimit,
_In_ const wchar_t* pwchBuffer, _In_ const wchar_t* pwchBuffer,
_In_reads_bytes_(*pcb) const wchar_t* pwchRealUnicode, _In_reads_bytes_(*pcb) const wchar_t* pwchRealUnicode,
@ -83,8 +80,7 @@ NTSTATUS WriteCharsLegacy(SCREEN_INFORMATION& screenInfo,
_Inout_opt_ PSHORT const psScrollY); _Inout_opt_ PSHORT const psScrollY);
// The new entry point for WriteChars to act as an intercept in case we place a Virtual Terminal processor in the way. // The new entry point for WriteChars to act as an intercept in case we place a Virtual Terminal processor in the way.
[[nodiscard]] [[nodiscard]] NTSTATUS WriteChars(SCREEN_INFORMATION& screenInfo,
NTSTATUS WriteChars(SCREEN_INFORMATION& screenInfo,
_In_range_(<=, pwchBuffer) const wchar_t* const pwchBufferBackupLimit, _In_range_(<=, pwchBuffer) const wchar_t* const pwchBufferBackupLimit,
_In_ const wchar_t* pwchBuffer, _In_ const wchar_t* pwchBuffer,
_In_reads_bytes_(*pcb) const wchar_t* pwchRealUnicode, _In_reads_bytes_(*pcb) const wchar_t* pwchRealUnicode,
@ -96,8 +92,7 @@ NTSTATUS WriteChars(SCREEN_INFORMATION& screenInfo,
// NOTE: console lock must be held when calling this routine // NOTE: console lock must be held when calling this routine
// String has been translated to unicode at this point. // String has been translated to unicode at this point.
[[nodiscard]] [[nodiscard]] NTSTATUS DoWriteConsole(_In_reads_bytes_(*pcbBuffer) PWCHAR pwchBuffer,
NTSTATUS DoWriteConsole(_In_reads_bytes_(*pcbBuffer) PWCHAR pwchBuffer,
_In_ size_t* const pcbBuffer, _In_ size_t* const pcbBuffer,
SCREEN_INFORMATION& screenInfo, SCREEN_INFORMATION& screenInfo,
std::unique_ptr<WriteData>& waiter); std::unique_ptr<WriteData>& waiter);

View file

@ -49,7 +49,8 @@ std::unordered_map<std::wstring,
case_insensitive_hash, case_insensitive_hash,
case_insensitive_equality>, case_insensitive_equality>,
case_insensitive_hash, case_insensitive_hash,
case_insensitive_equality> g_aliasData; case_insensitive_equality>
g_aliasData;
// Routine Description: // Routine Description:
// - Adds a command line alias to the global set. // - Adds a command line alias to the global set.
@ -60,8 +61,7 @@ std::unordered_map<std::wstring,
// - exeName - The client EXE application attached to the host to whom this substitution will apply // - exeName - The client EXE application attached to the host to whom this substitution will apply
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::AddConsoleAliasAImpl(const std::string_view source,
HRESULT ApiRoutines::AddConsoleAliasAImpl(const std::string_view source,
const std::string_view target, const std::string_view target,
const std::string_view exeName) noexcept const std::string_view exeName) noexcept
{ {
@ -87,8 +87,7 @@ HRESULT ApiRoutines::AddConsoleAliasAImpl(const std::string_view source,
// - exeName - The client EXE application attached to the host to whom this substitution will apply // - exeName - The client EXE application attached to the host to whom this substitution will apply
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::AddConsoleAliasWImpl(const std::wstring_view source,
HRESULT ApiRoutines::AddConsoleAliasWImpl(const std::wstring_view source,
const std::wstring_view target, const std::wstring_view target,
const std::wstring_view exeName) noexcept const std::wstring_view exeName) noexcept
{ {
@ -140,8 +139,7 @@ HRESULT ApiRoutines::AddConsoleAliasWImpl(const std::wstring_view source,
// - exeName - The client EXE application attached to the host whose set we should check // - exeName - The client EXE application attached to the host whose set we should check
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasWImplHelper(const std::wstring_view source,
HRESULT GetConsoleAliasWImplHelper(const std::wstring_view source,
std::optional<gsl::span<wchar_t>> target, std::optional<gsl::span<wchar_t>> target,
size_t& writtenOrNeeded, size_t& writtenOrNeeded,
const std::wstring_view exeName) const std::wstring_view exeName)
@ -199,8 +197,7 @@ HRESULT GetConsoleAliasWImplHelper(const std::wstring_view source,
// - exeName - The client EXE application attached to the host whose set we should check // - exeName - The client EXE application attached to the host whose set we should check
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasAImpl(const std::string_view source,
HRESULT ApiRoutines::GetConsoleAliasAImpl(const std::string_view source,
gsl::span<char> target, gsl::span<char> target,
size_t& written, size_t& written,
const std::string_view exeName) noexcept const std::string_view exeName) noexcept
@ -273,8 +270,7 @@ HRESULT ApiRoutines::GetConsoleAliasAImpl(const std::string_view source,
// - exeName - The client EXE application attached to the host whose set we should check // - exeName - The client EXE application attached to the host whose set we should check
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasWImpl(const std::wstring_view source,
HRESULT ApiRoutines::GetConsoleAliasWImpl(const std::wstring_view source,
gsl::span<wchar_t> target, gsl::span<wchar_t> target,
size_t& written, size_t& written,
const std::wstring_view exeName) noexcept const std::wstring_view exeName) noexcept
@ -312,8 +308,7 @@ static std::wstring aliasesSeparator(L"=");
// - bufferRequired - Receives the length of buffer that would be required to retrieve all aliases for the given exe. // - bufferRequired - Receives the length of buffer that would be required to retrieve all aliases for the given exe.
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasesLengthWImplHelper(const std::wstring_view exeName,
HRESULT GetConsoleAliasesLengthWImplHelper(const std::wstring_view exeName,
const bool countInUnicode, const bool countInUnicode,
const UINT codepage, const UINT codepage,
size_t& bufferRequired) size_t& bufferRequired)
@ -378,8 +373,7 @@ HRESULT GetConsoleAliasesLengthWImplHelper(const std::wstring_view exeName,
// - bufferRequired - Receives the length of buffer that would be required to retrieve all aliases for the given exe. // - bufferRequired - Receives the length of buffer that would be required to retrieve all aliases for the given exe.
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasesLengthAImpl(const std::string_view exeName,
HRESULT ApiRoutines::GetConsoleAliasesLengthAImpl(const std::string_view exeName,
size_t& bufferRequired) noexcept size_t& bufferRequired) noexcept
{ {
const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation(); const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
@ -409,8 +403,7 @@ HRESULT ApiRoutines::GetConsoleAliasesLengthAImpl(const std::string_view exeName
// - bufferRequired - Receives the length of buffer that would be required to retrieve all aliases for the given exe. // - bufferRequired - Receives the length of buffer that would be required to retrieve all aliases for the given exe.
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasesLengthWImpl(const std::wstring_view exeName,
HRESULT ApiRoutines::GetConsoleAliasesLengthWImpl(const std::wstring_view exeName,
size_t& bufferRequired) noexcept size_t& bufferRequired) noexcept
{ {
LockConsole(); LockConsole();
@ -449,8 +442,7 @@ void Alias::s_ClearCmdExeAliases()
// or how many characters would have been needed (if buffer is nullopt). // or how many characters would have been needed (if buffer is nullopt).
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasesWImplHelper(const std::wstring_view exeName,
HRESULT GetConsoleAliasesWImplHelper(const std::wstring_view exeName,
std::optional<gsl::span<wchar_t>> aliasBuffer, std::optional<gsl::span<wchar_t>> aliasBuffer,
size_t& writtenOrNeeded) size_t& writtenOrNeeded)
{ {
@ -537,8 +529,7 @@ HRESULT GetConsoleAliasesWImplHelper(const std::wstring_view exeName,
// - written - Will specify how many characters were written // - written - Will specify how many characters were written
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasesAImpl(const std::string_view exeName,
HRESULT ApiRoutines::GetConsoleAliasesAImpl(const std::string_view exeName,
gsl::span<char> alias, gsl::span<char> alias,
size_t& written) noexcept size_t& written) noexcept
{ {
@ -602,8 +593,7 @@ HRESULT ApiRoutines::GetConsoleAliasesAImpl(const std::string_view exeName,
// - written - Will specify how many characters were written // - written - Will specify how many characters were written
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasesWImpl(const std::wstring_view exeName,
HRESULT ApiRoutines::GetConsoleAliasesWImpl(const std::wstring_view exeName,
gsl::span<wchar_t> alias, gsl::span<wchar_t> alias,
size_t& written) noexcept size_t& written) noexcept
{ {
@ -628,8 +618,7 @@ HRESULT ApiRoutines::GetConsoleAliasesWImpl(const std::wstring_view exeName,
// - bufferRequired - Receives the length of buffer that would be required to retrieve all relevant EXE names. // - bufferRequired - Receives the length of buffer that would be required to retrieve all relevant EXE names.
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasExesLengthImplHelper(const bool countInUnicode, const UINT codepage, size_t& bufferRequired)
HRESULT GetConsoleAliasExesLengthImplHelper(const bool countInUnicode, const UINT codepage, size_t& bufferRequired)
{ {
// Ensure output variables are initialized // Ensure output variables are initialized
bufferRequired = 0; bufferRequired = 0;
@ -665,8 +654,7 @@ HRESULT GetConsoleAliasExesLengthImplHelper(const bool countInUnicode, const UIN
// - bufferRequired - Receives the length of buffer that would be required to retrieve all relevant EXE names. // - bufferRequired - Receives the length of buffer that would be required to retrieve all relevant EXE names.
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasExesLengthAImpl(size_t& bufferRequired) noexcept
HRESULT ApiRoutines::GetConsoleAliasExesLengthAImpl(size_t& bufferRequired) noexcept
{ {
LockConsole(); LockConsole();
const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation(); const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
@ -681,8 +669,7 @@ HRESULT ApiRoutines::GetConsoleAliasExesLengthAImpl(size_t& bufferRequired) noex
// - bufferRequired - Pointer to receive the length of buffer that would be required to retrieve all relevant EXE names. // - bufferRequired - Pointer to receive the length of buffer that would be required to retrieve all relevant EXE names.
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasExesLengthWImpl(size_t& bufferRequired) noexcept
HRESULT ApiRoutines::GetConsoleAliasExesLengthWImpl(size_t& bufferRequired) noexcept
{ {
LockConsole(); LockConsole();
auto Unlock = wil::scope_exit([&] { UnlockConsole(); }); auto Unlock = wil::scope_exit([&] { UnlockConsole(); });
@ -704,8 +691,7 @@ HRESULT ApiRoutines::GetConsoleAliasExesLengthWImpl(size_t& bufferRequired) noex
// or how many characters would have been needed (if buffer is nullopt). // or how many characters would have been needed (if buffer is nullopt).
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT GetConsoleAliasExesWImplHelper(std::optional<gsl::span<wchar_t>> aliasExesBuffer,
HRESULT GetConsoleAliasExesWImplHelper(std::optional<gsl::span<wchar_t>> aliasExesBuffer,
size_t& writtenOrNeeded) size_t& writtenOrNeeded)
{ {
// Ensure output variables are initialized. // Ensure output variables are initialized.
@ -747,12 +733,10 @@ HRESULT GetConsoleAliasExesWImplHelper(std::optional<gsl::span<wchar_t>> aliasEx
// Accumulate the total written amount. // Accumulate the total written amount.
RETURN_IF_FAILED(SizeTAdd(cchTotalLength, cchNeeded, &cchTotalLength)); RETURN_IF_FAILED(SizeTAdd(cchTotalLength, cchNeeded, &cchTotalLength));
} }
writtenOrNeeded = cchTotalLength; writtenOrNeeded = cchTotalLength;
return S_OK; return S_OK;
} }
@ -764,8 +748,7 @@ HRESULT GetConsoleAliasExesWImplHelper(std::optional<gsl::span<wchar_t>> aliasEx
// - written - Specifies how many characters were written // - written - Specifies how many characters were written
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasExesAImpl(gsl::span<char> aliasExes,
HRESULT ApiRoutines::GetConsoleAliasExesAImpl(gsl::span<char> aliasExes,
size_t& written) noexcept size_t& written) noexcept
{ {
const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation(); const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
@ -824,8 +807,7 @@ HRESULT ApiRoutines::GetConsoleAliasExesAImpl(gsl::span<char> aliasExes,
// - pcchAliasExesBufferWrittenOrNeeded - Pointer to space that will specify how many characters were written // - pcchAliasExesBufferWrittenOrNeeded - Pointer to space that will specify how many characters were written
// Return Value: // Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors. // - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]] [[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasExesWImpl(gsl::span<wchar_t> aliasExes,
HRESULT ApiRoutines::GetConsoleAliasExesWImpl(gsl::span<wchar_t> aliasExes,
size_t& written) noexcept size_t& written) noexcept
{ {
LockConsole(); LockConsole();

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