mirror of
https://github.com/microsoft/terminal.git
synced 2026-04-12 01:01:05 +00:00
Add an experimental "scratchpad pane", for testing (#16171)
## Summary of the Pull Request Builds upon #16170. This PR simply adds a singly type of non-terminal pane - a "scratchpad pane". This is literally just a single text box, in a pane. It's on the `{ "command": "experimental.openScratchpad" }` action. ## References and Relevant Issues See: #997 ## Detailed Description of the Pull Request / Additional comments I also put it behind velocity so it won't even go into preview while this bakes. This is really just here to demonstrate that this works, and is viable. The next PR is much more interesting. ## Validation Steps Performed Screenshot below. ## other PRs * #16170 * #16171 <-- you are here * #16172
This commit is contained in:
@@ -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"
|
||||
@@ -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 });
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
50
src/cascadia/TerminalApp/ScratchpadContent.cpp
Normal file
50
src/cascadia/TerminalApp/ScratchpadContent.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include "pch.h"
|
||||
#include "ScratchpadContent.h"
|
||||
|
||||
using namespace winrt::Windows::Foundation;
|
||||
using namespace winrt::Windows::UI::Xaml;
|
||||
using namespace winrt::Microsoft::Terminal::Settings::Model;
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
ScratchpadContent::ScratchpadContent()
|
||||
{
|
||||
_root = winrt::Windows::UI::Xaml::Controls::Grid{};
|
||||
// Vertical and HorizontalAlignment are Stretch by default
|
||||
|
||||
auto res = Windows::UI::Xaml::Application::Current().Resources();
|
||||
auto bg = res.Lookup(winrt::box_value(L"UnfocusedBorderBrush"));
|
||||
_root.Background(bg.try_as<Media::Brush>());
|
||||
|
||||
_box = winrt::Windows::UI::Xaml::Controls::TextBox{};
|
||||
_box.Margin({ 10, 10, 10, 10 });
|
||||
_box.AcceptsReturn(true);
|
||||
_box.TextWrapping(TextWrapping::Wrap);
|
||||
_root.Children().Append(_box);
|
||||
}
|
||||
|
||||
winrt::Windows::UI::Xaml::FrameworkElement ScratchpadContent::GetRoot()
|
||||
{
|
||||
return _root;
|
||||
}
|
||||
winrt::Windows::Foundation::Size ScratchpadContent::MinimumSize()
|
||||
{
|
||||
return { 1, 1 };
|
||||
}
|
||||
void ScratchpadContent::Focus(winrt::Windows::UI::Xaml::FocusState reason)
|
||||
{
|
||||
_box.Focus(reason);
|
||||
}
|
||||
void ScratchpadContent::Close()
|
||||
{
|
||||
CloseRequested.raise(*this, nullptr);
|
||||
}
|
||||
|
||||
NewTerminalArgs ScratchpadContent::GetNewTerminalArgs(const bool /* asContent */) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
40
src/cascadia/TerminalApp/ScratchpadContent.h
Normal file
40
src/cascadia/TerminalApp/ScratchpadContent.h
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#pragma once
|
||||
#include "winrt/TerminalApp.h"
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
class ScratchpadContent : public winrt::implements<ScratchpadContent, IPaneContent>
|
||||
{
|
||||
public:
|
||||
ScratchpadContent();
|
||||
|
||||
winrt::Windows::UI::Xaml::FrameworkElement GetRoot();
|
||||
|
||||
winrt::Windows::Foundation::Size MinimumSize();
|
||||
|
||||
void Focus(winrt::Windows::UI::Xaml::FocusState reason = winrt::Windows::UI::Xaml::FocusState::Programmatic);
|
||||
void Close();
|
||||
winrt::Microsoft::Terminal::Settings::Model::NewTerminalArgs GetNewTerminalArgs(const bool asContent) const;
|
||||
|
||||
winrt::hstring Title() { return L"Scratchpad"; }
|
||||
uint64_t TaskbarState() { return 0; }
|
||||
uint64_t TaskbarProgress() { return 0; }
|
||||
bool ReadOnly() { return false; }
|
||||
|
||||
til::typed_event<> ConnectionStateChanged;
|
||||
til::typed_event<IPaneContent> CloseRequested;
|
||||
til::typed_event<IPaneContent, winrt::TerminalApp::BellEventArgs> BellRequested;
|
||||
til::typed_event<IPaneContent> TitleChanged;
|
||||
til::typed_event<IPaneContent> TabColorChanged;
|
||||
til::typed_event<IPaneContent> TaskbarProgressChanged;
|
||||
til::typed_event<IPaneContent> ReadOnlyChanged;
|
||||
til::typed_event<IPaneContent> FocusRequested;
|
||||
|
||||
private:
|
||||
winrt::Windows::UI::Xaml::Controls::Grid _root{ nullptr };
|
||||
winrt::Windows::UI::Xaml::Controls::TextBox _box{ nullptr };
|
||||
};
|
||||
}
|
||||
@@ -161,6 +161,9 @@
|
||||
<ClInclude Include="TerminalPaneContent.h">
|
||||
<DependentUpon>TerminalPaneContent.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ScratchpadContent.h">
|
||||
<DependentUpon>TerminalPaneContent.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Toast.h" />
|
||||
<ClInclude Include="SuggestionsControl.h">
|
||||
<DependentUpon>SuggestionsControl.xaml</DependentUpon>
|
||||
@@ -268,6 +271,9 @@
|
||||
<ClCompile Include="TerminalPaneContent.cpp">
|
||||
<DependentUpon>TerminalPaneContent.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ScratchpadContent.cpp">
|
||||
<DependentUpon>ScratchpadContent.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
||||
<ClCompile Include="Toast.cpp" />
|
||||
<ClCompile Include="SuggestionsControl.cpp">
|
||||
|
||||
@@ -96,6 +96,7 @@ static constexpr std::string_view ShowContextMenuKey{ "showContextMenu" };
|
||||
static constexpr std::string_view ExpandSelectionToWordKey{ "expandSelectionToWord" };
|
||||
static constexpr std::string_view RestartConnectionKey{ "restartConnection" };
|
||||
static constexpr std::string_view ToggleBroadcastInputKey{ "toggleBroadcastInput" };
|
||||
static constexpr std::string_view OpenScratchpadKey{ "experimental.openScratchpad" };
|
||||
static constexpr std::string_view OpenAboutKey{ "openAbout" };
|
||||
|
||||
static constexpr std::string_view ActionKey{ "action" };
|
||||
@@ -431,6 +432,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
{ ShortcutAction::ExpandSelectionToWord, RS_(L"ExpandSelectionToWordCommandKey") },
|
||||
{ ShortcutAction::RestartConnection, RS_(L"RestartConnectionKey") },
|
||||
{ ShortcutAction::ToggleBroadcastInput, RS_(L"ToggleBroadcastInputCommandKey") },
|
||||
{ ShortcutAction::OpenScratchpad, RS_(L"OpenScratchpadKey") },
|
||||
{ ShortcutAction::OpenAbout, RS_(L"OpenAboutCommandKey") },
|
||||
};
|
||||
}();
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
ON_ALL_ACTIONS(CloseOtherPanes) \
|
||||
ON_ALL_ACTIONS(RestartConnection) \
|
||||
ON_ALL_ACTIONS(ToggleBroadcastInput) \
|
||||
ON_ALL_ACTIONS(OpenScratchpad) \
|
||||
ON_ALL_ACTIONS(OpenAbout)
|
||||
|
||||
#define ALL_SHORTCUT_ACTIONS_WITH_ARGS \
|
||||
|
||||
@@ -700,6 +700,9 @@
|
||||
<data name="RestartConnectionKey" xml:space="preserve">
|
||||
<value>Restart connection</value>
|
||||
</data>
|
||||
<data name="OpenScratchpadKey" xml:space="preserve">
|
||||
<value>Open scratchpad</value>
|
||||
</data>
|
||||
<data name="SelectOutputNextCommandKey" xml:space="preserve">
|
||||
<value>Select next command output</value>
|
||||
</data>
|
||||
@@ -724,4 +727,4 @@
|
||||
<value>Open about dialog</value>
|
||||
<comment>This will open the "about" dialog, to display version info and other documentation</comment>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
||||
@@ -159,6 +159,17 @@
|
||||
</alwaysEnabledBrandingTokens>
|
||||
</feature>
|
||||
|
||||
<feature>
|
||||
<name>Feature_ScratchpadPane</name>
|
||||
<description>Allow the user to create scratchpad panes. Mostly just exists to validate non-terminal panes.</description>
|
||||
<id>997</id>
|
||||
<stage>AlwaysDisabled</stage>
|
||||
<alwaysEnabledBrandingTokens>
|
||||
<brandingToken>Dev</brandingToken>
|
||||
<brandingToken>Canary</brandingToken>
|
||||
</alwaysEnabledBrandingTokens>
|
||||
</feature>
|
||||
|
||||
<feature>
|
||||
<name>Feature_KeypadModeEnabled</name>
|
||||
<description>Enables the DECKPAM, DECKPNM sequences to work as intended </description>
|
||||
|
||||
Reference in New Issue
Block a user