Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split TermControl into a Core, Interactivity, and Control layer #9820

Merged
98 commits merged into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from 96 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
0bd30c2
Move everything to a fresh branch
zadjii-msft Mar 11, 2021
b0f1fa4
fix some build breaks, because I was only playing in TerminalControl
zadjii-msft Mar 11, 2021
243867a
Merge remote-tracking branch 'origin/main' into dev/migrie/oop-tear-a…
zadjii-msft Mar 11, 2021
acf84f1
hey look it launches. But there's definitely a good amount of broken …
zadjii-msft Mar 11, 2021
5e655ef
I wasn't the murderer after all
zadjii-msft Mar 11, 2021
2402c59
Hokay, so that gets the control as a lib/dll split
zadjii-msft Mar 12, 2021
24765d7
its-all-coming-together.gif
zadjii-msft Mar 12, 2021
54f443b
can I get a big woop woop from all my homies
zadjii-msft Mar 12, 2021
322d511
Fix the tests
zadjii-msft Mar 12, 2021
8f8cf59
Rename Microsoft.Terminal.TerminalControl to just Microsoft.Terminal.…
zadjii-msft Mar 12, 2021
eee5bee
some dead code
zadjii-msft Mar 12, 2021
04d403c
Change the GUID, project name
zadjii-msft Mar 16, 2021
e8d06d7
Merge remote-tracking branch 'origin/main' into dev/migrie/r/split-te…
zadjii-msft Mar 16, 2021
f8e969e
oh! IT CAUGHT AN ISSUE! YAY!
zadjii-msft Mar 16, 2021
8c6c7ec
Bite-sized refactor: Move all the args in TermControl to their own fi…
zadjii-msft Mar 17, 2021
2f532bd
Hey, lets clean this up while we're at it
zadjii-msft Mar 17, 2021
093e8ac
Merge remote-tracking branch 'origin/dev/migrie/oop-tear-apart-contro…
zadjii-msft Mar 17, 2021
c035e69
Reorganize these files to be a little less painful to read
zadjii-msft Mar 18, 2021
801b296
Move isReadOnly to the core as well, through that really belongs in i…
zadjii-msft Mar 18, 2021
6ab8339
Ooh, do the font size event too
zadjii-msft Mar 18, 2021
df5f973
Merge remote-tracking branch 'origin/main' into dev/migrie/oop-termin…
zadjii-msft Mar 19, 2021
c29ffba
Start moving things to a shared middle bit too
zadjii-msft Mar 19, 2021
72c35a8
Move _UpdateSystemParameterSettings, 30 errors remain
zadjii-msft Mar 19, 2021
541d151
I suppose this should have been in the parent commit
zadjii-msft Mar 24, 2021
2035fcd
Merge remote-tracking branch 'origin/main' into dev/migrie/oop-core-i…
zadjii-msft Mar 29, 2021
bbf605b
I think this needs to go in main
zadjii-msft Mar 29, 2021
ad88c6a
Merge remote-tracking branch 'origin/main' into dev/migrie/oop-core-i…
zadjii-msft Mar 29, 2021
ed79dab
Move PointerPressed to ControlInteractivity
zadjii-msft Mar 29, 2021
618b207
Move more mouse methods
zadjii-msft Mar 29, 2021
e85bdff
Move around the clipboard handling methods
zadjii-msft Mar 29, 2021
60b939e
An easy fix for 4 total errors
zadjii-msft Mar 29, 2021
db1c36c
Try to move most of the mouse wheel handlers
zadjii-msft Mar 29, 2021
4d8c85b
Stashing this, down to 4 errors? But I don't think this is hooked up …
zadjii-msft Mar 30, 2021
7510176
Merge remote-tracking branch 'origin/main' into dev/migrie/oop-core-i…
zadjii-msft Mar 30, 2021
7b02393
HAHAHAHA IT builds again, 0 ERRORS REMAIN
zadjii-msft Mar 30, 2021
7a0dc43
its full of bugs
zadjii-msft Mar 30, 2021
68f3753
Merge remote-tracking branch 'origin/main' into dev/migrie/oop-core-i…
zadjii-msft Mar 31, 2021
2ac8318
dead code cleanup crew
zadjii-msft Mar 31, 2021
1b3dd74
This lock is redundant now?
zadjii-msft Mar 31, 2021
f355f88
Create a control unittesting project
zadjii-msft Mar 31, 2021
78bd806
Need settings to instantiate controls
zadjii-msft Mar 31, 2021
8c5faba
Successfully create an instance of ControlCore in the tests
zadjii-msft Mar 31, 2021
ae4d2f2
Start writing real tests for all this, which is just about insane
zadjii-msft Mar 31, 2021
fbc3175
And interactivity tests!
zadjii-msft Apr 2, 2021
c37c073
Fix mousewheeling opactiy in the control
zadjii-msft Apr 2, 2021
5591ef0
Taking this lock is redundant now? It causes a deadlock?
zadjii-msft Apr 2, 2021
6dfa1b6
Fiz the scrollbar
zadjii-msft Apr 2, 2021
ff8cd22
Whoop, a test for mouse scrolling!
zadjii-msft Apr 2, 2021
01d248f
Yank the PointerPoint from the function signature
zadjii-msft Apr 6, 2021
8216c55
Merge remote-tracking branch 'origin/main' into dev/migrie/oop-core-i…
zadjii-msft Apr 6, 2021
3cbf377
Fix the tests after the merge
zadjii-msft Apr 6, 2021
f959612
A test for #9725
zadjii-msft Apr 6, 2021
f5f9de2
Fix a double free when closing the terminal
zadjii-msft Apr 7, 2021
832bb66
move around the read only warning. Now, does it work?
zadjii-msft Apr 7, 2021
8bd5bb0
Convert ControlCore's privates to _camelCase
zadjii-msft Apr 7, 2021
61e91f6
Same deal, _camelCase the privates of ControlInteractivity
zadjii-msft Apr 7, 2021
06a9a10
Fix read-only mode
zadjii-msft Apr 7, 2021
198576a
Okay, this clearly isn't working. WTF did I do wrong?
zadjii-msft Apr 7, 2021
f057930
Revert "Okay, this clearly isn't working. WTF did I do wrong?"
zadjii-msft Apr 7, 2021
15b9936
These are all unnecessary, and might be slowing our builds down!
zadjii-msft Apr 8, 2021
021dc57
This is how the original taskbar update worked, which turns out, does…
zadjii-msft Apr 8, 2021
be80583
Revert "This is how the original taskbar update worked, which turns o…
zadjii-msft Apr 8, 2021
4189bb0
Okay, this clearly isn't working. WTF did I do wrong?
zadjii-msft Apr 7, 2021
d8beada
This fixes #9743, but I think I'm still doing something off the UI th…
zadjii-msft Apr 8, 2021
a34cc1a
I did forget the co_await after all.
zadjii-msft Apr 8, 2021
fa0897a
Get rid of some TODOs
zadjii-msft Apr 8, 2021
643f1b7
Oh my, the last of the TODO!s
zadjii-msft Apr 8, 2021
5dc1632
Merge remote-tracking branch 'origin/main' into dev/migrie/oop-core-i…
zadjii-msft Apr 13, 2021
4e8dace
Fix my font loading bug
zadjii-msft Apr 13, 2021
1ed1781
Merge remote-tracking branch 'origin/main' into dev/migrie/oop-core-i…
zadjii-msft Apr 13, 2021
f3ea7c1
fix some unit tests
zadjii-msft Apr 13, 2021
ac683c1
Merge remote-tracking branch 'origin/main' into dev/migrie/oop-core-i…
zadjii-msft Apr 14, 2021
1488079
Some cleanup for review
zadjii-msft Apr 14, 2021
fd8314e
Merge remote-tracking branch 'origin/main' into dev/migrie/oop-core-i…
zadjii-msft Apr 16, 2021
c14bdd6
what? I'm not just guessing at the compiler error rather than buildin…
zadjii-msft Apr 19, 2021
668fab4
nits from carlos
zadjii-msft Apr 20, 2021
69f22a7
hot reload anti-aliasing
zadjii-msft Apr 20, 2021
c113b65
Revert "Use DComp surface handle for Swap Chain management."
zadjii-msft Apr 20, 2021
bddae1c
make_self for fun and profit
zadjii-msft Apr 20, 2021
0e72f77
woah look, none of these tests were ever running :yikes:
zadjii-msft Apr 20, 2021
e271bdf
the really easy feedback from dustin
zadjii-msft Apr 20, 2021
0d78c16
some minor renames
zadjii-msft Apr 21, 2021
5b5ac1b
Merge remote-tracking branch 'origin/main' into dev/migrie/oop-core-i…
zadjii-msft Apr 21, 2021
e2499a4
Change the paste handler to a wstring_view
zadjii-msft Apr 21, 2021
03949ac
get rid of unnecessary `focused` param
zadjii-msft Apr 21, 2021
85fc41a
A pile of nits
zadjii-msft Apr 21, 2021
e6f93ba
a TON of `til::point`s
zadjii-msft Apr 21, 2021
6e47221
another pile of nits
zadjii-msft Apr 21, 2021
3cc4717
bunch of comments
zadjii-msft Apr 21, 2021
753ca1b
patch the tests up to not use Cascadia Mono anymore
zadjii-msft Apr 21, 2021
144d95a
punt this test to future me in #7001
zadjii-msft Apr 21, 2021
11cc17c
Merge remote-tracking branch 'origin/main' into dev/migrie/oop-core-i…
zadjii-msft Apr 21, 2021
65b84ff
I think this is the last of the 'trivial' notes. I still have to do t…
zadjii-msft Apr 21, 2021
6d5351e
This is all the major blockers IMO. not like anyone will review it wh…
zadjii-msft Apr 21, 2021
efbec1f
Leonard is right, this is better
zadjii-msft Apr 23, 2021
0f62cea
LOAD BEARING COMMIT
zadjii-msft Apr 26, 2021
88742d6
Merge remote-tracking branch 'origin/main' into dev/migrie/oop-core-i…
zadjii-msft Apr 27, 2021
9731636
an update from main
zadjii-msft Apr 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/spelling/dictionary/apis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CXICON
CYICON
D2DERR_SHADER_COMPILE_FAILED
dataobject
dcomp
DERR
dlldata
DONTADDTORECENT
Expand Down Expand Up @@ -126,9 +127,12 @@ wsregex
wwinmain
XDocument
XElement
xhash
xlocmes
xlocmon
xlocnum
xloctime
XParse
xstring
xtree
xutility
15 changes: 14 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,20 @@
"xloctime": "cpp",
"multi_span": "cpp",
"pointers": "cpp",
"vector": "cpp"
"vector": "cpp",
"bitset": "cpp",
"deque": "cpp",
"initializer_list": "cpp",
"list": "cpp",
"queue": "cpp",
"random": "cpp",
"regex": "cpp",
"stack": "cpp",
"xhash": "cpp",
"xtree": "cpp",
"xutility": "cpp",
"span": "cpp",
"string_span": "cpp"
},
"files.exclude": {
"**/bin/**": true,
Expand Down
7 changes: 4 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"-Command",
"Import-Module ${workspaceFolder}\\tools\\OpenConsole.psm1;",
"Set-MsBuildDevEnvironment;",
"$project = switch(\"${input:buildProjectChoice}\"){OpenConsole{\"Conhost\\Host_EXE\"} Terminal{\"Terminal\\CascadiaPackage\"}};",
"$project = switch(\"${input:buildProjectChoice}\"){OpenConsole{\"Conhost\\Host_EXE\"} Terminal{\"Terminal\\CascadiaPackage\"} TermControl{\"Terminal\\TerminalControl\"}};",
"$target = switch(\"${input:buildModeChoice}\"){Build{\"\"} Rebuild{\":Rebuild\"} Clean{\":Clean\"}};",
"$target = $project + $target;",
"msbuild",
Expand Down Expand Up @@ -111,10 +111,11 @@
"description": "OpenConsole or Terminal?",
"options":[
"OpenConsole",
"Terminal"
"Terminal",
"TermControl"
],
"default": "Terminal"
}

]
}
}
2 changes: 2 additions & 0 deletions OpenConsole.sln
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.Terminal.Control.
{CA5CAD1A-C46D-4588-B1C0-40F31AE9100B} = {CA5CAD1A-C46D-4588-B1C0-40F31AE9100B}
{CA5CAD1A-ABCD-429C-B551-8562EC954746} = {CA5CAD1A-ABCD-429C-B551-8562EC954746}
{1CF55140-EF6A-4736-A403-957E4F7430BB} = {1CF55140-EF6A-4736-A403-957E4F7430BB}
{48D21369-3D7B-4431-9967-24E81292CF62} = {48D21369-3D7B-4431-9967-24E81292CF62}
{48D21369-3D7B-4431-9967-24E81292CF63} = {48D21369-3D7B-4431-9967-24E81292CF63}
{AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F} = {AF0A096A-8B3A-4949-81EF-7DF8F0FEE91F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.Terminal.Control", "src\cascadia\TerminalControl\dll\TerminalControl.vcxproj", "{CA5CAD1A-F542-4635-A069-7CAEFB930070}"
Expand Down
6 changes: 3 additions & 3 deletions build/pipelines/templates/build-console-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ steps:
configPath: NuGet.config
restoreSolution: OpenConsole.sln
restoreDirectory: '$(Build.SourcesDirectory)\packages'

- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2
displayName: Restore NuGet packages for extraneous build actions
inputs:
Expand Down Expand Up @@ -96,7 +96,7 @@ steps:
displayName: 'Upload converted test logs'
inputs:
testResultsFormat: 'xUnit' # Options: JUnit, NUnit, VSTest, xUnit, cTest
testResultsFiles: '**/onBuildMachineResults.xml'
testResultsFiles: '**/onBuildMachineResults.xml'
#searchFolder: '$(System.DefaultWorkingDirectory)' # Optional
#mergeTestResults: false # Optional
#failTaskOnFailedTests: false # Optional
Expand Down Expand Up @@ -147,4 +147,4 @@ steps:
displayName: 'Publish All Build Artifacts'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
ArtifactName: 'drop'
3 changes: 1 addition & 2 deletions src/cascadia/TerminalApp/Pane.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
// - Mike Griese (zadjii-msft) 16-May-2019

#pragma once
#include <winrt/Microsoft.Terminal.Control.h>
#include <winrt/TerminalApp.h>

#include "../../cascadia/inc/cppwinrt_utils.h"

enum class Borders : int
Expand Down
2 changes: 0 additions & 2 deletions src/cascadia/TerminalApp/SettingsTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Author(s):
#pragma once
#include "TabBase.h"
#include "SettingsTab.g.h"
#include <winrt/TerminalApp.h>
#include <winrt/Microsoft.Terminal.Settings.Editor.h>
#include "../../cascadia/inc/cppwinrt_utils.h"

namespace winrt::TerminalApp::implementation
Expand Down
5 changes: 5 additions & 0 deletions src/cascadia/TerminalApp/TabManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ namespace winrt::TerminalApp::implementation
{
// Possibly update the icon of the tab.
page->_UpdateTabIcon(*tab);

// Update the taskbar progress as well. We'll raise our own
// SetTaskbarProgress event here, to get tell the hosting
// application to re-query this value from us.
page->_SetTaskbarProgressHandlers(*page, nullptr);
zadjii-msft marked this conversation as resolved.
Show resolved Hide resolved
}
});

Expand Down
61 changes: 36 additions & 25 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,9 +994,6 @@ namespace winrt::TerminalApp::implementation

term.OpenHyperlink({ this, &TerminalPage::_OpenHyperlinkHandler });

// Add an event handler for when the terminal wants to set a progress indicator on the taskbar
term.SetTaskbarProgress({ this, &TerminalPage::_SetTaskbarProgressHandler });

term.HidePointerCursor({ get_weak(), &TerminalPage::_HidePointerCursorHandler });
term.RestorePointerCursor({ get_weak(), &TerminalPage::_RestorePointerCursorHandler });

Expand Down Expand Up @@ -1051,6 +1048,11 @@ namespace winrt::TerminalApp::implementation
}
});

// Add an event handler for when the terminal or tab wants to set a
// progress indicator on the taskbar
hostingTab.TaskbarProgressChanged({ get_weak(), &TerminalPage::_SetTaskbarProgressHandler });
term.SetTaskbarProgress({ get_weak(), &TerminalPage::_SetTaskbarProgressHandler });

// TODO GH#3327: Once we support colorizing the NewTab button based on
// the color of the tab, we'll want to make sure to call
// _ClearNewTabButtonColor here, to reset it to the default (for the
Expand Down Expand Up @@ -1152,7 +1154,7 @@ namespace winrt::TerminalApp::implementation
{
// The magic value of WHEEL_PAGESCROLL indicates that we need to scroll the entire page
realRowsToScroll = _systemRowsToScroll == WHEEL_PAGESCROLL ?
terminalTab->GetActiveTerminalControl().GetViewHeight() :
terminalTab->GetActiveTerminalControl().ViewHeight() :
_systemRowsToScroll;
}
else
Expand Down Expand Up @@ -1293,7 +1295,7 @@ namespace winrt::TerminalApp::implementation
if (const auto terminalTab{ _GetFocusedTabImpl() })
{
const auto control = _GetActiveControl();
const auto termHeight = control.GetViewHeight();
const auto termHeight = control.ViewHeight();
auto scrollDelta = _ComputeScrollDelta(scrollDirection, termHeight);
terminalTab->Scroll(scrollDelta);
}
Expand Down Expand Up @@ -1645,29 +1647,37 @@ namespace winrt::TerminalApp::implementation
return false;
}

void TerminalPage::_ControlNoticeRaisedHandler(const IInspectable /*sender*/, const Microsoft::Terminal::Control::NoticeEventArgs eventArgs)
// Important! Don't take this eventArgs by reference, we need to extend the
// lifetime of it to the other side of the co_await!
winrt::fire_and_forget TerminalPage::_ControlNoticeRaisedHandler(const IInspectable /*sender*/,
const Microsoft::Terminal::Control::NoticeEventArgs eventArgs)
Comment on lines +1654 to +1655
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you make this method resistant against being called from a background thread you don't need to switch into the foreground thread in neither _RendererWarning nor _RaiseReadOnlyWarning.

{
winrt::hstring message = eventArgs.Message();
auto weakThis = get_weak();
co_await winrt::resume_foreground(Dispatcher());
if (auto page = weakThis.get())
{
winrt::hstring message = eventArgs.Message();

winrt::hstring title;
winrt::hstring title;

switch (eventArgs.Level())
{
case NoticeLevel::Debug:
title = RS_(L"NoticeDebug"); //\xebe8
break;
case NoticeLevel::Info:
title = RS_(L"NoticeInfo"); // \xe946
break;
case NoticeLevel::Warning:
title = RS_(L"NoticeWarning"); //\xe7ba
break;
case NoticeLevel::Error:
title = RS_(L"NoticeError"); //\xe783
break;
}
switch (eventArgs.Level())
{
case NoticeLevel::Debug:
title = RS_(L"NoticeDebug"); //\xebe8
break;
case NoticeLevel::Info:
title = RS_(L"NoticeInfo"); // \xe946
break;
case NoticeLevel::Warning:
title = RS_(L"NoticeWarning"); //\xe7ba
break;
case NoticeLevel::Error:
title = RS_(L"NoticeError"); //\xe783
break;
}

_ShowControlNoticeDialog(title, message);
page->_ShowControlNoticeDialog(title, message);
}
}

void TerminalPage::_ShowControlNoticeDialog(const winrt::hstring& title, const winrt::hstring& message)
Expand Down Expand Up @@ -1705,8 +1715,9 @@ namespace winrt::TerminalApp::implementation
// Arguments:
// - sender (not used)
// - eventArgs: the arguments specifying how to set the progress indicator
void TerminalPage::_SetTaskbarProgressHandler(const IInspectable /*sender*/, const IInspectable /*eventArgs*/)
winrt::fire_and_forget TerminalPage::_SetTaskbarProgressHandler(const IInspectable /*sender*/, const IInspectable /*eventArgs*/)
{
co_await resume_foreground(Dispatcher());
_SetTaskbarProgressHandlers(*this, nullptr);
}

Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@ namespace winrt::TerminalApp::implementation
void _ShowCouldNotOpenDialog(winrt::hstring reason, winrt::hstring uri);
bool _CopyText(const bool singleLine, const Windows::Foundation::IReference<Microsoft::Terminal::Control::CopyFormat>& formats);

void _SetTaskbarProgressHandler(const IInspectable sender, const IInspectable eventArgs);
winrt::fire_and_forget _SetTaskbarProgressHandler(const IInspectable sender, const IInspectable eventArgs);

void _PasteText();

void _ControlNoticeRaisedHandler(const IInspectable sender, const Microsoft::Terminal::Control::NoticeEventArgs eventArgs);
winrt::fire_and_forget _ControlNoticeRaisedHandler(const IInspectable sender, const Microsoft::Terminal::Control::NoticeEventArgs eventArgs);
void _ShowControlNoticeDialog(const winrt::hstring& title, const winrt::hstring& message);

fire_and_forget _LaunchSettings(const Microsoft::Terminal::Settings::Model::SettingsTarget target);
Expand Down
Loading