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.
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
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
- `runft.cmd` - run the feature tests
- `runuia.cmd` - run the UIA tests
- `runformat` - uses clang-format to format all c++ files to match our coding style.
## 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.
- `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.
- `Invoke-CodeFormat` - uses clang-format to format all c++ files to match our coding style.
## Configuration Types

View file

@ -210,7 +210,6 @@ void ATTR_ROW::ReplaceLegacyAttrs(_In_ WORD wToBeReplacedAttr, _In_ WORD wReplac
ReplaceAttrs(ToBeReplaced, ReplaceWith);
}
// Method Description:
// - Replaces all runs in the row with the given toBeReplacedAttr with the new
// attribute replaceWith.
@ -230,7 +229,6 @@ void ATTR_ROW::ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAtt
}
}
// Routine Description:
// - 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
@ -245,8 +243,7 @@ void ATTR_ROW::ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAtt
// Return Value:
// - STATUS_NO_MEMORY if there wasn't enough memory to insert the runs
// otherwise STATUS_SUCCESS if we were successful.
[[nodiscard]]
HRESULT ATTR_ROW::InsertAttrRuns(const std::basic_string_view<TextAttributeRun> newAttrs,
[[nodiscard]] HRESULT ATTR_ROW::InsertAttrRuns(const std::basic_string_view<TextAttributeRun> newAttrs,
const size_t iStart,
const size_t iEnd,
const size_t cBufferWidth)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -18,14 +18,12 @@ Author(s):
#include "DbcsAttribute.hpp"
#if (defined(_M_IX86) || defined(_M_AMD64))
// 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.
#pragma pack(push, 1)
#endif
class CharRowCell final
{
public:
@ -44,6 +42,7 @@ public:
const wchar_t& Char() const noexcept;
friend constexpr bool operator==(const CharRowCell& a, const CharRowCell& b) noexcept;
private:
wchar_t _wch;
DbcsAttribute _attr;

View file

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

View file

@ -23,7 +23,6 @@ class CharRow;
class CharRowCellReference final
{
public:
using const_iterator = const wchar_t*;
CharRowCellReference(CharRow& parent, const size_t index) :
@ -45,7 +44,6 @@ public:
const_iterator begin() const;
const_iterator end() const;
friend bool operator==(const CharRowCellReference& ref, const std::vector<wchar_t>& glyph);
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 "
" 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 },
_behavior{ TextAttributeBehavior::Stored }
{
}
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),
_fillLimit(fillLimit)
{
}
// Routine Description:
@ -43,7 +42,6 @@ OutputCellIterator::OutputCellIterator(const TextAttribute& attr, const size_t f
_distance(0),
_fillLimit(fillLimit)
{
}
// Routine Description:
@ -61,7 +59,6 @@ OutputCellIterator::OutputCellIterator(const wchar_t& wch, const TextAttribute&
_distance(0),
_fillLimit(fillLimit)
{
}
// Routine Description:
@ -78,7 +75,6 @@ OutputCellIterator::OutputCellIterator(const CHAR_INFO& charInfo, const size_t f
_distance(0),
_fillLimit(fillLimit)
{
}
// Routine Description:
@ -94,7 +90,6 @@ OutputCellIterator::OutputCellIterator(const std::wstring_view utf16Text) :
_distance(0),
_fillLimit(0)
{
}
// Routine Description:
@ -111,7 +106,6 @@ OutputCellIterator::OutputCellIterator(const std::wstring_view utf16Text, const
_pos(0),
_fillLimit(0)
{
}
// Routine Description:
@ -131,7 +125,6 @@ OutputCellIterator::OutputCellIterator(const std::basic_string_view<WORD> legacy
_pos(0),
_fillLimit(0)
{
}
// Routine Description:
@ -147,7 +140,6 @@ OutputCellIterator::OutputCellIterator(const std::basic_string_view<CHAR_INFO> c
_pos(0),
_fillLimit(0)
{
}
// Routine Description:
@ -163,7 +155,6 @@ OutputCellIterator::OutputCellIterator(const std::basic_string_view<OutputCell>
_pos(0),
_fillLimit(0)
{
}
// Routine Description:

View file

@ -59,7 +59,6 @@ public:
const OutputCellView* operator->() const;
private:
enum class Mode
{
// 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::basic_string_view<CHAR_INFO>,
std::basic_string_view<OutputCell>,
std::monostate> _run;
std::monostate>
_run;
TextAttribute _attr;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -748,8 +748,7 @@ const Cursor& TextBuffer::GetCursor() const
return _cursor;
}
[[nodiscard]]
TextAttribute TextBuffer::GetCurrentAttributes() const noexcept
[[nodiscard]] TextAttribute TextBuffer::GetCurrentAttributes() const noexcept
{
return _currentAttributes;
}
@ -779,8 +778,7 @@ void TextBuffer::Reset()
// - newSize - new size of screen.
// Return Value:
// - Success if successful. Invalid parameter if screen buffer size is unexpected. No memory if allocation failed.
[[nodiscard]]
NTSTATUS TextBuffer::ResizeTraditional(const COORD newSize) noexcept
[[nodiscard]] NTSTATUS TextBuffer::ResizeTraditional(const COORD newSize) noexcept
{
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
// and cleanup the UnicodeStorage characters that might fall outside the resized buffer.
_RefreshRowIDs(newSize.X);
}
CATCH_RETURN();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -18,7 +18,6 @@
namespace winrt::TerminalApp::implementation
{
// We dont use AppT as it does not provide access to protected constructors
template<typename D, typename... 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);
[[nodiscard]]
HRESULT _TryLoadSettings(const bool saveOnLoad) noexcept;
[[nodiscard]] HRESULT _TryLoadSettings(const bool saveOnLoad) noexcept;
void _LoadSettings();
void _OpenSettings();
@ -92,7 +90,6 @@ namespace winrt::TerminalApp::implementation
void _UpdateTabIcon(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 _CreateNewTabFromSettings(GUID profileGuid, winrt::Microsoft::Terminal::Settings::TerminalSettings settings);

View file

@ -23,7 +23,10 @@ namespace winrt::TerminalApp::implementation
{
for (auto& kv : _keyShortcuts)
{
if (kv.second == action) return kv.first;
if (kv.second == action)
{
return kv.first;
}
}
return { nullptr };
}
@ -208,6 +211,7 @@ namespace winrt::TerminalApp::implementation
}
// -------------------------------- Events ---------------------------------
// clang-format off
DEFINE_EVENT(AppKeyBindings, CopyText, _CopyTextHandlers, TerminalApp::CopyTextEventArgs);
DEFINE_EVENT(AppKeyBindings, PasteText, _PasteTextHandlers, TerminalApp::PasteTextEventArgs);
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, ScrollDownPage, _ScrollDownPageHandlers, TerminalApp::ScrollDownPageEventArgs);
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 winrt::hstring FormatOverrideShortcutText(winrt::Microsoft::Terminal::Settings::KeyModifiers modifiers);
// clang-format off
DECLARE_EVENT(CopyText, _CopyTextHandlers, TerminalApp::CopyTextEventArgs);
DECLARE_EVENT(PasteText, _PasteTextHandlers, TerminalApp::PasteTextEventArgs);
DECLARE_EVENT(NewTab, _NewTabHandlers, TerminalApp::NewTabEventArgs);
@ -58,11 +59,11 @@ namespace winrt::TerminalApp::implementation
DECLARE_EVENT(ScrollUpPage, _ScrollUpPageHandlers, TerminalApp::ScrollUpPageEventArgs);
DECLARE_EVENT(ScrollDownPage, _ScrollDownPageHandlers, TerminalApp::ScrollDownPageEventArgs);
DECLARE_EVENT(OpenSettings, _OpenSettingsHandlers, TerminalApp::OpenSettingsEventArgs);
// clang-format on
private:
std::unordered_map<winrt::Microsoft::Terminal::Settings::KeyChord, TerminalApp::ShortcutAction, KeyChordHash, KeyChordEquality> _keyShortcuts;
bool _DoAction(ShortcutAction action);
};
}

View file

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

View file

@ -18,8 +18,7 @@ using namespace Microsoft::Console;
// {2bde4a90-d05f-401c-9492-e40884ead1d8}
// uuidv5 properties: name format is UTF-16LE bytes
static constexpr GUID TERMINAL_PROFILE_NAMESPACE_GUID =
{ 0x2bde4a90, 0xd05f, 0x401c, { 0x94, 0x92, 0xe4, 0x8, 0x84, 0xea, 0xd1, 0xd8 } };
static constexpr GUID TERMINAL_PROFILE_NAMESPACE_GUID = { 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_EXTENSION{ L".png" };
@ -29,12 +28,10 @@ CascadiaSettings::CascadiaSettings() :
_globals{},
_profiles{}
{
}
CascadiaSettings::~CascadiaSettings()
{
}
ColorScheme _CreateCampbellScheme()
@ -50,6 +47,8 @@ ColorScheme _CreateCampbellScheme()
return campbellScheme;
}
// clang-format off
ColorScheme _CreateOneHalfDarkScheme()
{
// First 8 dark colors per: https://github.com/sonph/onehalf/blob/master/putty/onehalf-dark.reg
@ -167,6 +166,8 @@ ColorScheme _CreateSolarizedLightScheme()
return solarizedLightScheme;
}
// clang-format on
// Method Description:
// - Create the set of schemes to use as the default schemes. Currently creates
// 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());
command += L"\\wsl.exe --list";
THROW_IF_WIN32_BOOL_FALSE(CreateProcessW(nullptr, const_cast<LPWSTR>(command.c_str()), nullptr, nullptr,
TRUE, CREATE_NO_WINDOW, nullptr, nullptr, &si, &pi));
THROW_IF_WIN32_BOOL_FALSE(CreateProcessW(nullptr,
const_cast<LPWSTR>(command.c_str()),
nullptr,
nullptr,
TRUE,
CREATE_NO_WINDOW,
nullptr,
nullptr,
&si,
&pi));
switch (WaitForSingleObject(pi.hProcess, INFINITE))
{
case WAIT_OBJECT_0:
@ -524,7 +533,8 @@ void CascadiaSettings::_AppendWslProfiles(std::vector<TerminalApp::Profile>& pro
DWORD bytesAvailable;
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") };
//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::getline(pipe, wline); // remove the header from the output.
while (pipe.tellp() < bytesAvailable)

View file

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

View file

@ -40,7 +40,8 @@ std::unique_ptr<CascadiaSettings> CascadiaSettings::LoadAll(const bool saveOnLoa
{
std::unique_ptr<CascadiaSettings> resultPtr;
std::optional<std::string> fileData = _IsPackaged() ?
_LoadAsPackagedApp() : _LoadAsUnpackagedApp();
_LoadAsPackagedApp() :
_LoadAsUnpackagedApp();
const bool foundFile = fileData.has_value();
if (foundFile)
@ -340,7 +341,6 @@ std::optional<std::string> CascadiaSettings::_LoadAsPackagedApp()
return { resultString };
}
// Method Description:
// - Reads the content in UTF-8 enconding of our settings file using the Win32 APIs
// 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 ForegroundKey{ "foreground" };
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",
"red",
"green",
@ -43,7 +42,6 @@ ColorScheme::ColorScheme() :
_defaultForeground{ RGB(242, 242, 242) },
_defaultBackground{ RGB(12, 12, 12) }
{
}
ColorScheme::ColorScheme(std::wstring name, COLORREF defaultFg, COLORREF defaultBg) :
@ -52,12 +50,10 @@ ColorScheme::ColorScheme(std::wstring name, COLORREF defaultFg, COLORREF default
_defaultForeground{ defaultFg },
_defaultBackground{ defaultBg }
{
}
ColorScheme::~ColorScheme()
{
}
// Method Description:
@ -157,7 +153,6 @@ ColorScheme ColorScheme::FromJson(const Json::Value& json)
return result;
}
std::wstring_view ColorScheme::GetName() const noexcept
{
return { _schemeName };

View file

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

View file

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

View file

@ -24,7 +24,6 @@ namespace TerminalApp
class TerminalApp::GlobalAppSettings final
{
public:
GlobalAppSettings();
~GlobalAppSettings();
@ -73,5 +72,4 @@ private:
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;
};

View file

@ -12,6 +12,7 @@ static constexpr std::wstring_view ALT_KEY{ L"alt" };
static constexpr int MAX_CHORD_PARTS = 4;
// clang-format off
static const std::unordered_map<int32_t, std::wstring_view> vkeyNamePairs {
{ VK_BACK , L"backspace"},
{ 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_7 0xDE // ''"' for US
};
// clang-format on
// Function Description:
// - 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(_secondChild->GetRootElement());
// If the closed child was focused, transfer the focus to it's first sibling.
if (closedChild->_lastFocused)
{
@ -468,7 +467,6 @@ void Pane::_ApplySplitDefinitions()
Controls::Grid::SetColumn(_firstChild->GetRootElement(), 0);
Controls::Grid::SetColumn(_separatorRoot, 1);
Controls::Grid::SetColumn(_secondChild->GetRootElement(), 2);
}
else if (_splitState == SplitState::Horizontal)
{
@ -478,7 +476,6 @@ void Pane::_ApplySplitDefinitions()
}
}
// Method Description:
// - 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

View file

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

View file

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

View file

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

View file

@ -7,7 +7,6 @@
class Tab
{
public:
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);
private:
std::shared_ptr<Pane> _rootPane{ nullptr };
bool _focused{ false };

View file

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

View file

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

View file

@ -21,7 +21,6 @@ using namespace winrt::Microsoft::Terminal::Settings;
namespace winrt::Microsoft::Terminal::TerminalControl::implementation
{
TermControl::TermControl() :
TermControl(Settings::TerminalSettings{})
{
@ -262,8 +261,9 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// set a new image source for the brush
auto imageSource = brush.ImageSource().try_as<Media::Imaging::BitmapImage>();
if (imageSource == nullptr || imageSource.UriSource() == nullptr
|| imageSource.UriSource().RawUri() != imageUri.RawUri())
if (imageSource == nullptr ||
imageSource.UriSource() == nullptr ||
imageSource.UriSource().RawUri() != imageUri.RawUri())
{
// Note that BitmapImage handles the image load asynchronously,
// which is especially important since the image
@ -376,8 +376,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
}
auto chain = _renderEngine->GetSwapChain();
_swapChainPanel.Dispatcher().RunAsync(CoreDispatcherPriority::High, [=]()
{
_swapChainPanel.Dispatcher().RunAsync(CoreDispatcherPriority::High, [=]() {
auto lock = _terminal->LockForWriting();
auto nativePanel = _swapChainPanel.as<ISwapChainPanelNative>();
nativePanel->SetSwapChain(chain.Get());
@ -457,8 +456,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
_terminal->SetWriteInputCallback(inputFn);
auto chain = _renderEngine->GetSwapChain();
_swapChainPanel.Dispatcher().RunAsync(CoreDispatcherPriority::High, [this, chain]()
{
_swapChainPanel.Dispatcher().RunAsync(CoreDispatcherPriority::High, [this, chain]() {
_terminal->LockConsole();
auto nativePanel = _swapChainPanel.as<ISwapChainPanelNative>();
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
// actually fail. We need a way to gracefully fallback.
_renderer->TriggerFontChange(newDpi, _desiredFont, _actualFont);
}
// Method Description:
@ -1147,7 +1144,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
hstring TermControl::Title()
{
if (!_initializedTerminal) return L"";
if (!_initializedTerminal)
return L"";
hstring hstr(_terminal->GetConsoleTitle());
return hstr;
@ -1357,11 +1355,15 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
switch (paddingPropIndex)
{
case 1: return ThicknessHelper::FromUniformLength(thicknessArr[0]);
case 2: return ThicknessHelper::FromLengths(thicknessArr[0], thicknessArr[1], thicknessArr[0], thicknessArr[1]);
case 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
case 4: return ThicknessHelper::FromLengths(thicknessArr[0], thicknessArr[1], thicknessArr[2], thicknessArr[3]);
default: return Thickness();
case 4:
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)
{
// Exclude padding from cursor position calculation
COORD terminalPosition =
{
COORD terminalPosition = {
static_cast<SHORT>(cursorPosition.X - _root.Padding().Left),
static_cast<SHORT>(cursorPosition.Y - _root.Padding().Top)
};
@ -1434,6 +1435,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
return terminalPosition;
}
// clang-format off
// -------------------------------- WinRT Events ---------------------------------
// Winrt events need a method for adding a callback to the event and removing the callback.
// 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, CopyToClipboard, _clipboardCopyHandlers, TerminalControl::CopyToClipboardEventArgs);
DEFINE_EVENT(TermControl, ScrollPositionChanged, _scrollPositionChangedHandlers, TerminalControl::ScrollPositionChangedEventArgs);
// clang-format on
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:
PasteFromClipboardEventArgs(std::function<void(std::wstring)> clipboardDataHandler) : m_clipboardDataHandler(clipboardDataHandler) { }
PasteFromClipboardEventArgs(std::function<void(std::wstring)> clipboardDataHandler) :
m_clipboardDataHandler(clipboardDataHandler) {}
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);
// clang-format off
// -------------------------------- WinRT Events ---------------------------------
DECLARE_EVENT(TitleChanged, _titleChangedHandlers, TerminalControl::TitleChangedEventArgs);
DECLARE_EVENT(ConnectionClosed, _connectionClosedHandlers, TerminalControl::ConnectionClosedEventArgs);
@ -60,6 +62,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
DECLARE_EVENT(CopyToClipboard, _clipboardCopyHandlers, TerminalControl::CopyToClipboardEventArgs);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(PasteFromClipboard, _clipboardPasteHandlers, TerminalControl::TermControl, TerminalControl::PasteFromClipboardEventArgs);
// clang-format on
private:
TerminalConnection::ITerminalConnection _connection;

View file

@ -30,4 +30,3 @@
#include <winrt/Windows.ui.xaml.input.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;
// void SendMouseEvent(uint row, uint col, KeyModifiers modifiers);
[[nodiscard]]
virtual HRESULT UserResize(const COORD size) noexcept = 0;
[[nodiscard]] virtual HRESULT UserResize(const COORD size) noexcept = 0;
virtual void UserScrollViewport(const int viewTop) = 0;
virtual int GetScrollOffset() = 0;
};
}

View file

@ -50,9 +50,11 @@ Terminal::Terminal() :
{
_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);
_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
// nothing to do (the viewportSize is the same as our current size), or an
// appropriate HRESULT for failing to resize.
[[nodiscard]]
HRESULT Terminal::UserResize(const COORD viewportSize) noexcept
[[nodiscard]] HRESULT Terminal::UserResize(const COORD viewportSize) noexcept
{
const auto oldDimensions = _mutableViewport.Dimensions();
if (viewportSize == oldDimensions)
@ -212,11 +213,10 @@ bool Terminal::SendKeyEvent(const WORD vkey,
_NotifyScrollEvent();
}
DWORD modifiers = 0
| (ctrlPressed? LEFT_CTRL_PRESSED : 0)
| (altPressed? LEFT_ALT_PRESSED : 0)
| (shiftPressed? SHIFT_PRESSED : 0)
;
DWORD modifiers = 0 |
(ctrlPressed ? LEFT_CTRL_PRESSED : 0) |
(altPressed ? LEFT_ALT_PRESSED : 0) |
(shiftPressed ? SHIFT_PRESSED : 0);
// 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
@ -252,8 +252,7 @@ bool Terminal::SendKeyEvent(const WORD vkey,
// Return Value:
// - a shared_lock which can be used to unlock the terminal. The shared_lock
// will release this lock when it's destructed.
[[nodiscard]]
std::shared_lock<std::shared_mutex> Terminal::LockForReading()
[[nodiscard]] std::shared_lock<std::shared_mutex> Terminal::LockForReading()
{
return std::shared_lock<std::shared_mutex>(_readWriteLock);
}
@ -263,13 +262,11 @@ std::shared_lock<std::shared_mutex> Terminal::LockForReading()
// Return Value:
// - a unique_lock which can be used to unlock the terminal. The unique_lock
// will release this lock when it's destructed.
[[nodiscard]]
std::unique_lock<std::shared_mutex> Terminal::LockForWriting()
[[nodiscard]] std::unique_lock<std::shared_mutex> Terminal::LockForWriting()
{
return std::unique_lock<std::shared_mutex>(_readWriteLock);
}
Viewport Terminal::_GetMutableViewport() const noexcept
{
return _mutableViewport;
@ -527,8 +524,12 @@ std::vector<SMALL_RECT> Terminal::_GetSelectionRects() const
const COORD endSelectionPositionWithOffset = { _endSelectionPosition.X, temp2 };
// NOTE: (0,0) is top-left so vertical comparison is inverted
const COORD &higherCoord = (selectionAnchorWithOffset.Y <= endSelectionPositionWithOffset.Y) ? selectionAnchorWithOffset : endSelectionPositionWithOffset;
const COORD &lowerCoord = (selectionAnchorWithOffset.Y > endSelectionPositionWithOffset.Y) ? selectionAnchorWithOffset : endSelectionPositionWithOffset;
const COORD& higherCoord = (selectionAnchorWithOffset.Y <= endSelectionPositionWithOffset.Y) ?
selectionAnchorWithOffset :
endSelectionPositionWithOffset;
const COORD& lowerCoord = (selectionAnchorWithOffset.Y > endSelectionPositionWithOffset.Y) ?
selectionAnchorWithOffset :
endSelectionPositionWithOffset;
selectionArea.reserve(lowerCoord.Y - higherCoord.Y + 1);
for (auto row = higherCoord.Y; row <= lowerCoord.Y; row++)

View file

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

View file

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

View file

@ -43,5 +43,4 @@ private:
bool _SetBoldColorHelper(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);
};

View file

@ -6,6 +6,7 @@
using namespace ::Microsoft::Terminal::Core;
using namespace ::Microsoft::Console::VirtualTerminal;
// clang-format off
const BYTE RED_ATTR = 0x01;
const BYTE GREEN_ATTR = 0x02;
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_CYAN = BRIGHT_ATTR | GREEN_ATTR | BLUE_ATTR;
const BYTE BRIGHT_WHITE = BRIGHT_ATTR | RED_ATTR | GREEN_ATTR | BLUE_ATTR;
// clang-format on
// Routine Description:
// Returns true if the GraphicsOption represents an extended color option.

View file

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

View file

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

View file

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

View file

@ -102,7 +102,8 @@ void AppHost::AppTitleChanged(winrt::hstring newTitle)
// - <none>
// Return Value:
// - <none>
void AppHost::LastTabClosed() {
void AppHost::LastTabClosed()
{
_window->Close();
}
@ -140,7 +141,8 @@ void AppHost::_HandleCreateWindow(const HWND hwnd, const RECT proposedRect)
// Create a RECT from our requested client size
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
// 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.
LOG_LAST_ERROR();
nonClient = Viewport::FromDimensions({ _currentWidth,
_currentHeight }).ToRect();
_currentHeight })
.ToRect();
}
}
const auto adjustedHeight = nonClient.bottom - nonClient.top;
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);
bool succeeded = SetWindowPos(hwnd, nullptr,
bool succeeded = SetWindowPos(hwnd,
nullptr,
newPos.Left(),
newPos.Top(),
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
// the originally proposed window size.
LOG_LAST_ERROR_IF(!succeeded);
}

View file

@ -16,8 +16,7 @@ public:
return reinterpret_cast<T*>(GetWindowLongPtr(window, GWLP_USERDATA));
}
[[nodiscard]]
static LRESULT __stdcall WndProc(HWND const window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept
[[nodiscard]] static LRESULT __stdcall WndProc(HWND const window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept
{
WINRT_ASSERT(window);
@ -41,10 +40,10 @@ public:
return DefWindowProc(window, message, wparam, lparam);
}
[[nodiscard]]
virtual LRESULT MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept
[[nodiscard]] virtual LRESULT MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept
{
switch (message)
{
switch (message) {
case WM_DPICHANGED:
{
return HandleDpiChange(_window, wparam, lparam);
@ -100,8 +99,7 @@ public:
}
// DPI Change handler. on WM_DPICHANGE resize the window
[[nodiscard]]
LRESULT HandleDpiChange(const HWND hWnd, const WPARAM wParam, const LPARAM lParam)
[[nodiscard]] LRESULT HandleDpiChange(const HWND hWnd, const WPARAM wParam, const LPARAM lParam)
{
_inDpiChange = true;
const HWND hWndStatic = GetWindow(hWnd, GW_CHILD);
@ -112,9 +110,7 @@ public:
// Resize the window
auto lprcNewScale = reinterpret_cast<RECT*>(lParam);
SetWindowPos(hWnd, nullptr, lprcNewScale->left, lprcNewScale->top,
lprcNewScale->right - lprcNewScale->left, lprcNewScale->bottom - lprcNewScale->top,
SWP_NOZORDER | SWP_NOACTIVATE);
SetWindowPos(hWnd, nullptr, lprcNewScale->left, lprcNewScale->top, lprcNewScale->right - lprcNewScale->left, lprcNewScale->bottom - lprcNewScale->top, SWP_NOZORDER | SWP_NOACTIVATE);
_currentDpi = uDpi;
}
@ -203,4 +199,6 @@ protected:
};
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,
L"Windows Terminal",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
nullptr, nullptr, wc.hInstance, this));
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
nullptr,
nullptr,
wc.hInstance,
this));
WINRT_ASSERT(_window);
}
// Method Description:
@ -144,11 +149,10 @@ void IslandWindow::OnSize()
}
}
[[nodiscard]]
LRESULT IslandWindow::MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept
[[nodiscard]] LRESULT IslandWindow::MessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept
{
switch (message)
{
switch (message) {
case WM_CREATE:
{
_HandleCreateWindow(wparam, lparam);
@ -205,4 +209,3 @@ void IslandWindow::SetRootContent(winrt::Windows::UI::Xaml::UIElement content)
_rootGrid.Children().Clear();
_rootGrid.Children().Append(content);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -17,14 +17,12 @@ Author:
#include "popup.h"
class CommandListPopup : public Popup
{
public:
CommandListPopup(SCREEN_INFORMATION& screenInfo, const CommandHistory& history);
[[nodiscard]]
NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override;
[[nodiscard]] NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override;
protected:
void _DrawContent() override;
@ -37,14 +35,10 @@ private:
void _handleReturn(COOKED_READ_DATA& cookedReadData);
void _cycleSelectionToMatchingCommands(COOKED_READ_DATA& cookedReadData, const wchar_t wch);
void _setBottomIndex();
[[nodiscard]]
NTSTATUS _handlePopupKeys(COOKED_READ_DATA& cookedReadData, const wchar_t wch, const DWORD modifiers) noexcept;
[[nodiscard]]
NTSTATUS _deleteSelection(COOKED_READ_DATA& cookedReadData) noexcept;
[[nodiscard]]
NTSTATUS _swapUp(COOKED_READ_DATA& cookedReadData) noexcept;
[[nodiscard]]
NTSTATUS _swapDown(COOKED_READ_DATA& cookedReadData) noexcept;
[[nodiscard]] NTSTATUS _handlePopupKeys(COOKED_READ_DATA& cookedReadData, const wchar_t wch, const DWORD modifiers) noexcept;
[[nodiscard]] NTSTATUS _deleteSelection(COOKED_READ_DATA& cookedReadData) noexcept;
[[nodiscard]] NTSTATUS _swapUp(COOKED_READ_DATA& cookedReadData) noexcept;
[[nodiscard]] NTSTATUS _swapDown(COOKED_READ_DATA& cookedReadData) noexcept;
SHORT _currentCommand;
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:
// - CONSOLE_STATUS_WAIT - we ran out of input, so a wait block was created
// - CONSOLE_STATUS_READ_COMPLETE - user hit return
[[nodiscard]]
NTSTATUS CommandNumberPopup::Process(COOKED_READ_DATA& cookedReadData) noexcept
[[nodiscard]] NTSTATUS CommandNumberPopup::Process(COOKED_READ_DATA& cookedReadData) noexcept
{
NTSTATUS Status = STATUS_SUCCESS;
WCHAR wch = UNICODE_NULL;

View file

@ -17,14 +17,12 @@ Author:
#include "popup.h"
class CommandNumberPopup final : public Popup
{
public:
CommandNumberPopup(SCREEN_INFORMATION& screenInfo);
[[nodiscard]]
NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override;
[[nodiscard]] NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override;
protected:
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,
const HANDLE hStdIn,
const HANDLE hStdOut)
: _commandline(commandline),
const HANDLE hStdOut) :
_commandline(commandline),
_vtInHandle(hStdIn),
_vtOutHandle(hStdOut),
_recievedEarlySizeChange{ false },
@ -46,7 +46,6 @@ ConsoleArguments::ConsoleArguments(const std::wstring& commandline,
ConsoleArguments::ConsoleArguments() :
ConsoleArguments(L"", nullptr, nullptr)
{
}
ConsoleArguments& ConsoleArguments::operator=(const ConsoleArguments& other)
@ -106,8 +105,9 @@ void ConsoleArguments::s_ConsumeArg(_Inout_ std::vector<std::wstring>& args, _In
// Return Value:
// S_OK if we parsed the string successfully, otherwise E_INVALIDARG indicating
// failure.
[[nodiscard]]
HRESULT ConsoleArguments::s_GetArgumentValue(_Inout_ std::vector<std::wstring>& args, _Inout_ size_t& index, _Out_opt_ std::wstring* const pSetting)
[[nodiscard]] HRESULT ConsoleArguments::s_GetArgumentValue(_Inout_ std::vector<std::wstring>& args,
_Inout_ size_t& index,
_Out_opt_ std::wstring* const pSetting)
{
bool hasNext = (index + 1) < args.size();
if (hasNext)
@ -136,8 +136,7 @@ HRESULT ConsoleArguments::s_GetArgumentValue(_Inout_ std::vector<std::wstring>&
// Return Value:
// S_OK if we parsed the string successfully, otherwise E_INVALIDARG indicating
// failure.
[[nodiscard]]
HRESULT ConsoleArguments::s_HandleFeatureValue(_Inout_ std::vector<std::wstring>& args, _Inout_ size_t& index)
[[nodiscard]] HRESULT ConsoleArguments::s_HandleFeatureValue(_Inout_ std::vector<std::wstring>& args, _Inout_ size_t& index)
{
HRESULT hr = E_INVALIDARG;
bool hasNext = (index + 1) < args.size();
@ -167,8 +166,7 @@ HRESULT ConsoleArguments::s_HandleFeatureValue(_Inout_ std::vector<std::wstring>
// Return Value:
// S_OK if we parsed the short successfully, otherwise E_INVALIDARG indicating
// failure. This could be the case for non-numeric arguments, or for >SHORT_MAX args.
[[nodiscard]]
HRESULT ConsoleArguments::s_GetArgumentValue(_Inout_ std::vector<std::wstring>& args,
[[nodiscard]] HRESULT ConsoleArguments::s_GetArgumentValue(_Inout_ std::vector<std::wstring>& args,
_Inout_ size_t& index,
_Out_opt_ short* const pSetting)
{
@ -199,7 +197,6 @@ HRESULT ConsoleArguments::s_GetArgumentValue(_Inout_ std::vector<std::wstring>&
{
succeeded = false;
}
}
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.
// - E_INVALIDARG if we couldn't parse the text as a valid hex-encoded handle number OR
// if the handle value was already filled.
[[nodiscard]]
HRESULT ConsoleArguments::s_ParseHandleArg(const std::wstring& handleAsText, _Inout_ DWORD& handleAsVal)
[[nodiscard]] HRESULT ConsoleArguments::s_ParseHandleArg(const std::wstring& handleAsText, _Inout_ DWORD& handleAsVal)
{
HRESULT hr = S_OK;
@ -259,8 +255,7 @@ HRESULT ConsoleArguments::s_ParseHandleArg(const std::wstring& handleAsText, _In
// Return Value:
// S_OK if we parsed the string successfully, otherwise E_INVALIDARG indicating
// failure.
[[nodiscard]]
HRESULT ConsoleArguments::_GetClientCommandline(_Inout_ std::vector<std::wstring>& args, const size_t index, const bool skipFirst)
[[nodiscard]] HRESULT ConsoleArguments::_GetClientCommandline(_Inout_ std::vector<std::wstring>& args, const size_t index, const bool skipFirst)
{
auto start = args.begin() + index;
@ -297,8 +292,7 @@ HRESULT ConsoleArguments::_GetClientCommandline(_Inout_ std::vector<std::wstring
// Return Value:
// S_OK if we parsed our _commandline successfully, otherwise E_INVALIDARG
// indicating failure.
[[nodiscard]]
HRESULT ConsoleArguments::ParseCommandline()
[[nodiscard]] HRESULT ConsoleArguments::ParseCommandline()
{
// If the commandline was empty, quick return.
if (_commandline.length() == 0)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -35,15 +35,13 @@ Arguments:
Return Value:
--*/
[[nodiscard]]
NTSTATUS AdjustCursorPosition(SCREEN_INFORMATION& screenInfo,
[[nodiscard]] NTSTATUS AdjustCursorPosition(SCREEN_INFORMATION& screenInfo,
_In_ COORD coordCursor,
const BOOL fKeepCursorVisible,
_Inout_opt_ PSHORT psScrollY);
#define LOCAL_BUFFER_SIZE 100
/*++
Routine Description:
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
will be implemented as part of the line editing services.
--*/
[[nodiscard]]
NTSTATUS WriteCharsLegacy(SCREEN_INFORMATION& screenInfo,
[[nodiscard]] NTSTATUS WriteCharsLegacy(SCREEN_INFORMATION& screenInfo,
_In_range_(<=, pwchBuffer) const wchar_t* const pwchBufferBackupLimit,
_In_ const wchar_t* pwchBuffer,
_In_reads_bytes_(*pcb) const wchar_t* pwchRealUnicode,
@ -83,8 +80,7 @@ NTSTATUS WriteCharsLegacy(SCREEN_INFORMATION& screenInfo,
_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.
[[nodiscard]]
NTSTATUS WriteChars(SCREEN_INFORMATION& screenInfo,
[[nodiscard]] NTSTATUS WriteChars(SCREEN_INFORMATION& screenInfo,
_In_range_(<=, pwchBuffer) const wchar_t* const pwchBufferBackupLimit,
_In_ const wchar_t* pwchBuffer,
_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
// String has been translated to unicode at this point.
[[nodiscard]]
NTSTATUS DoWriteConsole(_In_reads_bytes_(*pcbBuffer) PWCHAR pwchBuffer,
[[nodiscard]] NTSTATUS DoWriteConsole(_In_reads_bytes_(*pcbBuffer) PWCHAR pwchBuffer,
_In_ size_t* const pcbBuffer,
SCREEN_INFORMATION& screenInfo,
std::unique_ptr<WriteData>& waiter);

View file

@ -49,7 +49,8 @@ std::unordered_map<std::wstring,
case_insensitive_hash,
case_insensitive_equality>,
case_insensitive_hash,
case_insensitive_equality> g_aliasData;
case_insensitive_equality>
g_aliasData;
// Routine Description:
// - 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
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT ApiRoutines::AddConsoleAliasAImpl(const std::string_view source,
[[nodiscard]] HRESULT ApiRoutines::AddConsoleAliasAImpl(const std::string_view source,
const std::string_view target,
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
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT ApiRoutines::AddConsoleAliasWImpl(const std::wstring_view source,
[[nodiscard]] HRESULT ApiRoutines::AddConsoleAliasWImpl(const std::wstring_view source,
const std::wstring_view target,
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
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT GetConsoleAliasWImplHelper(const std::wstring_view source,
[[nodiscard]] HRESULT GetConsoleAliasWImplHelper(const std::wstring_view source,
std::optional<gsl::span<wchar_t>> target,
size_t& writtenOrNeeded,
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
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT ApiRoutines::GetConsoleAliasAImpl(const std::string_view source,
[[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasAImpl(const std::string_view source,
gsl::span<char> target,
size_t& written,
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
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT ApiRoutines::GetConsoleAliasWImpl(const std::wstring_view source,
[[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasWImpl(const std::wstring_view source,
gsl::span<wchar_t> target,
size_t& written,
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.
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT GetConsoleAliasesLengthWImplHelper(const std::wstring_view exeName,
[[nodiscard]] HRESULT GetConsoleAliasesLengthWImplHelper(const std::wstring_view exeName,
const bool countInUnicode,
const UINT codepage,
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.
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT ApiRoutines::GetConsoleAliasesLengthAImpl(const std::string_view exeName,
[[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasesLengthAImpl(const std::string_view exeName,
size_t& bufferRequired) noexcept
{
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.
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT ApiRoutines::GetConsoleAliasesLengthWImpl(const std::wstring_view exeName,
[[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasesLengthWImpl(const std::wstring_view exeName,
size_t& bufferRequired) noexcept
{
LockConsole();
@ -449,8 +442,7 @@ void Alias::s_ClearCmdExeAliases()
// or how many characters would have been needed (if buffer is nullopt).
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT GetConsoleAliasesWImplHelper(const std::wstring_view exeName,
[[nodiscard]] HRESULT GetConsoleAliasesWImplHelper(const std::wstring_view exeName,
std::optional<gsl::span<wchar_t>> aliasBuffer,
size_t& writtenOrNeeded)
{
@ -537,8 +529,7 @@ HRESULT GetConsoleAliasesWImplHelper(const std::wstring_view exeName,
// - written - Will specify how many characters were written
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT ApiRoutines::GetConsoleAliasesAImpl(const std::string_view exeName,
[[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasesAImpl(const std::string_view exeName,
gsl::span<char> alias,
size_t& written) noexcept
{
@ -602,8 +593,7 @@ HRESULT ApiRoutines::GetConsoleAliasesAImpl(const std::string_view exeName,
// - written - Will specify how many characters were written
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT ApiRoutines::GetConsoleAliasesWImpl(const std::wstring_view exeName,
[[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasesWImpl(const std::wstring_view exeName,
gsl::span<wchar_t> alias,
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.
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT GetConsoleAliasExesLengthImplHelper(const bool countInUnicode, const UINT codepage, size_t& bufferRequired)
[[nodiscard]] HRESULT GetConsoleAliasExesLengthImplHelper(const bool countInUnicode, const UINT codepage, size_t& bufferRequired)
{
// Ensure output variables are initialized
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.
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT ApiRoutines::GetConsoleAliasExesLengthAImpl(size_t& bufferRequired) noexcept
[[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasExesLengthAImpl(size_t& bufferRequired) noexcept
{
LockConsole();
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.
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT ApiRoutines::GetConsoleAliasExesLengthWImpl(size_t& bufferRequired) noexcept
[[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasExesLengthWImpl(size_t& bufferRequired) noexcept
{
LockConsole();
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).
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT GetConsoleAliasExesWImplHelper(std::optional<gsl::span<wchar_t>> aliasExesBuffer,
[[nodiscard]] HRESULT GetConsoleAliasExesWImplHelper(std::optional<gsl::span<wchar_t>> aliasExesBuffer,
size_t& writtenOrNeeded)
{
// Ensure output variables are initialized.
@ -747,12 +733,10 @@ HRESULT GetConsoleAliasExesWImplHelper(std::optional<gsl::span<wchar_t>> aliasEx
// Accumulate the total written amount.
RETURN_IF_FAILED(SizeTAdd(cchTotalLength, cchNeeded, &cchTotalLength));
}
writtenOrNeeded = cchTotalLength;
return S_OK;
}
@ -764,8 +748,7 @@ HRESULT GetConsoleAliasExesWImplHelper(std::optional<gsl::span<wchar_t>> aliasEx
// - written - Specifies how many characters were written
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT ApiRoutines::GetConsoleAliasExesAImpl(gsl::span<char> aliasExes,
[[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasExesAImpl(gsl::span<char> aliasExes,
size_t& written) noexcept
{
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
// Return Value:
// - Check HRESULT with SUCCEEDED. Can return memory, safe math, safe string, or locale conversion errors.
[[nodiscard]]
HRESULT ApiRoutines::GetConsoleAliasExesWImpl(gsl::span<wchar_t> aliasExes,
[[nodiscard]] HRESULT ApiRoutines::GetConsoleAliasExesWImpl(gsl::span<wchar_t> aliasExes,
size_t& written) noexcept
{
LockConsole();

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