-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Fixed #3799: Introduce sendInput command #7249
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ static constexpr std::string_view ScrolluppageKey{ "scrollUpPage" }; | |
static constexpr std::string_view ScrolldownpageKey{ "scrollDownPage" }; | ||
static constexpr std::string_view SwitchToTabKey{ "switchToTab" }; | ||
static constexpr std::string_view OpenSettingsKey{ "openSettings" }; // TODO GH#2557: Add args for OpenSettings | ||
static constexpr std::string_view SendInputKey{ "sendInput" }; | ||
static constexpr std::string_view SplitPaneKey{ "splitPane" }; | ||
static constexpr std::string_view TogglePaneZoomKey{ "togglePaneZoom" }; | ||
static constexpr std::string_view ResizePaneKey{ "resizePane" }; | ||
|
@@ -90,6 +91,7 @@ namespace winrt::TerminalApp::implementation | |
{ ToggleFocusModeKey, ShortcutAction::ToggleFocusMode }, | ||
{ ToggleFullscreenKey, ShortcutAction::ToggleFullscreen }, | ||
{ ToggleAlwaysOnTopKey, ShortcutAction::ToggleAlwaysOnTop }, | ||
{ SendInputKey, ShortcutAction::SendInput }, | ||
{ SplitPaneKey, ShortcutAction::SplitPane }, | ||
{ TogglePaneZoomKey, ShortcutAction::TogglePaneZoom }, | ||
{ SetTabColorKey, ShortcutAction::SetTabColor }, | ||
|
@@ -125,6 +127,8 @@ namespace winrt::TerminalApp::implementation | |
|
||
{ ShortcutAction::AdjustFontSize, winrt::TerminalApp::implementation::AdjustFontSizeArgs::FromJson }, | ||
|
||
{ ShortcutAction::SendInput, winrt::TerminalApp::implementation::SendInputArgs::FromJson }, | ||
|
||
{ ShortcutAction::SplitPane, winrt::TerminalApp::implementation::SplitPaneArgs::FromJson }, | ||
|
||
{ ShortcutAction::OpenSettings, winrt::TerminalApp::implementation::OpenSettingsArgs::FromJson }, | ||
|
@@ -284,6 +288,7 @@ namespace winrt::TerminalApp::implementation | |
{ ShortcutAction::ToggleFocusMode, RS_(L"ToggleFocusModeCommandKey") }, | ||
{ ShortcutAction::ToggleFullscreen, RS_(L"ToggleFullscreenCommandKey") }, | ||
{ ShortcutAction::ToggleAlwaysOnTop, RS_(L"ToggleAlwaysOnTopCommandKey") }, | ||
{ ShortcutAction::SendInput, RS_(L"SendInputCommandKey") }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO this should be mapped to see for example: |
||
{ ShortcutAction::SplitPane, RS_(L"SplitPaneCommandKey") }, | ||
{ ShortcutAction::TogglePaneZoom, RS_(L"TogglePaneZoomCommandKey") }, | ||
{ ShortcutAction::Invalid, L"" }, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
#include "ResizePaneArgs.g.cpp" | ||
#include "MoveFocusArgs.g.cpp" | ||
#include "AdjustFontSizeArgs.g.cpp" | ||
#include "SendInputArgs.g.cpp" | ||
#include "SplitPaneArgs.g.cpp" | ||
#include "OpenSettingsArgs.g.cpp" | ||
#include "SetColorSchemeArgs.g.cpp" | ||
|
@@ -167,6 +168,16 @@ namespace winrt::TerminalApp::implementation | |
} | ||
} | ||
|
||
winrt::hstring SendInputArgs::GenerateName() const | ||
{ | ||
// The string will be similar to the following: | ||
// * "Send Input: ...input..." | ||
|
||
return winrt::hstring{ | ||
fmt::format(L"{}: {}", RS_(L"SendInputCommandKey"), _Input) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typically, it's best practice to have just two entirely different resources in Resources.resw for something like this. In this case though, I don't think we need the version without the argument at all, we could probably get away with a single resource for the formatted version: <data name="SendInputCommandKey" xml:space="preserve">
<value>Send Input: "{0}"</value>
<comment>{0} will be replaced with a string of input as defined by the user.</comment>
</data> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm suddenly worried about dropping the user's input right into a TextBlock. Should we transform the control characters <0x20 to their "control pictures" equivalents? It's as easy as adding 0x2400 to them! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what we do in the debug tap ... which I can't get a screenshot of because we broke it o_O There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or perhaps my right alt key no longer works. This would come as no big surprise. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm hugely in favor of this actually. Raw control characters |
||
}; | ||
} | ||
|
||
winrt::hstring SplitPaneArgs::GenerateName() const | ||
{ | ||
// The string will be similar to the following: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -296,6 +296,18 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation | |
} | ||
} | ||
} | ||
|
||
// Method Description: | ||
// - Writes the given sequence as input to the active terminal connection, | ||
// Arguments: | ||
// - wstr: the string of characters to write to the terminal connection. | ||
// Return Value: | ||
// - <none> | ||
void TermControl::SendInput(const winrt::hstring& input) | ||
{ | ||
_SendInputToConnection(input); | ||
} | ||
|
||
void TermControl::ToggleRetroEffect() | ||
{ | ||
auto lock = _terminal->LockForWriting(); | ||
|
@@ -1769,7 +1781,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation | |
// - wstr: the string of characters to write to the terminal connection. | ||
// Return Value: | ||
// - <none> | ||
void TermControl::_SendInputToConnection(const std::wstring& wstr) | ||
void TermControl::_SendInputToConnection(const winrt::param::hstring& wstr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unfortunately We might have to prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I've discussed this with the cppwinrt folks before. param::hstring does everything we might possibly want with regards to automatic promotion to hstring, but it's not part of the public interface :/) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not entirely sure I understand... Am I supposed to not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, just because it is a private namespace. |
||
{ | ||
_connection.WriteInput(wstr); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this classify as "Documentation updated"? Do I need to submit a PR to the docs repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, you do!