Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions doc/cascadia/profiles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,12 @@
"type": "string",
"default": "",
"description": "The text input to feed into the shell. ANSI escape sequences may be used. Escape codes like \\x1b must be written as \\u001b."
},
"enterDelayMs": {
"type": "integer",
"minimum": 0,
"default": 0,
"description": "Delay the trailing Enter key by the given number of milliseconds when the input should be submitted after a short pause."
}
}
}
Expand Down
389 changes: 376 additions & 13 deletions src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp

Large diffs are not rendered by default.

48 changes: 34 additions & 14 deletions src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,27 @@ namespace winrt
using IInspectable = Windows::Foundation::IInspectable;
}

namespace winrt::TerminalApp::implementation
{
TermControl TerminalPage::_senderOrActiveControl(const IInspectable& sender)
{
if (sender)
namespace winrt::TerminalApp::implementation
{
namespace
{
safe_void_coroutine _SendInputEnterAfterDelay(winrt::weak_ref<TermControl> weakControl, const CoreDispatcher dispatcher, const uint32_t enterDelayMs)
{
co_await winrt::resume_after(std::chrono::milliseconds{ enterDelayMs });
co_await wil::resume_foreground(dispatcher);

if (const auto termControl{ weakControl.get() })
{
// Delayed Enter is intentionally a second injection so clients can
// observe the text payload before submit.
termControl.SendInput(L"\r");
}
}
}

TermControl TerminalPage::_senderOrActiveControl(const IInspectable& sender)
{
if (sender)
{
if (auto arg{ sender.try_as<TermControl>() })
{
Expand Down Expand Up @@ -180,15 +196,19 @@ namespace winrt::TerminalApp::implementation
if (args == nullptr)
{
args.Handled(false);
}
else if (const auto& realArgs = args.ActionArgs().try_as<SendInputArgs>())
{
if (const auto termControl{ _senderOrActiveControl(sender) })
{
termControl.SendInput(realArgs.Input());
args.Handled(true);
}
}
}
else if (const auto& realArgs = args.ActionArgs().try_as<SendInputArgs>())
{
if (const auto termControl{ _senderOrActiveControl(sender) })
{
termControl.SendInput(realArgs.Input());
if (realArgs.EnterDelayMs() > 0)
{
_SendInputEnterAfterDelay(winrt::weak_ref<TermControl>{ termControl }, termControl.Dispatcher(), realArgs.EnterDelayMs());
}
args.Handled(true);
}
}
}

void TerminalPage::_HandleCloseOtherPanes(const IInspectable& sender,
Expand Down
Loading
Loading