-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
e8f18ea
commit 501522d
Showing
8 changed files
with
134 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters