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

Add an experimental "scratchpad pane", for testing #16171

Merged
merged 63 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
f353323
I wanted to do this in one shot but _zelda_
zadjii-msft May 12, 2023
4e14442
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Jul 17, 2023
ef6bb8a
hey look, it builds now
zadjii-msft Jul 17, 2023
5b3aa54
move GetNewTerminalArgs into IPaneContent
zadjii-msft Jul 17, 2023
84df819
close event
zadjii-msft Jul 17, 2023
7c9ffb0
snapping now uses an interface, so that it's not TermControl-specific
zadjii-msft Jul 18, 2023
a1da6c1
huge shuffling so that pane content can raise events instead of relyi…
zadjii-msft Jul 18, 2023
049c043
some last cleanups
zadjii-msft Jul 18, 2023
2dd8f40
[TO PARENT] dead code
zadjii-msft Jul 18, 2023
1b39db7
Single commit that adds the whole scratchpad and action
zadjii-msft Jul 18, 2023
63ba8e1
[PARENT] You know what, I just went for it.
zadjii-msft Jul 18, 2023
262d95a
[PARENT] try to use GetActiveTerminalControl less in TerminalTab
zadjii-msft Jul 18, 2023
2d40306
Let's just make it experimental
zadjii-msft Jul 18, 2023
e6dc314
Merge commit 'b4042ea' into dev/migrie/fhl/non-terminal-panes-2023
zadjii-msft Jul 19, 2023
e31202b
Merge commit '6a10ea5' into dev/migrie/fhl/non-terminal-panes-2023
zadjii-msft Jul 20, 2023
11126f9
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Jul 20, 2023
5f9add4
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Jul 20, 2023
a23c1a2
keybindings too
zadjii-msft Jul 20, 2023
5582e1b
[PARENT] You know what, I just went for it.
zadjii-msft Jul 18, 2023
f89368c
[PARENT] try to use GetActiveTerminalControl less in TerminalTab
zadjii-msft Jul 18, 2023
e0b003a
Merge branch 'main' into dev/migrie/fhl/non-terminal-panes-2023
zadjii-msft Jul 24, 2023
86914bd
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Jul 25, 2023
1cc9835
feature flags too
zadjii-msft Jul 27, 2023
c869b47
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Sep 11, 2023
46469aa
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Sep 11, 2023
2086e0f
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Oct 13, 2023
b49997b
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Oct 13, 2023
81889a6
derp
zadjii-msft Oct 13, 2023
fd06409
annoying build break
zadjii-msft Oct 13, 2023
8df9523
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Oct 25, 2023
58e8f3c
mostly nits
zadjii-msft Oct 25, 2023
e9e04d4
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Oct 25, 2023
7bc1457
nits and such
zadjii-msft Oct 25, 2023
cf920e7
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Nov 2, 2023
4cec7e9
try to remove a few of these but ultimately, eh
zadjii-msft Nov 6, 2023
f622d80
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Nov 8, 2023
6bc711d
maybe I'm not that good at coding
zadjii-msft Nov 8, 2023
0d528f8
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Jan 19, 2024
3982358
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Feb 8, 2024
c244633
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Feb 8, 2024
de5f7af
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Feb 28, 2024
25a8851
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Feb 28, 2024
a3fbc64
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Mar 8, 2024
35651bc
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Mar 8, 2024
ef775a8
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Mar 18, 2024
524d658
GREAT-GREAT-GRANDPARENT: Hey when a pane wants to get closed, we shou…
zadjii-msft Mar 15, 2024
1951f30
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Mar 18, 2024
6789ec0
some of the easier nits
zadjii-msft Mar 19, 2024
fd8b083
get rid of this file
zadjii-msft Mar 19, 2024
052dc78
more nits
zadjii-msft Mar 19, 2024
a7533fa
eh these events are from pane content anyways!
zadjii-msft Mar 19, 2024
826fc08
hey there buddy, did you get lost?
zadjii-msft Mar 19, 2024
52970ef
RegisterBigTimeEncapsulationViolatingTerminalPaneContentEvents
zadjii-msft Mar 19, 2024
2357653
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Mar 20, 2024
e0bb840
Fix scratch pane for merge
zadjii-msft Mar 20, 2024
2083b2f
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Mar 21, 2024
f1ab16e
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Mar 21, 2024
df73d75
derp
zadjii-msft Mar 21, 2024
d417934
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Mar 21, 2024
61e952c
Merge remote-tracking branch 'origin/main' into dev/migrie/fhl/non-te…
zadjii-msft Mar 26, 2024
0979cd6
Merge branch 'dev/migrie/fhl/non-terminal-panes-2023' into dev/migrie…
zadjii-msft Mar 26, 2024
b6e4b62
Doesn't really need to be projected
zadjii-msft Mar 26, 2024
1d20599
un fix this file
zadjii-msft Mar 26, 2024
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
20 changes: 10 additions & 10 deletions src/cascadia/LocalTests_TerminalApp/TabTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ namespace TerminalAppLocalTests
const auto& controlSettings = activeControl.Settings();
VERIFY_IS_NOT_NULL(controlSettings);

VERIFY_ARE_EQUAL(til::color{ 0xff0c0c0c }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(til::color{ 0xff0c0c0c }, til::color{ controlSettings.DefaultBackground() });
});

TestOnUIThread([&page]() {
Expand All @@ -1344,7 +1344,7 @@ namespace TerminalAppLocalTests
VERIFY_IS_NOT_NULL(controlSettings);

Log::Comment(L"Color should be changed to the preview");
VERIFY_ARE_EQUAL(til::color{ 0xff000000 }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(til::color{ 0xff000000 }, til::color{ controlSettings.DefaultBackground() });

// And we should have stored a function to revert the change.
VERIFY_ARE_EQUAL(1u, page->_restorePreviewFuncs.size());
Expand All @@ -1366,7 +1366,7 @@ namespace TerminalAppLocalTests
VERIFY_IS_NOT_NULL(controlSettings);

Log::Comment(L"Color should be changed");
VERIFY_ARE_EQUAL(til::color{ 0xff000000 }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(til::color{ 0xff000000 }, til::color{ controlSettings.DefaultBackground() });

// After preview there should be no more restore functions to execute.
VERIFY_ARE_EQUAL(0u, page->_restorePreviewFuncs.size());
Expand Down Expand Up @@ -1394,7 +1394,7 @@ namespace TerminalAppLocalTests
const auto& controlSettings = activeControl.Settings();
VERIFY_IS_NOT_NULL(controlSettings);

VERIFY_ARE_EQUAL(til::color{ 0xff0c0c0c }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(til::color{ 0xff0c0c0c }, til::color{ controlSettings.DefaultBackground() });
});

TestOnUIThread([&page]() {
Expand All @@ -1412,7 +1412,7 @@ namespace TerminalAppLocalTests
VERIFY_IS_NOT_NULL(controlSettings);

Log::Comment(L"Color should be changed to the preview");
VERIFY_ARE_EQUAL(til::color{ 0xff000000 }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(til::color{ 0xff000000 }, til::color{ controlSettings.DefaultBackground() });
});

TestOnUIThread([&page]() {
Expand All @@ -1428,7 +1428,7 @@ namespace TerminalAppLocalTests
VERIFY_IS_NOT_NULL(controlSettings);

Log::Comment(L"Color should be the same as it originally was");
VERIFY_ARE_EQUAL(til::color{ 0xff0c0c0c }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(til::color{ 0xff0c0c0c }, til::color{ controlSettings.DefaultBackground() });
});
Log::Comment(L"Sleep to let events propagate");
Sleep(250);
Expand All @@ -1450,7 +1450,7 @@ namespace TerminalAppLocalTests
const auto& controlSettings = activeControl.Settings();
VERIFY_IS_NOT_NULL(controlSettings);

VERIFY_ARE_EQUAL(til::color{ 0xff0c0c0c }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(til::color{ 0xff0c0c0c }, til::color{ controlSettings.DefaultBackground() });
});

TestOnUIThread([&page]() {
Expand All @@ -1467,7 +1467,7 @@ namespace TerminalAppLocalTests
VERIFY_IS_NOT_NULL(controlSettings);

Log::Comment(L"Color should be changed to the preview");
VERIFY_ARE_EQUAL(til::color{ 0xff000000 }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(til::color{ 0xff000000 }, til::color{ controlSettings.DefaultBackground() });
});

TestOnUIThread([&page]() {
Expand All @@ -1484,7 +1484,7 @@ namespace TerminalAppLocalTests
VERIFY_IS_NOT_NULL(controlSettings);

Log::Comment(L"Color should be changed to the preview");
VERIFY_ARE_EQUAL(til::color{ 0xffFAFAFA }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(til::color{ 0xffFAFAFA }, til::color{ controlSettings.DefaultBackground() });
});

TestOnUIThread([&page]() {
Expand All @@ -1503,7 +1503,7 @@ namespace TerminalAppLocalTests
VERIFY_IS_NOT_NULL(controlSettings);

Log::Comment(L"Color should be changed");
VERIFY_ARE_EQUAL(til::color{ 0xffFAFAFA }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(til::color{ 0xffFAFAFA }, til::color{ controlSettings.DefaultBackground() });
});
Log::Comment(L"Sleep to let events propagate");
Sleep(250);
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/LocalTests_TerminalApp/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Author(s):
#include <winrt/windows.applicationmodel.core.h>

#include <winrt/Microsoft.Terminal.TerminalConnection.h>
#include <winrt/Microsoft.Terminal.Core.h>
#include <winrt/Microsoft.Terminal.Control.h>
#include <winrt/Microsoft.Terminal.Settings.Model.h>

#include <winrt/Microsoft.UI.Xaml.Controls.h>
Expand Down
22 changes: 21 additions & 1 deletion src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "App.h"

#include "TerminalPage.h"
#include "ScratchpadContent.h"
#include "../WinRTUtils/inc/WtExeUtils.h"
#include "../../types/inc/utils.hpp"
#include "Utils.h"
Expand Down Expand Up @@ -1401,7 +1402,7 @@ namespace winrt::TerminalApp::implementation
{
if (const auto activePane{ activeTab->GetActivePane() })
{
_restartPaneConnection(activePane);
_restartPaneConnection(activePane->GetContent().try_as<TerminalApp::TerminalPaneContent>(), nullptr);
}
}
args.Handled(true);
Expand All @@ -1416,6 +1417,25 @@ namespace winrt::TerminalApp::implementation
}
args.Handled(true);
}

void TerminalPage::_HandleOpenScratchpad(const IInspectable& /*sender*/,
const ActionEventArgs& args)
{
if (Feature_ScratchpadPane::IsEnabled())
{
const auto& scratchPane{ winrt::make_self<ScratchpadContent>() };

// This is maybe a little wacky - add our key event handler to the pane
// we made. So that we can get actions for keys that the content didn't
// handle.
scratchPane->GetRoot().KeyDown({ this, &TerminalPage::_KeyDownHandler });
Copy link
Member

Choose a reason for hiding this comment

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

I've got a few questions about actions:

  • Is the order of handling "Default TextBox key bindings" --> "Terminal key bindings"?
  • (building off of the above) What happens if the user presses ctrl+shift+c and that's set as "copy" in the settings?
  • Can the user open the command palette and run a command from there? What do we do for some that make sense like "copy", "paste", "setFontSize", "searchWeb", "
  • I'm assuming all the pane actions work? (zoom, close, etc...)
  • [Feature Request] hook up "exportBuffer" to this so that it saves the contents to a file?

I'm having a hard time understanding where the line is between "full blown text editor" and "text box in a pane", so I'm ok with you rejecting some of the ideas above. That said, I think a few of them (namely copy, paste, and font size [maybe searchWeb, but that one I care less about tbh]) are important.

Copy link
Member Author

Choose a reason for hiding this comment

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

  • yep
  • That just so happens to work (because I think ctrl+shift+c just works for a TextBox too), but I don't think binding copy to ctrl+q or something weird will.
  • Nope. Not gonna pretend it does. Hence, experimental.
  • They do shockingly well
  • meh?

It's a text box in a pane, literally nothing more. I'm not promising any more either, it's really just for testing

Copy link
Member Author

Choose a reason for hiding this comment

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

<dustin voice>we should have some sort of notion of what actions work where - like, searchWeb right now requires an actual TermControl to be the focused thing. ClosePane only really needs a Pane. A concept of what actions work on what layers, etc, etc.</dustin>

Pretty sure we've all discussed that to death. We've all accepted it's a good idea, but not something to block this over. Incremental progress baby.


const auto resultPane = std::make_shared<Pane>(*scratchPane);
_SplitPane(_GetFocusedTabImpl(), SplitDirection::Automatic, 0.5f, resultPane);
args.Handled(true);
}
}

void TerminalPage::_HandleOpenAbout(const IInspectable& /*sender*/,
const ActionEventArgs& args)
{
Expand Down
52 changes: 52 additions & 0 deletions src/cascadia/TerminalApp/IPaneContent.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

namespace TerminalApp
{

runtimeclass BellEventArgs
{
Boolean FlashTaskbar { get; };
};

interface IPaneContent
{
Windows.UI.Xaml.FrameworkElement GetRoot();

Windows.Foundation.Size MinimumSize { get; };

String Title { get; };
UInt64 TaskbarState { get; };
UInt64 TaskbarProgress { get; };
Boolean ReadOnly { get; };

Microsoft.Terminal.Settings.Model.NewTerminalArgs GetNewTerminalArgs(Boolean asContent);

void Focus(Windows.UI.Xaml.FocusState reason);

void Close();

event Windows.Foundation.TypedEventHandler<IPaneContent, Object> CloseRequested;

event Windows.Foundation.TypedEventHandler<Object, Object> ConnectionStateChanged;
event Windows.Foundation.TypedEventHandler<IPaneContent, BellEventArgs> BellRequested;
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> TitleChanged;
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> TabColorChanged;
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> TaskbarProgressChanged;
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> ReadOnlyChanged;
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> FocusRequested;
};


enum PaneSnapDirection
{
Width,
Height
};

interface ISnappable
{
Single SnapDownToGrid(PaneSnapDirection direction, Single sizeToSnap);
Windows.Foundation.Size GridUnitSize { get; };
};
}
Loading
Loading