diff --git a/.clang-format b/.clang-format index 9e5a7d131..26a27f32e 100644 --- a/.clang-format +++ b/.clang-format @@ -1,17 +1,19 @@ AccessModifierOffset: -4 AlignAfterOpenBracket: Align -#AllowAllArgumentsOnNextLine: false +AllowAllArgumentsOnNextLine: true +AlignConsecutiveMacros: false AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false -#AllowAllConstructorInitializersOnNextLine: false +AllowAllConstructorInitializersOnNextLine: true AlignEscapedNewlines: Left AlignOperands: true AlignTrailingComments: false AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Never AllowShortFunctionsOnASingleLine: Inline AllowShortCaseLabelsOnASingleLine: false -AllowShortIfStatementsOnASingleLine: false +AllowShortIfStatementsOnASingleLine: Never #AllowShortLambdasOnASingleLine: Inline AllowShortLoopsOnASingleLine: false AlwaysBreakAfterReturnType: None @@ -20,6 +22,7 @@ AlwaysBreakTemplateDeclarations: Yes BinPackArguments: false BinPackParameters: false BraceWrapping: + AfterCaseLabel: true AfterClass: true AfterControlStatement: true AfterEnum: true @@ -47,6 +50,7 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: false +DeriveLineEnding: true DerivePointerAlignment: false FixNamespaceComments: false IncludeBlocks: Regroup @@ -73,7 +77,7 @@ ReflowComments: false SortIncludes: false SortUsingDeclarations: true SpaceAfterCStyleCast: false -#SpaceAfterLogicalNot: false +SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: false SpaceBeforeAssignmentOperators: true SpaceBeforeCpp11BracedList: false @@ -88,6 +92,6 @@ SpacesInCStyleCastParentheses: false SpacesInContainerLiterals: false SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: Cpp11 +Standard: Latest TabWidth: 4 UseTab: Never diff --git a/dep/llvm/clang-format.exe b/dep/llvm/clang-format.exe deleted file mode 100644 index efed82cc0..000000000 Binary files a/dep/llvm/clang-format.exe and /dev/null differ diff --git a/src/cascadia/PublicTerminalCore/HwndTerminal.cpp b/src/cascadia/PublicTerminalCore/HwndTerminal.cpp index 0a0090338..6280ae37e 100644 --- a/src/cascadia/PublicTerminalCore/HwndTerminal.cpp +++ b/src/cascadia/PublicTerminalCore/HwndTerminal.cpp @@ -242,7 +242,7 @@ HRESULT HwndTerminal::Initialize() _terminal->Create(COORD{ 80, 25 }, 1000, *_renderer); _terminal->SetDefaultBackground(RGB(12, 12, 12)); _terminal->SetDefaultForeground(RGB(204, 204, 204)); - _terminal->SetWriteInputCallback([=](std::wstring & input) noexcept { _WriteTextToConnection(input); }); + _terminal->SetWriteInputCallback([=](std::wstring& input) noexcept { _WriteTextToConnection(input); }); localPointerToThread->EnablePainting(); _multiClickTime = std::chrono::milliseconds{ GetDoubleClickTime() }; diff --git a/src/inc/til/static_map.h b/src/inc/til/static_map.h index 452e2dab3..1a82ac6ff 100644 --- a/src/inc/til/static_map.h +++ b/src/inc/til/static_map.h @@ -70,5 +70,5 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned" // 1. static_map's member types are all the same // 2. static_map's fourth template argument (otherwise undeduced) is how many pairs it contains template - static_map(First, Rest...)->static_map...>, typename First::first_type, void>, typename First::second_type, std::less, 1 + sizeof...(Rest)>; + static_map(First, Rest...) -> static_map...>, typename First::first_type, void>, typename First::second_type, std::less, 1 + sizeof...(Rest)>; } diff --git a/src/propsheet/PropSheetHandler.cpp b/src/propsheet/PropSheetHandler.cpp index f06d4fc6e..f34581d52 100644 --- a/src/propsheet/PropSheetHandler.cpp +++ b/src/propsheet/PropSheetHandler.cpp @@ -34,7 +34,7 @@ public: } // IPersist - STDMETHODIMP GetClassID(_Out_ CLSID* clsid) override + STDMETHODIMP GetClassID(_Out_ CLSID * clsid) override { *clsid = __uuidof(this); return S_OK; @@ -43,7 +43,7 @@ public: // IShellExtInit // Shell QI's for IShellExtInit and calls Initialize first. If we return a succeeding HRESULT, the shell will QI for // IShellPropSheetExt and call AddPages. A failing HRESULT causes the shell to skip us. - STDMETHODIMP Initialize(_In_ PCIDLIST_ABSOLUTE /*pidlFolder*/, _In_ IDataObject* pdtobj, _In_ HKEY /*hkeyProgID*/) + STDMETHODIMP Initialize(_In_ PCIDLIST_ABSOLUTE /*pidlFolder*/, _In_ IDataObject * pdtobj, _In_ HKEY /*hkeyProgID*/) { WCHAR szLinkFileName[MAX_PATH]; HRESULT hr = _ShouldAddPropertySheet(pdtobj, szLinkFileName, ARRAYSIZE(szLinkFileName)); @@ -139,7 +139,7 @@ private: /////////////////////////////////////////////////////////////////////////// // CODE FROM THE SHELL DEPOT'S `idllib.h` // get a link target item without resolving it. - HRESULT GetTargetIdList(_In_ IShellItem* psiLink, _COM_Outptr_ PIDLIST_ABSOLUTE* ppidl) + HRESULT GetTargetIdList(_In_ IShellItem * psiLink, _COM_Outptr_ PIDLIST_ABSOLUTE * ppidl) { *ppidl = nullptr; @@ -156,7 +156,7 @@ private: } return hr; } - HRESULT GetTargetItem(_In_ IShellItem* psiLink, _In_ REFIID riid, _COM_Outptr_ void** ppv) + HRESULT GetTargetItem(_In_ IShellItem * psiLink, _In_ REFIID riid, _COM_Outptr_ void** ppv) { *ppv = nullptr; @@ -171,7 +171,7 @@ private: } /////////////////////////////////////////////////////////////////////////// - HRESULT _GetShellItemLinkTargetExpanded(_In_ IShellItem* pShellItem, + HRESULT _GetShellItemLinkTargetExpanded(_In_ IShellItem * pShellItem, _Out_writes_(cchFilePathExtended) PWSTR pszFilePathExtended, const size_t cchFilePathExtended) { @@ -190,7 +190,7 @@ private: return hr; } - HRESULT _ShouldAddPropertySheet(_In_ IDataObject* pdtobj, + HRESULT _ShouldAddPropertySheet(_In_ IDataObject * pdtobj, _Out_writes_(cchLinkFileName) PWSTR pszLinkFileName, const size_t cchLinkFileName) { diff --git a/src/renderer/dx/DxRenderer.cpp b/src/renderer/dx/DxRenderer.cpp index e77d5660f..6e7709456 100644 --- a/src/renderer/dx/DxRenderer.cpp +++ b/src/renderer/dx/DxRenderer.cpp @@ -1488,8 +1488,7 @@ try const D2D_POINT_2F target = { coordTarget.X * font.width, coordTarget.Y * font.height }; const auto fullRunWidth = font.width * gsl::narrow_cast(cchLine); - const auto DrawLine = [=](const auto x0, const auto y0, const auto x1, const auto y1, const auto strokeWidth) noexcept - { + const auto DrawLine = [=](const auto x0, const auto y0, const auto x1, const auto y1, const auto strokeWidth) noexcept { _d2dDeviceContext->DrawLine({ x0, y0 }, { x1, y1 }, _d2dBrushForeground.Get(), strokeWidth, _strokeStyle.Get()); }; diff --git a/src/terminal/input/terminalInput.cpp b/src/terminal/input/terminalInput.cpp index 8f5c5c4f7..328ec1c67 100644 --- a/src/terminal/input/terminalInput.cpp +++ b/src/terminal/input/terminalInput.cpp @@ -588,8 +588,7 @@ bool TerminalInput::HandleKey(const IInputEvent* const pInEvent) } } - const auto senderFunc = [this](const std::wstring_view seq) noexcept - { + const auto senderFunc = [this](const std::wstring_view seq) noexcept { _SendInputSequence(seq); }; diff --git a/tools/OpenConsole.psm1 b/tools/OpenConsole.psm1 index 78c5416ed..3f628e423 100644 --- a/tools/OpenConsole.psm1 +++ b/tools/OpenConsole.psm1 @@ -323,7 +323,10 @@ function Invoke-ClangFormat { [CmdletBinding()] Param ( [Parameter(Mandatory=$true,ValueFromPipeline=$true)] - [string[]]$Path + [string[]]$Path, + + [Parameter(Mandatory=$false)] + [string]$ClangFormatPath = "clang-format" # (whichever one is in $PATH) ) Begin { @@ -340,7 +343,7 @@ function Invoke-ClangFormat { End { For($i = [int]0; $i -Lt $Paths.Length; $i += $BatchSize) { Try { - & "$env:OpenconsoleRoot/dep/llvm/clang-format" -i $Paths[$i .. ($i + $BatchSize - 1)] + & $ClangFormatPath -i $Paths[$i .. ($i + $BatchSize - 1)] } Catch { Write-Error $_ } @@ -351,9 +354,12 @@ function Invoke-ClangFormat { #.SYNOPSIS # runs code formatting on all c++ files function Invoke-CodeFormat() { + & "$env:OpenConsoleRoot\dep\nuget\nuget.exe" restore "$env:OpenConsoleRoot\tools\packages.config" + $clangPackage = ([xml](Get-Content "$env:OpenConsoleRoot\tools\packages.config")).packages.package | Where-Object id -like "clang-format*" + $clangFormatPath = "$env:OpenConsoleRoot\packages\$($clangPackage.id).$($clangPackage.version)\tools\clang-format.exe" Get-ChildItem -Recurse "$env:OpenConsoleRoot/src" -Include *.cpp, *.hpp, *.h | Where FullName -NotLike "*Generated Files*" | - Invoke-ClangFormat + Invoke-ClangFormat -ClangFormatPath $clangFormatPath } Export-ModuleMember -Function Set-MsbuildDevEnvironment,Invoke-OpenConsoleTests,Invoke-OpenConsoleBuild,Start-OpenConsole,Debug-OpenConsole,Invoke-CodeFormat diff --git a/tools/packages.config b/tools/packages.config new file mode 100644 index 000000000..a552f5bc0 --- /dev/null +++ b/tools/packages.config @@ -0,0 +1,4 @@ + + + +