mirror of
https://github.com/microsoft/terminal.git
synced 2026-05-21 14:27:22 +00:00
Compare commits
70 Commits
dev/duhowe
...
dev/cazamo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48097d39c8 | ||
|
|
6bdb4c2718 | ||
|
|
2d340a3be5 | ||
|
|
88eacef821 | ||
|
|
60f583108a | ||
|
|
7e7e79ae0c | ||
|
|
9713ca4192 | ||
|
|
d63d84c54c | ||
|
|
30020752ca | ||
|
|
dc27359f56 | ||
|
|
8f4aa8e635 | ||
|
|
e82fe2e548 | ||
|
|
f15a9305fe | ||
|
|
dadde2fb11 | ||
|
|
8edac5fb12 | ||
|
|
d5d4f99673 | ||
|
|
7dd7783aff | ||
|
|
ee1601e405 | ||
|
|
071963420e | ||
|
|
07a4f3acfc | ||
|
|
042eb5b1a9 | ||
|
|
dbc5177f7f | ||
|
|
611f5a31b4 | ||
|
|
cdb99bbe8b | ||
|
|
fbec4ee41f | ||
|
|
cab78edde0 | ||
|
|
b044fd661d | ||
|
|
234838075f | ||
|
|
4e6209247f | ||
|
|
b753e3dee3 | ||
|
|
a834313fb7 | ||
|
|
059986ebce | ||
|
|
a07dba52ef | ||
|
|
fcaf3daa8d | ||
|
|
68fccb5efb | ||
|
|
e4e3f08efc | ||
|
|
6c2b796253 | ||
|
|
d4ff09f82e | ||
|
|
19286b7043 | ||
|
|
8868dfa6ee | ||
|
|
04f6273e4b | ||
|
|
f483eae7a9 | ||
|
|
0856bce421 | ||
|
|
582ffb615e | ||
|
|
84e807cbeb | ||
|
|
115ec2cbb9 | ||
|
|
da00f8863b | ||
|
|
62727bf6d1 | ||
|
|
15ce2fd513 | ||
|
|
6c88741e26 | ||
|
|
54009e1305 | ||
|
|
3362651659 | ||
|
|
c72600dd4f | ||
|
|
0c0a16e10a | ||
|
|
fe650d0c27 | ||
|
|
b53ccb853e | ||
|
|
ac400756e8 | ||
|
|
7378b8ac8c | ||
|
|
9f2dcfd5ee | ||
|
|
ab2514b9cc | ||
|
|
b21ba2b053 | ||
|
|
1ecb08351b | ||
|
|
5279226646 | ||
|
|
c7a51c978c | ||
|
|
44456be4eb | ||
|
|
5f3db13e5f | ||
|
|
9df166efec | ||
|
|
aeb531f666 | ||
|
|
c23e507c20 | ||
|
|
c49bc1a789 |
3
.github/actions/spelling/expect/expect.txt
vendored
3
.github/actions/spelling/expect/expect.txt
vendored
@@ -241,6 +241,7 @@ consoletaeftemplates
|
||||
consoleuwp
|
||||
CONSOLEWINDOWOWNER
|
||||
consrv
|
||||
consteval
|
||||
constexprable
|
||||
contentfiles
|
||||
conterm
|
||||
@@ -1104,6 +1105,7 @@ NOSIZE
|
||||
NOSNAPSHOT
|
||||
NOTHOUSANDS
|
||||
NOTICKS
|
||||
notif
|
||||
NOTIMEOUTIFNOTHUNG
|
||||
NOTIMPL
|
||||
NOTOPMOST
|
||||
@@ -1753,6 +1755,7 @@ UPKEY
|
||||
upss
|
||||
uregex
|
||||
URegular
|
||||
urxvt
|
||||
usebackq
|
||||
USECALLBACK
|
||||
USECOLOR
|
||||
|
||||
@@ -60,7 +60,8 @@
|
||||
"enum": [
|
||||
"audible",
|
||||
"window",
|
||||
"taskbar"
|
||||
"taskbar",
|
||||
"notification"
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -70,6 +71,7 @@
|
||||
"audible",
|
||||
"taskbar",
|
||||
"window",
|
||||
"notification",
|
||||
"all",
|
||||
"none"
|
||||
]
|
||||
@@ -2654,10 +2656,21 @@
|
||||
"type": "string"
|
||||
},
|
||||
"warning.confirmCloseAllTabs": {
|
||||
"deprecated": true,
|
||||
"description": "[Deprecated] Use \"warning.confirmOnClose\" instead.",
|
||||
"default": true,
|
||||
"description": "When set to \"true\" closing a window with multiple tabs open will require confirmation. When set to \"false\", the confirmation dialog will not appear.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"warning.confirmOnClose": {
|
||||
"default": "automatic",
|
||||
"description": "Controls when a confirmation dialog appears before closing tabs or windows.",
|
||||
"enum": [
|
||||
"never",
|
||||
"automatic",
|
||||
"always"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"useTabSwitcher": {
|
||||
"description": "[Deprecated] Replaced with the \"tabSwitcherMode\" setting.",
|
||||
"default": true,
|
||||
@@ -2774,6 +2787,11 @@
|
||||
"description": "When set to true, VT applications will be allowed to set the contents of the local clipboard using OSC 52 (Manipulate Selection Data).",
|
||||
"type": "boolean"
|
||||
},
|
||||
"compatibility.allowOSC777": {
|
||||
"default": false,
|
||||
"description": "When set to true, applications can send OSC 777 escape sequences to trigger desktop toast notifications with a custom title and body.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"unfocusedAppearance": {
|
||||
"$ref": "#/$defs/AppearanceConfig",
|
||||
"description": "Sets the appearance of the terminal when it is unfocused.",
|
||||
@@ -2849,6 +2867,73 @@
|
||||
"description": "Sets the sound played when the application emits a BEL. When set to an array, the terminal will pick one of those sounds at random.",
|
||||
"$ref": "#/$defs/BellSound"
|
||||
},
|
||||
"notifyOnActivity": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"taskbar",
|
||||
"audible",
|
||||
"tab",
|
||||
"notification"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"taskbar",
|
||||
"audible",
|
||||
"tab",
|
||||
"notification",
|
||||
"all",
|
||||
"none"
|
||||
]
|
||||
}
|
||||
],
|
||||
"description": "Controls how you are notified when an inactive tab produces new output."
|
||||
},
|
||||
"notifyOnNextPrompt": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"taskbar",
|
||||
"audible",
|
||||
"tab",
|
||||
"notification"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"taskbar",
|
||||
"audible",
|
||||
"tab",
|
||||
"notification",
|
||||
"all",
|
||||
"none"
|
||||
]
|
||||
}
|
||||
],
|
||||
"description": "Controls how you are notified when a new shell prompt is detected. Requires shell integration."
|
||||
},
|
||||
"autoDetectRunningCommand": {
|
||||
"default": false,
|
||||
"description": "Automatically detect when a command is running and show a progress indicator in the tab and taskbar.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"closeOnExit": {
|
||||
"default": "automatic",
|
||||
"description": "Sets how the profile reacts to termination or failure to launch. Possible values:\n -\"graceful\" (close when exit is typed or the process exits normally)\n -\"always\" (always close)\n -\"automatic\" (behave as \"graceful\" only for processes launched by terminal, behave as \"always\" otherwise)\n -\"never\" (never close).\ntrue and false are accepted as synonyms for \"graceful\" and \"never\" respectively.",
|
||||
|
||||
@@ -237,6 +237,7 @@
|
||||
<Capability Name="internetClient" />
|
||||
<rescap:Capability Name="runFullTrust" />
|
||||
<rescap:Capability Name="unvirtualizedResources" />
|
||||
<rescap:Capability Name="appLicensing" />
|
||||
</Capabilities>
|
||||
|
||||
<Extensions>
|
||||
|
||||
@@ -237,6 +237,7 @@
|
||||
<Capability Name="internetClient" />
|
||||
<rescap:Capability Name="runFullTrust" />
|
||||
<rescap:Capability Name="unvirtualizedResources" />
|
||||
<rescap:Capability Name="appLicensing" />
|
||||
</Capabilities>
|
||||
|
||||
<Extensions>
|
||||
|
||||
@@ -185,8 +185,7 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
if (const auto termControl{ _senderOrActiveControl(sender) })
|
||||
{
|
||||
const auto broadcastGroup{ _getBroadcastGroupFromControl(termControl) };
|
||||
_writeInputStringToBroadcastGroup(broadcastGroup, realArgs.Input(), WriteInputStringType::Raw);
|
||||
termControl.SendInput(realArgs.Input());
|
||||
args.Handled(true);
|
||||
}
|
||||
}
|
||||
@@ -453,11 +452,8 @@ namespace winrt::TerminalApp::implementation
|
||||
void TerminalPage::_HandlePasteText(const IInspectable& /*sender*/,
|
||||
const ActionEventArgs& args)
|
||||
{
|
||||
if (const auto& control{ _GetActiveControl() })
|
||||
{
|
||||
_PasteFromClipboardHandler(control, nullptr);
|
||||
args.Handled(true);
|
||||
}
|
||||
_PasteText();
|
||||
args.Handled(true);
|
||||
}
|
||||
|
||||
void TerminalPage::_HandleNewTab(const IInspectable& /*sender*/,
|
||||
@@ -503,8 +499,8 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
else
|
||||
{
|
||||
_ResizePane(realArgs.ResizeDirection());
|
||||
args.Handled(true);
|
||||
const auto resizeSucceeded = _ResizePane(realArgs.ResizeDirection());
|
||||
args.Handled(resizeSucceeded);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -805,7 +801,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
_RemoveTabs(tabsToRemove);
|
||||
|
||||
actionArgs.Handled(true);
|
||||
actionArgs.Handled(!tabsToRemove.empty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -841,7 +837,7 @@ namespace winrt::TerminalApp::implementation
|
||||
// tab row, until you mouse over them. Probably has something to do
|
||||
// with tabs not resizing down until there's a mouse exit event.
|
||||
|
||||
actionArgs.Handled(true);
|
||||
actionArgs.Handled(!tabsToRemove.empty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -942,6 +938,27 @@ namespace winrt::TerminalApp::implementation
|
||||
co_return;
|
||||
}
|
||||
|
||||
// Launch `wt -w <name>` so the monarch can either summon an existing
|
||||
// window with that name or restore a persisted workspace.
|
||||
safe_void_coroutine TerminalPage::_OpenWorkspaceWindow(const winrt::hstring name)
|
||||
{
|
||||
co_await winrt::resume_background();
|
||||
|
||||
const auto exePath{ GetWtExePath() };
|
||||
const auto cmdline = fmt::format(FMT_COMPILE(L"-w {}"), std::wstring_view{ name });
|
||||
|
||||
SHELLEXECUTEINFOW seInfo{ 0 };
|
||||
seInfo.cbSize = sizeof(seInfo);
|
||||
seInfo.fMask = SEE_MASK_NOASYNC;
|
||||
seInfo.lpVerb = L"open";
|
||||
seInfo.lpFile = exePath.c_str();
|
||||
seInfo.lpParameters = cmdline.c_str();
|
||||
seInfo.nShow = SW_SHOWNORMAL;
|
||||
LOG_IF_WIN32_BOOL_FALSE(ShellExecuteExW(&seInfo));
|
||||
|
||||
co_return;
|
||||
}
|
||||
|
||||
void TerminalPage::_HandleNewWindow(const IInspectable& /*sender*/,
|
||||
const ActionEventArgs& actionArgs)
|
||||
{
|
||||
@@ -1637,4 +1654,25 @@ namespace winrt::TerminalApp::implementation
|
||||
args.Handled(handled);
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalPage::_HandleOpenWorkspace(const IInspectable& /*sender*/,
|
||||
const ActionEventArgs& args)
|
||||
{
|
||||
// Open (or summon) a named window. We launch a new `wt -w <name>`
|
||||
// process which the monarch will route to the correct live window or
|
||||
// restore from a persisted workspace.
|
||||
if (args)
|
||||
{
|
||||
if (const auto& realArgs = args.ActionArgs().try_as<OpenWorkspaceArgs>())
|
||||
{
|
||||
const auto name = realArgs.Name();
|
||||
if (!name.empty())
|
||||
{
|
||||
_OpenWorkspaceWindow(name);
|
||||
}
|
||||
args.Handled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1068,6 +1068,15 @@ int AppCommandlineArgs::ParseArgs(winrt::array_view<const winrt::hstring> args)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// When a toast notification is clicked, Windows may launch a new instance
|
||||
// with "--from-toast" as the argument. This is a no-op sentinel — the
|
||||
// in-process Activated handler on the toast already handled activation.
|
||||
// See DesktopNotification.cpp for more details.
|
||||
if (args.size() == 2 && args[1] == L"--from-toast")
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto commands = ::TerminalApp::AppCommandlineArgs::BuildCommands(args);
|
||||
|
||||
for (auto& cmdBlob : commands)
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace winrt::TerminalApp::implementation
|
||||
til::typed_event<IPaneContent> TaskbarProgressChanged;
|
||||
til::typed_event<IPaneContent> ReadOnlyChanged;
|
||||
til::typed_event<IPaneContent> FocusRequested;
|
||||
til::typed_event<IPaneContent, winrt::TerminalApp::NotificationEventArgs> NotificationRequested;
|
||||
|
||||
til::typed_event<winrt::Windows::Foundation::IInspectable, Microsoft::Terminal::Settings::Model::Command> DispatchCommandRequested;
|
||||
};
|
||||
|
||||
@@ -231,6 +231,12 @@
|
||||
Glyph=""
|
||||
Visibility="{x:Bind Item.(local:TabPaletteItem.TabStatus).BellIndicator, Mode=OneWay}" />
|
||||
|
||||
<FontIcon Margin="0,0,8,0"
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="8"
|
||||
Glyph=""
|
||||
Visibility="{x:Bind Item.(local:TabPaletteItem.TabStatus).ActivityIndicator, Mode=OneWay}" />
|
||||
|
||||
<FontIcon Margin="0,0,8,0"
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="12"
|
||||
|
||||
129
src/cascadia/TerminalApp/DesktopNotification.cpp
Normal file
129
src/cascadia/TerminalApp/DesktopNotification.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include "pch.h"
|
||||
#include "DesktopNotification.h"
|
||||
|
||||
#include <WtExeUtils.h>
|
||||
|
||||
using namespace winrt::Windows::UI::Notifications;
|
||||
using namespace winrt::Windows::Data::Xml::Dom;
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
std::atomic<uint64_t> DesktopNotification::_lastNotificationTime{ 0 };
|
||||
|
||||
// Method Description:
|
||||
// - Rate-limits toast notifications so we don't spam the user.
|
||||
// Return Value:
|
||||
// - Returns true if a notification is allowed, false if too recent.
|
||||
bool DesktopNotification::ShouldSendNotification()
|
||||
{
|
||||
const auto now = GetTickCount64();
|
||||
auto last = _lastNotificationTime.load(std::memory_order_relaxed);
|
||||
|
||||
// Subtraction wraps cleanly modulo 2^64, so the delta is correct even
|
||||
// across the (~584 million year) GetTickCount64 rollover.
|
||||
if (now - last < MinNotificationIntervalMs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Attempt to update; if another thread beat us, that's fine — we'll skip this one.
|
||||
return _lastNotificationTime.compare_exchange_strong(last, now, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sends a toast notification with the given title and message.
|
||||
// - When the user clicks the toast, the `Activated` callback fires
|
||||
// with the tabIndex that was passed in, so the caller can switch
|
||||
// to the correct tab and summon the window.
|
||||
// Arguments:
|
||||
// - args: The title, message, and tab index to include in the notification.
|
||||
// - activated: A callback invoked on the background thread when the
|
||||
// toast is clicked. The uint32_t parameter is the tab index.
|
||||
void DesktopNotification::SendNotification(const DesktopNotificationArgs& args, std::function<void()> activatedFunc)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ShouldSendNotification())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Build the toast XML. We use a simple template with a title and body text.
|
||||
//
|
||||
// <toast launch="--from-toast">
|
||||
// <visual>
|
||||
// <binding template="ToastGeneric">
|
||||
// <text>Title</text>
|
||||
// <text>Message</text>
|
||||
// </binding>
|
||||
// </visual>
|
||||
// </toast>
|
||||
auto toastXml = ToastNotificationManager::GetTemplateContent(ToastTemplateType::ToastText02);
|
||||
auto textNodes = toastXml.GetElementsByTagName(L"text");
|
||||
|
||||
// First <text> is the title
|
||||
textNodes.Item(0).InnerText(args.Title);
|
||||
// Second <text> is the body
|
||||
textNodes.Item(1).InnerText(args.Message);
|
||||
|
||||
auto toastElement = toastXml.DocumentElement();
|
||||
|
||||
// When a toast is clicked, Windows launches a new instance of the app
|
||||
// with the "launch" attribute as command-line arguments. We handle
|
||||
// toast activation in-process via the Activated event below, so the
|
||||
// new instance should do nothing. "--from-toast" is recognized by
|
||||
// AppCommandlineArgs::ParseArgs as a no-op sentinel.
|
||||
toastElement.SetAttribute(L"launch", L"--from-toast");
|
||||
|
||||
toastElement.SetAttribute(L"scenario", L"default");
|
||||
|
||||
auto toast = ToastNotification{ toastXml };
|
||||
|
||||
// Set the tag and group to enable notification replacement.
|
||||
// Repeated notifications with the same tag replace the previous one
|
||||
// rather than stacking in the notification center.
|
||||
toast.Tag(args.Tag);
|
||||
toast.Group(L"WindowsTerminal");
|
||||
|
||||
// When the user activates (clicks) the toast, fire the callback.
|
||||
if (activatedFunc)
|
||||
{
|
||||
toast.Activated([activatedFunc = std::move(activatedFunc)](const auto& /*sender*/, const auto& /*eventArgs*/) {
|
||||
activatedFunc();
|
||||
});
|
||||
}
|
||||
|
||||
// For packaged apps, CreateToastNotifier() uses the package identity automatically.
|
||||
// For unpackaged apps, we must pass the explicit AUMID that was registered
|
||||
// at startup via SetCurrentProcessExplicitAppUserModelID.
|
||||
winrt::Windows::UI::Notifications::ToastNotifier notifier{ nullptr };
|
||||
if (IsPackaged())
|
||||
{
|
||||
notifier = ToastNotificationManager::CreateToastNotifier();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Retrieve the AUMID that was set by WindowEmperor at startup.
|
||||
wil::unique_cotaskmem_string aumid;
|
||||
if (SUCCEEDED(GetCurrentProcessExplicitAppUserModelID(&aumid)))
|
||||
{
|
||||
notifier = ToastNotificationManager::CreateToastNotifier(aumid.get());
|
||||
}
|
||||
}
|
||||
if (notifier)
|
||||
{
|
||||
notifier.Show(toast);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Toast notification is a best-effort feature. If it fails (e.g., notifications
|
||||
// are disabled, or the app is unpackaged without proper AUMID setup), we silently
|
||||
// ignore the error.
|
||||
LOG_CAUGHT_EXCEPTION();
|
||||
}
|
||||
}
|
||||
}
|
||||
37
src/cascadia/TerminalApp/DesktopNotification.h
Normal file
37
src/cascadia/TerminalApp/DesktopNotification.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*++
|
||||
Copyright (c) Microsoft Corporation
|
||||
Licensed under the MIT license.
|
||||
|
||||
Module Name:
|
||||
- DesktopNotification.h
|
||||
|
||||
Module Description:
|
||||
- Helper for sending Windows desktop toast notifications. Used to surface
|
||||
terminal activity events to the user via the Windows notification center.
|
||||
--*/
|
||||
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
struct DesktopNotificationArgs
|
||||
{
|
||||
winrt::hstring Title;
|
||||
winrt::hstring Message;
|
||||
winrt::hstring Tag;
|
||||
};
|
||||
|
||||
class DesktopNotification
|
||||
{
|
||||
public:
|
||||
static bool ShouldSendNotification();
|
||||
static void SendNotification(const DesktopNotificationArgs& args, std::function<void()> activatedFunc);
|
||||
|
||||
private:
|
||||
static std::atomic<uint64_t> _lastNotificationTime;
|
||||
|
||||
// Minimum interval between notifications, in milliseconds (GetTickCount64 units).
|
||||
static constexpr uint64_t MinNotificationIntervalMs = 5'000;
|
||||
};
|
||||
}
|
||||
@@ -14,6 +14,15 @@ namespace TerminalApp
|
||||
runtimeclass BellEventArgs
|
||||
{
|
||||
Boolean FlashTaskbar { get; };
|
||||
Boolean SendNotification { get; };
|
||||
};
|
||||
|
||||
runtimeclass NotificationEventArgs
|
||||
{
|
||||
String Title { get; };
|
||||
String Body { get; };
|
||||
Microsoft.Terminal.Control.OutputNotificationStyle Style { get; };
|
||||
Boolean AlwaysNotify { get; };
|
||||
};
|
||||
|
||||
interface IPaneContent
|
||||
@@ -24,7 +33,7 @@ namespace TerminalApp
|
||||
Windows.Foundation.Size MinimumSize { get; };
|
||||
|
||||
String Title { get; };
|
||||
UInt64 TaskbarState { get; };
|
||||
Microsoft.Terminal.Control.TaskbarState TaskbarState { get; };
|
||||
UInt64 TaskbarProgress { get; };
|
||||
Boolean ReadOnly { get; };
|
||||
String Icon { get; };
|
||||
@@ -46,6 +55,7 @@ namespace TerminalApp
|
||||
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> TaskbarProgressChanged;
|
||||
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> ReadOnlyChanged;
|
||||
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> FocusRequested;
|
||||
event Windows.Foundation.TypedEventHandler<IPaneContent, NotificationEventArgs> NotificationRequested;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace winrt::TerminalApp::implementation
|
||||
winrt::Microsoft::Terminal::Settings::Model::INewContentArgs GetNewTerminalArgs(BuildStartupKind kind) const;
|
||||
|
||||
winrt::hstring Title() { return _filePath; }
|
||||
uint64_t TaskbarState() { return 0; }
|
||||
winrt::Microsoft::Terminal::Control::TaskbarState TaskbarState() { return winrt::Microsoft::Terminal::Control::TaskbarState::Clear; }
|
||||
uint64_t TaskbarProgress() { return 0; }
|
||||
bool ReadOnly() { return false; }
|
||||
winrt::hstring Icon() const;
|
||||
|
||||
@@ -31,10 +31,14 @@ Pane::Pane(IPaneContent content, const bool lastFocused) :
|
||||
_lastActive{ lastFocused }
|
||||
{
|
||||
_setPaneContent(std::move(content));
|
||||
_root.Children().Append(_borderFirst);
|
||||
_CreatePaneHeader();
|
||||
|
||||
const auto& control{ _content.GetRoot() };
|
||||
_borderFirst.Child(control);
|
||||
|
||||
// Set up leaf layout: header in _root row 0, content in _borderFirst row 1.
|
||||
// The TermControl stays as the direct child of _borderFirst (no Grid wrapper)
|
||||
// so the SwapChainPanel renders correctly.
|
||||
_SetupLeafLayout(control);
|
||||
|
||||
// Register an event with the control to have it inform us when it gains focus.
|
||||
if (control)
|
||||
@@ -1228,6 +1232,12 @@ void Pane::UpdateVisuals()
|
||||
const auto& brush{ _ComputeBorderColor() };
|
||||
_borderFirst.BorderBrush(brush);
|
||||
_borderSecond.BorderBrush(brush);
|
||||
|
||||
// Update pane header color to match focus state
|
||||
if (_paneHeaderBorder && _paneHeaderBorder.Visibility() == winrt::Windows::UI::Xaml::Visibility::Visible)
|
||||
{
|
||||
_paneHeaderBorder.Background(brush);
|
||||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -1450,9 +1460,9 @@ void Pane::_CloseChild(const bool closeFirst)
|
||||
_root.RowDefinitions().Clear();
|
||||
|
||||
// Reattach the TermControl to our grid.
|
||||
_root.Children().Append(_borderFirst);
|
||||
_CreatePaneHeader();
|
||||
const auto& control{ _content.GetRoot() };
|
||||
_borderFirst.Child(control);
|
||||
_SetupLeafLayout(control);
|
||||
|
||||
// Make sure to set our _splitState before focusing the control. If you
|
||||
// fail to do this, when the tab handles the GotFocus event and asks us
|
||||
@@ -1755,7 +1765,92 @@ void Pane::_setPaneContent(IPaneContent content)
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sets up row/column definitions for this pane. There are three total
|
||||
// - Creates the pane header UI elements (title bar shown above the content).
|
||||
// The header is initially collapsed and only shown via ShowPaneHeaders().
|
||||
void Pane::_CreatePaneHeader()
|
||||
{
|
||||
namespace WUX = winrt::Windows::UI::Xaml;
|
||||
|
||||
_paneHeaderText = Controls::TextBlock{};
|
||||
_paneHeaderText.FontSize(12);
|
||||
_paneHeaderText.Padding({ 8, 2, 8, 2 });
|
||||
_paneHeaderText.IsTextSelectionEnabled(false);
|
||||
_paneHeaderText.TextTrimming(WUX::TextTrimming::CharacterEllipsis);
|
||||
if (_content)
|
||||
{
|
||||
_paneHeaderText.Text(_content.Title());
|
||||
_titleChangedRevoker = _content.TitleChanged(winrt::auto_revoke, [this](auto&&, auto&&) {
|
||||
_paneHeaderBorder.Dispatcher().RunAsync(
|
||||
winrt::Windows::UI::Core::CoreDispatcherPriority::Normal,
|
||||
[this]() {
|
||||
if (_content && _paneHeaderText)
|
||||
{
|
||||
_paneHeaderText.Text(_content.Title());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_paneHeaderBorder = Controls::Border{};
|
||||
_paneHeaderBorder.Padding({ 0, 0, 0, 0 });
|
||||
_paneHeaderBorder.Child(_paneHeaderText);
|
||||
_paneHeaderBorder.Visibility(WUX::Visibility::Collapsed);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sets up the leaf pane layout in _root: a header row (auto-sized) and a
|
||||
// content row (star-sized). The TermControl stays as the direct child of
|
||||
// _borderFirst so the SwapChainPanel renders correctly.
|
||||
void Pane::_SetupLeafLayout(const winrt::Windows::UI::Xaml::UIElement& control)
|
||||
{
|
||||
auto headerRow = Controls::RowDefinition{};
|
||||
headerRow.Height(GridLengthHelper::Auto());
|
||||
auto contentRow = Controls::RowDefinition{};
|
||||
contentRow.Height(GridLengthHelper::FromValueAndType(1, GridUnitType::Star));
|
||||
_root.RowDefinitions().Append(headerRow);
|
||||
_root.RowDefinitions().Append(contentRow);
|
||||
|
||||
Controls::Grid::SetRow(_paneHeaderBorder, 0);
|
||||
Controls::Grid::SetRow(_borderFirst, 1);
|
||||
|
||||
_root.Children().Append(_paneHeaderBorder);
|
||||
_root.Children().Append(_borderFirst);
|
||||
|
||||
if (control)
|
||||
{
|
||||
_borderFirst.Child(control);
|
||||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Show or hide the pane header title bar on all leaf panes in the tree.
|
||||
// Called by Tab when the number of panes changes.
|
||||
void Pane::ShowPaneHeaders(bool show)
|
||||
{
|
||||
if (_IsLeaf())
|
||||
{
|
||||
if (_paneHeaderBorder)
|
||||
{
|
||||
namespace WUX = winrt::Windows::UI::Xaml;
|
||||
_paneHeaderBorder.Visibility(show ? WUX::Visibility::Visible : WUX::Visibility::Collapsed);
|
||||
|
||||
if (show)
|
||||
{
|
||||
const auto& brush = _ComputeBorderColor();
|
||||
_paneHeaderBorder.Background(brush);
|
||||
_paneHeaderText.Foreground(winrt::Windows::UI::Xaml::Media::SolidColorBrush(winrt::Windows::UI::Colors::White()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_firstChild->ShowPaneHeaders(show);
|
||||
_secondChild->ShowPaneHeaders(show);
|
||||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sets up row/column definitions for this pane.There are three total
|
||||
// row/cols. The middle one is for the separator. The first and third are for
|
||||
// each of the child panes, and are given a size in pixels, based off the
|
||||
// available space, and the percent of the space they respectively consume,
|
||||
@@ -2321,6 +2416,10 @@ std::pair<std::shared_ptr<Pane>, std::shared_ptr<Pane>> Pane::_Split(SplitDirect
|
||||
_root.RowDefinitions().Clear();
|
||||
_CreateRowColDefinitions();
|
||||
|
||||
// Reset Grid.Row on _borderFirst — it may have been set to row 1 in the
|
||||
// leaf layout (header=row0, content=row1).
|
||||
Controls::Grid::SetRow(_borderFirst, 0);
|
||||
|
||||
_borderFirst.Child(_firstChild->GetRootElement());
|
||||
_borderSecond.Child(_secondChild->GetRootElement());
|
||||
|
||||
@@ -3044,15 +3143,14 @@ void Pane::BroadcastChar(const winrt::Microsoft::Terminal::Control::TermControl&
|
||||
}
|
||||
|
||||
void Pane::BroadcastString(const winrt::Microsoft::Terminal::Control::TermControl& sourceControl,
|
||||
const winrt::hstring& text,
|
||||
const winrt::Microsoft::Terminal::Control::WriteInputStringType type)
|
||||
const winrt::hstring& text)
|
||||
{
|
||||
WalkTree([&](const auto& pane) {
|
||||
if (const auto& termControl{ pane->GetTerminalControl() })
|
||||
{
|
||||
if (termControl != sourceControl && !termControl.ReadOnly())
|
||||
{
|
||||
termControl.WriteInputString(text, type);
|
||||
termControl.RawWriteString(text);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -150,9 +150,10 @@ public:
|
||||
bool ContainsReadOnly() const;
|
||||
|
||||
void EnableBroadcast(bool enabled);
|
||||
void ShowPaneHeaders(bool show);
|
||||
void BroadcastKey(const winrt::Microsoft::Terminal::Control::TermControl& sourceControl, const WORD vkey, const WORD scanCode, const winrt::Microsoft::Terminal::Core::ControlKeyStates modifiers, const bool keyDown);
|
||||
void BroadcastChar(const winrt::Microsoft::Terminal::Control::TermControl& sourceControl, const wchar_t vkey, const WORD scanCode, const winrt::Microsoft::Terminal::Core::ControlKeyStates modifiers);
|
||||
void BroadcastString(const winrt::Microsoft::Terminal::Control::TermControl& sourceControl, const winrt::hstring& text, const winrt::Microsoft::Terminal::Control::WriteInputStringType type);
|
||||
void BroadcastString(const winrt::Microsoft::Terminal::Control::TermControl& sourceControl, const winrt::hstring& text);
|
||||
|
||||
void UpdateResources(const PaneResources& resources);
|
||||
|
||||
@@ -235,6 +236,11 @@ private:
|
||||
winrt::Windows::UI::Xaml::Controls::Border _borderFirst{};
|
||||
winrt::Windows::UI::Xaml::Controls::Border _borderSecond{};
|
||||
|
||||
// Per-pane title header (visible when there are split panes)
|
||||
winrt::Windows::UI::Xaml::Controls::Border _paneHeaderBorder{ nullptr };
|
||||
winrt::Windows::UI::Xaml::Controls::TextBlock _paneHeaderText{ nullptr };
|
||||
winrt::TerminalApp::IPaneContent::TitleChanged_revoker _titleChangedRevoker;
|
||||
|
||||
PaneResources _themeResources;
|
||||
|
||||
#pragma region Properties that need to be transferred between child / parent panes upon splitting / closing
|
||||
@@ -266,6 +272,8 @@ private:
|
||||
void _SetupChildCloseHandlers();
|
||||
winrt::TerminalApp::IPaneContent _takePaneContent();
|
||||
void _setPaneContent(winrt::TerminalApp::IPaneContent content);
|
||||
void _CreatePaneHeader();
|
||||
void _SetupLeafLayout(const winrt::Windows::UI::Xaml::UIElement& control);
|
||||
bool _HasChild(const std::shared_ptr<Pane> child);
|
||||
winrt::TerminalApp::TerminalPaneContent _getTerminalContent() const;
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ namespace winrt::TerminalApp::implementation
|
||||
WINRT_PROPERTY(TerminalApp::CommandlineArgs, Command, nullptr);
|
||||
WINRT_PROPERTY(winrt::hstring, Content);
|
||||
WINRT_PROPERTY(Windows::Foundation::IReference<Windows::Foundation::Rect>, InitialBounds);
|
||||
WINRT_PROPERTY(winrt::Microsoft::Terminal::Settings::Model::WindowLayout, PersistedLayout, nullptr);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -51,5 +51,6 @@ namespace TerminalApp
|
||||
CommandlineArgs Command { get; };
|
||||
String Content { get; };
|
||||
Windows.Foundation.IReference<Windows.Foundation.Rect> InitialBounds { get; };
|
||||
Microsoft.Terminal.Settings.Model.WindowLayout PersistedLayout;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -496,24 +496,48 @@
|
||||
<value>Third-Party notices</value>
|
||||
<comment>A hyperlink name for the Terminal's third-party notices</comment>
|
||||
</data>
|
||||
<data name="QuitDialog.CloseButtonText" xml:space="preserve">
|
||||
<data name="ConfirmCloseDialog_Cancel" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
<data name="QuitDialog.PrimaryButtonText" xml:space="preserve">
|
||||
<value>Close all</value>
|
||||
</data>
|
||||
<data name="QuitDialog.Title" xml:space="preserve">
|
||||
<data name="ConfirmCloseDialog_CloseAllTitle" xml:space="preserve">
|
||||
<value>Do you want to close all windows?</value>
|
||||
</data>
|
||||
<data name="CloseAllDialog.CloseButtonText" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
<data name="CloseAllDialog.PrimaryButtonText" xml:space="preserve">
|
||||
<data name="ConfirmCloseDialog_CloseAllPrimary" xml:space="preserve">
|
||||
<value>Close all</value>
|
||||
</data>
|
||||
<data name="CloseAllDialog.Title" xml:space="preserve">
|
||||
<data name="ConfirmCloseDialog_WindowTitle" xml:space="preserve">
|
||||
<value>Do you want to close all tabs?</value>
|
||||
</data>
|
||||
<data name="ConfirmCloseDialog_WindowPrimary" xml:space="preserve">
|
||||
<value>Close all</value>
|
||||
</data>
|
||||
<data name="ConfirmCloseDialog_TabTitle" xml:space="preserve">
|
||||
<value>Do you want to close this tab?</value>
|
||||
</data>
|
||||
<data name="ConfirmCloseDialog_TabPrimary" xml:space="preserve">
|
||||
<value>Close tab</value>
|
||||
</data>
|
||||
<data name="ConfirmCloseDialog_PaneTitle" xml:space="preserve">
|
||||
<value>Do you want to close this pane?</value>
|
||||
</data>
|
||||
<data name="ConfirmCloseDialog_PanePrimary" xml:space="preserve">
|
||||
<value>Close pane</value>
|
||||
</data>
|
||||
<data name="ConfirmCloseDialog_MultipleTabsTitle" xml:space="preserve">
|
||||
<value>Do you want to close these tabs?</value>
|
||||
</data>
|
||||
<data name="ConfirmCloseDialog_MultipleTabsPrimary" xml:space="preserve">
|
||||
<value>Close tabs</value>
|
||||
</data>
|
||||
<data name="ConfirmCloseDialog_MultiplePanesTitle" xml:space="preserve">
|
||||
<value>Do you want to close these panes?</value>
|
||||
</data>
|
||||
<data name="ConfirmCloseDialog_MultiplePanesPrimary" xml:space="preserve">
|
||||
<value>Close panes</value>
|
||||
</data>
|
||||
<data name="DontAskAgainCheckBox.Content" xml:space="preserve">
|
||||
<value>Don't ask me again</value>
|
||||
</data>
|
||||
<data name="CloseReadOnlyDialog.CloseButtonText" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
@@ -719,6 +743,18 @@
|
||||
<value>unnamed window</value>
|
||||
<comment>text used to identify when a window hasn't been assigned a name by the user</comment>
|
||||
</data>
|
||||
<data name="NameThisWindowMenuItem" xml:space="preserve">
|
||||
<value>Name this window…</value>
|
||||
<comment>Menu item text shown when the current window has no name assigned</comment>
|
||||
</data>
|
||||
<data name="RenameThisWindowMenuItem" xml:space="preserve">
|
||||
<value>Rename this window…</value>
|
||||
<comment>Menu item text shown when the current window already has a name</comment>
|
||||
</data>
|
||||
<data name="WindowListUnnamedEntry" xml:space="preserve">
|
||||
<value>#{0} (unnamed)</value>
|
||||
<comment>{0} is the window ID number. Shown in the workspace flyout for windows that have no name assigned.</comment>
|
||||
</data>
|
||||
<data name="WindowRenamer.Subtitle" xml:space="preserve">
|
||||
<value>Enter a new name:</value>
|
||||
</data>
|
||||
@@ -745,6 +781,14 @@
|
||||
<value>Windows</value>
|
||||
<comment>This is displayed as a label for the context menu item that holds the submenu of available windows.</comment>
|
||||
</data>
|
||||
<data name="NotificationMessage_TabActivity" xml:space="preserve">
|
||||
<value>Activity in tab "{0}"</value>
|
||||
<comment>{0} is the tab title. Shown as the body of a desktop notification when tab activity is detected.</comment>
|
||||
</data>
|
||||
<data name="NotificationMessage_TabActivityInWindow" xml:space="preserve">
|
||||
<value>Activity in tab "{0}" (window "{1}")</value>
|
||||
<comment>{0} is the tab title, {1} is the window name. Shown as the body of a desktop notification when tab activity is detected and the window has a name.</comment>
|
||||
</data>
|
||||
<data name="DropPathTabRun.Text" xml:space="preserve">
|
||||
<value>Open a new tab in given starting directory</value>
|
||||
</data>
|
||||
@@ -881,10 +925,10 @@
|
||||
<value>If set, the command will be appended to the profile's default command instead of replacing it.</value>
|
||||
</data>
|
||||
<data name="RestartConnectionText" xml:space="preserve">
|
||||
<value>Restart connection</value>
|
||||
<value>Restart session</value>
|
||||
</data>
|
||||
<data name="RestartConnectionToolTip" xml:space="preserve">
|
||||
<value>Restart the active pane connection</value>
|
||||
<value>Restart the session in the active pane</value>
|
||||
</data>
|
||||
<data name="SnippetPaneTitle.Text" xml:space="preserve">
|
||||
<value>Snippets</value>
|
||||
@@ -929,12 +973,4 @@
|
||||
<data name="InvalidRegex" xml:space="preserve">
|
||||
<value>An invalid regular expression was found.</value>
|
||||
</data>
|
||||
<data name="DragFileCaption" xml:space="preserve">
|
||||
<value>Paste path to file</value>
|
||||
<comment>The displayed caption for dragging a file onto a terminal.</comment>
|
||||
</data>
|
||||
<data name="DragTextCaption" xml:space="preserve">
|
||||
<value>Paste text</value>
|
||||
<comment>The displayed caption for dragging text onto a terminal.</comment>
|
||||
</data>
|
||||
</root>
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace winrt::TerminalApp::implementation
|
||||
winrt::Microsoft::Terminal::Settings::Model::INewContentArgs GetNewTerminalArgs(BuildStartupKind kind) const;
|
||||
|
||||
winrt::hstring Title() { return L"Scratchpad"; }
|
||||
uint64_t TaskbarState() { return 0; }
|
||||
winrt::Microsoft::Terminal::Control::TaskbarState TaskbarState() { return winrt::Microsoft::Terminal::Control::TaskbarState::Clear; }
|
||||
uint64_t TaskbarProgress() { return 0; }
|
||||
bool ReadOnly() { return false; }
|
||||
winrt::hstring Icon() const;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace winrt::TerminalApp::implementation
|
||||
winrt::Microsoft::Terminal::Settings::Model::INewContentArgs GetNewTerminalArgs(const BuildStartupKind kind) const;
|
||||
|
||||
winrt::hstring Title() { return RS_(L"SettingsTab"); }
|
||||
uint64_t TaskbarState() { return 0; }
|
||||
winrt::Microsoft::Terminal::Control::TaskbarState TaskbarState() { return winrt::Microsoft::Terminal::Control::TaskbarState::Clear; }
|
||||
uint64_t TaskbarProgress() { return 0; }
|
||||
bool ReadOnly() { return false; }
|
||||
winrt::hstring Icon() const;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace winrt::TerminalApp::implementation
|
||||
winrt::Microsoft::Terminal::Settings::Model::INewContentArgs GetNewTerminalArgs(BuildStartupKind kind) const;
|
||||
|
||||
winrt::hstring Title() { return RS_(L"SnippetPaneTitle/Text"); }
|
||||
uint64_t TaskbarState() { return 0; }
|
||||
winrt::Microsoft::Terminal::Control::TaskbarState TaskbarState() { return winrt::Microsoft::Terminal::Control::TaskbarState::Clear; }
|
||||
uint64_t TaskbarProgress() { return 0; }
|
||||
bool ReadOnly() { return false; }
|
||||
winrt::hstring Icon() const;
|
||||
|
||||
@@ -35,7 +35,6 @@ namespace winrt::TerminalApp::implementation
|
||||
_activePane = nullptr;
|
||||
|
||||
_closePaneMenuItem.Visibility(WUX::Visibility::Collapsed);
|
||||
_restartConnectionMenuItem.Visibility(WUX::Visibility::Collapsed);
|
||||
|
||||
auto firstId = _nextPaneId;
|
||||
|
||||
@@ -86,6 +85,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
_MakeTabViewItem();
|
||||
_CreateContextMenu();
|
||||
_UpdateMenuItemStates();
|
||||
|
||||
_headerControl.TabStatus(_tabStatus);
|
||||
|
||||
@@ -123,6 +123,12 @@ namespace winrt::TerminalApp::implementation
|
||||
_bellIndicatorTimer.Stop();
|
||||
}
|
||||
|
||||
void Tab::_ActivityIndicatorTimerTick(const Windows::Foundation::IInspectable& /*sender*/, const Windows::Foundation::IInspectable& /*e*/)
|
||||
{
|
||||
ShowActivityIndicator(false);
|
||||
_activityIndicatorTimer.Stop();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Initializes a TabViewItem for this Tab instance.
|
||||
// Arguments:
|
||||
@@ -329,6 +335,10 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
ShowBellIndicator(false);
|
||||
}
|
||||
if (_tabStatus.ActivityIndicator())
|
||||
{
|
||||
ShowActivityIndicator(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,6 +371,10 @@ namespace winrt::TerminalApp::implementation
|
||||
// The tabWidthMode may have changed, update the header control accordingly
|
||||
_UpdateHeaderControlMaxWidth();
|
||||
|
||||
// Refresh pane header visibility based on the current setting
|
||||
const auto showHeaders = settings.GlobalSettings().ShowPaneHeaders() && _rootPane->GetLeafPaneCount() > 1;
|
||||
_rootPane->ShowPaneHeaders(showHeaders);
|
||||
|
||||
// Update the settings on all our panes.
|
||||
_rootPane->WalkTree([&](const auto& pane) {
|
||||
pane->UpdateSettings(settings);
|
||||
@@ -459,6 +473,26 @@ namespace winrt::TerminalApp::implementation
|
||||
_bellIndicatorTimer.Start();
|
||||
}
|
||||
|
||||
void Tab::ShowActivityIndicator(const bool show)
|
||||
{
|
||||
ASSERT_UI_THREAD();
|
||||
|
||||
_tabStatus.ActivityIndicator(show);
|
||||
}
|
||||
|
||||
void Tab::ActivateActivityIndicatorTimer()
|
||||
{
|
||||
ASSERT_UI_THREAD();
|
||||
|
||||
if (!_activityIndicatorTimer)
|
||||
{
|
||||
_activityIndicatorTimer.Interval(std::chrono::milliseconds(2000));
|
||||
_activityIndicatorTimer.Tick({ get_weak(), &Tab::_ActivityIndicatorTimerTick });
|
||||
}
|
||||
|
||||
_activityIndicatorTimer.Start();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Gets the title string of the last focused terminal control in our tree.
|
||||
// Returns the empty string if there is no such control.
|
||||
@@ -646,6 +680,14 @@ namespace winrt::TerminalApp::implementation
|
||||
// After split, Close Pane Menu Item should be visible
|
||||
_closePaneMenuItem.Visibility(WUX::Visibility::Visible);
|
||||
|
||||
// Show pane headers now that we have multiple panes (if the setting is enabled)
|
||||
try
|
||||
{
|
||||
const auto settings{ winrt::TerminalApp::implementation::AppLogic::CurrentAppSettings() };
|
||||
_rootPane->ShowPaneHeaders(settings.GlobalSettings().ShowPaneHeaders());
|
||||
}
|
||||
CATCH_LOG();
|
||||
|
||||
// The active pane has an id if it is a leaf
|
||||
if (activePaneId)
|
||||
{
|
||||
@@ -844,14 +886,14 @@ namespace winrt::TerminalApp::implementation
|
||||
// Arguments:
|
||||
// - direction: The direction to move the separator in.
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void Tab::ResizePane(const ResizeDirection& direction)
|
||||
// - whether a pane was resized
|
||||
bool Tab::ResizePane(const ResizeDirection& direction)
|
||||
{
|
||||
ASSERT_UI_THREAD();
|
||||
|
||||
// NOTE: This _must_ be called on the root pane, so that it can propagate
|
||||
// throughout the entire tree.
|
||||
_rootPane->ResizePane(direction);
|
||||
return _rootPane->ResizePane(direction);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -1148,6 +1190,14 @@ namespace winrt::TerminalApp::implementation
|
||||
tab->TabRaiseVisualBell.raise();
|
||||
}
|
||||
|
||||
// Send a desktop toast notification if requested, but only if
|
||||
// the pane isn't already in the belled state. This prevents
|
||||
// sending repeated toasts for repeated BEL characters.
|
||||
if (bellArgs.SendNotification() && !tab->_tabStatus.BellIndicator())
|
||||
{
|
||||
tab->TabToastNotificationRequested.raise(tab->Title(), L"", sender);
|
||||
}
|
||||
|
||||
// Show the bell indicator in the tab header
|
||||
tab->ShowBellIndicator(true);
|
||||
|
||||
@@ -1166,6 +1216,55 @@ namespace winrt::TerminalApp::implementation
|
||||
events.RestartTerminalRequested = terminal.RestartTerminalRequested(winrt::auto_revoke, { get_weak(), &Tab::_bubbleRestartTerminalRequested });
|
||||
}
|
||||
|
||||
events.NotificationRequested = content.NotificationRequested(
|
||||
winrt::auto_revoke,
|
||||
[dispatcher, weakThis](TerminalApp::IPaneContent sender, auto notifArgs) -> safe_void_coroutine {
|
||||
const auto weakThisCopy = weakThis;
|
||||
co_await wil::resume_foreground(dispatcher);
|
||||
if (const auto tab{ weakThisCopy.get() })
|
||||
{
|
||||
const auto activeContent = tab->GetActiveContent();
|
||||
const auto isActivePaneContent = activeContent && activeContent == sender;
|
||||
|
||||
if (!notifArgs.AlwaysNotify() && isActivePaneContent &&
|
||||
tab->_focusState != WUX::FocusState::Unfocused)
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
|
||||
const auto style = notifArgs.Style();
|
||||
|
||||
if (WI_IsFlagSet(style, OutputNotificationStyle::Taskbar))
|
||||
{
|
||||
tab->TabRaiseVisualBell.raise();
|
||||
}
|
||||
|
||||
if (WI_IsFlagSet(style, winrt::Microsoft::Terminal::Control::OutputNotificationStyle::Audible))
|
||||
{
|
||||
if (const auto termContent{ sender.try_as<TerminalApp::TerminalPaneContent>() })
|
||||
{
|
||||
termContent.PlayNotificationSound();
|
||||
}
|
||||
}
|
||||
|
||||
if (WI_IsFlagSet(style, winrt::Microsoft::Terminal::Control::OutputNotificationStyle::Tab))
|
||||
{
|
||||
tab->ShowActivityIndicator(true);
|
||||
|
||||
if (tab->_focusState != WUX::FocusState::Unfocused)
|
||||
{
|
||||
tab->ActivateActivityIndicatorTimer();
|
||||
}
|
||||
}
|
||||
|
||||
if (WI_IsFlagSet(style, winrt::Microsoft::Terminal::Control::OutputNotificationStyle::Notification))
|
||||
{
|
||||
const auto title = notifArgs.Title().empty() ? tab->Title() : notifArgs.Title();
|
||||
tab->TabToastNotificationRequested.raise(title, notifArgs.Body(), sender);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (_tabStatus.IsInputBroadcastActive())
|
||||
{
|
||||
if (const auto& termContent{ content.try_as<TerminalApp::TerminalPaneContent>() })
|
||||
@@ -1222,11 +1321,10 @@ namespace winrt::TerminalApp::implementation
|
||||
const auto taskbarState = state.State();
|
||||
// The progress of the control changed, but not necessarily the progress of the tab.
|
||||
// Set the tab's progress ring to the active pane's progress
|
||||
if (taskbarState > 0)
|
||||
if (taskbarState != winrt::Microsoft::Terminal::Control::TaskbarState::Clear)
|
||||
{
|
||||
if (taskbarState == 3)
|
||||
if (taskbarState == winrt::Microsoft::Terminal::Control::TaskbarState::Indeterminate)
|
||||
{
|
||||
// 3 is the indeterminate state, set the progress ring as such
|
||||
_tabStatus.IsProgressRingIndeterminate(true);
|
||||
}
|
||||
else
|
||||
@@ -1254,7 +1352,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
// Method Description:
|
||||
// - Set an indicator on the tab if any pane is in a closed connection state.
|
||||
// - Show/hide the Restart Connection context menu entry depending on active pane's state.
|
||||
// - Show/hide the Restart Session context menu entry depending on active pane's state.
|
||||
// Arguments:
|
||||
// - <none>
|
||||
// Return Value:
|
||||
@@ -1271,13 +1369,6 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
_tabStatus.IsConnectionClosed(isClosed);
|
||||
}
|
||||
|
||||
if (_activePane)
|
||||
{
|
||||
_restartConnectionMenuItem.Visibility(_activePane->IsConnectionClosed() ?
|
||||
WUX::Visibility::Visible :
|
||||
WUX::Visibility::Collapsed);
|
||||
}
|
||||
}
|
||||
|
||||
void Tab::_RestartActivePaneConnection()
|
||||
@@ -1324,6 +1415,7 @@ namespace winrt::TerminalApp::implementation
|
||||
if (_rootPane->GetLeafPaneCount() == 1)
|
||||
{
|
||||
_closePaneMenuItem.Visibility(WUX::Visibility::Collapsed);
|
||||
_rootPane->ShowPaneHeaders(false);
|
||||
}
|
||||
|
||||
_RecalculateAndApplyReadOnly();
|
||||
@@ -1348,6 +1440,22 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_UpdateMenuItemStates();
|
||||
}
|
||||
|
||||
void Tab::_UpdateMenuItemStates()
|
||||
{
|
||||
// Terminal-specific menu items
|
||||
const auto content = _activePane ? _activePane->GetContent() : nullptr;
|
||||
const auto isTerm = content && content.try_as<winrt::TerminalApp::TerminalPaneContent>() != nullptr;
|
||||
_duplicateTabMenuItem.IsEnabled(isTerm);
|
||||
_exportTabMenuItem.IsEnabled(isTerm);
|
||||
_findMenuItem.IsEnabled(isTerm);
|
||||
_restartConnectionMenuItem.IsEnabled(isTerm);
|
||||
|
||||
// Snippets Pane can technically be split
|
||||
_splitTabMenuItem.IsEnabled(isTerm || (content && content.try_as<winrt::TerminalApp::SnippetsPaneContent>() != nullptr));
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -1393,6 +1501,10 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
tab->ShowBellIndicator(false);
|
||||
}
|
||||
if (tab->_tabStatus.ActivityIndicator())
|
||||
{
|
||||
tab->ShowActivityIndicator(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1652,106 +1764,100 @@ namespace winrt::TerminalApp::implementation
|
||||
Automation::AutomationProperties::SetHelpText(renameTabMenuItem, renameTabToolTip);
|
||||
}
|
||||
|
||||
Controls::MenuFlyoutItem duplicateTabMenuItem;
|
||||
{
|
||||
// "Duplicate tab"
|
||||
Controls::FontIcon duplicateTabSymbol;
|
||||
duplicateTabSymbol.FontFamily(Media::FontFamily{ L"Segoe Fluent Icons, Segoe MDL2 Assets" });
|
||||
duplicateTabSymbol.Glyph(L"\xF5ED");
|
||||
|
||||
duplicateTabMenuItem.Click({ get_weak(), &Tab::_duplicateTabClicked });
|
||||
duplicateTabMenuItem.Text(RS_(L"DuplicateTabText"));
|
||||
duplicateTabMenuItem.Icon(duplicateTabSymbol);
|
||||
_duplicateTabMenuItem.Click({ get_weak(), &Tab::_duplicateTabClicked });
|
||||
_duplicateTabMenuItem.Text(RS_(L"DuplicateTabText"));
|
||||
_duplicateTabMenuItem.Icon(duplicateTabSymbol);
|
||||
|
||||
const auto duplicateTabToolTip = RS_(L"DuplicateTabToolTip");
|
||||
|
||||
WUX::Controls::ToolTipService::SetToolTip(duplicateTabMenuItem, box_value(duplicateTabToolTip));
|
||||
Automation::AutomationProperties::SetHelpText(duplicateTabMenuItem, duplicateTabToolTip);
|
||||
WUX::Controls::ToolTipService::SetToolTip(_duplicateTabMenuItem, box_value(duplicateTabToolTip));
|
||||
Automation::AutomationProperties::SetHelpText(_duplicateTabMenuItem, duplicateTabToolTip);
|
||||
}
|
||||
|
||||
Controls::MenuFlyoutItem splitTabMenuItem;
|
||||
{
|
||||
// "Split tab"
|
||||
Controls::FontIcon splitTabSymbol;
|
||||
splitTabSymbol.FontFamily(Media::FontFamily{ L"Segoe Fluent Icons, Segoe MDL2 Assets" });
|
||||
splitTabSymbol.Glyph(L"\xF246"); // ViewDashboard
|
||||
|
||||
splitTabMenuItem.Click({ get_weak(), &Tab::_splitTabClicked });
|
||||
splitTabMenuItem.Text(RS_(L"SplitTabText"));
|
||||
splitTabMenuItem.Icon(splitTabSymbol);
|
||||
_splitTabMenuItem.Click({ get_weak(), &Tab::_splitTabClicked });
|
||||
_splitTabMenuItem.Text(RS_(L"SplitTabText"));
|
||||
_splitTabMenuItem.Icon(splitTabSymbol);
|
||||
|
||||
const auto splitTabToolTip = RS_(L"SplitTabToolTip");
|
||||
|
||||
WUX::Controls::ToolTipService::SetToolTip(splitTabMenuItem, box_value(splitTabToolTip));
|
||||
Automation::AutomationProperties::SetHelpText(splitTabMenuItem, splitTabToolTip);
|
||||
WUX::Controls::ToolTipService::SetToolTip(_splitTabMenuItem, box_value(splitTabToolTip));
|
||||
Automation::AutomationProperties::SetHelpText(_splitTabMenuItem, splitTabToolTip);
|
||||
}
|
||||
|
||||
Controls::MenuFlyoutItem closePaneMenuItem = _closePaneMenuItem;
|
||||
{
|
||||
// "Close pane"
|
||||
closePaneMenuItem.Click({ get_weak(), &Tab::_closePaneClicked });
|
||||
closePaneMenuItem.Text(RS_(L"ClosePaneText"));
|
||||
_closePaneMenuItem.Click({ get_weak(), &Tab::_closePaneClicked });
|
||||
_closePaneMenuItem.Text(RS_(L"ClosePaneText"));
|
||||
|
||||
const auto closePaneToolTip = RS_(L"ClosePaneToolTip");
|
||||
|
||||
WUX::Controls::ToolTipService::SetToolTip(closePaneMenuItem, box_value(closePaneToolTip));
|
||||
Automation::AutomationProperties::SetHelpText(closePaneMenuItem, closePaneToolTip);
|
||||
WUX::Controls::ToolTipService::SetToolTip(_closePaneMenuItem, box_value(closePaneToolTip));
|
||||
Automation::AutomationProperties::SetHelpText(_closePaneMenuItem, closePaneToolTip);
|
||||
}
|
||||
|
||||
Controls::MenuFlyoutItem exportTabMenuItem;
|
||||
{
|
||||
// "Export tab"
|
||||
Controls::FontIcon exportTabSymbol;
|
||||
exportTabSymbol.FontFamily(Media::FontFamily{ L"Segoe Fluent Icons, Segoe MDL2 Assets" });
|
||||
exportTabSymbol.Glyph(L"\xE74E"); // Save
|
||||
|
||||
exportTabMenuItem.Click({ get_weak(), &Tab::_exportTextClicked });
|
||||
exportTabMenuItem.Text(RS_(L"ExportTabText"));
|
||||
exportTabMenuItem.Icon(exportTabSymbol);
|
||||
_exportTabMenuItem.Click({ get_weak(), &Tab::_exportTextClicked });
|
||||
_exportTabMenuItem.Text(RS_(L"ExportTabText"));
|
||||
_exportTabMenuItem.Icon(exportTabSymbol);
|
||||
|
||||
const auto exportTabToolTip = RS_(L"ExportTabToolTip");
|
||||
|
||||
WUX::Controls::ToolTipService::SetToolTip(exportTabMenuItem, box_value(exportTabToolTip));
|
||||
Automation::AutomationProperties::SetHelpText(exportTabMenuItem, exportTabToolTip);
|
||||
WUX::Controls::ToolTipService::SetToolTip(_exportTabMenuItem, box_value(exportTabToolTip));
|
||||
Automation::AutomationProperties::SetHelpText(_exportTabMenuItem, exportTabToolTip);
|
||||
}
|
||||
|
||||
Controls::MenuFlyoutItem findMenuItem;
|
||||
{
|
||||
// "Find"
|
||||
Controls::FontIcon findSymbol;
|
||||
findSymbol.FontFamily(Media::FontFamily{ L"Segoe Fluent Icons, Segoe MDL2 Assets" });
|
||||
findSymbol.Glyph(L"\xF78B"); // SearchMedium
|
||||
|
||||
findMenuItem.Click({ get_weak(), &Tab::_findClicked });
|
||||
findMenuItem.Text(RS_(L"FindText"));
|
||||
findMenuItem.Icon(findSymbol);
|
||||
_findMenuItem.Click({ get_weak(), &Tab::_findClicked });
|
||||
_findMenuItem.Text(RS_(L"FindText"));
|
||||
_findMenuItem.Icon(findSymbol);
|
||||
|
||||
const auto findToolTip = RS_(L"FindToolTip");
|
||||
|
||||
WUX::Controls::ToolTipService::SetToolTip(findMenuItem, box_value(findToolTip));
|
||||
Automation::AutomationProperties::SetHelpText(findMenuItem, findToolTip);
|
||||
WUX::Controls::ToolTipService::SetToolTip(_findMenuItem, box_value(findToolTip));
|
||||
Automation::AutomationProperties::SetHelpText(_findMenuItem, findToolTip);
|
||||
}
|
||||
|
||||
Controls::MenuFlyoutItem restartConnectionMenuItem = _restartConnectionMenuItem;
|
||||
{
|
||||
// "Restart connection"
|
||||
// "Restart session"
|
||||
Controls::FontIcon restartConnectionSymbol;
|
||||
restartConnectionSymbol.FontFamily(Media::FontFamily{ L"Segoe Fluent Icons, Segoe MDL2 Assets" });
|
||||
restartConnectionSymbol.Glyph(L"\xE72C");
|
||||
|
||||
restartConnectionMenuItem.Click([weakThis](auto&&, auto&&) {
|
||||
_restartConnectionMenuItem.Click([weakThis](auto&&, auto&&) {
|
||||
if (auto tab{ weakThis.get() })
|
||||
{
|
||||
tab->_RestartActivePaneConnection();
|
||||
}
|
||||
});
|
||||
restartConnectionMenuItem.Text(RS_(L"RestartConnectionText"));
|
||||
restartConnectionMenuItem.Icon(restartConnectionSymbol);
|
||||
_restartConnectionMenuItem.Text(RS_(L"RestartConnectionText"));
|
||||
_restartConnectionMenuItem.Icon(restartConnectionSymbol);
|
||||
|
||||
const auto restartConnectionToolTip = RS_(L"RestartConnectionToolTip");
|
||||
|
||||
WUX::Controls::ToolTipService::SetToolTip(restartConnectionMenuItem, box_value(restartConnectionToolTip));
|
||||
Automation::AutomationProperties::SetHelpText(restartConnectionMenuItem, restartConnectionToolTip);
|
||||
WUX::Controls::ToolTipService::SetToolTip(_restartConnectionMenuItem, box_value(restartConnectionToolTip));
|
||||
Automation::AutomationProperties::SetHelpText(_restartConnectionMenuItem, restartConnectionToolTip);
|
||||
}
|
||||
|
||||
// Build the menu
|
||||
@@ -1759,16 +1865,16 @@ namespace winrt::TerminalApp::implementation
|
||||
Controls::MenuFlyoutSeparator menuSeparator;
|
||||
contextMenuFlyout.Items().Append(chooseColorMenuItem);
|
||||
contextMenuFlyout.Items().Append(renameTabMenuItem);
|
||||
contextMenuFlyout.Items().Append(duplicateTabMenuItem);
|
||||
contextMenuFlyout.Items().Append(splitTabMenuItem);
|
||||
contextMenuFlyout.Items().Append(_duplicateTabMenuItem);
|
||||
contextMenuFlyout.Items().Append(_splitTabMenuItem);
|
||||
_AppendMoveMenuItems(contextMenuFlyout);
|
||||
contextMenuFlyout.Items().Append(exportTabMenuItem);
|
||||
contextMenuFlyout.Items().Append(findMenuItem);
|
||||
contextMenuFlyout.Items().Append(restartConnectionMenuItem);
|
||||
contextMenuFlyout.Items().Append(_exportTabMenuItem);
|
||||
contextMenuFlyout.Items().Append(_findMenuItem);
|
||||
contextMenuFlyout.Items().Append(_restartConnectionMenuItem);
|
||||
contextMenuFlyout.Items().Append(menuSeparator);
|
||||
|
||||
auto closeSubMenu = _AppendCloseMenuItems(contextMenuFlyout);
|
||||
closeSubMenu.Items().Append(closePaneMenuItem);
|
||||
closeSubMenu.Items().Append(_closePaneMenuItem);
|
||||
|
||||
// GH#5750 - When the context menu is dismissed with ESC, toss the focus
|
||||
// back to our control.
|
||||
@@ -2174,6 +2280,7 @@ namespace winrt::TerminalApp::implementation
|
||||
// Always clear out old ones, just in case.
|
||||
events.KeySent.revoke();
|
||||
events.CharSent.revoke();
|
||||
events.StringSent.revoke();
|
||||
|
||||
if (newIsBroadcasting)
|
||||
{
|
||||
@@ -2214,6 +2321,17 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
events.StringSent = termControl.StringSent(winrt::auto_revoke, [weakThis](auto&& sender, auto&& e) {
|
||||
if (const auto tab{ weakThis.get() })
|
||||
{
|
||||
if (tab->_tabStatus.IsInputBroadcastActive())
|
||||
{
|
||||
tab->_rootPane->BroadcastString(sender.try_as<TermControl>(),
|
||||
e.Text());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Tab::ThemeColor(const winrt::Microsoft::Terminal::Settings::Model::ThemeColor& focused,
|
||||
|
||||
@@ -48,12 +48,15 @@ namespace winrt::TerminalApp::implementation
|
||||
void ShowBellIndicator(const bool show);
|
||||
void ActivateBellIndicatorTimer();
|
||||
|
||||
void ShowActivityIndicator(const bool show);
|
||||
void ActivateActivityIndicatorTimer();
|
||||
|
||||
float CalcSnappedDimension(const bool widthOrHeight, const float dimension) const;
|
||||
std::optional<winrt::Microsoft::Terminal::Settings::Model::SplitDirection> PreCalculateCanSplit(winrt::Microsoft::Terminal::Settings::Model::SplitDirection splitType,
|
||||
const float splitSize,
|
||||
winrt::Windows::Foundation::Size availableSpace) const;
|
||||
|
||||
void ResizePane(const winrt::Microsoft::Terminal::Settings::Model::ResizeDirection& direction);
|
||||
bool ResizePane(const winrt::Microsoft::Terminal::Settings::Model::ResizeDirection& direction);
|
||||
bool NavigateFocus(const winrt::Microsoft::Terminal::Settings::Model::FocusDirection& direction);
|
||||
bool SwapPane(const winrt::Microsoft::Terminal::Settings::Model::FocusDirection& direction);
|
||||
bool FocusPane(const uint32_t id);
|
||||
@@ -121,6 +124,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
til::typed_event<TerminalApp::Tab, IInspectable> ActivePaneChanged;
|
||||
til::event<winrt::delegate<>> TabRaiseVisualBell;
|
||||
til::event<winrt::delegate<winrt::hstring /*title*/, winrt::hstring /*body*/, winrt::TerminalApp::IPaneContent /*content*/>> TabToastNotificationRequested;
|
||||
til::typed_event<IInspectable, IInspectable> TaskbarProgressChanged;
|
||||
|
||||
// The TabViewIndex is the index this Tab object resides in TerminalPage's _tabs vector.
|
||||
@@ -140,11 +144,17 @@ namespace winrt::TerminalApp::implementation
|
||||
static constexpr double HeaderRenameBoxWidthTitleLength{ std::numeric_limits<double>::infinity() };
|
||||
|
||||
winrt::Windows::UI::Xaml::FocusState _focusState{ winrt::Windows::UI::Xaml::FocusState::Unfocused };
|
||||
winrt::Windows::UI::Xaml::Controls::MenuFlyoutItem _closeOtherTabsMenuItem{};
|
||||
winrt::Windows::UI::Xaml::Controls::MenuFlyoutItem _closeTabsAfterMenuItem{};
|
||||
winrt::Windows::UI::Xaml::Controls::MenuFlyoutItem _duplicateTabMenuItem{};
|
||||
winrt::Windows::UI::Xaml::Controls::MenuFlyoutItem _splitTabMenuItem{};
|
||||
winrt::Windows::UI::Xaml::Controls::MenuFlyoutItem _moveToNewWindowMenuItem{};
|
||||
winrt::Windows::UI::Xaml::Controls::MenuFlyoutItem _moveRightMenuItem{};
|
||||
winrt::Windows::UI::Xaml::Controls::MenuFlyoutItem _moveLeftMenuItem{};
|
||||
winrt::Windows::UI::Xaml::Controls::MenuFlyoutItem _exportTabMenuItem{};
|
||||
winrt::Windows::UI::Xaml::Controls::MenuFlyoutItem _findMenuItem{};
|
||||
winrt::Windows::UI::Xaml::Controls::MenuFlyoutItem _restartConnectionMenuItem{};
|
||||
winrt::Windows::UI::Xaml::Controls::MenuFlyoutItem _closeOtherTabsMenuItem{};
|
||||
winrt::Windows::UI::Xaml::Controls::MenuFlyoutItem _closeTabsAfterMenuItem{};
|
||||
winrt::Windows::UI::Xaml::Controls::MenuFlyoutItem _closePaneMenuItem{};
|
||||
winrt::TerminalApp::ShortcutActionDispatch _dispatch;
|
||||
Microsoft::Terminal::Settings::Model::IActionMapView _actionMap{ nullptr };
|
||||
winrt::hstring _keyChord{};
|
||||
@@ -159,9 +169,6 @@ namespace winrt::TerminalApp::implementation
|
||||
std::shared_ptr<Pane> _activePane{ nullptr };
|
||||
std::shared_ptr<Pane> _zoomedPane{ nullptr };
|
||||
|
||||
Windows::UI::Xaml::Controls::MenuFlyoutItem _closePaneMenuItem;
|
||||
Windows::UI::Xaml::Controls::MenuFlyoutItem _restartConnectionMenuItem;
|
||||
|
||||
winrt::Microsoft::Terminal::Settings::Model::IconStyle _lastIconStyle;
|
||||
winrt::hstring _lastIconPath{};
|
||||
std::optional<winrt::Windows::UI::Color> _runtimeTabColor{};
|
||||
@@ -182,10 +189,12 @@ namespace winrt::TerminalApp::implementation
|
||||
winrt::TerminalApp::IPaneContent::ConnectionStateChanged_revoker ConnectionStateChanged;
|
||||
winrt::TerminalApp::IPaneContent::ReadOnlyChanged_revoker ReadOnlyChanged;
|
||||
winrt::TerminalApp::IPaneContent::FocusRequested_revoker FocusRequested;
|
||||
winrt::TerminalApp::IPaneContent::NotificationRequested_revoker NotificationRequested;
|
||||
|
||||
// These events literally only apply if the content is a TermControl.
|
||||
winrt::Microsoft::Terminal::Control::TermControl::KeySent_revoker KeySent;
|
||||
winrt::Microsoft::Terminal::Control::TermControl::CharSent_revoker CharSent;
|
||||
winrt::Microsoft::Terminal::Control::TermControl::StringSent_revoker StringSent;
|
||||
|
||||
winrt::TerminalApp::TerminalPaneContent::RestartTerminalRequested_revoker RestartTerminalRequested;
|
||||
};
|
||||
@@ -209,6 +218,9 @@ namespace winrt::TerminalApp::implementation
|
||||
SafeDispatcherTimer _bellIndicatorTimer;
|
||||
void _BellIndicatorTimerTick(const Windows::Foundation::IInspectable& sender, const Windows::Foundation::IInspectable& e);
|
||||
|
||||
SafeDispatcherTimer _activityIndicatorTimer;
|
||||
void _ActivityIndicatorTimerTick(const Windows::Foundation::IInspectable& sender, const Windows::Foundation::IInspectable& e);
|
||||
|
||||
void _UpdateHeaderControlMaxWidth();
|
||||
|
||||
void _CreateContextMenu();
|
||||
@@ -219,6 +231,7 @@ namespace winrt::TerminalApp::implementation
|
||||
void _AttachEventHandlersToPane(std::shared_ptr<Pane> pane);
|
||||
|
||||
void _UpdateActivePane(std::shared_ptr<Pane> pane);
|
||||
void _UpdateMenuItemStates();
|
||||
|
||||
winrt::hstring _GetActiveTitle() const;
|
||||
|
||||
@@ -229,8 +242,6 @@ namespace winrt::TerminalApp::implementation
|
||||
void _UpdateConnectionClosedState();
|
||||
void _RestartActivePaneConnection();
|
||||
|
||||
void _DuplicateTab();
|
||||
|
||||
winrt::Windows::UI::Xaml::Media::Brush _BackgroundBrush();
|
||||
|
||||
void _MakeTabViewItem();
|
||||
|
||||
@@ -32,6 +32,12 @@
|
||||
FontSize="12"
|
||||
Glyph=""
|
||||
Visibility="{x:Bind TabStatus.BellIndicator, Mode=OneWay}" />
|
||||
<FontIcon x:Name="HeaderActivityIndicator"
|
||||
Margin="0,0,8,0"
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="8"
|
||||
Glyph=""
|
||||
Visibility="{x:Bind TabStatus.ActivityIndicator, Mode=OneWay}" />
|
||||
<FontIcon x:Name="HeaderZoomIcon"
|
||||
Margin="0,0,8,0"
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "TabRowControl.h"
|
||||
#include "DebugTapConnection.h"
|
||||
#include "DesktopNotification.h"
|
||||
#include "..\TerminalSettingsModel\FileUtils.h"
|
||||
#include "../TerminalSettingsAppAdapterLib/TerminalSettings.h"
|
||||
|
||||
@@ -150,6 +151,18 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
});
|
||||
|
||||
// When a tab requests a desktop toast notification, send the toast
|
||||
// and handle activation by summoning this window and switching to the tab.
|
||||
newTabImpl->TabToastNotificationRequested([weakThis{ get_weak() }, weakTab{ newTabImpl->get_weak() }](const winrt::hstring& title, const winrt::hstring& body, const winrt::TerminalApp::IPaneContent& content) {
|
||||
if (const auto page{ weakThis.get() })
|
||||
{
|
||||
if (const auto tab{ weakTab.get() })
|
||||
{
|
||||
page->_SendDesktopNotification(title, body, tab, content);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
auto tabViewItem = newTabImpl->TabViewItem();
|
||||
_tabView.TabItems().InsertAt(insertPosition, tabViewItem);
|
||||
|
||||
@@ -394,7 +407,9 @@ namespace winrt::TerminalApp::implementation
|
||||
// - Removes the tab (both TerminalControl and XAML) after prompting for approval
|
||||
// Arguments:
|
||||
// - tab: the tab to remove
|
||||
winrt::Windows::Foundation::IAsyncAction TerminalPage::_HandleCloseTabRequested(winrt::TerminalApp::Tab tab)
|
||||
// - skipConfirmClose: if true, skip the confirmOnClose check. Used when
|
||||
// an aggregate confirmation has already been shown (i.e. close other tabs)
|
||||
winrt::Windows::Foundation::IAsyncAction TerminalPage::_HandleCloseTabRequested(winrt::TerminalApp::Tab tab, bool skipConfirmClose)
|
||||
{
|
||||
winrt::com_ptr<TerminalPage> strong;
|
||||
|
||||
@@ -413,6 +428,24 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
}
|
||||
|
||||
// Skip the per-tab confirmOnClose check when the caller has already
|
||||
// shown an aggregate confirmation dialog (e.g. _RemoveTabs).
|
||||
if (!skipConfirmClose)
|
||||
{
|
||||
const auto tabImpl = _GetTabImpl(tab);
|
||||
if (tabImpl && _ShouldWarnOnCloseTab(tabImpl))
|
||||
{
|
||||
const auto weak = get_weak();
|
||||
|
||||
auto warningResult = co_await _ShowConfirmCloseDialog(ConfirmCloseDialogKind::Tab);
|
||||
strong = weak.get();
|
||||
if (!strong || warningResult != ContentDialogResult::Primary)
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto t = winrt::get_self<implementation::Tab>(tab);
|
||||
auto actions = t->BuildStartupActions(BuildStartupKind::None);
|
||||
_AddPreviouslyClosedPaneOrTab(std::move(actions));
|
||||
@@ -438,6 +471,21 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
const auto focusedTabIndex{ _GetFocusedTabIndex() };
|
||||
|
||||
// If this is the last tab in a named window, persist the workspace
|
||||
// layout now—before the tab is shut down—so GetWindowLayout() can
|
||||
// still see its tab data.
|
||||
if (_tabs.Size() == 1)
|
||||
{
|
||||
const auto& windowName = _WindowProperties.WindowName();
|
||||
if (!windowName.empty())
|
||||
{
|
||||
if (const auto layout = GetWindowLayout())
|
||||
{
|
||||
ApplicationState::SharedInstance().SaveWorkspace(windowName, layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Removing the tab from the collection should destroy its control and disconnect its connection,
|
||||
// but it doesn't always do so. The UI tree may still be holding the control and preventing its destruction.
|
||||
tab.Shutdown();
|
||||
@@ -782,6 +830,26 @@ namespace winrt::TerminalApp::implementation
|
||||
if (const auto pane{ activeTab->GetActivePane() })
|
||||
{
|
||||
const auto weak = get_weak();
|
||||
|
||||
// Check if we should warn before closing a single pane
|
||||
// (only triggers on Always — Automatic doesn't warn for single pane)
|
||||
const auto setting = _settings.GlobalSettings().ConfirmOnClose();
|
||||
if (setting == ConfirmOnClose::Always)
|
||||
{
|
||||
// If this is the last pane, closing it closes the tab,
|
||||
// so use the tab dialog text instead.
|
||||
const auto kind = activeTab->GetLeafPaneCount() == 1 ? ConfirmCloseDialogKind::Tab : ConfirmCloseDialogKind::Pane;
|
||||
auto warningResult = co_await _ShowConfirmCloseDialog(kind);
|
||||
|
||||
// Hold a strong reference to `this` for the rest of the
|
||||
// method; we may be the last holder after `co_await`.
|
||||
auto strong = weak.get();
|
||||
if (!strong || warningResult != ContentDialogResult::Primary)
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
}
|
||||
|
||||
if (co_await _PaneConfirmCloseReadOnly(pane))
|
||||
{
|
||||
if (const auto strong = weak.get())
|
||||
@@ -795,10 +863,37 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
// Method Description:
|
||||
// - Close all panes with the given IDs sequentially.
|
||||
// - Shows a single aggregate confirmation dialog upfront if the confirmOnClose setting warrants it.
|
||||
// Arguments:
|
||||
// - weakTab: weak reference to the tab that the pane belongs to.
|
||||
// - weakTab: weak reference to the tab that the panes belong to.
|
||||
// - paneIds: collection of the IDs of the panes that are marked for removal.
|
||||
void TerminalPage::_ClosePanes(weak_ref<Tab> weakTab, std::vector<uint32_t> paneIds)
|
||||
safe_void_coroutine TerminalPage::_ClosePanes(weak_ref<Tab> weakTab, std::vector<uint32_t> paneIds)
|
||||
{
|
||||
// Show a single aggregate confirmation for closing multiple panes.
|
||||
if (_settings.GlobalSettings().ConfirmOnClose() != ConfirmOnClose::Never)
|
||||
{
|
||||
const auto weak = get_weak();
|
||||
auto warningResult = co_await _ShowConfirmCloseDialog(ConfirmCloseDialogKind::MultiplePanes);
|
||||
|
||||
// Hold a strong reference to `this` after the co_await; we may
|
||||
// be the last holder if the page was being torn down.
|
||||
auto strong = weak.get();
|
||||
if (!strong || warningResult != ContentDialogResult::Primary)
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
}
|
||||
_CloseRemainingPanes(weakTab, std::move(paneIds));
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Recursively closes panes by ID, chaining each close via the
|
||||
// ClosedByParent callback. Called after confirmation has already
|
||||
// been handled by _ClosePanes.
|
||||
// Arguments:
|
||||
// - weakTab: weak reference to the tab that the panes belong to
|
||||
// - paneIds: remaining pane IDs to close
|
||||
void TerminalPage::_CloseRemainingPanes(weak_ref<Tab> weakTab, std::vector<uint32_t> paneIds)
|
||||
{
|
||||
if (auto strongTab{ weakTab.get() })
|
||||
{
|
||||
@@ -813,10 +908,9 @@ namespace winrt::TerminalApp::implementation
|
||||
pane->ClosedByParent([ids{ std::move(paneIds) }, weakThis{ get_weak() }, weakTab]() {
|
||||
if (auto strongThis{ weakThis.get() })
|
||||
{
|
||||
strongThis->_ClosePanes(weakTab, std::move(ids));
|
||||
strongThis->_CloseRemainingPanes(weakTab, std::move(ids));
|
||||
}
|
||||
});
|
||||
|
||||
// Close the pane which will eventually trigger the closed by parent event
|
||||
_HandleClosePaneRequested(pane);
|
||||
break;
|
||||
@@ -841,18 +935,37 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
// Method Description:
|
||||
// - Closes provided tabs one by one
|
||||
// - Shows a single aggregate confirmation dialog upfront if the confirmOnClose setting warrants it.
|
||||
// Arguments:
|
||||
// - tabs - tabs to remove
|
||||
safe_void_coroutine TerminalPage::_RemoveTabs(const std::vector<winrt::TerminalApp::Tab> tabs)
|
||||
{
|
||||
if (tabs.empty())
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
|
||||
// Show a single aggregate confirmation instead of per-tab dialogs.
|
||||
const auto weak = get_weak();
|
||||
if (_settings.GlobalSettings().ConfirmOnClose() != ConfirmOnClose::Never)
|
||||
{
|
||||
auto warningResult = co_await _ShowConfirmCloseDialog(ConfirmCloseDialogKind::MultipleTabs);
|
||||
|
||||
// Hold a strong reference to `this` after the co_await so that
|
||||
// the for-loop below can safely dispatch on us.
|
||||
auto strong = weak.get();
|
||||
if (!strong || warningResult != ContentDialogResult::Primary)
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& tab : tabs)
|
||||
{
|
||||
winrt::Windows::Foundation::IAsyncAction action{ nullptr };
|
||||
if (const auto strong = weak.get())
|
||||
{
|
||||
action = _HandleCloseTabRequested(tab);
|
||||
action = _HandleCloseTabRequested(tab, /*skipConfirmClose*/ true);
|
||||
}
|
||||
|
||||
if (!action)
|
||||
@@ -1185,4 +1298,132 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
return _tabs.Size() > 1;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Attempts to find and focus the given tab in this window.
|
||||
// Arguments:
|
||||
// - tab: The tab to focus.
|
||||
// Return Value:
|
||||
// - true if the tab was found and focused, false otherwise.
|
||||
bool TerminalPage::FocusTab(const winrt::TerminalApp::Tab& tab)
|
||||
{
|
||||
if (const auto tabIndex{ _GetTabIndex(tab) })
|
||||
{
|
||||
_SelectTab(tabIndex.value());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sends a desktop toast notification with the given title and body.
|
||||
// When the toast is activated (clicked), the window is summoned and
|
||||
// the originating tab is focused.
|
||||
// Arguments:
|
||||
// - tabTitle: The title to display in the notification.
|
||||
// - body: The body text. If empty, a standard tab-activity message is built.
|
||||
// - tab: The tab to switch to when the toast is activated.
|
||||
void TerminalPage::_SendDesktopNotification(const winrt::hstring& tabTitle, const winrt::hstring& body, const winrt::com_ptr<Tab>& tab, const winrt::TerminalApp::IPaneContent& content)
|
||||
{
|
||||
// Don't send a notification if the window is focused and the requesting
|
||||
// pane is the active pane. The user is already looking at it.
|
||||
if (_activated && tab == _GetFocusedTabImpl())
|
||||
{
|
||||
if (const auto activePane{ tab->GetActivePane() })
|
||||
{
|
||||
if (activePane->GetContent() == content)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build the notification message.
|
||||
// If a custom body is provided (e.g. from OSC 777), use the title/body directly.
|
||||
// Otherwise, build the standard tab-activity notification message.
|
||||
winrt::hstring notificationTitle;
|
||||
winrt::hstring message;
|
||||
if (!body.empty())
|
||||
{
|
||||
notificationTitle = tabTitle;
|
||||
message = body;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use the window name if available for context; otherwise just use the tab title.
|
||||
// Use the raw WindowName (not WindowNameForDisplay) so we don't include
|
||||
// the "<unnamed window>" placeholder in the notification body.
|
||||
const auto windowName = _WindowProperties ? _WindowProperties.WindowName() : winrt::hstring{};
|
||||
if (!windowName.empty())
|
||||
{
|
||||
message = RS_fmt(L"NotificationMessage_TabActivityInWindow", std::wstring_view{ tabTitle }, std::wstring_view{ windowName });
|
||||
}
|
||||
else
|
||||
{
|
||||
message = RS_fmt(L"NotificationMessage_TabActivity", std::wstring_view{ tabTitle });
|
||||
}
|
||||
notificationTitle = CascadiaSettings::ApplicationDisplayName();
|
||||
}
|
||||
|
||||
// Use the Tab object's identity hash as a stable toast tag.
|
||||
// This survives tab reordering and cross-window moves.
|
||||
const auto tabHash = std::hash<winrt::Windows::Foundation::IUnknown>{}(*tab);
|
||||
#ifdef _WIN64
|
||||
const hstring tabTag{ fmt::format(FMT_COMPILE(L"wt-tab-{:016x}"), tabHash) };
|
||||
#else
|
||||
const hstring tabTag{ fmt::format(FMT_COMPILE(L"wt-tab-{:08x}"), tabHash) };
|
||||
#endif
|
||||
|
||||
const implementation::DesktopNotificationArgs args{
|
||||
.Title = notificationTitle,
|
||||
.Message = message,
|
||||
.Tag = tabTag
|
||||
};
|
||||
|
||||
implementation::DesktopNotification::SendNotification(args, [weakThis{ get_weak() }, weakTab{ tab->get_weak() }, weakContent{ winrt::make_weak(content) }]() {
|
||||
if (const auto page{ weakThis.get() })
|
||||
{
|
||||
// The toast Activated callback runs on a background thread.
|
||||
// Marshal to the UI thread for tab focus and window summon.
|
||||
page->Dispatcher().RunAsync(winrt::Windows::UI::Core::CoreDispatcherPriority::Normal, [weakThis, weakTab, weakContent]() {
|
||||
if (const auto p{ weakThis.get() })
|
||||
{
|
||||
if (const auto t{ weakTab.get() })
|
||||
{
|
||||
// Try to find and focus the tab in this window first.
|
||||
if (const auto tabIndex{ p->_GetTabIndex(*t) })
|
||||
{
|
||||
p->SummonWindowRequested.raise(nullptr, nullptr);
|
||||
p->_SelectTab(tabIndex.value());
|
||||
|
||||
// Focus the specific pane that raised the notification.
|
||||
if (const auto paneContent{ weakContent.get() })
|
||||
{
|
||||
const auto rootPane = t->GetRootPane();
|
||||
rootPane->WalkTree([&](const auto& pane) {
|
||||
if (pane->GetContent() == paneContent)
|
||||
{
|
||||
rootPane->FocusPane(pane);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// The tab may have moved to another window.
|
||||
// Raise FocusTabRequested so the emperor can
|
||||
// search all windows for it.
|
||||
p->FocusTabRequested.raise(nullptr, *t);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Tab was closed. Just summon this window.
|
||||
p->SummonWindowRequested.raise(nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,21 @@ namespace winrt::TerminalApp::implementation
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
void TabRowControl::WorkspaceName(const winrt::hstring& value)
|
||||
{
|
||||
if (_WorkspaceName != value)
|
||||
{
|
||||
_WorkspaceName = value;
|
||||
PropertyChanged.raise(*this, WUX::Data::PropertyChangedEventArgs{ L"WorkspaceName" });
|
||||
|
||||
// Collapse the name text when empty so the button shows only the icon.
|
||||
if (const auto textBlock = WorkspaceNameText())
|
||||
{
|
||||
textBlock.Visibility(value.empty() ? WUX::Visibility::Collapsed : WUX::Visibility::Visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Bound in the Xaml editor to the [+] button.
|
||||
// Arguments:
|
||||
|
||||
@@ -19,6 +19,14 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
til::property_changed_event PropertyChanged;
|
||||
WINRT_OBSERVABLE_PROPERTY(bool, ShowElevationShield, PropertyChanged.raise, false);
|
||||
WINRT_OBSERVABLE_PROPERTY(bool, ShowWindowsButton, PropertyChanged.raise, true);
|
||||
|
||||
public:
|
||||
winrt::hstring WorkspaceName() const noexcept { return _WorkspaceName; }
|
||||
void WorkspaceName(const winrt::hstring& value);
|
||||
|
||||
private:
|
||||
winrt::hstring _WorkspaceName{};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,5 +9,7 @@ namespace TerminalApp
|
||||
TabRowControl();
|
||||
Microsoft.UI.Xaml.Controls.TabView TabView { get; };
|
||||
Boolean ShowElevationShield;
|
||||
Boolean ShowWindowsButton;
|
||||
String WorkspaceName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,14 +35,43 @@
|
||||
TabWidthMode="Equal">
|
||||
|
||||
<mux:TabView.TabStripHeader>
|
||||
<!-- EA18 is the "Shield" glyph -->
|
||||
<FontIcon x:Uid="ElevationShield"
|
||||
Margin="9,4,0,4"
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="16"
|
||||
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
|
||||
Glyph=""
|
||||
Visibility="{x:Bind ShowElevationShield, Mode=OneWay}" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<!-- EA18 is the "Shield" glyph -->
|
||||
<FontIcon x:Uid="ElevationShield"
|
||||
Margin="9,4,0,4"
|
||||
FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="16"
|
||||
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
|
||||
Glyph=""
|
||||
Visibility="{x:Bind ShowElevationShield, Mode=OneWay}" />
|
||||
|
||||
<!-- Workspace/windows button -->
|
||||
<Button x:Name="WorkspaceDropdown"
|
||||
Margin="4,4,0,4"
|
||||
Padding="8,2,4,2"
|
||||
VerticalAlignment="Center"
|
||||
BorderThickness="0"
|
||||
Background="Transparent"
|
||||
Visibility="{x:Bind ShowWindowsButton, Mode=OneWay}">
|
||||
<Button.Content>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Spacing="4">
|
||||
<!-- EE40 is the "TaskViewSettings" glyph -->
|
||||
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="12"
|
||||
Glyph="" />
|
||||
<TextBlock x:Name="WorkspaceNameText"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="12"
|
||||
Visibility="Collapsed"
|
||||
Text="{x:Bind WorkspaceName, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
</Button.Content>
|
||||
<Button.Flyout>
|
||||
<MenuFlyout x:Name="WorkspaceFlyout" />
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</mux:TabView.TabStripHeader>
|
||||
|
||||
<mux:TabView.TabStripFooter>
|
||||
|
||||
@@ -9,27 +9,28 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
// Default to unset, 0%.
|
||||
TaskbarState::TaskbarState() :
|
||||
TaskbarState(0, 0) {};
|
||||
TaskbarState(winrt::Microsoft::Terminal::Control::TaskbarState::Clear, 0) {};
|
||||
|
||||
TaskbarState::TaskbarState(const uint64_t dispatchTypesState, const uint64_t progressParam) :
|
||||
_State{ dispatchTypesState },
|
||||
TaskbarState::TaskbarState(const winrt::Microsoft::Terminal::Control::TaskbarState state, const uint64_t progressParam) :
|
||||
_State{ state },
|
||||
_Progress{ progressParam } {}
|
||||
|
||||
uint64_t TaskbarState::Priority() const
|
||||
{
|
||||
// This seemingly nonsensical ordering is from
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setprogressstate#how-the-taskbar-button-chooses-the-progress-indicator-for-a-group
|
||||
using TbState = winrt::Microsoft::Terminal::Control::TaskbarState;
|
||||
switch (_State)
|
||||
{
|
||||
case 0: // Clear = 0,
|
||||
case TbState::Clear:
|
||||
return 5;
|
||||
case 1: // Set = 1,
|
||||
case TbState::Set:
|
||||
return 3;
|
||||
case 2: // Error = 2,
|
||||
case TbState::Error:
|
||||
return 1;
|
||||
case 3: // Indeterminate = 3,
|
||||
case TbState::Indeterminate:
|
||||
return 4;
|
||||
case 4: // Paused = 4
|
||||
case TbState::Paused:
|
||||
return 2;
|
||||
}
|
||||
// Here, return 6, to definitely be greater than all the other valid values.
|
||||
|
||||
@@ -16,13 +16,13 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
public:
|
||||
TaskbarState();
|
||||
TaskbarState(const uint64_t dispatchTypesState, const uint64_t progress);
|
||||
TaskbarState(const winrt::Microsoft::Terminal::Control::TaskbarState state, const uint64_t progress);
|
||||
|
||||
static int ComparePriority(const winrt::TerminalApp::TaskbarState& lhs, const winrt::TerminalApp::TaskbarState& rhs);
|
||||
|
||||
uint64_t Priority() const;
|
||||
|
||||
WINRT_PROPERTY(uint64_t, State, 0);
|
||||
WINRT_PROPERTY(winrt::Microsoft::Terminal::Control::TaskbarState, State, winrt::Microsoft::Terminal::Control::TaskbarState::Clear);
|
||||
WINRT_PROPERTY(uint64_t, Progress, 0);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace TerminalApp
|
||||
[default_interface] runtimeclass TaskbarState
|
||||
{
|
||||
TaskbarState();
|
||||
TaskbarState(UInt64 dispatchTypesState, UInt64 progress);
|
||||
TaskbarState(Microsoft.Terminal.Control.TaskbarState state, UInt64 progress);
|
||||
|
||||
UInt64 State{ get; };
|
||||
Microsoft.Terminal.Control.TaskbarState State{ get; };
|
||||
UInt64 Progress{ get; };
|
||||
UInt64 Priority { get; };
|
||||
}
|
||||
|
||||
@@ -174,6 +174,7 @@
|
||||
<DependentUpon>TerminalPaneContent.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Toast.h" />
|
||||
<ClInclude Include="DesktopNotification.h" />
|
||||
<ClInclude Include="TerminalSettingsCache.h" />
|
||||
<ClInclude Include="SuggestionsControl.h">
|
||||
<DependentUpon>SuggestionsControl.xaml</DependentUpon>
|
||||
@@ -287,6 +288,7 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
||||
<ClCompile Include="Toast.cpp" />
|
||||
<ClCompile Include="DesktopNotification.cpp" />
|
||||
<ClCompile Include="TerminalSettingsCache.cpp" />
|
||||
<ClCompile Include="SuggestionsControl.cpp">
|
||||
<DependentUpon>SuggestionsControl.xaml</DependentUpon>
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "TerminalSettingsCache.h"
|
||||
|
||||
#include "LaunchPositionRequest.g.cpp"
|
||||
#include "WindowListEntry.g.cpp"
|
||||
#include "WindowListRequest.g.cpp"
|
||||
#include "RenameWindowRequestedArgs.g.cpp"
|
||||
#include "RequestMoveContentArgs.g.cpp"
|
||||
#include "TerminalPage.g.cpp"
|
||||
@@ -37,7 +39,6 @@ using namespace winrt::Microsoft::Terminal::TerminalConnection;
|
||||
using namespace winrt::Microsoft::Terminal;
|
||||
using namespace winrt::Windows::ApplicationModel::DataTransfer;
|
||||
using namespace winrt::Windows::Foundation::Collections;
|
||||
using namespace winrt::Windows::Storage::Streams;
|
||||
using namespace winrt::Windows::System;
|
||||
using namespace winrt::Windows::UI;
|
||||
using namespace winrt::Windows::UI::Core;
|
||||
@@ -335,6 +336,20 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
auto tabRowImpl = winrt::get_self<implementation::TabRowControl>(_tabRow);
|
||||
_newTabButton = tabRowImpl->NewTabButton();
|
||||
_workspaceFlyout = tabRowImpl->WorkspaceFlyout();
|
||||
|
||||
// Set the initial workspace name from the window name.
|
||||
// Use raw WindowName() so unnamed windows show no text.
|
||||
_tabRow.WorkspaceName(_WindowProperties.WindowName());
|
||||
|
||||
// Rebuild the workspace flyout each time it opens so it always
|
||||
// reflects the latest set of persisted workspaces.
|
||||
_workspaceFlyout.Opening([weakThis{ get_weak() }](auto&&, auto&&) {
|
||||
if (auto page{ weakThis.get() })
|
||||
{
|
||||
page->_PopulateWorkspaceFlyout();
|
||||
}
|
||||
});
|
||||
|
||||
if (_settings.GlobalSettings().ShowTabsInTitlebar())
|
||||
{
|
||||
@@ -444,6 +459,12 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
_tabRow.ShowElevationShield(IsRunningElevated() && _settings.GlobalSettings().ShowAdminShield());
|
||||
|
||||
// Apply the ShowWindowsButton theme setting.
|
||||
if (const auto theme = _settings.GlobalSettings().CurrentTheme())
|
||||
{
|
||||
_tabRow.ShowWindowsButton(theme.Window() ? theme.Window().ShowWindowsButton() : true);
|
||||
}
|
||||
|
||||
_adjustProcessPriorityThrottled = std::make_shared<ThrottledFunc<>>(
|
||||
DispatcherQueue::GetForCurrentThread(),
|
||||
til::throttled_func_options{
|
||||
@@ -885,26 +906,78 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Displays a dialog to warn the user that they are about to close all open windows.
|
||||
// Once the user clicks the OK button, shut down the application.
|
||||
// If cancel is clicked, the dialog will close.
|
||||
// - Displays the unified close confirmation dialog configured for the
|
||||
// given scenario. Resets the "don't ask me again" checkbox before showing.
|
||||
// If the user confirms and checked "don't ask me again", sets
|
||||
// confirmOnClose to Never and writes settings to disk.
|
||||
// - Only one dialog can be visible at a time. If another dialog is visible
|
||||
// when this is called, nothing happens. See _ShowDialog for details
|
||||
winrt::Windows::Foundation::IAsyncOperation<ContentDialogResult> TerminalPage::_ShowQuitDialog()
|
||||
winrt::Windows::Foundation::IAsyncOperation<ContentDialogResult> TerminalPage::_ShowConfirmCloseDialog(ConfirmCloseDialogKind kind)
|
||||
{
|
||||
return _ShowDialogHelper(L"QuitDialog");
|
||||
}
|
||||
// Load the dialog (triggers x:Load) and configure its strings.
|
||||
const auto dialog = FindName(L"ConfirmCloseDialog").as<ContentDialog>();
|
||||
|
||||
// Method Description:
|
||||
// - Displays a dialog for warnings found while closing the terminal app using
|
||||
// key binding with multiple tabs opened. Display messages to warn user
|
||||
// that more than 1 tab is opened, and once the user clicks the OK button, remove
|
||||
// all the tabs and shut down and app. If cancel is clicked, the dialog will close
|
||||
// - Only one dialog can be visible at a time. If another dialog is visible
|
||||
// when this is called, nothing happens. See _ShowDialog for details
|
||||
winrt::Windows::Foundation::IAsyncOperation<ContentDialogResult> TerminalPage::_ShowCloseWarningDialog()
|
||||
{
|
||||
return _ShowDialogHelper(L"CloseAllDialog");
|
||||
winrt::hstring title;
|
||||
winrt::hstring primary;
|
||||
switch (kind)
|
||||
{
|
||||
case ConfirmCloseDialogKind::CloseAll:
|
||||
title = RS_(L"ConfirmCloseDialog_CloseAllTitle");
|
||||
primary = RS_(L"ConfirmCloseDialog_CloseAllPrimary");
|
||||
break;
|
||||
case ConfirmCloseDialogKind::Window:
|
||||
title = RS_(L"ConfirmCloseDialog_WindowTitle");
|
||||
primary = RS_(L"ConfirmCloseDialog_WindowPrimary");
|
||||
break;
|
||||
case ConfirmCloseDialogKind::Tab:
|
||||
title = RS_(L"ConfirmCloseDialog_TabTitle");
|
||||
primary = RS_(L"ConfirmCloseDialog_TabPrimary");
|
||||
break;
|
||||
case ConfirmCloseDialogKind::MultiplePanes:
|
||||
title = RS_(L"ConfirmCloseDialog_MultiplePanesTitle");
|
||||
primary = RS_(L"ConfirmCloseDialog_MultiplePanesPrimary");
|
||||
break;
|
||||
case ConfirmCloseDialogKind::MultipleTabs:
|
||||
title = RS_(L"ConfirmCloseDialog_MultipleTabsTitle");
|
||||
primary = RS_(L"ConfirmCloseDialog_MultipleTabsPrimary");
|
||||
break;
|
||||
case ConfirmCloseDialogKind::Pane:
|
||||
title = RS_(L"ConfirmCloseDialog_PaneTitle");
|
||||
primary = RS_(L"ConfirmCloseDialog_PanePrimary");
|
||||
break;
|
||||
}
|
||||
dialog.Title(winrt::box_value(title));
|
||||
dialog.PrimaryButtonText(primary);
|
||||
dialog.CloseButtonText(RS_(L"ConfirmCloseDialog_Cancel"));
|
||||
|
||||
// BODGY: After a ContentDialog is dismissed, FindName() can no longer
|
||||
// resolve children inside it. Use Content() to get the checkbox directly.
|
||||
const auto checkbox = dialog.Content().as<CheckBox>();
|
||||
checkbox.IsChecked(false);
|
||||
|
||||
auto result = ContentDialogResult::None;
|
||||
if (auto presenter{ _dialogPresenter.get() })
|
||||
{
|
||||
const auto weak = get_weak();
|
||||
result = co_await presenter.ShowDialog(dialog);
|
||||
|
||||
// ShowDialog blocks until the dialog is dismissed, so it is
|
||||
// possible for `this` to be torn down while we wait. Re-acquire
|
||||
// a strong reference before touching any of our state.
|
||||
const auto strong = weak.get();
|
||||
if (!strong)
|
||||
{
|
||||
co_return ContentDialogResult::None;
|
||||
}
|
||||
|
||||
if (result == ContentDialogResult::Primary && checkbox.IsChecked().Value())
|
||||
{
|
||||
_settings.GlobalSettings().ConfirmOnClose(ConfirmOnClose::Never);
|
||||
_settings.WriteSettingsToDisk();
|
||||
}
|
||||
}
|
||||
|
||||
co_return result;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -1965,9 +2038,6 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
term.OpenHyperlink({ this, &TerminalPage::_OpenHyperlinkHandler });
|
||||
|
||||
term.DragOver({ this, &TerminalPage::_ControlDragOverHandler });
|
||||
term.Drop({ this, &TerminalPage::_ControlDragDropHandler });
|
||||
|
||||
// Add an event handler for when the terminal or tab wants to set a
|
||||
// progress indicator on the taskbar
|
||||
term.SetTaskbarProgress({ get_weak(), &TerminalPage::_SetTaskbarProgressHandler });
|
||||
@@ -2213,12 +2283,13 @@ namespace winrt::TerminalApp::implementation
|
||||
// signal that we want to close everything.
|
||||
safe_void_coroutine TerminalPage::RequestQuit()
|
||||
{
|
||||
if (!_displayingCloseDialog)
|
||||
const auto setting = _settings.GlobalSettings().ConfirmOnClose();
|
||||
if (setting != ConfirmOnClose::Never && !_displayingCloseDialog)
|
||||
{
|
||||
_displayingCloseDialog = true;
|
||||
|
||||
const auto weak = get_weak();
|
||||
auto warningResult = co_await _ShowQuitDialog();
|
||||
auto warningResult = co_await _ShowConfirmCloseDialog(ConfirmCloseDialogKind::CloseAll);
|
||||
const auto strong = weak.get();
|
||||
if (!strong)
|
||||
{
|
||||
@@ -2231,19 +2302,19 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
|
||||
QuitRequested.raise(nullptr, nullptr);
|
||||
}
|
||||
|
||||
QuitRequested.raise(nullptr, nullptr);
|
||||
}
|
||||
|
||||
void TerminalPage::PersistState()
|
||||
WindowLayout TerminalPage::GetWindowLayout()
|
||||
{
|
||||
// This method may be called for a window even if it hasn't had a tab yet or lost all of them.
|
||||
// We shouldn't persist such windows.
|
||||
const auto tabCount = _tabs.Size();
|
||||
if (_startupState != StartupState::Initialized || tabCount == 0)
|
||||
{
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<ActionAndArgs> actions;
|
||||
@@ -2258,7 +2329,7 @@ namespace winrt::TerminalApp::implementation
|
||||
// Avoid persisting a window with zero tabs, because `BuildStartupActions` happened to return an empty vector.
|
||||
if (actions.empty())
|
||||
{
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// if the focused tab was not the last tab, restore that
|
||||
@@ -2307,16 +2378,105 @@ namespace winrt::TerminalApp::implementation
|
||||
RequestLaunchPosition.raise(*this, launchPosRequest);
|
||||
layout.InitialPosition(launchPosRequest.Position());
|
||||
|
||||
ApplicationState::SharedInstance().AppendPersistedWindowLayout(layout);
|
||||
return layout;
|
||||
}
|
||||
|
||||
void TerminalPage::PersistState()
|
||||
{
|
||||
// There are two persistence mechanisms in play here:
|
||||
// * PersistedWindowLayouts (vector) — consumed on next startup to
|
||||
// re-open a matching set of windows. Cleared after restore.
|
||||
// * PersistedWorkspaces (name-keyed map) — the full tab/buffer
|
||||
// state of a named window, claimed by name on demand via
|
||||
// ApplicationState::TakeWorkspace.
|
||||
//
|
||||
// For named windows we save the full layout into the workspace map
|
||||
// and drop a lightweight `openWorkspace` stub into the generic vector,
|
||||
// so the generic restore path re-opens the named window which in
|
||||
// turn claims its own workspace. Unnamed windows don't have a stable
|
||||
// key, so their full layout is stored directly in the vector.
|
||||
if (const auto layout = GetWindowLayout())
|
||||
{
|
||||
const auto& windowName = _WindowProperties.WindowName();
|
||||
if (!windowName.empty())
|
||||
{
|
||||
// Persist the full layout into the workspace collection.
|
||||
ApplicationState::SharedInstance().SaveWorkspace(windowName, layout);
|
||||
|
||||
// Build a minimal layout with just an openWorkspace action
|
||||
// so the generic restore path re-opens this workspace by name.
|
||||
std::vector<ActionAndArgs> actions;
|
||||
ActionAndArgs action;
|
||||
action.Action(ShortcutAction::OpenWorkspace);
|
||||
OpenWorkspaceArgs args{ windowName };
|
||||
action.Args(args);
|
||||
actions.emplace_back(std::move(action));
|
||||
|
||||
WindowLayout stub;
|
||||
stub.TabLayout(winrt::single_threaded_vector<ActionAndArgs>(std::move(actions)));
|
||||
ApplicationState::SharedInstance().AppendPersistedWindowLayout(stub);
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplicationState::SharedInstance().AppendPersistedWindowLayout(layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Close the terminal app. If there is more
|
||||
// than one tab opened, show a warning dialog.
|
||||
// - Determines whether a close-window action should show a confirmation
|
||||
// dialog, based on the confirmOnClose setting and the current window state.
|
||||
// Arguments:
|
||||
// - <none>
|
||||
// Return Value:
|
||||
// - true, if a warning dialog should be shown before closing the window
|
||||
bool TerminalPage::_ShouldWarnOnClose() const
|
||||
{
|
||||
const auto setting = _settings.GlobalSettings().ConfirmOnClose();
|
||||
switch (setting)
|
||||
{
|
||||
case ConfirmOnClose::Always:
|
||||
return true;
|
||||
case ConfirmOnClose::Automatic:
|
||||
{
|
||||
// Warn if there's more than one tab, or the one tab has more than one pane.
|
||||
return _HasMultipleTabs() || _GetTabImpl(_tabs.GetAt(0))->GetLeafPaneCount() > 1;
|
||||
}
|
||||
case ConfirmOnClose::Never:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Determines whether closing a specific tab should show a confirmation
|
||||
// dialog, based on the confirmOnClose setting and the tab's state.
|
||||
// Arguments:
|
||||
// - tab: The tab being closed
|
||||
// Return Value:
|
||||
// - true, if a warning dialog should be shown before closing the tab
|
||||
bool TerminalPage::_ShouldWarnOnCloseTab(const winrt::com_ptr<Tab>& tab) const
|
||||
{
|
||||
const auto setting = _settings.GlobalSettings().ConfirmOnClose();
|
||||
switch (setting)
|
||||
{
|
||||
case ConfirmOnClose::Always:
|
||||
return true;
|
||||
case ConfirmOnClose::Automatic:
|
||||
// Warn if this tab has more than one pane.
|
||||
return tab->GetLeafPaneCount() > 1;
|
||||
case ConfirmOnClose::Never:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Close the terminal app. If the confirmOnClose setting indicates we should
|
||||
// warn for the current window state, show a warning dialog.
|
||||
safe_void_coroutine TerminalPage::CloseWindow()
|
||||
{
|
||||
if (_HasMultipleTabs() &&
|
||||
_settings.GlobalSettings().ConfirmCloseAllTabs() &&
|
||||
if (_ShouldWarnOnClose() &&
|
||||
!_displayingCloseDialog)
|
||||
{
|
||||
if (_newTabButton && _newTabButton.Flyout())
|
||||
@@ -2325,7 +2485,17 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
_DismissTabContextMenus();
|
||||
_displayingCloseDialog = true;
|
||||
auto warningResult = co_await _ShowCloseWarningDialog();
|
||||
|
||||
const auto weak = get_weak();
|
||||
auto warningResult = co_await _ShowConfirmCloseDialog(ConfirmCloseDialogKind::Window);
|
||||
// Hold a strong reference to `this` after the co_await; we may
|
||||
// be the last holder if the window was already being torn down.
|
||||
auto strong = weak.get();
|
||||
if (!strong)
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
|
||||
_displayingCloseDialog = false;
|
||||
|
||||
if (warningResult != ContentDialogResult::Primary)
|
||||
@@ -2794,14 +2964,15 @@ namespace winrt::TerminalApp::implementation
|
||||
// Arguments:
|
||||
// - direction: The direction to move the separator in.
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void TerminalPage::_ResizePane(const ResizeDirection& direction)
|
||||
// - whether a pane was resized
|
||||
bool TerminalPage::_ResizePane(const ResizeDirection& direction)
|
||||
{
|
||||
if (const auto tabImpl{ _GetFocusedTabImpl() })
|
||||
{
|
||||
_UnZoomIfNeeded();
|
||||
tabImpl->ResizePane(direction);
|
||||
return tabImpl->ResizePane(direction);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -2949,7 +3120,9 @@ namespace winrt::TerminalApp::implementation
|
||||
// - Sends the text back to the TermControl through the event's
|
||||
// `HandleClipboardData` member function.
|
||||
// - Does some of this in a background thread, as to not hang/crash the UI thread.
|
||||
safe_void_coroutine TerminalPage::_PasteFromClipboardHandler(const IInspectable sender, const IInspectable /* args */)
|
||||
// Arguments:
|
||||
// - eventArgs: the PasteFromClipboard event sent from the TermControl
|
||||
safe_void_coroutine TerminalPage::_PasteFromClipboardHandler(const IInspectable sender, const PasteFromClipboardEventArgs eventArgs)
|
||||
try
|
||||
{
|
||||
// The old Win32 clipboard API as used below is somewhere in the order of 300-1000x faster than
|
||||
@@ -2957,19 +3130,8 @@ namespace winrt::TerminalApp::implementation
|
||||
const auto weakThis = get_weak();
|
||||
const auto dispatcher = Dispatcher();
|
||||
const auto globalSettings = _settings.GlobalSettings();
|
||||
const auto control = sender.as<TermControl>();
|
||||
const auto broadcastGroup = _getBroadcastGroupFromControl(control);
|
||||
// Used to determine whether to emit empty pastes and strip extra whitespace
|
||||
const auto anyHasBracketedPaste = std::any_of(std::begin(broadcastGroup), std::end(broadcastGroup), [](auto&& content) {
|
||||
const auto control{ content.GetTermControl() };
|
||||
return control && !control.ReadOnly() && control.BracketedPasteEnabled();
|
||||
});
|
||||
// Used to determine whether to warn on multi-line paste
|
||||
// If none lack bracketed paste, we can skip the warning.
|
||||
const auto anyHasUnbracketedPaste = !anyHasBracketedPaste || std::any_of(std::begin(broadcastGroup), std::end(broadcastGroup), [](auto&& content) {
|
||||
const auto control{ content.GetTermControl() };
|
||||
return control && !control.ReadOnly() && !control.BracketedPasteEnabled();
|
||||
});
|
||||
const auto bracketedPaste = eventArgs.BracketedPasteEnabled();
|
||||
const auto sourceId = sender.try_as<ControlInteractivity>().Id();
|
||||
|
||||
// GetClipboardData might block for up to 30s for delay-rendered contents.
|
||||
co_await winrt::resume_background();
|
||||
@@ -2980,11 +3142,8 @@ namespace winrt::TerminalApp::implementation
|
||||
text = clipboard::read();
|
||||
}
|
||||
|
||||
if (!anyHasBracketedPaste && globalSettings.TrimPaste())
|
||||
if (!bracketedPaste && globalSettings.TrimPaste())
|
||||
{
|
||||
// Warning - when broadcast is enabled, this will trim the paste for all receivers.
|
||||
// Until we propagate this decision-making elsewhere, this is safer; broadcast will not auto-submit commands in other panes.
|
||||
// Tracked in GH#20164
|
||||
text = winrt::hstring{ Utils::TrimPaste(text) };
|
||||
}
|
||||
|
||||
@@ -2992,7 +3151,7 @@ namespace winrt::TerminalApp::implementation
|
||||
// Bracketed Paste provides an application a way to know whether the
|
||||
// user pasted, even if there was no applicable content on it. This
|
||||
// behavior is observed in GNOME Terminal, among others.
|
||||
if (!anyHasBracketedPaste && text.empty())
|
||||
if (!bracketedPaste && text.empty())
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
@@ -3004,7 +3163,7 @@ namespace winrt::TerminalApp::implementation
|
||||
// NOTE that this is unsafe, because a shell that doesn't support bracketed paste
|
||||
// will allow an attacker to enable the mode, not realize that, and then accept
|
||||
// the paste as if it was a series of legitimate commands. See GH#13014.
|
||||
warnMultiLine = anyHasUnbracketedPaste;
|
||||
warnMultiLine = !bracketedPaste;
|
||||
break;
|
||||
case WarnAboutMultiLinePaste::Always:
|
||||
warnMultiLine = true;
|
||||
@@ -3074,7 +3233,30 @@ namespace winrt::TerminalApp::implementation
|
||||
// This will end up calling ConptyConnection::WriteInput which calls WriteFile which may block for
|
||||
// an indefinite amount of time. Avoid freezes and deadlocks by running this on a background thread.
|
||||
assert(!dispatcher.HasThreadAccess());
|
||||
_writeInputStringToBroadcastGroup(broadcastGroup, text, WriteInputStringType::Clipboard);
|
||||
eventArgs.HandleClipboardData(text);
|
||||
|
||||
// GH#18821: If broadcast input is active, paste the same text into all other
|
||||
// panes on the tab. We do this here (rather than re-reading the
|
||||
// clipboard per-pane) so that only one paste warning is shown.
|
||||
co_await wil::resume_foreground(dispatcher);
|
||||
if (const auto strongThis = weakThis.get())
|
||||
{
|
||||
if (const auto& tab{ strongThis->_GetFocusedTabImpl() })
|
||||
{
|
||||
if (tab->TabStatus().IsInputBroadcastActive())
|
||||
{
|
||||
tab->GetRootPane()->WalkTree([&](auto&& pane) {
|
||||
if (const auto control = pane->GetTerminalControl())
|
||||
{
|
||||
if (control.ContentId() != sourceId && !control.ReadOnly())
|
||||
{
|
||||
control.RawWriteString(text);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CATCH_LOG();
|
||||
|
||||
@@ -3429,6 +3611,16 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Paste text from the Windows Clipboard to the focused terminal
|
||||
void TerminalPage::_PasteText()
|
||||
{
|
||||
if (const auto& control{ _GetActiveControl() })
|
||||
{
|
||||
control.PasteTextFromClipboard();
|
||||
}
|
||||
}
|
||||
|
||||
// Function Description:
|
||||
// - Called when the settings button is clicked. ShellExecutes the settings
|
||||
// file, as to open it in the default editor for .json files. Does this in
|
||||
@@ -3917,6 +4109,12 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
_tabRow.ShowElevationShield(IsRunningElevated() && _settings.GlobalSettings().ShowAdminShield());
|
||||
|
||||
// Apply the ShowWindowsButton theme setting.
|
||||
if (const auto theme = _settings.GlobalSettings().CurrentTheme())
|
||||
{
|
||||
_tabRow.ShowWindowsButton(theme.Window() ? theme.Window().ShowWindowsButton() : true);
|
||||
}
|
||||
|
||||
Media::SolidColorBrush transparent{ Windows::UI::Colors::Transparent() };
|
||||
_tabView.Background(transparent);
|
||||
|
||||
@@ -5557,6 +5755,156 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuild the workspace flyout contents. Called every time the flyout opens
|
||||
// so it reflects the current set of persisted workspaces.
|
||||
void TerminalPage::_PopulateWorkspaceFlyout()
|
||||
{
|
||||
if (!_workspaceFlyout)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_workspaceFlyout.Items().Clear();
|
||||
|
||||
// --- "Name / Rename this window" ---
|
||||
{
|
||||
MenuFlyoutItem item{};
|
||||
item.Text(_WindowProperties.WindowName().empty() ? RS_(L"NameThisWindowMenuItem") : RS_(L"RenameThisWindowMenuItem"));
|
||||
|
||||
auto iconElement = UI::IconPathConverter::IconWUX(L"\uE8AC"); // Rename glyph
|
||||
Automation::AutomationProperties::SetAccessibilityView(iconElement, Automation::Peers::AccessibilityView::Raw);
|
||||
item.Icon(iconElement);
|
||||
|
||||
item.Click([weakThis{ get_weak() }](auto&&, auto&&) {
|
||||
if (auto page{ weakThis.get() })
|
||||
{
|
||||
// Re-use the existing openWindowRenamer action.
|
||||
page->_actionDispatch->DoAction(ActionAndArgs{ ShortcutAction::OpenWindowRenamer, nullptr });
|
||||
}
|
||||
});
|
||||
_workspaceFlyout.Items().Append(item);
|
||||
}
|
||||
|
||||
// --- Gather open window info first so we can filter workspaces ---
|
||||
// Ask the host (via AppHost → WindowEmperor) for all live windows.
|
||||
const auto windowListReq{ winrt::make<WindowListRequest>() };
|
||||
RequestWindowList.raise(*this, windowListReq);
|
||||
const auto windowEntries = windowListReq.Entries();
|
||||
|
||||
// Collect the names of all currently-open windows so we can hide
|
||||
// workspaces that are already live from the saved-workspaces list.
|
||||
std::set<winrt::hstring> openWindowNames;
|
||||
if (windowEntries)
|
||||
{
|
||||
for (const auto& entry : windowEntries)
|
||||
{
|
||||
const auto& name = entry.Name();
|
||||
if (!name.empty())
|
||||
{
|
||||
openWindowNames.emplace(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Saved workspaces section (only those not currently open) ---
|
||||
const auto workspaces = ApplicationState::SharedInstance().AllPersistedWorkspaces();
|
||||
if (workspaces && workspaces.Size() > 0)
|
||||
{
|
||||
bool addedSeparator = false;
|
||||
|
||||
for (const auto& pair : workspaces)
|
||||
{
|
||||
const auto name = pair.Key();
|
||||
|
||||
// Skip workspaces that correspond to a currently-open window.
|
||||
if (openWindowNames.count(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!addedSeparator)
|
||||
{
|
||||
_workspaceFlyout.Items().Append(MenuFlyoutSeparator{});
|
||||
addedSeparator = true;
|
||||
}
|
||||
|
||||
MenuFlyoutItem item{};
|
||||
item.Text(name);
|
||||
|
||||
auto iconElement = UI::IconPathConverter::IconWUX(L"\uE8F1"); // SwitchApps glyph
|
||||
Automation::AutomationProperties::SetAccessibilityView(iconElement, Automation::Peers::AccessibilityView::Raw);
|
||||
item.Icon(iconElement);
|
||||
|
||||
item.Click([weakThis{ get_weak() }, name](auto&&, auto&&) {
|
||||
if (auto page{ weakThis.get() })
|
||||
{
|
||||
page->_OpenWorkspaceWindow(name);
|
||||
}
|
||||
});
|
||||
|
||||
_workspaceFlyout.Items().Append(item);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Open windows section ---
|
||||
|
||||
if (windowEntries && windowEntries.Size() > 0)
|
||||
{
|
||||
_workspaceFlyout.Items().Append(MenuFlyoutSeparator{});
|
||||
|
||||
const auto thisWindowId = _WindowProperties.WindowId();
|
||||
|
||||
for (const auto& entry : windowEntries)
|
||||
{
|
||||
const auto id = entry.Id();
|
||||
const auto& name = entry.Name();
|
||||
|
||||
// Build display text like "#1: MyWindow" or "#2: <unnamed>"
|
||||
winrt::hstring displayText;
|
||||
if (name.empty())
|
||||
{
|
||||
displayText = winrt::hstring{ RS_fmt(L"WindowListUnnamedEntry", id) };
|
||||
}
|
||||
else
|
||||
{
|
||||
displayText = winrt::hstring{ fmt::format(FMT_COMPILE(L"#{}: {}"), id, name) };
|
||||
}
|
||||
|
||||
MenuFlyoutItem item{};
|
||||
item.Text(displayText);
|
||||
|
||||
// Use a different glyph for the current window
|
||||
if (id == thisWindowId)
|
||||
{
|
||||
auto iconElement = UI::IconPathConverter::IconWUX(L"\uE73E"); // CheckMark glyph
|
||||
Automation::AutomationProperties::SetAccessibilityView(iconElement, Automation::Peers::AccessibilityView::Raw);
|
||||
item.Icon(iconElement);
|
||||
item.IsEnabled(false); // Can't summon yourself
|
||||
}
|
||||
else
|
||||
{
|
||||
auto iconElement = UI::IconPathConverter::IconWUX(L"\uE737"); // ChromeRestore glyph
|
||||
Automation::AutomationProperties::SetAccessibilityView(iconElement, Automation::Peers::AccessibilityView::Raw);
|
||||
item.Icon(iconElement);
|
||||
|
||||
// Click handler: summon the target window by ID.
|
||||
// We raise SummonWindowByIdRequested which is handled by
|
||||
// AppHost to directly summon the window without creating
|
||||
// a new tab (unlike _OpenWorkspaceWindow which launches
|
||||
// `wt -w <name>` and creates a tab).
|
||||
item.Click([weakThis{ get_weak() }, id](auto&&, auto&&) {
|
||||
if (auto page{ weakThis.get() })
|
||||
{
|
||||
page->SummonWindowByIdRequested.raise(*page, winrt::make<SummonWindowByIdRequestedArgs>(id));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_workspaceFlyout.Items().Append(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handler for our WindowProperties's PropertyChanged event. We'll use this
|
||||
// to pop the "Identify Window" toast when the user renames our window.
|
||||
void TerminalPage::_windowPropertyChanged(const IInspectable& /*sender*/, const WUX::Data::PropertyChangedEventArgs& args)
|
||||
@@ -5566,6 +5914,10 @@ namespace winrt::TerminalApp::implementation
|
||||
return;
|
||||
}
|
||||
|
||||
// Keep the workspace dropdown label in sync with the window name.
|
||||
// Use raw WindowName() so clearing the name hides the text.
|
||||
_tabRow.WorkspaceName(_WindowProperties.WindowName());
|
||||
|
||||
// DON'T display the confirmation if this is the name we were
|
||||
// given on startup!
|
||||
if (_startupState == StartupState::Initialized)
|
||||
@@ -5810,326 +6162,4 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
return profileMenuItemFlyout;
|
||||
}
|
||||
|
||||
static void _translatePathInPlace(std::wstring& fullPath, PathTranslationStyle translationStyle)
|
||||
{
|
||||
static constexpr wil::zwstring_view s_pathPrefixes[] = {
|
||||
{},
|
||||
/* WSL */ L"/mnt/",
|
||||
/* Cygwin */ L"/cygdrive/",
|
||||
/* MSYS2 */ L"/",
|
||||
/* MinGW */ {},
|
||||
};
|
||||
static constexpr wil::zwstring_view sSingleQuoteEscape = L"'\\''";
|
||||
static constexpr auto cchSingleQuoteEscape = sSingleQuoteEscape.size();
|
||||
|
||||
if (translationStyle == PathTranslationStyle::None)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// All of the other path translation modes current result in /-delimited paths
|
||||
std::replace(fullPath.begin(), fullPath.end(), L'\\', L'/');
|
||||
|
||||
// Escape single quotes, assuming translated paths are always quoted by a pair of single quotes.
|
||||
size_t pos = 0;
|
||||
while ((pos = fullPath.find(L'\'', pos)) != std::wstring::npos)
|
||||
{
|
||||
// ' -> '\'' (for POSIX shell)
|
||||
fullPath.replace(pos, 1, sSingleQuoteEscape);
|
||||
// Arithmetic overflow cannot occur here.
|
||||
pos += cchSingleQuoteEscape;
|
||||
}
|
||||
|
||||
if (translationStyle == PathTranslationStyle::MinGW)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (fullPath.size() >= 2 && fullPath.at(1) == L':')
|
||||
{
|
||||
// C:/foo/bar -> Cc/foo/bar
|
||||
fullPath.at(1) = til::tolower_ascii(fullPath.at(0));
|
||||
// Cc/foo/bar -> [PREFIX]c/foo/bar
|
||||
fullPath.replace(0, 1, s_pathPrefixes[static_cast<int>(translationStyle)]);
|
||||
}
|
||||
else if (translationStyle == PathTranslationStyle::WSL)
|
||||
{
|
||||
// Stripping the UNC name and distribution prefix only applies to WSL.
|
||||
static constexpr std::wstring_view wslPathPrefixes[] = { L"//wsl.localhost/", L"//wsl$/" };
|
||||
for (auto prefix : wslPathPrefixes)
|
||||
{
|
||||
if (til::starts_with(fullPath, prefix))
|
||||
{
|
||||
if (const auto idx = fullPath.find(L'/', prefix.size()); idx != std::wstring::npos)
|
||||
{
|
||||
// //wsl.localhost/Ubuntu-18.04/foo/bar -> /foo/bar
|
||||
fullPath.erase(0, idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
// //wsl.localhost/Ubuntu-18.04 -> /
|
||||
fullPath = L"/";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Handle the DragOver event. We'll signal that the drag operation we
|
||||
// support is the "copy" operation, and we'll also customize the
|
||||
// appearance of the drag-drop UI, by removing the preview and setting a
|
||||
// custom caption. For more information, see
|
||||
// https://docs.microsoft.com/en-us/windows/uwp/design/input/drag-and-drop#customize-the-ui
|
||||
// Arguments:
|
||||
// - e: The DragEventArgs from the DragOver event
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void TerminalPage::_ControlDragOverHandler(const Windows::Foundation::IInspectable& /*sender*/,
|
||||
const DragEventArgs& e)
|
||||
{
|
||||
// We can only handle drag/dropping StorageItems (files) and plain Text
|
||||
// currently. If the format on the clipboard is anything else, returning
|
||||
// early here will prevent the drag/drop from doing anything.
|
||||
if (!(e.DataView().Contains(StandardDataFormats::StorageItems()) ||
|
||||
e.DataView().Contains(StandardDataFormats::Text())))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure to set the AcceptedOperation, so that we can later receive the path in the Drop event
|
||||
e.AcceptedOperation(DataPackageOperation::Copy);
|
||||
|
||||
// Sets custom UI text
|
||||
if (e.DataView().Contains(StandardDataFormats::StorageItems()))
|
||||
{
|
||||
e.DragUIOverride().Caption(RS_(L"DragFileCaption"));
|
||||
}
|
||||
else if (e.DataView().Contains(StandardDataFormats::Text()))
|
||||
{
|
||||
e.DragUIOverride().Caption(RS_(L"DragTextCaption"));
|
||||
}
|
||||
|
||||
// Sets if the caption is visible
|
||||
e.DragUIOverride().IsCaptionVisible(true);
|
||||
// Sets if the dragged content is visible
|
||||
e.DragUIOverride().IsContentVisible(false);
|
||||
// Sets if the glyph is visible
|
||||
e.DragUIOverride().IsGlyphVisible(false);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Async handler for the "Drop" event. If a file was dropped onto our
|
||||
// root, we'll try to get the path of the file dropped onto us, and write
|
||||
// the full path of the file to our terminal connection. Like conhost, if
|
||||
// the path contains a space, we'll wrap the path in quotes.
|
||||
// - Unlike conhost, if multiple files are dropped onto the terminal, we'll
|
||||
// write all the paths to the terminal, separated by spaces.
|
||||
// Arguments:
|
||||
// - e: The DragEventArgs from the Drop event
|
||||
// Return Value:
|
||||
// - <none>
|
||||
safe_void_coroutine TerminalPage::_ControlDragDropHandler(Windows::Foundation::IInspectable sender,
|
||||
DragEventArgs e)
|
||||
{
|
||||
auto dispatcher = Dispatcher();
|
||||
auto weak = get_weak();
|
||||
const auto control = sender.as<TermControl>();
|
||||
const auto broadcastGroup = _getBroadcastGroupFromControl(control);
|
||||
|
||||
if (_hostingHwnd)
|
||||
{
|
||||
SetForegroundWindow(*_hostingHwnd);
|
||||
}
|
||||
|
||||
if (e.DataView().Contains(StandardDataFormats::ApplicationLink()))
|
||||
{
|
||||
try
|
||||
{
|
||||
auto link{ co_await e.DataView().GetApplicationLinkAsync() };
|
||||
if (const auto strong = weak.get())
|
||||
{
|
||||
_writeInputStringToBroadcastGroup(broadcastGroup, link.AbsoluteUri(), WriteInputStringType::Clipboard);
|
||||
}
|
||||
}
|
||||
CATCH_LOG();
|
||||
}
|
||||
else if (e.DataView().Contains(StandardDataFormats::WebLink()))
|
||||
{
|
||||
try
|
||||
{
|
||||
auto link{ co_await e.DataView().GetWebLinkAsync() };
|
||||
if (const auto strong = weak.get())
|
||||
{
|
||||
_writeInputStringToBroadcastGroup(broadcastGroup, link.AbsoluteUri(), WriteInputStringType::Clipboard);
|
||||
}
|
||||
}
|
||||
CATCH_LOG();
|
||||
}
|
||||
else if (e.DataView().Contains(StandardDataFormats::Text()))
|
||||
{
|
||||
try
|
||||
{
|
||||
auto text{ co_await e.DataView().GetTextAsync() };
|
||||
if (const auto strong = weak.get())
|
||||
{
|
||||
_writeInputStringToBroadcastGroup(broadcastGroup, text, WriteInputStringType::Clipboard);
|
||||
}
|
||||
}
|
||||
CATCH_LOG();
|
||||
}
|
||||
// StorageItem must be last. Some applications put hybrid data format items
|
||||
// in a drop message and we'll eat a crash when we request them.
|
||||
// Those applications usually include Text as well, so having storage items
|
||||
// last makes sure we'll hit text before getting to them.
|
||||
else if (e.DataView().Contains(StandardDataFormats::StorageItems()))
|
||||
{
|
||||
Windows::Foundation::Collections::IVectorView<Windows::Storage::IStorageItem> items;
|
||||
try
|
||||
{
|
||||
items = co_await e.DataView().GetStorageItemsAsync();
|
||||
}
|
||||
CATCH_LOG();
|
||||
|
||||
if (items && items.Size() > 0)
|
||||
{
|
||||
std::vector<std::wstring> fullPaths;
|
||||
|
||||
// GH#14628: Workaround for GetStorageItemsAsync() only returning 16 items
|
||||
// at most when dragging and dropping from archives (zip, 7z, rar, etc.)
|
||||
if (items.Size() == 16 && e.DataView().Contains(winrt::hstring{ L"FileDrop" }))
|
||||
{
|
||||
auto fileDropData = co_await e.DataView().GetDataAsync(winrt::hstring{ L"FileDrop" });
|
||||
if (fileDropData != nullptr)
|
||||
{
|
||||
auto stream = fileDropData.as<IRandomAccessStream>();
|
||||
stream.Seek(0);
|
||||
|
||||
const uint32_t streamSize = gsl::narrow_cast<uint32_t>(stream.Size());
|
||||
const Buffer buf(streamSize);
|
||||
const auto buffer = co_await stream.ReadAsync(buf, streamSize, InputStreamOptions::None);
|
||||
|
||||
const HGLOBAL hGlobal = buffer.data();
|
||||
const auto count = DragQueryFileW(static_cast<HDROP>(hGlobal), 0xFFFFFFFF, nullptr, 0);
|
||||
fullPaths.reserve(count);
|
||||
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
std::wstring path;
|
||||
path.resize(wil::max_path_length);
|
||||
const auto charsCopied = DragQueryFileW(static_cast<HDROP>(hGlobal), i, path.data(), wil::max_path_length);
|
||||
|
||||
if (charsCopied > 0)
|
||||
{
|
||||
path.resize(charsCopied);
|
||||
fullPaths.emplace_back(std::move(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fullPaths.reserve(items.Size());
|
||||
for (const auto& item : items)
|
||||
{
|
||||
fullPaths.emplace_back(item.Path());
|
||||
}
|
||||
}
|
||||
|
||||
const auto strong = weak.get();
|
||||
if (!strong)
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
|
||||
// TODO(DH) the fuckin' delimiter from DragDropDelimiter
|
||||
std::unordered_map<PathTranslationStyle, winrt::hstring> translatedPaths;
|
||||
for (auto&& target : broadcastGroup)
|
||||
{
|
||||
const auto profile{ target.GetProfile() };
|
||||
auto translationStyle{ profile.PathTranslationStyle() };
|
||||
const auto broadcastTargetControl{ target.GetTermControl() };
|
||||
if (broadcastTargetControl.ReadOnly())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
auto [it, isNew] = translatedPaths.try_emplace(translationStyle, winrt::hstring{});
|
||||
if (isNew)
|
||||
{
|
||||
std::wstring allPathsString;
|
||||
for (auto fullPath : fullPaths)
|
||||
{
|
||||
// Join the paths with spaces
|
||||
if (!allPathsString.empty())
|
||||
{
|
||||
allPathsString += L" ";
|
||||
}
|
||||
|
||||
_translatePathInPlace(fullPath, translationStyle);
|
||||
|
||||
// All translated paths get quotes, and all strings spaces get quotes; all translated paths get single quotes
|
||||
const auto quotesNeeded = translationStyle != PathTranslationStyle::None || fullPath.find(L' ') != std::wstring::npos;
|
||||
const auto quotesChar = translationStyle != PathTranslationStyle::None ? L'\'' : L'"';
|
||||
|
||||
// Append fullPath and also wrap it in quotes if needed
|
||||
if (quotesNeeded)
|
||||
{
|
||||
allPathsString.push_back(quotesChar);
|
||||
}
|
||||
allPathsString.append(fullPath);
|
||||
if (quotesNeeded)
|
||||
{
|
||||
allPathsString.push_back(quotesChar);
|
||||
}
|
||||
}
|
||||
it->second = winrt::hstring{ allPathsString };
|
||||
}
|
||||
|
||||
broadcastTargetControl.WriteInputString(it->second, WriteInputStringType::Clipboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TerminalPage::broadcast_group TerminalPage::_getBroadcastGroupFromControl(const TermControl& control)
|
||||
{
|
||||
TerminalPage::broadcast_group contents;
|
||||
auto controlContent{ TerminalPaneContent::ContentFromControl(control) };
|
||||
if (controlContent)
|
||||
{
|
||||
contents.emplace_back(controlContent);
|
||||
}
|
||||
|
||||
if (const auto& tab{ _GetFocusedTabImpl() })
|
||||
{
|
||||
if (tab->TabStatus().IsInputBroadcastActive())
|
||||
{
|
||||
tab->GetRootPane()->WalkTree([&](auto&& pane) {
|
||||
if (auto content = pane->GetContent(); content && content != controlContent)
|
||||
{
|
||||
if (const auto termContent{ content.try_as<TerminalPaneContent>() })
|
||||
{
|
||||
contents.emplace_back(*termContent);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
||||
void TerminalPage::_writeInputStringToBroadcastGroup(const TerminalPage::broadcast_group& broadcastGroup, const winrt::hstring text, WriteInputStringType type)
|
||||
{
|
||||
for (auto&& content : broadcastGroup)
|
||||
{
|
||||
auto nextControl{ content.GetTermControl() };
|
||||
if (!nextControl.ReadOnly())
|
||||
{
|
||||
nextControl.WriteInputString(text, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,11 @@
|
||||
#include "AppKeyBindings.h"
|
||||
#include "AppCommandlineArgs.h"
|
||||
#include "RenameWindowRequestedArgs.g.h"
|
||||
#include "SummonWindowByIdRequestedArgs.g.h"
|
||||
#include "RequestMoveContentArgs.g.h"
|
||||
#include "LaunchPositionRequest.g.h"
|
||||
#include "WindowListEntry.g.h"
|
||||
#include "WindowListRequest.g.h"
|
||||
#include "Toast.h"
|
||||
|
||||
#include "WindowsPackageManagerFactory.h"
|
||||
@@ -54,6 +57,16 @@ namespace winrt::TerminalApp::implementation
|
||||
ScrollDown = 1
|
||||
};
|
||||
|
||||
enum class ConfirmCloseDialogKind
|
||||
{
|
||||
Pane,
|
||||
Tab,
|
||||
MultiplePanes,
|
||||
MultipleTabs,
|
||||
Window,
|
||||
CloseAll
|
||||
};
|
||||
|
||||
struct RenameWindowRequestedArgs : RenameWindowRequestedArgsT<RenameWindowRequestedArgs>
|
||||
{
|
||||
WINRT_PROPERTY(winrt::hstring, ProposedName);
|
||||
@@ -63,6 +76,15 @@ namespace winrt::TerminalApp::implementation
|
||||
_ProposedName{ name } {};
|
||||
};
|
||||
|
||||
struct SummonWindowByIdRequestedArgs : SummonWindowByIdRequestedArgsT<SummonWindowByIdRequestedArgs>
|
||||
{
|
||||
WINRT_PROPERTY(uint64_t, WindowId);
|
||||
|
||||
public:
|
||||
SummonWindowByIdRequestedArgs(uint64_t id) :
|
||||
_WindowId{ id } {};
|
||||
};
|
||||
|
||||
struct RequestMoveContentArgs : RequestMoveContentArgsT<RequestMoveContentArgs>
|
||||
{
|
||||
WINRT_PROPERTY(winrt::hstring, Window);
|
||||
@@ -84,6 +106,25 @@ namespace winrt::TerminalApp::implementation
|
||||
til::property<winrt::Microsoft::Terminal::Settings::Model::LaunchPosition> Position;
|
||||
};
|
||||
|
||||
struct WindowListEntry : WindowListEntryT<WindowListEntry>
|
||||
{
|
||||
WindowListEntry() = default;
|
||||
|
||||
til::property<uint64_t> Id;
|
||||
til::property<winrt::hstring> Name;
|
||||
};
|
||||
|
||||
struct WindowListRequest : WindowListRequestT<WindowListRequest>
|
||||
{
|
||||
WindowListRequest() :
|
||||
_Entries{ winrt::single_threaded_vector<winrt::TerminalApp::WindowListEntry>() } {}
|
||||
|
||||
winrt::Windows::Foundation::Collections::IVector<winrt::TerminalApp::WindowListEntry> Entries() const { return _Entries; }
|
||||
|
||||
private:
|
||||
winrt::Windows::Foundation::Collections::IVector<winrt::TerminalApp::WindowListEntry> _Entries;
|
||||
};
|
||||
|
||||
struct WinGetSearchParams
|
||||
{
|
||||
winrt::Microsoft::Management::Deployment::PackageMatchField Field;
|
||||
@@ -122,6 +163,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
safe_void_coroutine RequestQuit();
|
||||
safe_void_coroutine CloseWindow();
|
||||
winrt::Microsoft::Terminal::Settings::Model::WindowLayout GetWindowLayout();
|
||||
void PersistState();
|
||||
std::vector<IPaneContent> Panes() const;
|
||||
|
||||
@@ -168,6 +210,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
void OpenSettingsUI();
|
||||
void WindowActivated(const bool activated);
|
||||
bool FocusTab(const winrt::TerminalApp::Tab& tab);
|
||||
|
||||
bool OnDirectKeyEvent(const uint32_t vkey, const uint8_t scanCode, const bool down);
|
||||
|
||||
@@ -192,6 +235,8 @@ namespace winrt::TerminalApp::implementation
|
||||
til::typed_event<IInspectable, IInspectable> IdentifyWindowsRequested;
|
||||
til::typed_event<IInspectable, winrt::TerminalApp::RenameWindowRequestedArgs> RenameWindowRequested;
|
||||
til::typed_event<IInspectable, IInspectable> SummonWindowRequested;
|
||||
til::typed_event<IInspectable, winrt::TerminalApp::SummonWindowByIdRequestedArgs> SummonWindowByIdRequested;
|
||||
til::typed_event<IInspectable, winrt::TerminalApp::Tab> FocusTabRequested;
|
||||
til::typed_event<IInspectable, winrt::Microsoft::Terminal::Control::WindowSizeChangedEventArgs> WindowSizeChanged;
|
||||
|
||||
til::typed_event<IInspectable, IInspectable> OpenSystemMenu;
|
||||
@@ -203,6 +248,7 @@ namespace winrt::TerminalApp::implementation
|
||||
til::typed_event<Windows::Foundation::IInspectable, winrt::TerminalApp::RequestReceiveContentArgs> RequestReceiveContent;
|
||||
|
||||
til::typed_event<IInspectable, winrt::TerminalApp::LaunchPositionRequest> RequestLaunchPosition;
|
||||
til::typed_event<IInspectable, winrt::TerminalApp::WindowListRequest> RequestWindowList;
|
||||
|
||||
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::UI::Xaml::Media::Brush, TitlebarBrush, PropertyChanged.raise, nullptr);
|
||||
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::UI::Xaml::Media::Brush, FrameBrush, PropertyChanged.raise, nullptr);
|
||||
@@ -225,6 +271,7 @@ namespace winrt::TerminalApp::implementation
|
||||
TerminalApp::TabRowControl _tabRow{ nullptr };
|
||||
Windows::UI::Xaml::Controls::Grid _tabContent{ nullptr };
|
||||
Microsoft::UI::Xaml::Controls::SplitButton _newTabButton{ nullptr };
|
||||
Windows::UI::Xaml::Controls::MenuFlyout _workspaceFlyout{ nullptr };
|
||||
winrt::TerminalApp::ColorPickupFlyout _tabColorPicker{ nullptr };
|
||||
|
||||
Microsoft::Terminal::Settings::Model::CascadiaSettings _settings{ nullptr };
|
||||
@@ -301,8 +348,7 @@ namespace winrt::TerminalApp::implementation
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> _ShowDialogHelper(const std::wstring_view& name);
|
||||
|
||||
void _ShowAboutDialog();
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> _ShowQuitDialog();
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> _ShowCloseWarningDialog();
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> _ShowConfirmCloseDialog(ConfirmCloseDialogKind kind);
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> _ShowCloseReadOnlyDialog();
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> _ShowMultiLinePasteWarningDialog();
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> _ShowLargePasteWarningDialog();
|
||||
@@ -324,6 +370,7 @@ namespace winrt::TerminalApp::implementation
|
||||
void _restartPaneConnection(const TerminalApp::TerminalPaneContent&, const winrt::Windows::Foundation::IInspectable&);
|
||||
|
||||
safe_void_coroutine _OpenNewWindow(const Microsoft::Terminal::Settings::Model::INewContentArgs newContentArgs);
|
||||
safe_void_coroutine _OpenWorkspaceWindow(const winrt::hstring name);
|
||||
|
||||
void _OpenNewTerminalViaDropdown(const Microsoft::Terminal::Settings::Model::NewTerminalArgs newTerminalArgs);
|
||||
|
||||
@@ -349,7 +396,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
safe_void_coroutine _ExportTab(const Tab& tab, winrt::hstring filepath);
|
||||
|
||||
winrt::Windows::Foundation::IAsyncAction _HandleCloseTabRequested(winrt::TerminalApp::Tab tab);
|
||||
winrt::Windows::Foundation::IAsyncAction _HandleCloseTabRequested(winrt::TerminalApp::Tab tab, bool skipConfirmClose = false);
|
||||
void _CloseTabAtIndex(uint32_t index);
|
||||
void _RemoveTab(const winrt::TerminalApp::Tab& tab);
|
||||
safe_void_coroutine _RemoveTabs(const std::vector<winrt::TerminalApp::Tab> tabs);
|
||||
@@ -400,9 +447,12 @@ namespace winrt::TerminalApp::implementation
|
||||
TerminalApp::Tab _GetTabByTabViewItem(const IInspectable& tabViewItem) const noexcept;
|
||||
|
||||
void _HandleClosePaneRequested(std::shared_ptr<Pane> pane);
|
||||
bool _ShouldWarnOnClose() const;
|
||||
bool _ShouldWarnOnCloseTab(const winrt::com_ptr<Tab>& tab) const;
|
||||
safe_void_coroutine _SetFocusedTab(const winrt::TerminalApp::Tab tab);
|
||||
safe_void_coroutine _CloseFocusedPane();
|
||||
void _ClosePanes(weak_ref<Tab> weakTab, std::vector<uint32_t> paneIds);
|
||||
safe_void_coroutine _ClosePanes(weak_ref<Tab> weakTab, std::vector<uint32_t> paneIds);
|
||||
void _CloseRemainingPanes(weak_ref<Tab> weakTab, std::vector<uint32_t> paneIds);
|
||||
winrt::Windows::Foundation::IAsyncOperation<bool> _PaneConfirmCloseReadOnly(std::shared_ptr<Pane> pane);
|
||||
void _AddPreviouslyClosedPaneOrTab(std::vector<Microsoft::Terminal::Settings::Model::ActionAndArgs>&& args);
|
||||
|
||||
@@ -412,7 +462,7 @@ namespace winrt::TerminalApp::implementation
|
||||
const Microsoft::Terminal::Settings::Model::SplitDirection splitType,
|
||||
const float splitSize,
|
||||
std::shared_ptr<Pane> newPane);
|
||||
void _ResizePane(const Microsoft::Terminal::Settings::Model::ResizeDirection& direction);
|
||||
bool _ResizePane(const Microsoft::Terminal::Settings::Model::ResizeDirection& direction);
|
||||
void _ToggleSplitOrientation();
|
||||
|
||||
void _ScrollPage(ScrollDirection scrollDirection);
|
||||
@@ -420,7 +470,7 @@ namespace winrt::TerminalApp::implementation
|
||||
void _SetAcceleratorForMenuItem(Windows::UI::Xaml::Controls::MenuFlyoutItem& menuItem, const winrt::Microsoft::Terminal::Control::KeyChord& keyChord);
|
||||
|
||||
safe_void_coroutine _PasteFromClipboardHandler(const IInspectable sender,
|
||||
const IInspectable eventArgs);
|
||||
const Microsoft::Terminal::Control::PasteFromClipboardEventArgs eventArgs);
|
||||
|
||||
safe_void_coroutine _OpenHyperlinkHandler(const IInspectable sender, const Microsoft::Terminal::Control::OpenHyperlinkEventArgs eventArgs);
|
||||
static bool _IsUriSupported(const winrt::Windows::Foundation::Uri& parsedUri);
|
||||
@@ -437,9 +487,6 @@ namespace winrt::TerminalApp::implementation
|
||||
safe_void_coroutine _ControlNoticeRaisedHandler(const IInspectable sender, const Microsoft::Terminal::Control::NoticeEventArgs eventArgs);
|
||||
void _ShowControlNoticeDialog(const winrt::hstring& title, const winrt::hstring& message);
|
||||
|
||||
safe_void_coroutine _ControlDragDropHandler(Windows::Foundation::IInspectable sender, Windows::UI::Xaml::DragEventArgs e);
|
||||
void _ControlDragOverHandler(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::DragEventArgs& e);
|
||||
|
||||
safe_void_coroutine _LaunchSettings(const Microsoft::Terminal::Settings::Model::SettingsTarget target);
|
||||
|
||||
void _TabDragStarted(const IInspectable& sender, const IInspectable& eventArgs);
|
||||
@@ -566,6 +613,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
void _PopulateContextMenu(const Microsoft::Terminal::Control::TermControl& control, const Microsoft::UI::Xaml::Controls::CommandBarFlyout& sender, const bool withSelection);
|
||||
void _PopulateQuickFixMenu(const Microsoft::Terminal::Control::TermControl& control, const Windows::UI::Xaml::Controls::MenuFlyout& sender);
|
||||
void _PopulateWorkspaceFlyout();
|
||||
winrt::Windows::UI::Xaml::Controls::MenuFlyout _CreateRunAsAdminFlyout(int profileIndex);
|
||||
|
||||
winrt::Microsoft::Terminal::Control::TermControl _senderOrActiveControl(const winrt::Windows::Foundation::IInspectable& sender);
|
||||
@@ -574,9 +622,7 @@ namespace winrt::TerminalApp::implementation
|
||||
void _activePaneChanged(winrt::TerminalApp::Tab tab, Windows::Foundation::IInspectable args);
|
||||
safe_void_coroutine _doHandleSuggestions(Microsoft::Terminal::Settings::Model::SuggestionsArgs realArgs);
|
||||
|
||||
using broadcast_group = til::small_vector<TerminalApp::TerminalPaneContent, 1>;
|
||||
broadcast_group _getBroadcastGroupFromControl(const Microsoft::Terminal::Control::TermControl& control);
|
||||
void _writeInputStringToBroadcastGroup(const broadcast_group& broadcastGroup, const winrt::hstring text, Microsoft::Terminal::Control::WriteInputStringType type);
|
||||
void _SendDesktopNotification(const winrt::hstring& tabTitle, const winrt::hstring& body, const winrt::com_ptr<Tab>& tab, const winrt::TerminalApp::IPaneContent& content);
|
||||
|
||||
#pragma region ActionHandlers
|
||||
// These are all defined in AppActionHandlers.cpp
|
||||
@@ -594,4 +640,5 @@ namespace winrt::TerminalApp::implementation
|
||||
namespace winrt::TerminalApp::factory_implementation
|
||||
{
|
||||
BASIC_FACTORY(TerminalPage);
|
||||
BASIC_FACTORY(WindowListEntry);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,10 @@ namespace TerminalApp
|
||||
{
|
||||
String ProposedName { get; };
|
||||
};
|
||||
[default_interface] runtimeclass SummonWindowByIdRequestedArgs
|
||||
{
|
||||
UInt64 WindowId { get; };
|
||||
};
|
||||
[default_interface] runtimeclass RequestMoveContentArgs
|
||||
{
|
||||
String Window { get; };
|
||||
@@ -50,6 +54,20 @@ namespace TerminalApp
|
||||
Microsoft.Terminal.Settings.Model.LaunchPosition Position;
|
||||
}
|
||||
|
||||
[default_interface] runtimeclass WindowListEntry
|
||||
{
|
||||
WindowListEntry();
|
||||
UInt64 Id;
|
||||
String Name;
|
||||
}
|
||||
|
||||
// Raised by TerminalPage when it needs the list of open windows.
|
||||
// The handler (AppHost) fills Entries synchronously.
|
||||
[default_interface] runtimeclass WindowListRequest
|
||||
{
|
||||
Windows.Foundation.Collections.IVector<WindowListEntry> Entries { get; };
|
||||
}
|
||||
|
||||
[default_interface] runtimeclass TerminalPage : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged, Microsoft.Terminal.UI.IDirectKeyListener
|
||||
{
|
||||
TerminalPage(WindowProperties properties, ContentManager manager);
|
||||
@@ -93,6 +111,7 @@ namespace TerminalApp
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> IdentifyWindowsRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, RenameWindowRequestedArgs> RenameWindowRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> SummonWindowRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, SummonWindowByIdRequestedArgs> SummonWindowByIdRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Microsoft.Terminal.Control.WindowSizeChangedEventArgs> WindowSizeChanged;
|
||||
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> OpenSystemMenu;
|
||||
@@ -103,5 +122,6 @@ namespace TerminalApp
|
||||
event Windows.Foundation.TypedEventHandler<Object, RequestReceiveContentArgs> RequestReceiveContent;
|
||||
|
||||
event Windows.Foundation.TypedEventHandler<Object, LaunchPositionRequest> RequestLaunchPosition;
|
||||
event Windows.Foundation.TypedEventHandler<Object, WindowListRequest> RequestWindowList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,17 +86,12 @@
|
||||
Grid.Row="2"
|
||||
x:Load="False" />
|
||||
|
||||
<ContentDialog x:Name="QuitDialog"
|
||||
x:Uid="QuitDialog"
|
||||
<ContentDialog x:Name="ConfirmCloseDialog"
|
||||
Grid.Row="2"
|
||||
x:Load="False"
|
||||
DefaultButton="Primary" />
|
||||
|
||||
<ContentDialog x:Name="CloseAllDialog"
|
||||
x:Uid="CloseAllDialog"
|
||||
Grid.Row="2"
|
||||
x:Load="False"
|
||||
DefaultButton="Primary" />
|
||||
DefaultButton="Primary">
|
||||
<CheckBox x:Uid="DontAskAgainCheckBox" />
|
||||
</ContentDialog>
|
||||
|
||||
<ContentDialog x:Name="CloseReadOnlyDialog"
|
||||
x:Uid="CloseReadOnlyDialog"
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "../../types/inc/utils.hpp"
|
||||
|
||||
#include "BellEventArgs.g.cpp"
|
||||
#include "NotificationEventArgs.g.cpp"
|
||||
#include "TerminalPaneContent.g.cpp"
|
||||
|
||||
using namespace winrt::Windows::Foundation;
|
||||
@@ -20,8 +21,6 @@ using namespace winrt::Microsoft::Terminal::TerminalConnection;
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
til::shared_mutex<std::unordered_map<void*, winrt::weak_ref<TerminalApp::implementation::TerminalPaneContent>>> TerminalPaneContent::_controlToContentMap{};
|
||||
|
||||
TerminalPaneContent::TerminalPaneContent(const winrt::Microsoft::Terminal::Settings::Model::Profile& profile,
|
||||
const std::shared_ptr<TerminalSettingsCache>& cache,
|
||||
const winrt::Microsoft::Terminal::Control::TermControl& control) :
|
||||
@@ -30,15 +29,13 @@ namespace winrt::TerminalApp::implementation
|
||||
_profile{ profile }
|
||||
{
|
||||
_setupControlEvents();
|
||||
|
||||
auto map{ _controlToContentMap.lock() };
|
||||
map->insert_or_assign(winrt::get_abi(control), get_weak());
|
||||
}
|
||||
|
||||
void TerminalPaneContent::_setupControlEvents()
|
||||
{
|
||||
_controlEvents._ConnectionStateChanged = _control.ConnectionStateChanged(winrt::auto_revoke, { this, &TerminalPaneContent::_controlConnectionStateChangedHandler });
|
||||
_controlEvents._WarningBell = _control.WarningBell(winrt::auto_revoke, { get_weak(), &TerminalPaneContent::_controlWarningBellHandler });
|
||||
_controlEvents._PromptStarted = _control.PromptStarted(winrt::auto_revoke, { get_weak(), &TerminalPaneContent::_controlPromptStartedHandler });
|
||||
_controlEvents._CloseTerminalRequested = _control.CloseTerminalRequested(winrt::auto_revoke, { get_weak(), &TerminalPaneContent::_closeTerminalRequestedHandler });
|
||||
_controlEvents._RestartTerminalRequested = _control.RestartTerminalRequested(winrt::auto_revoke, { get_weak(), &TerminalPaneContent::_restartTerminalRequestedHandler });
|
||||
|
||||
@@ -47,6 +44,8 @@ namespace winrt::TerminalApp::implementation
|
||||
_controlEvents._SetTaskbarProgress = _control.SetTaskbarProgress(winrt::auto_revoke, { get_weak(), &TerminalPaneContent::_controlSetTaskbarProgress });
|
||||
_controlEvents._ReadOnlyChanged = _control.ReadOnlyChanged(winrt::auto_revoke, { get_weak(), &TerminalPaneContent::_controlReadOnlyChanged });
|
||||
_controlEvents._FocusFollowMouseRequested = _control.FocusFollowMouseRequested(winrt::auto_revoke, { get_weak(), &TerminalPaneContent::_controlFocusFollowMouseRequested });
|
||||
_controlEvents._OutputBurstEnded = _control.OutputIdle(winrt::auto_revoke, { get_weak(), &TerminalPaneContent::_controlOutputBurstEndedHandler });
|
||||
_controlEvents._ShowNotification = _control.ShowNotification(winrt::auto_revoke, { get_weak(), &TerminalPaneContent::_controlShowNotification });
|
||||
}
|
||||
void TerminalPaneContent::_removeControlEvents()
|
||||
{
|
||||
@@ -77,11 +76,6 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
_control.Close();
|
||||
|
||||
{
|
||||
auto map{ _controlToContentMap.lock() };
|
||||
map->erase(winrt::get_abi(_control));
|
||||
}
|
||||
|
||||
// Clear out our media player callbacks, and stop any playing media. This
|
||||
// will prevent the callback from being triggered after we've closed, and
|
||||
// also make sure that our sound stops when we're closed.
|
||||
@@ -183,6 +177,16 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
TaskbarProgressChanged.raise(*this, nullptr);
|
||||
}
|
||||
|
||||
winrt::Microsoft::Terminal::Control::TaskbarState TerminalPaneContent::TaskbarState()
|
||||
{
|
||||
return _control.TaskbarState();
|
||||
}
|
||||
|
||||
uint64_t TerminalPaneContent::TaskbarProgress()
|
||||
{
|
||||
return _control.TaskbarProgress();
|
||||
}
|
||||
void TerminalPaneContent::_controlReadOnlyChanged(const IInspectable&, const IInspectable&)
|
||||
{
|
||||
ReadOnlyChanged.raise(*this, nullptr);
|
||||
@@ -192,6 +196,11 @@ namespace winrt::TerminalApp::implementation
|
||||
FocusRequested.raise(*this, nullptr);
|
||||
}
|
||||
|
||||
void TerminalPaneContent::_controlShowNotification(const IInspectable& /*sender*/, const ShowNotificationEventArgs& args)
|
||||
{
|
||||
NotificationRequested.raise(*this, winrt::make<implementation::NotificationEventArgs>(OutputNotificationStyle::Notification, true, args.Title(), args.Body()));
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Called when our attached control is closed. Triggers listeners to our close
|
||||
// event, if we're a leaf pane.
|
||||
@@ -271,6 +280,25 @@ namespace winrt::TerminalApp::implementation
|
||||
// has the 'visual' flag set
|
||||
// Arguments:
|
||||
// - <unused>
|
||||
void TerminalPaneContent::PlayNotificationSound()
|
||||
{
|
||||
if (_profile)
|
||||
{
|
||||
auto sounds{ _profile.BellSound() };
|
||||
if (sounds && sounds.Size() > 0)
|
||||
{
|
||||
winrt::hstring soundPath{ sounds.GetAt(rand() % sounds.Size()).Resolved() };
|
||||
winrt::Windows::Foundation::Uri uri{ soundPath };
|
||||
_playBellSound(uri);
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto soundAlias = reinterpret_cast<LPCTSTR>(SND_ALIAS_SYSTEMHAND);
|
||||
PlaySound(soundAlias, NULL, SND_ALIAS_ID | SND_ASYNC | SND_SENTRY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalPaneContent::_controlWarningBellHandler(const winrt::Windows::Foundation::IInspectable& /*sender*/,
|
||||
const winrt::Windows::Foundation::IInspectable& /*eventArgs*/)
|
||||
{
|
||||
@@ -282,18 +310,7 @@ namespace winrt::TerminalApp::implementation
|
||||
if (WI_IsFlagSet(_profile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Audible))
|
||||
{
|
||||
// Audible is set, play the sound
|
||||
auto sounds{ _profile.BellSound() };
|
||||
if (sounds && sounds.Size() > 0)
|
||||
{
|
||||
winrt::hstring soundPath{ sounds.GetAt(rand() % sounds.Size()).Resolved() };
|
||||
winrt::Windows::Foundation::Uri uri{ soundPath };
|
||||
_playBellSound(uri);
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto soundAlias = reinterpret_cast<LPCTSTR>(SND_ALIAS_SYSTEMHAND);
|
||||
PlaySound(soundAlias, NULL, SND_ALIAS_ID | SND_ASYNC | SND_SENTRY);
|
||||
}
|
||||
PlayNotificationSound();
|
||||
}
|
||||
|
||||
if (WI_IsFlagSet(_profile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Window))
|
||||
@@ -301,9 +318,43 @@ namespace winrt::TerminalApp::implementation
|
||||
_control.BellLightOn();
|
||||
}
|
||||
|
||||
// raise the event with the bool value corresponding to the taskbar flag
|
||||
// raise the event with the bool values corresponding to the taskbar and notification flags
|
||||
BellRequested.raise(*this,
|
||||
*winrt::make_self<TerminalApp::implementation::BellEventArgs>(WI_IsFlagSet(_profile.BellStyle(), BellStyle::Taskbar)));
|
||||
*winrt::make_self<TerminalApp::implementation::BellEventArgs>(
|
||||
WI_IsFlagSet(_profile.BellStyle(), BellStyle::Taskbar),
|
||||
WI_IsFlagSet(_profile.BellStyle(), BellStyle::Notification)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalPaneContent::_controlPromptStartedHandler(const winrt::Windows::Foundation::IInspectable& /*sender*/,
|
||||
const winrt::Windows::Foundation::IInspectable& /*eventArgs*/)
|
||||
{
|
||||
if (_profile)
|
||||
{
|
||||
const auto notifyStyle = _profile.NotifyOnNextPrompt();
|
||||
if (notifyStyle != OutputNotificationStyle::None)
|
||||
{
|
||||
NotificationRequested.raise(*this,
|
||||
*winrt::make_self<TerminalApp::implementation::NotificationEventArgs>(notifyStyle, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The underlying TermControl::OutputIdle event is fired on the trailing
|
||||
// edge of a 100ms-debounced output burst (see ControlCore::Initialize).
|
||||
// When "notifyOnActivity" is enabled, we get one event per burst of
|
||||
// output, which naturally coalesces a stream of output into a single notification.
|
||||
void TerminalPaneContent::_controlOutputBurstEndedHandler(const winrt::Windows::Foundation::IInspectable& /*sender*/,
|
||||
const winrt::Windows::Foundation::IInspectable& /*eventArgs*/)
|
||||
{
|
||||
if (_profile)
|
||||
{
|
||||
const auto notifyStyle = _profile.NotifyOnActivity();
|
||||
if (notifyStyle != OutputNotificationStyle::None)
|
||||
{
|
||||
NotificationRequested.raise(*this,
|
||||
*winrt::make_self<TerminalApp::implementation::NotificationEventArgs>(notifyStyle, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -381,14 +432,4 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
return _control.CharacterDimensions();
|
||||
}
|
||||
|
||||
TerminalApp::TerminalPaneContent TerminalPaneContent::ContentFromControl(const winrt::Microsoft::Terminal::Control::TermControl& control)
|
||||
{
|
||||
const auto map{ _controlToContentMap.lock_shared() };
|
||||
if (auto found{ map->find(winrt::get_abi(control)) }; found != map->end())
|
||||
{
|
||||
return *found->second.get();
|
||||
}
|
||||
return { nullptr };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
#include "TerminalPaneContent.g.h"
|
||||
#include "BellEventArgs.g.h"
|
||||
#include "NotificationEventArgs.g.h"
|
||||
#include "BasicPaneEvents.h"
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
@@ -13,10 +14,23 @@ namespace winrt::TerminalApp::implementation
|
||||
struct BellEventArgs : public BellEventArgsT<BellEventArgs>
|
||||
{
|
||||
public:
|
||||
BellEventArgs(bool flashTaskbar) :
|
||||
FlashTaskbar(flashTaskbar) {}
|
||||
BellEventArgs(bool flashTaskbar, bool sendNotification) :
|
||||
FlashTaskbar(flashTaskbar), SendNotification(sendNotification) {}
|
||||
|
||||
til::property<bool> FlashTaskbar;
|
||||
til::property<bool> SendNotification;
|
||||
};
|
||||
|
||||
struct NotificationEventArgs : public NotificationEventArgsT<NotificationEventArgs>
|
||||
{
|
||||
public:
|
||||
NotificationEventArgs(winrt::Microsoft::Terminal::Control::OutputNotificationStyle style, bool alwaysNotify = true, const winrt::hstring& title = {}, const winrt::hstring& body = {}) :
|
||||
Style(style), AlwaysNotify(alwaysNotify), Title(title), Body(body) {}
|
||||
|
||||
til::property<winrt::Microsoft::Terminal::Control::OutputNotificationStyle> Style;
|
||||
til::property<bool> AlwaysNotify;
|
||||
til::property<winrt::hstring> Title;
|
||||
til::property<winrt::hstring> Body;
|
||||
};
|
||||
|
||||
struct TerminalPaneContent : TerminalPaneContentT<TerminalPaneContent>, BasicPaneEvents
|
||||
@@ -36,6 +50,7 @@ namespace winrt::TerminalApp::implementation
|
||||
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings);
|
||||
|
||||
void MarkAsDefterm();
|
||||
void PlayNotificationSound();
|
||||
|
||||
winrt::Microsoft::Terminal::Settings::Model::Profile GetProfile() const
|
||||
{
|
||||
@@ -43,8 +58,8 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
|
||||
winrt::hstring Title() { return _control.Title(); }
|
||||
uint64_t TaskbarState() { return _control.TaskbarState(); }
|
||||
uint64_t TaskbarProgress() { return _control.TaskbarProgress(); }
|
||||
winrt::Microsoft::Terminal::Control::TaskbarState TaskbarState();
|
||||
uint64_t TaskbarProgress();
|
||||
bool ReadOnly() { return _control.ReadOnly(); }
|
||||
winrt::hstring Icon() const;
|
||||
Windows::Foundation::IReference<winrt::Windows::UI::Color> TabColor() const noexcept;
|
||||
@@ -55,13 +70,9 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
til::typed_event<TerminalApp::TerminalPaneContent, winrt::Windows::Foundation::IInspectable> RestartTerminalRequested;
|
||||
|
||||
static TerminalApp::TerminalPaneContent ContentFromControl(const winrt::Microsoft::Terminal::Control::TermControl& control);
|
||||
|
||||
// See BasicPaneEvents for most generic event definitions
|
||||
|
||||
private:
|
||||
static til::shared_mutex<std::unordered_map<void*, winrt::weak_ref<TerminalApp::implementation::TerminalPaneContent>>> _controlToContentMap;
|
||||
|
||||
winrt::Microsoft::Terminal::Control::TermControl _control{ nullptr };
|
||||
winrt::Microsoft::Terminal::TerminalConnection::ConnectionState _connectionState{ winrt::Microsoft::Terminal::TerminalConnection::ConnectionState::NotConnected };
|
||||
winrt::Microsoft::Terminal::Settings::Model::Profile _profile{ nullptr };
|
||||
@@ -75,6 +86,8 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
winrt::Microsoft::Terminal::Control::TermControl::ConnectionStateChanged_revoker _ConnectionStateChanged;
|
||||
winrt::Microsoft::Terminal::Control::TermControl::WarningBell_revoker _WarningBell;
|
||||
winrt::Microsoft::Terminal::Control::TermControl::PromptStarted_revoker _PromptStarted;
|
||||
winrt::Microsoft::Terminal::Control::TermControl::OutputIdle_revoker _OutputBurstEnded;
|
||||
winrt::Microsoft::Terminal::Control::TermControl::CloseTerminalRequested_revoker _CloseTerminalRequested;
|
||||
winrt::Microsoft::Terminal::Control::TermControl::RestartTerminalRequested_revoker _RestartTerminalRequested;
|
||||
|
||||
@@ -83,6 +96,7 @@ namespace winrt::TerminalApp::implementation
|
||||
winrt::Microsoft::Terminal::Control::TermControl::SetTaskbarProgress_revoker _SetTaskbarProgress;
|
||||
winrt::Microsoft::Terminal::Control::TermControl::ReadOnlyChanged_revoker _ReadOnlyChanged;
|
||||
winrt::Microsoft::Terminal::Control::TermControl::FocusFollowMouseRequested_revoker _FocusFollowMouseRequested;
|
||||
winrt::Microsoft::Terminal::Control::TermControl::ShowNotification_revoker _ShowNotification;
|
||||
|
||||
} _controlEvents;
|
||||
void _setupControlEvents();
|
||||
@@ -93,6 +107,8 @@ namespace winrt::TerminalApp::implementation
|
||||
safe_void_coroutine _controlConnectionStateChangedHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& /*args*/);
|
||||
void _controlWarningBellHandler(const winrt::Windows::Foundation::IInspectable& sender,
|
||||
const winrt::Windows::Foundation::IInspectable& e);
|
||||
void _controlPromptStartedHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& eventArgs);
|
||||
void _controlOutputBurstEndedHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& eventArgs);
|
||||
void _controlReadOnlyChangedHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& e);
|
||||
|
||||
void _controlTitleChanged(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args);
|
||||
@@ -100,6 +116,7 @@ namespace winrt::TerminalApp::implementation
|
||||
void _controlSetTaskbarProgress(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args);
|
||||
void _controlReadOnlyChanged(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args);
|
||||
void _controlFocusFollowMouseRequested(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args);
|
||||
void _controlShowNotification(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Microsoft::Terminal::Control::ShowNotificationEventArgs& args);
|
||||
|
||||
void _closeTerminalRequestedHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& /*args*/);
|
||||
void _restartTerminalRequestedHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& /*args*/);
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace TerminalApp
|
||||
Microsoft.Terminal.Control.TermControl GetTermControl();
|
||||
|
||||
void MarkAsDefterm();
|
||||
void PlayNotificationSound();
|
||||
|
||||
Microsoft.Terminal.Settings.Model.Profile GetProfile();
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace winrt::TerminalApp::implementation
|
||||
WINRT_OBSERVABLE_PROPERTY(bool, IsProgressRingActive, PropertyChanged.raise);
|
||||
WINRT_OBSERVABLE_PROPERTY(bool, IsProgressRingIndeterminate, PropertyChanged.raise);
|
||||
WINRT_OBSERVABLE_PROPERTY(bool, BellIndicator, PropertyChanged.raise);
|
||||
WINRT_OBSERVABLE_PROPERTY(bool, ActivityIndicator, PropertyChanged.raise);
|
||||
WINRT_OBSERVABLE_PROPERTY(bool, IsReadOnlyActive, PropertyChanged.raise);
|
||||
WINRT_OBSERVABLE_PROPERTY(uint32_t, ProgressValue, PropertyChanged.raise);
|
||||
WINRT_OBSERVABLE_PROPERTY(bool, IsInputBroadcastActive, PropertyChanged.raise);
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace TerminalApp
|
||||
Boolean IsProgressRingActive { get; set; };
|
||||
Boolean IsProgressRingIndeterminate { get; set; };
|
||||
Boolean BellIndicator { get; set; };
|
||||
Boolean ActivityIndicator { get; set; };
|
||||
UInt32 ProgressValue { get; set; };
|
||||
Boolean IsReadOnlyActive { get; set; };
|
||||
Boolean IsInputBroadcastActive { get; set; };
|
||||
|
||||
@@ -108,13 +108,19 @@ static Documents::Run _BuildErrorRun(const winrt::hstring& text, const ResourceD
|
||||
Documents::Run textRun;
|
||||
textRun.Text(text);
|
||||
|
||||
// Color the text red (light theme) or yellow (dark theme) based on the system theme
|
||||
auto key = winrt::box_value(L"ErrorTextBrush");
|
||||
if (resources.HasKey(key))
|
||||
// GH #18147 - In High Contrast mode, don't override the foreground.
|
||||
// Let the text inherit the system HC text color from its parent element,
|
||||
// since SystemErrorTextColor doesn't adapt to High Contrast themes.
|
||||
if (!winrt::Windows::UI::ViewManagement::AccessibilitySettings{}.HighContrast())
|
||||
{
|
||||
auto g = resources.Lookup(key);
|
||||
auto brush = g.try_as<winrt::Windows::UI::Xaml::Media::Brush>();
|
||||
textRun.Foreground(brush);
|
||||
// Color the text red (light theme) or yellow (dark theme) based on the system theme
|
||||
auto key = winrt::box_value(L"ErrorTextBrush");
|
||||
if (resources.HasKey(key))
|
||||
{
|
||||
auto g = resources.Lookup(key);
|
||||
auto brush = g.try_as<winrt::Windows::UI::Xaml::Media::Brush>();
|
||||
textRun.Foreground(brush);
|
||||
}
|
||||
}
|
||||
|
||||
return textRun;
|
||||
@@ -252,6 +258,15 @@ namespace winrt::TerminalApp::implementation
|
||||
AppLogic::Current()->NotifyRootInitialized();
|
||||
}
|
||||
|
||||
WindowLayout TerminalWindow::GetWindowLayout()
|
||||
{
|
||||
if (_root)
|
||||
{
|
||||
return _root->GetWindowLayout();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TerminalWindow::PersistState()
|
||||
{
|
||||
if (_root)
|
||||
@@ -1097,6 +1112,11 @@ namespace winrt::TerminalApp::implementation
|
||||
_initialContentArgs = wil::to_vector(args);
|
||||
}
|
||||
|
||||
void TerminalWindow::SetPersistedLayout(const winrt::Microsoft::Terminal::Settings::Model::WindowLayout& layout)
|
||||
{
|
||||
_cachedLayout = layout;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Parse the provided commandline arguments into actions, and try to
|
||||
// perform them immediately.
|
||||
@@ -1205,10 +1225,26 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
}
|
||||
|
||||
bool TerminalWindow::FocusTab(const winrt::TerminalApp::Tab& tab)
|
||||
{
|
||||
if (_root)
|
||||
{
|
||||
return _root->FocusTab(tab);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void TerminalWindow::WindowName(const winrt::hstring& name)
|
||||
{
|
||||
const auto oldIsQuakeMode = _WindowProperties->IsQuakeWindow();
|
||||
const auto oldName = _WindowProperties->WindowName();
|
||||
_WindowProperties->WindowName(name);
|
||||
// If this window had a persisted workspace under the old name, rename
|
||||
// that entry too so we don't leave a stale copy behind.
|
||||
if (!oldName.empty() && !name.empty() && oldName != name)
|
||||
{
|
||||
ApplicationState::SharedInstance().RenameWorkspace(oldName, name);
|
||||
}
|
||||
if (!_root)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -71,6 +71,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
void Create();
|
||||
|
||||
winrt::Microsoft::Terminal::Settings::Model::WindowLayout GetWindowLayout();
|
||||
void PersistState();
|
||||
|
||||
void UpdateSettings(winrt::TerminalApp::SettingsLoadEventArgs args);
|
||||
@@ -79,6 +80,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
int32_t SetStartupCommandline(TerminalApp::CommandlineArgs args);
|
||||
void SetStartupContent(const winrt::hstring& content, const Windows::Foundation::IReference<Windows::Foundation::Rect>& contentBounds);
|
||||
void SetPersistedLayout(const winrt::Microsoft::Terminal::Settings::Model::WindowLayout& layout);
|
||||
int32_t ExecuteCommandline(TerminalApp::CommandlineArgs args);
|
||||
void SetSettingsStartupArgs(const std::vector<winrt::Microsoft::Terminal::Settings::Model::ActionAndArgs>& actions);
|
||||
|
||||
@@ -92,6 +94,7 @@ namespace winrt::TerminalApp::implementation
|
||||
bool ShowTabsFullscreen() const;
|
||||
bool AutoHideWindow();
|
||||
void IdentifyWindow();
|
||||
bool FocusTab(const winrt::TerminalApp::Tab& tab);
|
||||
|
||||
std::optional<uint32_t> LoadPersistedLayoutIdx() const;
|
||||
winrt::Microsoft::Terminal::Settings::Model::WindowLayout LoadPersistedLayout();
|
||||
@@ -221,6 +224,8 @@ namespace winrt::TerminalApp::implementation
|
||||
FORWARDED_TYPED_EVENT(SetTaskbarProgress, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, SetTaskbarProgress);
|
||||
FORWARDED_TYPED_EVENT(IdentifyWindowsRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, IdentifyWindowsRequested);
|
||||
FORWARDED_TYPED_EVENT(SummonWindowRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, SummonWindowRequested);
|
||||
FORWARDED_TYPED_EVENT(SummonWindowByIdRequested, Windows::Foundation::IInspectable, winrt::TerminalApp::SummonWindowByIdRequestedArgs, _root, SummonWindowByIdRequested);
|
||||
FORWARDED_TYPED_EVENT(FocusTabRequested, Windows::Foundation::IInspectable, winrt::TerminalApp::Tab, _root, FocusTabRequested);
|
||||
FORWARDED_TYPED_EVENT(OpenSystemMenu, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, OpenSystemMenu);
|
||||
FORWARDED_TYPED_EVENT(QuitRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, QuitRequested);
|
||||
FORWARDED_TYPED_EVENT(ShowWindowChanged, Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Control::ShowWindowArgs, _root, ShowWindowChanged);
|
||||
@@ -229,6 +234,7 @@ namespace winrt::TerminalApp::implementation
|
||||
FORWARDED_TYPED_EVENT(RequestReceiveContent, Windows::Foundation::IInspectable, winrt::TerminalApp::RequestReceiveContentArgs, _root, RequestReceiveContent);
|
||||
|
||||
FORWARDED_TYPED_EVENT(RequestLaunchPosition, Windows::Foundation::IInspectable, winrt::TerminalApp::LaunchPositionRequest, _root, RequestLaunchPosition);
|
||||
FORWARDED_TYPED_EVENT(RequestWindowList, Windows::Foundation::IInspectable, winrt::TerminalApp::WindowListRequest, _root, RequestWindowList);
|
||||
|
||||
#ifdef UNIT_TESTING
|
||||
friend class TerminalAppLocalTests::CommandlineTest;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import "IPaneContent.idl";
|
||||
import "TerminalPage.idl";
|
||||
import "ShortcutActionDispatch.idl";
|
||||
import "Tab.idl";
|
||||
|
||||
namespace TerminalApp
|
||||
{
|
||||
@@ -55,11 +56,13 @@ namespace TerminalApp
|
||||
|
||||
Int32 SetStartupCommandline(CommandlineArgs args);
|
||||
void SetStartupContent(String json, Windows.Foundation.IReference<Windows.Foundation.Rect> bounds);
|
||||
void SetPersistedLayout(Microsoft.Terminal.Settings.Model.WindowLayout layout);
|
||||
Int32 ExecuteCommandline(CommandlineArgs args);
|
||||
|
||||
Boolean ShouldImmediatelyHandoffToElevated();
|
||||
void HandoffToElevated();
|
||||
|
||||
Microsoft.Terminal.Settings.Model.WindowLayout GetWindowLayout();
|
||||
void PersistState();
|
||||
|
||||
Windows.UI.Xaml.UIElement GetRoot();
|
||||
@@ -74,6 +77,7 @@ namespace TerminalApp
|
||||
Boolean ShowTabsFullscreen { get; };
|
||||
|
||||
void IdentifyWindow();
|
||||
Boolean FocusTab(TerminalApp.Tab tab);
|
||||
void SetPersistedLayoutIdx(UInt32 idx);
|
||||
void RequestExitFullscreen();
|
||||
|
||||
@@ -126,6 +130,8 @@ namespace TerminalApp
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> IdentifyWindowsRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> IsQuakeWindowChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> SummonWindowRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, SummonWindowByIdRequestedArgs> SummonWindowByIdRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, TerminalApp.Tab> FocusTabRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> OpenSystemMenu;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> QuitRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, TerminalApp.SystemMenuChangeArgs> SystemMenuChangeRequested;
|
||||
@@ -137,6 +143,7 @@ namespace TerminalApp
|
||||
event Windows.Foundation.TypedEventHandler<Object, RequestMoveContentArgs> RequestMoveContent;
|
||||
event Windows.Foundation.TypedEventHandler<Object, RequestReceiveContentArgs> RequestReceiveContent;
|
||||
event Windows.Foundation.TypedEventHandler<Object, LaunchPositionRequest> RequestLaunchPosition;
|
||||
event Windows.Foundation.TypedEventHandler<Object, WindowListRequest> RequestWindowList;
|
||||
|
||||
void AttachContent(String content, UInt32 tabIndex);
|
||||
void SendContentToOther(RequestReceiveContentArgs args);
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include <winrt/Windows.Globalization.h>
|
||||
#include <winrt/Windows.Graphics.Display.h>
|
||||
#include <winrt/Windows.System.h>
|
||||
#include <winrt/Windows.Storage.Streams.h>
|
||||
#include <winrt/Windows.UI.Core.h>
|
||||
#include <winrt/Windows.UI.Input.h>
|
||||
#include <winrt/Windows.UI.Text.h>
|
||||
@@ -55,6 +54,9 @@
|
||||
#include <winrt/Windows.Media.Playback.h>
|
||||
#include <winrt/Windows.Management.Deployment.h>
|
||||
|
||||
#include <winrt/Windows.UI.Notifications.h>
|
||||
#include <winrt/Windows.Data.Xml.Dom.h>
|
||||
|
||||
#include <winrt/Microsoft.UI.Xaml.Controls.h>
|
||||
#include <winrt/Microsoft.UI.Xaml.Controls.Primitives.h>
|
||||
#include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h>
|
||||
@@ -89,7 +91,6 @@ TRACELOGGING_DECLARE_PROVIDER(g_hTerminalAppProvider);
|
||||
|
||||
// Manually include til after we include Windows.Foundation to give it winrt superpowers
|
||||
#include "til.h"
|
||||
#include <til/mutex.h>
|
||||
#include <til/winrt.h>
|
||||
|
||||
#include <SafeDispatcherTimer.h>
|
||||
|
||||
@@ -139,6 +139,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
auto pfnSearchMissingCommand = [this](auto&& PH1, auto&& PH2) { _terminalSearchMissingCommand(std::forward<decltype(PH1)>(PH1), std::forward<decltype(PH2)>(PH2)); };
|
||||
_terminal->SetSearchMissingCommandCallback(pfnSearchMissingCommand);
|
||||
|
||||
auto pfnPromptStarted = [this] { _terminalPromptStarted(); };
|
||||
_terminal->SetPromptStartedCallback(pfnPromptStarted);
|
||||
|
||||
auto pfnOutputStarted = [this] { _terminalOutputStarted(); };
|
||||
_terminal->SetOutputStartedCallback(pfnOutputStarted);
|
||||
|
||||
auto pfnShowNotification = [this](auto&& PH1, auto&& PH2) { _terminalShowNotification(std::forward<decltype(PH1)>(PH1), std::forward<decltype(PH2)>(PH2)); };
|
||||
_terminal->SetShowNotificationCallback(pfnShowNotification);
|
||||
|
||||
auto pfnClearQuickFix = [this] { ClearQuickFix(); };
|
||||
_terminal->SetClearQuickFixCallback(pfnClearQuickFix);
|
||||
|
||||
@@ -498,7 +507,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// - wstr: the string of characters to write to the terminal connection.
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void ControlCore::_sendInput(const std::wstring_view wstr)
|
||||
void ControlCore::SendInput(const std::wstring_view wstr)
|
||||
{
|
||||
if (wstr.empty())
|
||||
{
|
||||
@@ -554,7 +563,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
}
|
||||
if (out)
|
||||
{
|
||||
_sendInput(*out);
|
||||
SendInput(*out);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -712,7 +721,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
}
|
||||
if (out)
|
||||
{
|
||||
_sendInput(*out);
|
||||
SendInput(*out);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -731,7 +740,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
}
|
||||
if (out)
|
||||
{
|
||||
_sendInput(*out);
|
||||
SendInput(*out);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -913,6 +922,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
_hasUnfocusedAppearance = static_cast<bool>(newAppearance);
|
||||
_unfocusedAppearance = _hasUnfocusedAppearance ? newAppearance : settings;
|
||||
|
||||
// Cache the auto-detect setting in an atomic so the off-thread output/prompt
|
||||
// callbacks can read it without synchronizing with _settings. If the effective
|
||||
// taskbar state changes (because a command is currently active and the setting
|
||||
// toggled), notify listeners.
|
||||
const auto nowEnabled = _settings.AutoDetectRunningCommand();
|
||||
const auto wasEnabled = _autoDetectCommandActivity.exchange(nowEnabled, std::memory_order_relaxed);
|
||||
if (wasEnabled != nowEnabled && _commandActive.load(std::memory_order_relaxed))
|
||||
{
|
||||
TaskbarProgressChanged.raise(*this, nullptr);
|
||||
}
|
||||
|
||||
const auto lock = _terminal->LockForWriting();
|
||||
|
||||
_builtinGlyphs = _settings.EnableBuiltinGlyphs();
|
||||
@@ -1451,34 +1471,24 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// Method Description:
|
||||
// - Pre-process text pasted (presumably from the clipboard)
|
||||
// before sending it over the terminal's connection.
|
||||
void ControlCore::WriteInputString(const std::wstring_view& str, WriteInputStringType type)
|
||||
void ControlCore::PasteText(const winrt::hstring& hstr)
|
||||
{
|
||||
switch (type)
|
||||
using namespace ::Microsoft::Console::Utils;
|
||||
|
||||
auto filtered = FilterStringForPaste(hstr, CarriageReturnNewline | ControlCodes);
|
||||
if (BracketedPasteEnabled())
|
||||
{
|
||||
case WriteInputStringType::Clipboard:
|
||||
{
|
||||
using namespace ::Microsoft::Console::Utils;
|
||||
|
||||
auto filtered = FilterStringForPaste(str, CarriageReturnNewline | ControlCodes);
|
||||
if (BracketedPasteEnabled())
|
||||
{
|
||||
filtered.insert(0, L"\x1b[200~");
|
||||
filtered.append(L"\x1b[201~");
|
||||
}
|
||||
|
||||
// It's important to not hold the terminal lock while calling this function as sending the data may take a long time.
|
||||
_sendInput(filtered);
|
||||
|
||||
const auto lock = _terminal->LockForWriting();
|
||||
_terminal->ClearSelection();
|
||||
_updateSelectionUI();
|
||||
_terminal->TrySnapOnInput();
|
||||
return;
|
||||
}
|
||||
case WriteInputStringType::Raw:
|
||||
_sendInput(str);
|
||||
return;
|
||||
filtered.insert(0, L"\x1b[200~");
|
||||
filtered.append(L"\x1b[201~");
|
||||
}
|
||||
|
||||
// It's important to not hold the terminal lock while calling this function as sending the data may take a long time.
|
||||
SendInput(filtered);
|
||||
|
||||
const auto lock = _terminal->LockForWriting();
|
||||
_terminal->ClearSelection();
|
||||
_updateSelectionUI();
|
||||
_terminal->TrySnapOnInput();
|
||||
}
|
||||
|
||||
FontInfo ControlCore::GetFont() const
|
||||
@@ -1557,10 +1567,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// - Gets the internal taskbar state value
|
||||
// Return Value:
|
||||
// - The taskbar state of this control
|
||||
const size_t ControlCore::TaskbarState() const noexcept
|
||||
const Control::TaskbarState ControlCore::TaskbarState() const noexcept
|
||||
{
|
||||
const auto lock = _terminal->LockForReading();
|
||||
return _terminal->GetTaskbarState();
|
||||
const auto vtState = static_cast<Control::TaskbarState>(_terminal->GetTaskbarState());
|
||||
if (vtState == Control::TaskbarState::Clear &&
|
||||
_autoDetectCommandActivity.load(std::memory_order_relaxed) &&
|
||||
_commandActive.load(std::memory_order_relaxed))
|
||||
{
|
||||
return Control::TaskbarState::Indeterminate;
|
||||
}
|
||||
return vtState;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -1590,6 +1607,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
return _terminal->GetViewport().Height();
|
||||
}
|
||||
|
||||
// Function Description:
|
||||
// - Gets the width of the terminal in columns. This is just the
|
||||
// width of the viewport.
|
||||
// Return Value:
|
||||
// - The width of the terminal in columns
|
||||
int ControlCore::ViewWidth() const
|
||||
{
|
||||
const auto lock = _terminal->LockForReading();
|
||||
return _terminal->GetViewport().Width();
|
||||
}
|
||||
|
||||
// Function Description:
|
||||
// - Gets the height of the terminal in lines of text. This includes the
|
||||
// history AND the viewport.
|
||||
@@ -1609,6 +1637,26 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
WarningBell.raise(*this, nullptr);
|
||||
}
|
||||
|
||||
void ControlCore::_terminalPromptStarted()
|
||||
{
|
||||
if (_commandActive.exchange(false, std::memory_order_relaxed) &&
|
||||
_autoDetectCommandActivity.load(std::memory_order_relaxed))
|
||||
{
|
||||
TaskbarProgressChanged.raise(*this, nullptr);
|
||||
}
|
||||
PromptStarted.raise(*this, nullptr);
|
||||
}
|
||||
|
||||
void ControlCore::_terminalOutputStarted()
|
||||
{
|
||||
if (!_commandActive.exchange(true, std::memory_order_relaxed) &&
|
||||
_autoDetectCommandActivity.load(std::memory_order_relaxed))
|
||||
{
|
||||
TaskbarProgressChanged.raise(*this, nullptr);
|
||||
}
|
||||
OutputStarted.raise(*this, nullptr);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Called for the Terminal's TitleChanged callback. This will re-raise
|
||||
// a new winrt TypedEvent that can be listened to.
|
||||
@@ -1701,6 +1749,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
SearchMissingCommand.raise(*this, make<implementation::SearchMissingCommandEventArgs>(hstring{ missingCommand }, bufferRow));
|
||||
}
|
||||
|
||||
void ControlCore::_terminalShowNotification(std::wstring_view title, std::wstring_view body)
|
||||
{
|
||||
ShowNotification.raise(*this, make<implementation::ShowNotificationEventArgs>(hstring{ title }, hstring{ body }));
|
||||
}
|
||||
|
||||
void ControlCore::OpenCWD()
|
||||
{
|
||||
const auto workingDirectory = WorkingDirectory();
|
||||
@@ -2207,7 +2260,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// Sending input requires that we're unlocked, because
|
||||
// writing the input pipe may block indefinitely.
|
||||
const auto suspension = _terminal->SuspendLock();
|
||||
_sendInput(buffer);
|
||||
SendInput(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2348,6 +2401,13 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
}
|
||||
|
||||
_terminal->Write(sequence);
|
||||
|
||||
// Clear scroll marks so they don't remain stale in the scrollbar.
|
||||
// The Scrollback case is already handled by the \x1b[3J path (TextBuffer::ClearScrollback).
|
||||
if (clearType != ClearBufferType::Scrollback)
|
||||
{
|
||||
_terminal->ClearAllMarks();
|
||||
}
|
||||
}
|
||||
|
||||
if (clearType == Control::ClearBufferType::Screen || clearType == Control::ClearBufferType::All)
|
||||
|
||||
@@ -122,7 +122,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
til::color ForegroundColor() const;
|
||||
til::color BackgroundColor() const;
|
||||
|
||||
void WriteInputString(const std::wstring_view& str, WriteInputStringType type);
|
||||
void SendInput(std::wstring_view wstr);
|
||||
void PasteText(const winrt::hstring& hstr);
|
||||
bool CopySelectionToClipboard(bool singleLine, bool withControlSequences, const CopyFormat formats);
|
||||
void SelectAll();
|
||||
void ClearSelection();
|
||||
@@ -160,7 +161,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
void OpenCWD();
|
||||
|
||||
#pragma region ICoreState
|
||||
const size_t TaskbarState() const noexcept;
|
||||
const Control::TaskbarState TaskbarState() const noexcept;
|
||||
const size_t TaskbarProgress() const noexcept;
|
||||
|
||||
hstring Title();
|
||||
@@ -171,6 +172,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
||||
int ScrollOffset();
|
||||
int ViewHeight() const;
|
||||
int ViewWidth() const;
|
||||
int BufferHeight() const;
|
||||
|
||||
bool HasSelection() const;
|
||||
@@ -274,6 +276,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
til::typed_event<IInspectable, Control::TitleChangedEventArgs> TitleChanged;
|
||||
til::typed_event<IInspectable, Control::WriteToClipboardEventArgs> WriteToClipboard;
|
||||
til::typed_event<> WarningBell;
|
||||
til::typed_event<> PromptStarted;
|
||||
til::typed_event<> OutputStarted;
|
||||
til::typed_event<> TabColorChanged;
|
||||
til::typed_event<> BackgroundColorChanged;
|
||||
til::typed_event<IInspectable, Control::ScrollPositionChangedArgs> ScrollPositionChanged;
|
||||
@@ -291,6 +295,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
til::typed_event<IInspectable, Control::OpenHyperlinkEventArgs> OpenHyperlink;
|
||||
til::typed_event<IInspectable, Control::CompletionsChangedEventArgs> CompletionsChanged;
|
||||
til::typed_event<IInspectable, Control::SearchMissingCommandEventArgs> SearchMissingCommand;
|
||||
til::typed_event<IInspectable, Control::ShowNotificationEventArgs> ShowNotification;
|
||||
til::typed_event<> RefreshQuickFixUI;
|
||||
til::typed_event<IInspectable, Control::WindowSizeChangedEventArgs> WindowSizeChanged;
|
||||
|
||||
@@ -319,10 +324,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
||||
void _handleControlC();
|
||||
void _sendInputToConnection(std::wstring_view wstr);
|
||||
void _sendInput(std::wstring_view wstr);
|
||||
|
||||
#pragma region TerminalCoreCallbacks
|
||||
void _terminalWarningBell();
|
||||
void _terminalPromptStarted();
|
||||
void _terminalOutputStarted();
|
||||
void _terminalTitleChanged(std::wstring_view wstr);
|
||||
void _terminalScrollPositionChanged(const int viewTop,
|
||||
const int viewHeight,
|
||||
@@ -333,6 +339,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
const int velocity,
|
||||
const std::chrono::microseconds duration);
|
||||
void _terminalSearchMissingCommand(std::wstring_view missingCommand, const til::CoordType& bufferRow);
|
||||
void _terminalShowNotification(std::wstring_view title, std::wstring_view body);
|
||||
void _terminalWindowSizeChanged(int32_t width, int32_t height);
|
||||
|
||||
void _terminalCompletionsChanged(std::wstring_view menuJson, unsigned int replaceLength);
|
||||
@@ -419,6 +426,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
std::optional<til::point> _lastHoveredCell;
|
||||
uint16_t _lastHoveredId{ 0 };
|
||||
std::atomic<bool> _initializedTerminal{ false };
|
||||
std::atomic<bool> _autoDetectCommandActivity{ false };
|
||||
std::atomic<bool> _commandActive{ false };
|
||||
bool _isReadOnly{ false };
|
||||
bool _closing{ false };
|
||||
|
||||
|
||||
@@ -68,14 +68,6 @@ namespace Microsoft.Terminal.Control
|
||||
Boolean SearchRegexInvalid;
|
||||
};
|
||||
|
||||
enum WriteInputStringType
|
||||
{
|
||||
// Text which is to be passed through unmodified.
|
||||
Raw,
|
||||
// Text which is to be treated as clipboard input, stripped and formatted according to the application's wishes.
|
||||
Clipboard,
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass SelectionColor
|
||||
{
|
||||
SelectionColor();
|
||||
@@ -136,7 +128,8 @@ namespace Microsoft.Terminal.Control
|
||||
Boolean SendCharEvent(Char ch,
|
||||
Int16 scanCode,
|
||||
Microsoft.Terminal.Core.ControlKeyStates modifiers);
|
||||
void WriteInputString(String text, WriteInputStringType type);
|
||||
void SendInput(String text);
|
||||
void PasteText(String text);
|
||||
void SelectAll();
|
||||
void ClearSelection();
|
||||
Boolean ToggleBlockSelection();
|
||||
@@ -199,12 +192,15 @@ namespace Microsoft.Terminal.Control
|
||||
event Windows.Foundation.TypedEventHandler<Object, TitleChangedEventArgs> TitleChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, WriteToClipboardEventArgs> WriteToClipboard;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> WarningBell;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> PromptStarted;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> OutputStarted;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> TabColorChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> BackgroundColorChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> TaskbarProgressChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> RendererEnteredErrorState;
|
||||
event Windows.Foundation.TypedEventHandler<Object, ShowWindowArgs> ShowWindowChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, SearchMissingCommandEventArgs> SearchMissingCommand;
|
||||
event Windows.Foundation.TypedEventHandler<Object, ShowNotificationEventArgs> ShowNotification;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> RefreshQuickFixUI;
|
||||
event Windows.Foundation.TypedEventHandler<Object, WindowSizeChangedEventArgs> WindowSizeChanged;
|
||||
|
||||
|
||||
@@ -242,8 +242,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// - Initiate a paste operation.
|
||||
void ControlInteractivity::RequestPasteTextFromClipboard()
|
||||
{
|
||||
auto args = winrt::make<PasteFromClipboardEventArgs>(
|
||||
[core = _core](const winrt::hstring& wstr) {
|
||||
core->PasteText(wstr);
|
||||
},
|
||||
_core->BracketedPasteEnabled());
|
||||
|
||||
// send paste event up to TermApp
|
||||
PasteFromClipboard.raise(*this, nullptr);
|
||||
PasteFromClipboard.raise(*this, std::move(args));
|
||||
}
|
||||
|
||||
void ControlInteractivity::PointerPressed(const uint32_t /*pointerId*/,
|
||||
@@ -303,8 +309,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
const auto isOnOriginalPosition = _lastMouseClickPosNoSelection == pixelPosition;
|
||||
|
||||
// Rounded coordinates for text selection.
|
||||
// Don't round in VT mouse mode; cell-level precision matters more
|
||||
const auto round = !_core->IsVtMouseModeEnabled();
|
||||
// Don't round in VT mouse mode; cell-level precision matters more.
|
||||
// Only round for single-click: for double/triple-click, rounding
|
||||
// can push the position to the next cell, selecting the wrong word.
|
||||
const auto round = multiClickMapper == 1 && !_core->IsVtMouseModeEnabled();
|
||||
_core->LeftClickOnTerminal(_getTerminalPosition(til::point{ pixelPosition }, round),
|
||||
multiClickMapper,
|
||||
altEnabled,
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
void AttachToNewControl();
|
||||
|
||||
til::typed_event<IInspectable, Control::OpenHyperlinkEventArgs> OpenHyperlink;
|
||||
til::typed_event<IInspectable, IInspectable> PasteFromClipboard;
|
||||
til::typed_event<IInspectable, Control::PasteFromClipboardEventArgs> PasteFromClipboard;
|
||||
til::typed_event<IInspectable, Control::ScrollPositionChangedArgs> ScrollPositionChanged;
|
||||
til::typed_event<IInspectable, Control::ContextMenuRequestedEventArgs> ContextMenuRequested;
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Microsoft.Terminal.Control
|
||||
|
||||
event Windows.Foundation.TypedEventHandler<Object, OpenHyperlinkEventArgs> OpenHyperlink;
|
||||
event Windows.Foundation.TypedEventHandler<Object, ScrollPositionChangedArgs> ScrollPositionChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> PasteFromClipboard;
|
||||
event Windows.Foundation.TypedEventHandler<Object, PasteFromClipboardEventArgs> PasteFromClipboard;
|
||||
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> Closed;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "TitleChangedEventArgs.g.cpp"
|
||||
#include "ContextMenuRequestedEventArgs.g.cpp"
|
||||
#include "WriteToClipboardEventArgs.g.cpp"
|
||||
#include "PasteFromClipboardEventArgs.g.cpp"
|
||||
#include "OpenHyperlinkEventArgs.g.cpp"
|
||||
#include "NoticeEventArgs.g.cpp"
|
||||
#include "ScrollPositionChangedArgs.g.cpp"
|
||||
@@ -17,5 +18,6 @@
|
||||
#include "CompletionsChangedEventArgs.g.cpp"
|
||||
#include "KeySentEventArgs.g.cpp"
|
||||
#include "CharSentEventArgs.g.cpp"
|
||||
#include "StringSentEventArgs.g.cpp"
|
||||
#include "SearchMissingCommandEventArgs.g.cpp"
|
||||
#include "WindowSizeChangedEventArgs.g.cpp"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "TitleChangedEventArgs.g.h"
|
||||
#include "ContextMenuRequestedEventArgs.g.h"
|
||||
#include "WriteToClipboardEventArgs.g.h"
|
||||
#include "PasteFromClipboardEventArgs.g.h"
|
||||
#include "OpenHyperlinkEventArgs.g.h"
|
||||
#include "NoticeEventArgs.g.h"
|
||||
#include "ScrollPositionChangedArgs.g.h"
|
||||
@@ -17,7 +18,9 @@
|
||||
#include "CompletionsChangedEventArgs.g.h"
|
||||
#include "KeySentEventArgs.g.h"
|
||||
#include "CharSentEventArgs.g.h"
|
||||
#include "StringSentEventArgs.g.h"
|
||||
#include "SearchMissingCommandEventArgs.g.h"
|
||||
#include "ShowNotificationEventArgs.g.h"
|
||||
#include "WindowSizeChangedEventArgs.g.h"
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
@@ -81,6 +84,24 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
std::string _rtf;
|
||||
};
|
||||
|
||||
struct PasteFromClipboardEventArgs : public PasteFromClipboardEventArgsT<PasteFromClipboardEventArgs>
|
||||
{
|
||||
public:
|
||||
PasteFromClipboardEventArgs(std::function<void(const hstring&)> clipboardDataHandler, bool bracketedPasteEnabled) :
|
||||
m_clipboardDataHandler(clipboardDataHandler),
|
||||
_BracketedPasteEnabled{ bracketedPasteEnabled } {}
|
||||
|
||||
void HandleClipboardData(hstring value)
|
||||
{
|
||||
m_clipboardDataHandler(value);
|
||||
};
|
||||
|
||||
WINRT_PROPERTY(bool, BracketedPasteEnabled, false);
|
||||
|
||||
private:
|
||||
std::function<void(const hstring&)> m_clipboardDataHandler;
|
||||
};
|
||||
|
||||
struct OpenHyperlinkEventArgs : public OpenHyperlinkEventArgsT<OpenHyperlinkEventArgs>
|
||||
{
|
||||
public:
|
||||
@@ -212,6 +233,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
WINRT_PROPERTY(winrt::Microsoft::Terminal::Core::ControlKeyStates, Modifiers);
|
||||
};
|
||||
|
||||
struct StringSentEventArgs : public StringSentEventArgsT<StringSentEventArgs>
|
||||
{
|
||||
public:
|
||||
StringSentEventArgs(const winrt::hstring& text) :
|
||||
_Text(text) {}
|
||||
|
||||
WINRT_PROPERTY(winrt::hstring, Text);
|
||||
};
|
||||
|
||||
struct SearchMissingCommandEventArgs : public SearchMissingCommandEventArgsT<SearchMissingCommandEventArgs>
|
||||
{
|
||||
public:
|
||||
@@ -223,6 +253,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
til::property<til::CoordType> BufferRow;
|
||||
};
|
||||
|
||||
struct ShowNotificationEventArgs : public ShowNotificationEventArgsT<ShowNotificationEventArgs>
|
||||
{
|
||||
public:
|
||||
ShowNotificationEventArgs(const winrt::hstring& title, const winrt::hstring& body) :
|
||||
Title(title),
|
||||
Body(body) {}
|
||||
|
||||
til::property<winrt::hstring> Title;
|
||||
til::property<winrt::hstring> Body;
|
||||
};
|
||||
|
||||
struct WindowSizeChangedEventArgs : public WindowSizeChangedEventArgsT<WindowSizeChangedEventArgs>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -68,6 +68,12 @@ namespace Microsoft.Terminal.Control
|
||||
byte[] Rtf { get; }; // UTF-8, as required by "Rich Text Format"
|
||||
}
|
||||
|
||||
runtimeclass PasteFromClipboardEventArgs
|
||||
{
|
||||
void HandleClipboardData(String data);
|
||||
Boolean BracketedPasteEnabled { get; };
|
||||
}
|
||||
|
||||
runtimeclass OpenHyperlinkEventArgs
|
||||
{
|
||||
OpenHyperlinkEventArgs(String uri);
|
||||
@@ -143,12 +149,23 @@ namespace Microsoft.Terminal.Control
|
||||
Microsoft.Terminal.Core.ControlKeyStates Modifiers { get; };
|
||||
}
|
||||
|
||||
runtimeclass StringSentEventArgs
|
||||
{
|
||||
String Text { get; };
|
||||
}
|
||||
|
||||
runtimeclass SearchMissingCommandEventArgs
|
||||
{
|
||||
String MissingCommand { get; };
|
||||
Int32 BufferRow { get; };
|
||||
}
|
||||
|
||||
runtimeclass ShowNotificationEventArgs
|
||||
{
|
||||
String Title { get; };
|
||||
String Body { get; };
|
||||
}
|
||||
|
||||
runtimeclass WindowSizeChangedEventArgs
|
||||
{
|
||||
Int32 Width;
|
||||
|
||||
@@ -29,6 +29,30 @@ namespace Microsoft.Terminal.Control
|
||||
MinGW,
|
||||
};
|
||||
|
||||
[flags]
|
||||
enum OutputNotificationStyle
|
||||
{
|
||||
None = 0,
|
||||
Taskbar = 0x1,
|
||||
Audible = 0x2,
|
||||
Tab = 0x4,
|
||||
Notification = 0x8,
|
||||
All = 0xffffffff
|
||||
};
|
||||
|
||||
// Mirrors Microsoft::Console::VirtualTerminal::DispatchTypes::TaskbarState
|
||||
// (which is shared with conhost and lives outside the WinRT projection).
|
||||
// Values must remain numerically identical so the conversion at the
|
||||
// ControlCore boundary is a 1:1 cast.
|
||||
enum TaskbarState
|
||||
{
|
||||
Clear = 0,
|
||||
Set = 1,
|
||||
Error = 2,
|
||||
Indeterminate = 3,
|
||||
Paused = 4,
|
||||
};
|
||||
|
||||
// Class Description:
|
||||
// TerminalSettings encapsulates all settings that control the
|
||||
// TermControl's behavior. In these settings there is both the entirety
|
||||
@@ -78,6 +102,10 @@ namespace Microsoft.Terminal.Control
|
||||
PathTranslationStyle PathTranslationStyle { get; };
|
||||
String DragDropDelimiter { get; };
|
||||
|
||||
OutputNotificationStyle NotifyOnActivity { get; };
|
||||
OutputNotificationStyle NotifyOnNextPrompt { get; };
|
||||
Boolean AutoDetectRunningCommand { get; };
|
||||
|
||||
// NOTE! When adding something here, make sure to update ControlProperties.h too!
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import "IControlSettings.idl";
|
||||
|
||||
namespace Microsoft.Terminal.Control
|
||||
{
|
||||
enum MarkCategory
|
||||
@@ -31,7 +33,7 @@ namespace Microsoft.Terminal.Control
|
||||
interface ICoreState
|
||||
{
|
||||
String Title { get; };
|
||||
UInt64 TaskbarState { get; };
|
||||
Microsoft.Terminal.Control.TaskbarState TaskbarState { get; };
|
||||
UInt64 TaskbarProgress { get; };
|
||||
|
||||
String WorkingDirectory { get; };
|
||||
|
||||
@@ -137,6 +137,14 @@
|
||||
<value>Find</value>
|
||||
<comment>The placeholder text in the search box control.</comment>
|
||||
</data>
|
||||
<data name="DragFileCaption" xml:space="preserve">
|
||||
<value>Paste path to file</value>
|
||||
<comment>The displayed caption for dragging a file onto a terminal.</comment>
|
||||
</data>
|
||||
<data name="DragTextCaption" xml:space="preserve">
|
||||
<value>Paste text</value>
|
||||
<comment>The displayed caption for dragging text onto a terminal.</comment>
|
||||
</data>
|
||||
<data name="SearchBox_CaseSensitivity.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
||||
<value>Case Sensitivity</value>
|
||||
<comment>The name of the case sensitivity button on the search box control for accessibility.</comment>
|
||||
|
||||
@@ -23,6 +23,8 @@ using namespace winrt::Windows::UI::Core;
|
||||
using namespace winrt::Windows::UI::ViewManagement;
|
||||
using namespace winrt::Windows::UI::Input;
|
||||
using namespace winrt::Windows::System;
|
||||
using namespace winrt::Windows::ApplicationModel::DataTransfer;
|
||||
using namespace winrt::Windows::Storage::Streams;
|
||||
|
||||
// The minimum delay between updates to the scroll bar's values.
|
||||
// The updates are throttled to limit power usage.
|
||||
@@ -87,6 +89,72 @@ static Microsoft::Console::TSF::Handle& GetTSFHandle()
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
{
|
||||
static void _translatePathInPlace(std::wstring& fullPath, PathTranslationStyle translationStyle)
|
||||
{
|
||||
static constexpr wil::zwstring_view s_pathPrefixes[] = {
|
||||
{},
|
||||
/* WSL */ L"/mnt/",
|
||||
/* Cygwin */ L"/cygdrive/",
|
||||
/* MSYS2 */ L"/",
|
||||
/* MinGW */ {},
|
||||
};
|
||||
static constexpr wil::zwstring_view sSingleQuoteEscape = L"'\\''";
|
||||
static constexpr auto cchSingleQuoteEscape = sSingleQuoteEscape.size();
|
||||
|
||||
if (translationStyle == PathTranslationStyle::None)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// All of the other path translation modes current result in /-delimited paths
|
||||
std::replace(fullPath.begin(), fullPath.end(), L'\\', L'/');
|
||||
|
||||
// Escape single quotes, assuming translated paths are always quoted by a pair of single quotes.
|
||||
size_t pos = 0;
|
||||
while ((pos = fullPath.find(L'\'', pos)) != std::wstring::npos)
|
||||
{
|
||||
// ' -> '\'' (for POSIX shell)
|
||||
fullPath.replace(pos, 1, sSingleQuoteEscape);
|
||||
// Arithmetic overflow cannot occur here.
|
||||
pos += cchSingleQuoteEscape;
|
||||
}
|
||||
|
||||
if (translationStyle == PathTranslationStyle::MinGW)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (fullPath.size() >= 2 && fullPath.at(1) == L':')
|
||||
{
|
||||
// C:/foo/bar -> Cc/foo/bar
|
||||
fullPath.at(1) = til::tolower_ascii(fullPath.at(0));
|
||||
// Cc/foo/bar -> [PREFIX]c/foo/bar
|
||||
fullPath.replace(0, 1, s_pathPrefixes[static_cast<int>(translationStyle)]);
|
||||
}
|
||||
else if (translationStyle == PathTranslationStyle::WSL)
|
||||
{
|
||||
// Stripping the UNC name and distribution prefix only applies to WSL.
|
||||
static constexpr std::wstring_view wslPathPrefixes[] = { L"//wsl.localhost/", L"//wsl$/" };
|
||||
for (auto prefix : wslPathPrefixes)
|
||||
{
|
||||
if (til::starts_with(fullPath, prefix))
|
||||
{
|
||||
if (const auto idx = fullPath.find(L'/', prefix.size()); idx != std::wstring::npos)
|
||||
{
|
||||
// //wsl.localhost/Ubuntu-18.04/foo/bar -> /foo/bar
|
||||
fullPath.erase(0, idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
// //wsl.localhost/Ubuntu-18.04 -> /
|
||||
fullPath = L"/";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TsfDataProvider::TsfDataProvider(TermControl* termControl) noexcept :
|
||||
_termControl{ termControl }
|
||||
{
|
||||
@@ -170,7 +238,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
{
|
||||
return;
|
||||
}
|
||||
core->WriteInputString(text, WriteInputStringType::Raw);
|
||||
core->SendInput(text);
|
||||
}
|
||||
|
||||
::Microsoft::Console::Render::Renderer* TsfDataProvider::GetRenderer()
|
||||
@@ -260,6 +328,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
_revokers.CompletionsChanged = _core.CompletionsChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleCompletionsChanged });
|
||||
_revokers.RestartTerminalRequested = _core.RestartTerminalRequested(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleRestartTerminalRequested });
|
||||
_revokers.SearchMissingCommand = _core.SearchMissingCommand(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleSearchMissingCommand });
|
||||
_revokers.ShowNotification = _core.ShowNotification(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleShowNotification });
|
||||
_revokers.WindowSizeChanged = _core.WindowSizeChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleWindowSizeChanged });
|
||||
_revokers.WriteToClipboard = _core.WriteToClipboard(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleWriteToClipboard });
|
||||
|
||||
@@ -325,6 +394,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// attached content before we set up the throttled func, and that'll A/V
|
||||
_revokers.coreScrollPositionChanged = _core.ScrollPositionChanged(winrt::auto_revoke, { get_weak(), &TermControl::_ScrollPositionChanged });
|
||||
_revokers.WarningBell = _core.WarningBell(winrt::auto_revoke, { get_weak(), &TermControl::_coreWarningBell });
|
||||
_revokers.PromptStarted = _core.PromptStarted(winrt::auto_revoke, { get_weak(), &TermControl::_corePromptStarted });
|
||||
_revokers.OutputStarted = _core.OutputStarted(winrt::auto_revoke, { get_weak(), &TermControl::_coreOutputStarted });
|
||||
|
||||
static constexpr auto AutoScrollUpdateInterval = std::chrono::microseconds(static_cast<int>(1.0 / 30.0 * 1000000));
|
||||
_autoScrollTimer.Interval(AutoScrollUpdateInterval);
|
||||
@@ -844,13 +915,19 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// - wstr: the string of characters to write to the terminal connection.
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void TermControl::WriteInputString(const winrt::hstring& wstr, WriteInputStringType type)
|
||||
void TermControl::SendInput(const winrt::hstring& wstr)
|
||||
{
|
||||
// Dismiss any previewed input.
|
||||
PreviewInput(hstring{});
|
||||
_core.WriteInputString(wstr, type);
|
||||
}
|
||||
|
||||
// only broadcast if there's an actual listener. Saves the overhead of some object creation.
|
||||
if (StringSent)
|
||||
{
|
||||
StringSent.raise(*this, winrt::make<StringSentEventArgs>(wstr));
|
||||
}
|
||||
|
||||
RawWriteString(wstr);
|
||||
}
|
||||
void TermControl::ClearBuffer(Control::ClearBufferType clearType)
|
||||
{
|
||||
_core.ClearBuffer(clearType);
|
||||
@@ -1450,6 +1527,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
return _core.SendCharEvent(character, scanCode, modifiers);
|
||||
}
|
||||
|
||||
void TermControl::RawWriteString(const winrt::hstring& text)
|
||||
{
|
||||
_core.SendInput(text);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Manually handles key events for certain keys that can't be passed to us
|
||||
// normally. Namely, the keys we're concerned with are F7 down and Alt up.
|
||||
@@ -1596,7 +1678,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// If it encounters a string that isn't, cppwinrt will abort().
|
||||
// It should already be null-terminated, but let's make sure to not crash.
|
||||
buf[buf_len] = L'\0';
|
||||
_core.WriteInputString(std::wstring_view{ &buf[0], buf_len }, WriteInputStringType::Raw);
|
||||
_core.SendInput(std::wstring_view{ &buf[0], buf_len });
|
||||
}
|
||||
|
||||
s = {};
|
||||
@@ -2377,6 +2459,46 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
{
|
||||
_automationPeer.UpdateControlBounds();
|
||||
}
|
||||
|
||||
// Show resize overlay with columns x rows
|
||||
_ShowResizeOverlay();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Shows a centered overlay with the current terminal dimensions (columns x rows).
|
||||
// Used during window resize and font size changes. Skipped for disabled controls
|
||||
// (e.g. the Settings preview terminal) to avoid visual noise.
|
||||
void TermControl::_ShowResizeOverlay()
|
||||
{
|
||||
// Don't show the overlay in the Settings preview control
|
||||
if (!IsEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto coreImpl = winrt::get_self<ControlCore>(_core);
|
||||
const auto cols = coreImpl->ViewWidth();
|
||||
const auto rows = coreImpl->ViewHeight();
|
||||
if (cols > 0 && rows > 0)
|
||||
{
|
||||
ResizeOverlayText().Text(fmt::format(FMT_COMPILE(L"{} \u00D7 {}"), cols, rows));
|
||||
ResizeOverlay().Visibility(Visibility::Visible);
|
||||
|
||||
if (!_resizeOverlayTimer)
|
||||
{
|
||||
_resizeOverlayTimer.emplace();
|
||||
_resizeOverlayTimer->Interval(std::chrono::milliseconds(750));
|
||||
_resizeOverlayTimer->Tick([weakThis = get_weak()](auto&&, auto&&) {
|
||||
if (auto self = weakThis.get())
|
||||
{
|
||||
self->ResizeOverlay().Visibility(Visibility::Collapsed);
|
||||
self->_resizeOverlayTimer->Stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_resizeOverlayTimer->Start();
|
||||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -2990,6 +3112,230 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
return std::pow(cursorDistanceFromBorder, 2.0) / 25.0 + 2.0;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Async handler for the "Drop" event. If a file was dropped onto our
|
||||
// root, we'll try to get the path of the file dropped onto us, and write
|
||||
// the full path of the file to our terminal connection. Like conhost, if
|
||||
// the path contains a space, we'll wrap the path in quotes.
|
||||
// - Unlike conhost, if multiple files are dropped onto the terminal, we'll
|
||||
// write all the paths to the terminal, separated by the configured delimiter.
|
||||
// Arguments:
|
||||
// - e: The DragEventArgs from the Drop event
|
||||
// Return Value:
|
||||
// - <none>
|
||||
safe_void_coroutine TermControl::_DragDropHandler(Windows::Foundation::IInspectable /*sender*/,
|
||||
DragEventArgs e)
|
||||
{
|
||||
if (_IsClosing())
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
|
||||
if (const auto hwnd = reinterpret_cast<HWND>(OwningHwnd()))
|
||||
{
|
||||
SetForegroundWindow(hwnd);
|
||||
}
|
||||
|
||||
const auto weak = get_weak();
|
||||
|
||||
if (e.DataView().Contains(StandardDataFormats::ApplicationLink()))
|
||||
{
|
||||
try
|
||||
{
|
||||
auto link{ co_await e.DataView().GetApplicationLinkAsync() };
|
||||
if (const auto strong = weak.get())
|
||||
{
|
||||
_pasteTextWithBroadcast(link.AbsoluteUri());
|
||||
}
|
||||
}
|
||||
CATCH_LOG();
|
||||
}
|
||||
else if (e.DataView().Contains(StandardDataFormats::WebLink()))
|
||||
{
|
||||
try
|
||||
{
|
||||
auto link{ co_await e.DataView().GetWebLinkAsync() };
|
||||
if (const auto strong = weak.get())
|
||||
{
|
||||
_pasteTextWithBroadcast(link.AbsoluteUri());
|
||||
}
|
||||
}
|
||||
CATCH_LOG();
|
||||
}
|
||||
else if (e.DataView().Contains(StandardDataFormats::Text()))
|
||||
{
|
||||
try
|
||||
{
|
||||
auto text{ co_await e.DataView().GetTextAsync() };
|
||||
if (const auto strong = weak.get())
|
||||
{
|
||||
_pasteTextWithBroadcast(text);
|
||||
}
|
||||
}
|
||||
CATCH_LOG();
|
||||
}
|
||||
// StorageItem must be last. Some applications put hybrid data format items
|
||||
// in a drop message and we'll eat a crash when we request them.
|
||||
// Those applications usually include Text as well, so having storage items
|
||||
// last makes sure we'll hit text before getting to them.
|
||||
else if (e.DataView().Contains(StandardDataFormats::StorageItems()))
|
||||
{
|
||||
Windows::Foundation::Collections::IVectorView<Windows::Storage::IStorageItem> items;
|
||||
try
|
||||
{
|
||||
items = co_await e.DataView().GetStorageItemsAsync();
|
||||
}
|
||||
CATCH_LOG();
|
||||
|
||||
if (items && items.Size() > 0)
|
||||
{
|
||||
std::vector<std::wstring> fullPaths;
|
||||
|
||||
// GH#14628: Workaround for GetStorageItemsAsync() only returning 16 items
|
||||
// at most when dragging and dropping from archives (zip, 7z, rar, etc.)
|
||||
if (items.Size() == 16 && e.DataView().Contains(winrt::hstring{ L"FileDrop" }))
|
||||
{
|
||||
auto fileDropData = co_await e.DataView().GetDataAsync(winrt::hstring{ L"FileDrop" });
|
||||
if (fileDropData != nullptr)
|
||||
{
|
||||
auto stream = fileDropData.as<IRandomAccessStream>();
|
||||
stream.Seek(0);
|
||||
|
||||
const uint32_t streamSize = gsl::narrow_cast<uint32_t>(stream.Size());
|
||||
const Buffer buf(streamSize);
|
||||
const auto buffer = co_await stream.ReadAsync(buf, streamSize, InputStreamOptions::None);
|
||||
|
||||
const HGLOBAL hGlobal = buffer.data();
|
||||
const auto count = DragQueryFileW(static_cast<HDROP>(hGlobal), 0xFFFFFFFF, nullptr, 0);
|
||||
fullPaths.reserve(count);
|
||||
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
std::wstring path;
|
||||
path.resize(wil::max_path_length);
|
||||
const auto charsCopied = DragQueryFileW(static_cast<HDROP>(hGlobal), i, path.data(), wil::max_path_length);
|
||||
|
||||
if (charsCopied > 0)
|
||||
{
|
||||
path.resize(charsCopied);
|
||||
fullPaths.emplace_back(std::move(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fullPaths.reserve(items.Size());
|
||||
for (const auto& item : items)
|
||||
{
|
||||
fullPaths.emplace_back(item.Path());
|
||||
}
|
||||
}
|
||||
|
||||
const auto strong = weak.get();
|
||||
if (!strong)
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
|
||||
std::wstring allPathsString;
|
||||
const auto delimiter{ _core.Settings().DragDropDelimiter() };
|
||||
for (auto& fullPath : fullPaths)
|
||||
{
|
||||
// Join the paths with the delimiter
|
||||
if (!allPathsString.empty())
|
||||
{
|
||||
allPathsString += delimiter;
|
||||
}
|
||||
|
||||
const auto translationStyle{ _core.Settings().PathTranslationStyle() };
|
||||
_translatePathInPlace(fullPath, translationStyle);
|
||||
|
||||
// All translated paths get quotes, and all strings spaces get quotes; all translated paths get single quotes
|
||||
const auto quotesNeeded = translationStyle != PathTranslationStyle::None || fullPath.find(L' ') != std::wstring::npos;
|
||||
const auto quotesChar = translationStyle != PathTranslationStyle::None ? L'\'' : L'"';
|
||||
|
||||
// Append fullPath and also wrap it in quotes if needed
|
||||
if (quotesNeeded)
|
||||
{
|
||||
allPathsString.push_back(quotesChar);
|
||||
}
|
||||
allPathsString.append(fullPath);
|
||||
if (quotesNeeded)
|
||||
{
|
||||
allPathsString.push_back(quotesChar);
|
||||
}
|
||||
}
|
||||
|
||||
_pasteTextWithBroadcast(winrt::hstring{ allPathsString });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Paste this text, and raise a StringSent, to potentially broadcast this
|
||||
// text to other controls in the app. For certain interactions, like
|
||||
// drag/dropping a file, we want to act like we "pasted" the text (even if
|
||||
// the text didn't come from the clipboard). This lets those interactions
|
||||
// broadcast as well.
|
||||
void TermControl::_pasteTextWithBroadcast(const winrt::hstring& text)
|
||||
{
|
||||
// only broadcast if there's an actual listener. Saves the overhead of some object creation.
|
||||
if (StringSent)
|
||||
{
|
||||
StringSent.raise(*this, winrt::make<StringSentEventArgs>(text));
|
||||
}
|
||||
_core.PasteText(text);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Handle the DragOver event. We'll signal that the drag operation we
|
||||
// support is the "copy" operation, and we'll also customize the
|
||||
// appearance of the drag-drop UI, by removing the preview and setting a
|
||||
// custom caption. For more information, see
|
||||
// https://docs.microsoft.com/en-us/windows/uwp/design/input/drag-and-drop#customize-the-ui
|
||||
// Arguments:
|
||||
// - e: The DragEventArgs from the DragOver event
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void TermControl::_DragOverHandler(const Windows::Foundation::IInspectable& /*sender*/,
|
||||
const DragEventArgs& e)
|
||||
{
|
||||
if (_IsClosing())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// We can only handle drag/dropping StorageItems (files) and plain Text
|
||||
// currently. If the format on the clipboard is anything else, returning
|
||||
// early here will prevent the drag/drop from doing anything.
|
||||
if (!(e.DataView().Contains(StandardDataFormats::StorageItems()) ||
|
||||
e.DataView().Contains(StandardDataFormats::Text())))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure to set the AcceptedOperation, so that we can later receive the path in the Drop event
|
||||
e.AcceptedOperation(DataPackageOperation::Copy);
|
||||
|
||||
// Sets custom UI text
|
||||
if (e.DataView().Contains(StandardDataFormats::StorageItems()))
|
||||
{
|
||||
e.DragUIOverride().Caption(RS_(L"DragFileCaption"));
|
||||
}
|
||||
else if (e.DataView().Contains(StandardDataFormats::Text()))
|
||||
{
|
||||
e.DragUIOverride().Caption(RS_(L"DragTextCaption"));
|
||||
}
|
||||
|
||||
// Sets if the caption is visible
|
||||
e.DragUIOverride().IsCaptionVisible(true);
|
||||
// Sets if the dragged content is visible
|
||||
e.DragUIOverride().IsContentVisible(false);
|
||||
// Sets if the glyph is visible
|
||||
e.DragUIOverride().IsGlyphVisible(false);
|
||||
}
|
||||
|
||||
// Method description:
|
||||
// - Checks if the uri is valid and sends an event if so
|
||||
// Arguments:
|
||||
@@ -3053,7 +3399,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// - Gets the internal taskbar state value
|
||||
// Return Value:
|
||||
// - The taskbar state of this control
|
||||
const uint64_t TermControl::TaskbarState() const noexcept
|
||||
const Control::TaskbarState TermControl::TaskbarState() const noexcept
|
||||
{
|
||||
return _core.TaskbarState();
|
||||
}
|
||||
@@ -3423,6 +3769,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
_playWarningBell->Run();
|
||||
}
|
||||
|
||||
void TermControl::_corePromptStarted(const IInspectable& /*sender*/, const IInspectable& /*args*/)
|
||||
{
|
||||
PromptStarted.raise(*this, nullptr);
|
||||
}
|
||||
|
||||
void TermControl::_coreOutputStarted(const IInspectable& /*sender*/, const IInspectable& /*args*/)
|
||||
{
|
||||
OutputStarted.raise(*this, nullptr);
|
||||
}
|
||||
|
||||
hstring TermControl::ReadEntireBuffer() const
|
||||
{
|
||||
return _core.ReadEntireBuffer();
|
||||
@@ -3540,6 +3896,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
void TermControl::_coreOutputIdle(const IInspectable& /*sender*/, const IInspectable& /*args*/)
|
||||
{
|
||||
_refreshSearch();
|
||||
OutputIdle.raise(*this, nullptr);
|
||||
}
|
||||
|
||||
void TermControl::OwningHwnd(uint64_t owner)
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
void ColorSelection(Control::SelectionColor fg, Control::SelectionColor bg, Core::MatchMode matchMode);
|
||||
|
||||
#pragma region ICoreState
|
||||
const uint64_t TaskbarState() const noexcept;
|
||||
const Control::TaskbarState TaskbarState() const noexcept;
|
||||
const uint64_t TaskbarProgress() const noexcept;
|
||||
|
||||
hstring Title();
|
||||
@@ -125,7 +125,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
void ResetFontSize();
|
||||
winrt::Windows::Foundation::Size GetFontSize() const;
|
||||
|
||||
void WriteInputString(const winrt::hstring& wstr, WriteInputStringType type);
|
||||
void SendInput(const winrt::hstring& input);
|
||||
void ClearBuffer(Control::ClearBufferType clearType);
|
||||
|
||||
void ToggleShaderEffects();
|
||||
@@ -179,6 +179,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
||||
bool RawWriteKeyEvent(const WORD vkey, const WORD scanCode, const winrt::Microsoft::Terminal::Core::ControlKeyStates modifiers, const bool keyDown);
|
||||
bool RawWriteChar(const wchar_t character, const WORD scanCode, const winrt::Microsoft::Terminal::Core::ControlKeyStates modifiers);
|
||||
void RawWriteString(const winrt::hstring& text);
|
||||
|
||||
void ShowContextMenu();
|
||||
bool OpenQuickFixMenu();
|
||||
@@ -210,8 +211,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
til::typed_event<IInspectable, IInspectable> FocusFollowMouseRequested;
|
||||
til::typed_event<Control::TermControl, Windows::UI::Xaml::RoutedEventArgs> Initialized;
|
||||
til::typed_event<> WarningBell;
|
||||
til::typed_event<> PromptStarted;
|
||||
til::typed_event<> OutputStarted;
|
||||
til::typed_event<> OutputIdle;
|
||||
til::typed_event<IInspectable, Control::KeySentEventArgs> KeySent;
|
||||
til::typed_event<IInspectable, Control::CharSentEventArgs> CharSent;
|
||||
til::typed_event<IInspectable, Control::StringSentEventArgs> StringSent;
|
||||
til::typed_event<IInspectable, Control::SearchMissingCommandEventArgs> SearchMissingCommand;
|
||||
til::typed_event<IInspectable, Control::WindowSizeChangedEventArgs> WindowSizeChanged;
|
||||
|
||||
@@ -227,7 +232,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
BUBBLED_FORWARDED_TYPED_EVENT(CompletionsChanged, IInspectable, Control::CompletionsChangedEventArgs);
|
||||
BUBBLED_FORWARDED_TYPED_EVENT(RestartTerminalRequested, IInspectable, IInspectable);
|
||||
BUBBLED_FORWARDED_TYPED_EVENT(WriteToClipboard, IInspectable, Control::WriteToClipboardEventArgs);
|
||||
BUBBLED_FORWARDED_TYPED_EVENT(PasteFromClipboard, IInspectable, IInspectable);
|
||||
BUBBLED_FORWARDED_TYPED_EVENT(PasteFromClipboard, IInspectable, Control::PasteFromClipboardEventArgs);
|
||||
BUBBLED_FORWARDED_TYPED_EVENT(ShowNotification, IInspectable, Control::ShowNotificationEventArgs);
|
||||
|
||||
// clang-format on
|
||||
|
||||
@@ -314,6 +320,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
winrt::hstring _restorePath;
|
||||
bool _showMarksInScrollbar{ false };
|
||||
|
||||
std::optional<SafeDispatcherTimer> _resizeOverlayTimer;
|
||||
void _ShowResizeOverlay();
|
||||
|
||||
bool _isBackgroundLight{ false };
|
||||
bool _detached{ false };
|
||||
til::CoordType _searchScrollOffset = 0;
|
||||
@@ -376,6 +385,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
void _GotFocusHandler(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);
|
||||
void _LostFocusHandler(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);
|
||||
|
||||
safe_void_coroutine _DragDropHandler(Windows::Foundation::IInspectable sender, Windows::UI::Xaml::DragEventArgs e);
|
||||
void _DragOverHandler(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::DragEventArgs& e);
|
||||
|
||||
safe_void_coroutine _HyperlinkHandler(Windows::Foundation::IInspectable sender, Control::OpenHyperlinkEventArgs e);
|
||||
|
||||
void _BellLightOff(const Windows::Foundation::IInspectable& sender, const Windows::Foundation::IInspectable& e);
|
||||
@@ -419,11 +431,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
void _coreTransparencyChanged(IInspectable sender, Control::TransparencyChangedEventArgs args);
|
||||
void _coreRaisedNotice(const IInspectable& s, const Control::NoticeEventArgs& args);
|
||||
void _coreWarningBell(const IInspectable& sender, const IInspectable& args);
|
||||
void _corePromptStarted(const IInspectable& sender, const IInspectable& args);
|
||||
void _coreOutputStarted(const IInspectable& sender, const IInspectable& args);
|
||||
void _coreOutputIdle(const IInspectable& sender, const IInspectable& args);
|
||||
|
||||
winrt::Windows::Foundation::Point _toPosInDips(const Core::Point terminalCellPos);
|
||||
void _throttledUpdateScrollbar(const ScrollBarUpdate& update);
|
||||
|
||||
void _pasteTextWithBroadcast(const winrt::hstring& text);
|
||||
|
||||
void _contextMenuHandler(IInspectable sender, Control::ContextMenuRequestedEventArgs args);
|
||||
void _showContextMenuAt(const winrt::Windows::Foundation::Point& controlRelativePos);
|
||||
|
||||
@@ -442,6 +458,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
{
|
||||
Control::ControlCore::ScrollPositionChanged_revoker coreScrollPositionChanged;
|
||||
Control::ControlCore::WarningBell_revoker WarningBell;
|
||||
Control::ControlCore::PromptStarted_revoker PromptStarted;
|
||||
Control::ControlCore::OutputStarted_revoker OutputStarted;
|
||||
Control::ControlCore::RendererEnteredErrorState_revoker RendererEnteredErrorState;
|
||||
Control::ControlCore::BackgroundColorChanged_revoker BackgroundColorChanged;
|
||||
Control::ControlCore::FontSizeChanged_revoker FontSizeChanged;
|
||||
@@ -461,6 +479,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
Control::ControlCore::CompletionsChanged_revoker CompletionsChanged;
|
||||
Control::ControlCore::RestartTerminalRequested_revoker RestartTerminalRequested;
|
||||
Control::ControlCore::SearchMissingCommand_revoker SearchMissingCommand;
|
||||
Control::ControlCore::ShowNotification_revoker ShowNotification;
|
||||
Control::ControlCore::RefreshQuickFixUI_revoker RefreshQuickFixUI;
|
||||
Control::ControlCore::WindowSizeChanged_revoker WindowSizeChanged;
|
||||
|
||||
|
||||
@@ -64,11 +64,14 @@ namespace Microsoft.Terminal.Control
|
||||
|
||||
event Windows.Foundation.TypedEventHandler<Object, TitleChangedEventArgs> TitleChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, WriteToClipboardEventArgs> WriteToClipboard;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> PasteFromClipboard;
|
||||
event Windows.Foundation.TypedEventHandler<Object, PasteFromClipboardEventArgs> PasteFromClipboard;
|
||||
event Windows.Foundation.TypedEventHandler<Object, OpenHyperlinkEventArgs> OpenHyperlink;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> SetTaskbarProgress;
|
||||
event Windows.Foundation.TypedEventHandler<Object, NoticeEventArgs> RaiseNotice;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> WarningBell;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> PromptStarted;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> OutputStarted;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> OutputIdle;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> HidePointerCursor;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> RestorePointerCursor;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> TabColorChanged;
|
||||
@@ -80,7 +83,9 @@ namespace Microsoft.Terminal.Control
|
||||
|
||||
event Windows.Foundation.TypedEventHandler<Object, KeySentEventArgs> KeySent;
|
||||
event Windows.Foundation.TypedEventHandler<Object, CharSentEventArgs> CharSent;
|
||||
event Windows.Foundation.TypedEventHandler<Object, StringSentEventArgs> StringSent;
|
||||
event Windows.Foundation.TypedEventHandler<Object, SearchMissingCommandEventArgs> SearchMissingCommand;
|
||||
event Windows.Foundation.TypedEventHandler<Object, ShowNotificationEventArgs> ShowNotification;
|
||||
|
||||
|
||||
Microsoft.UI.Xaml.Controls.CommandBarFlyout ContextMenu { get; };
|
||||
@@ -126,9 +131,10 @@ namespace Microsoft.Terminal.Control
|
||||
void ResetFontSize();
|
||||
|
||||
void ToggleShaderEffects();
|
||||
void SendInput(String input);
|
||||
Boolean RawWriteKeyEvent(UInt16 vkey, UInt16 scanCode, Microsoft.Terminal.Core.ControlKeyStates modifiers, Boolean keyDown);
|
||||
Boolean RawWriteChar(Char character, UInt16 scanCode, Microsoft.Terminal.Core.ControlKeyStates modifiers);
|
||||
void WriteInputString(String text, WriteInputStringType type);
|
||||
void RawWriteString(String text);
|
||||
|
||||
void BellLightOn();
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
AllowFocusOnInteraction="True"
|
||||
Background="Transparent"
|
||||
CharacterReceived="_CharacterHandler"
|
||||
DragOver="_DragOverHandler"
|
||||
Drop="_DragDropHandler"
|
||||
GotFocus="_GotFocusHandler"
|
||||
IsTabStop="True"
|
||||
KeyUp="_KeyUpHandler"
|
||||
@@ -1363,6 +1365,24 @@
|
||||
|
||||
</Grid>
|
||||
|
||||
<!-- Resize overlay: shows columns x rows when terminal is resized -->
|
||||
<Border x:Name="ResizeOverlay"
|
||||
Padding="16,8,16,8"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Background="{ThemeResource SystemControlBackgroundAltHighBrush}"
|
||||
BorderBrush="{ThemeResource SystemAccentColor}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="{ThemeResource OverlayCornerRadius}"
|
||||
IsHitTestVisible="False"
|
||||
Visibility="Collapsed">
|
||||
<TextBlock x:Name="ResizeOverlayText"
|
||||
FontSize="18"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}"
|
||||
TextAlignment="Center" />
|
||||
</Border>
|
||||
|
||||
<Grid x:Name="RendererFailedNotice"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <winrt/Windows.ui.xaml.markup.h>
|
||||
#include <winrt/Windows.ui.xaml.shapes.h>
|
||||
#include <winrt/Windows.ApplicationModel.DataTransfer.h>
|
||||
#include <winrt/Windows.Storage.h>
|
||||
#include <winrt/Windows.Storage.Streams.h>
|
||||
#include <winrt/Windows.UI.Xaml.Shapes.h>
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ namespace Microsoft.Terminal.Core
|
||||
Boolean AllowKittyKeyboardMode { get; };
|
||||
Boolean AllowVtChecksumReport { get; };
|
||||
Boolean AllowVtClipboardWrite { get; };
|
||||
Boolean AllowOscNotifications { get; };
|
||||
Boolean TrimBlockSelection { get; };
|
||||
Boolean DetectURLs { get; };
|
||||
|
||||
|
||||
@@ -263,6 +263,7 @@ void Terminal::SetOptionalFeatures(winrt::Microsoft::Terminal::Core::ICoreSettin
|
||||
auto features = til::enumset<ITermDispatch::OptionalFeature>{};
|
||||
features.set(ITermDispatch::OptionalFeature::ChecksumReport, settings.AllowVtChecksumReport());
|
||||
features.set(ITermDispatch::OptionalFeature::ClipboardWrite, settings.AllowVtClipboardWrite());
|
||||
features.set(ITermDispatch::OptionalFeature::DesktopNotification, settings.AllowOscNotifications());
|
||||
engine.Dispatch().SetOptionalFeatures(features);
|
||||
}
|
||||
|
||||
@@ -763,6 +764,11 @@ TerminalInput::OutputType Terminal::SendCharEvent(const wchar_t ch, const WORD s
|
||||
// This changed the scrollbar marks - raise a notification to update them
|
||||
_NotifyScrollEvent();
|
||||
}
|
||||
// regardless, notify that we started command output
|
||||
if (_pfnOutputStarted)
|
||||
{
|
||||
_pfnOutputStarted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1248,7 +1254,7 @@ const std::optional<til::color> Terminal::GetTabColor() const
|
||||
// - Gets the internal taskbar state value
|
||||
// Return Value:
|
||||
// - The taskbar state
|
||||
const size_t Microsoft::Terminal::Core::Terminal::GetTaskbarState() const noexcept
|
||||
const Microsoft::Console::VirtualTerminal::DispatchTypes::TaskbarState Microsoft::Terminal::Core::Terminal::GetTaskbarState() const noexcept
|
||||
{
|
||||
return _taskbarState;
|
||||
}
|
||||
@@ -1272,11 +1278,26 @@ void Microsoft::Terminal::Core::Terminal::SetSearchMissingCommandCallback(std::f
|
||||
_pfnSearchMissingCommand.swap(pfn);
|
||||
}
|
||||
|
||||
void Microsoft::Terminal::Core::Terminal::SetShowNotificationCallback(std::function<void(std::wstring_view, std::wstring_view)> pfn) noexcept
|
||||
{
|
||||
_pfnShowNotification.swap(pfn);
|
||||
}
|
||||
|
||||
void Microsoft::Terminal::Core::Terminal::SetClearQuickFixCallback(std::function<void()> pfn) noexcept
|
||||
{
|
||||
_pfnClearQuickFix.swap(pfn);
|
||||
}
|
||||
|
||||
void Terminal::SetPromptStartedCallback(std::function<void()> pfn) noexcept
|
||||
{
|
||||
_pfnPromptStarted.swap(pfn);
|
||||
}
|
||||
|
||||
void Terminal::SetOutputStartedCallback(std::function<void()> pfn) noexcept
|
||||
{
|
||||
_pfnOutputStarted.swap(pfn);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Stores the search highlighted regions in the terminal
|
||||
void Terminal::SetSearchHighlights(const std::vector<til::point_span>& highlights) noexcept
|
||||
|
||||
@@ -159,12 +159,14 @@ public:
|
||||
|
||||
bool IsVtInputEnabled() const noexcept override;
|
||||
void NotifyBufferRotation(const int delta) override;
|
||||
void NotifyShellIntegrationMark() override;
|
||||
void NotifyShellIntegrationMark(ShellIntegrationMark mark) override;
|
||||
|
||||
void InvokeCompletions(std::wstring_view menuJson, unsigned int replaceLength) override;
|
||||
|
||||
void SearchMissingCommand(const std::wstring_view command) override;
|
||||
|
||||
void ShowNotification(const std::wstring_view title, const std::wstring_view body) override;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
void ClearMark();
|
||||
@@ -233,8 +235,11 @@ public:
|
||||
void SetPlayMidiNoteCallback(std::function<void(const int, const int, const std::chrono::microseconds)> pfn) noexcept;
|
||||
void CompletionsChangedCallback(std::function<void(std::wstring_view, unsigned int)> pfn) noexcept;
|
||||
void SetSearchMissingCommandCallback(std::function<void(std::wstring_view, const til::CoordType)> pfn) noexcept;
|
||||
void SetShowNotificationCallback(std::function<void(std::wstring_view, std::wstring_view)> pfn) noexcept;
|
||||
void SetClearQuickFixCallback(std::function<void()> pfn) noexcept;
|
||||
void SetWindowSizeChangedCallback(std::function<void(int32_t, int32_t)> pfn) noexcept;
|
||||
void SetPromptStartedCallback(std::function<void()> pfn) noexcept;
|
||||
void SetOutputStartedCallback(std::function<void()> pfn) noexcept;
|
||||
void SetSearchHighlights(const std::vector<til::point_span>& highlights) noexcept;
|
||||
void SetSearchHighlightFocused(size_t focusedIdx) noexcept;
|
||||
void ScrollToSearchHighlight(til::CoordType searchScrollOffset);
|
||||
@@ -243,7 +248,7 @@ public:
|
||||
|
||||
const std::optional<til::color> GetTabColor() const;
|
||||
|
||||
const size_t GetTaskbarState() const noexcept;
|
||||
const ::Microsoft::Console::VirtualTerminal::DispatchTypes::TaskbarState GetTaskbarState() const noexcept;
|
||||
const size_t GetTaskbarProgress() const noexcept;
|
||||
|
||||
void ColorSelection(const TextAttribute& attr, winrt::Microsoft::Terminal::Core::MatchMode matchMode);
|
||||
@@ -341,8 +346,11 @@ private:
|
||||
std::function<void(const int, const int, const std::chrono::microseconds)> _pfnPlayMidiNote;
|
||||
std::function<void(std::wstring_view, unsigned int)> _pfnCompletionsChanged;
|
||||
std::function<void(std::wstring_view, const til::CoordType)> _pfnSearchMissingCommand;
|
||||
std::function<void(std::wstring_view, std::wstring_view)> _pfnShowNotification;
|
||||
std::function<void()> _pfnClearQuickFix;
|
||||
std::function<void(int32_t, int32_t)> _pfnWindowSizeChanged;
|
||||
std::function<void()> _pfnPromptStarted;
|
||||
std::function<void()> _pfnOutputStarted;
|
||||
|
||||
RenderSettings _renderSettings;
|
||||
std::unique_ptr<::Microsoft::Console::VirtualTerminal::StateMachine> _stateMachine;
|
||||
@@ -363,6 +371,9 @@ private:
|
||||
|
||||
til::enumset<Mode> _systemMode{ Mode::AutoWrap };
|
||||
|
||||
::Microsoft::Console::VirtualTerminal::DispatchTypes::TaskbarState _taskbarState{ ::Microsoft::Console::VirtualTerminal::DispatchTypes::TaskbarState::Clear };
|
||||
size_t _taskbarProgress = 0;
|
||||
|
||||
bool _focused = false;
|
||||
bool _snapOnInput = true;
|
||||
bool _altGrAliasing = true;
|
||||
@@ -371,9 +382,6 @@ private:
|
||||
bool _autoMarkPrompts = false;
|
||||
bool _rainbowSuggestions = false;
|
||||
|
||||
size_t _taskbarState = 0;
|
||||
size_t _taskbarProgress = 0;
|
||||
|
||||
size_t _hyperlinkPatternId = 0;
|
||||
|
||||
std::wstring _answerbackMessage;
|
||||
|
||||
@@ -162,7 +162,7 @@ void Terminal::SetTaskbarProgress(const ::Microsoft::Console::VirtualTerminal::D
|
||||
{
|
||||
_assertLocked();
|
||||
|
||||
_taskbarState = static_cast<size_t>(state);
|
||||
_taskbarState = state;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
@@ -369,6 +369,14 @@ void Terminal::SearchMissingCommand(const std::wstring_view command)
|
||||
}
|
||||
}
|
||||
|
||||
void Terminal::ShowNotification(const std::wstring_view title, const std::wstring_view body)
|
||||
{
|
||||
if (_pfnShowNotification)
|
||||
{
|
||||
_pfnShowNotification(title, body);
|
||||
}
|
||||
}
|
||||
|
||||
void Terminal::NotifyBufferRotation(const int delta)
|
||||
{
|
||||
// Update our selection, so it doesn't move as the buffer is cycled
|
||||
@@ -405,8 +413,26 @@ void Terminal::NotifyBufferRotation(const int delta)
|
||||
}
|
||||
}
|
||||
|
||||
void Terminal::NotifyShellIntegrationMark()
|
||||
void Terminal::NotifyShellIntegrationMark(ShellIntegrationMark mark)
|
||||
{
|
||||
// Notify the scrollbar that marks have been added so it can refresh the mark indicators
|
||||
_NotifyScrollEvent();
|
||||
|
||||
switch (mark)
|
||||
{
|
||||
case ShellIntegrationMark::Prompt:
|
||||
if (_pfnPromptStarted)
|
||||
{
|
||||
_pfnPromptStarted();
|
||||
}
|
||||
break;
|
||||
case ShellIntegrationMark::Output:
|
||||
if (_pfnOutputStarted)
|
||||
{
|
||||
_pfnOutputStarted();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,8 +352,12 @@ namespace winrt::Microsoft::Terminal::Settings
|
||||
_AllowKittyKeyboardMode = profile.AllowKittyKeyboardMode();
|
||||
_AllowVtChecksumReport = profile.AllowVtChecksumReport();
|
||||
_AllowVtClipboardWrite = profile.AllowVtClipboardWrite();
|
||||
_AllowOscNotifications = profile.AllowOscNotifications();
|
||||
_PathTranslationStyle = profile.PathTranslationStyle();
|
||||
_DragDropDelimiter = profile.DragDropDelimiter();
|
||||
_NotifyOnActivity = profile.NotifyOnActivity();
|
||||
_NotifyOnNextPrompt = profile.NotifyOnNextPrompt();
|
||||
_AutoDetectRunningCommand = profile.AutoDetectRunningCommand();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
||||
@@ -75,6 +75,13 @@
|
||||
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
|
||||
</local:SettingContainer>
|
||||
|
||||
<!-- Show pane headers -->
|
||||
<local:SettingContainer x:Name="ShowPaneHeaders"
|
||||
x:Uid="Globals_ShowPaneHeaders">
|
||||
<ToggleSwitch IsOn="{x:Bind ViewModel.ShowPaneHeaders, Mode=TwoWay}"
|
||||
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
|
||||
</local:SettingContainer>
|
||||
|
||||
<!-- Show Acrylic in Tab Row -->
|
||||
<local:SettingContainer x:Name="AcrylicTabRow"
|
||||
x:Uid="Globals_AcrylicTabRow">
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, AlwaysShowTabs);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ShowTabsFullscreen);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ShowPaneHeaders);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ShowTabsInTitlebar);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, UseAcrylicInTabRow);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ShowTitleInTitlebar);
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, AlwaysShowTabs);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ShowTabsFullscreen);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ShowPaneHeaders);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ShowTabsInTitlebar);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, UseAcrylicInTabRow);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ShowTitleInTitlebar);
|
||||
|
||||
@@ -135,11 +135,14 @@
|
||||
<TextBlock x:Uid="Globals_WarningsHeader"
|
||||
Style="{StaticResource TextBlockSubHeaderStyle}" />
|
||||
|
||||
<!-- Close All Tabs Warning -->
|
||||
<local:SettingContainer x:Name="ConfirmCloseAllTabs"
|
||||
x:Uid="Globals_ConfirmCloseAllTabs">
|
||||
<ToggleSwitch IsOn="{x:Bind ViewModel.ConfirmCloseAllTabs, Mode=TwoWay}"
|
||||
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
|
||||
<!-- Confirm Close On -->
|
||||
<local:SettingContainer x:Name="ConfirmOnClose"
|
||||
x:Uid="Globals_ConfirmOnClose">
|
||||
<ComboBox AutomationProperties.AccessibilityView="Content"
|
||||
ItemTemplate="{StaticResource EnumComboBoxTemplate}"
|
||||
ItemsSource="{x:Bind ViewModel.ConfirmOnCloseList}"
|
||||
SelectedItem="{x:Bind ViewModel.CurrentConfirmOnClose, Mode=TwoWay}"
|
||||
Style="{StaticResource ComboBoxSettingStyle}" />
|
||||
</local:SettingContainer>
|
||||
|
||||
<!-- Input Service Warning -->
|
||||
|
||||
@@ -17,5 +17,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
INITIALIZE_BINDABLE_ENUM_SETTING(TabSwitcherMode, TabSwitcherMode, TabSwitcherMode, L"Globals_TabSwitcherMode", L"Content");
|
||||
INITIALIZE_BINDABLE_ENUM_SETTING(CopyFormat, CopyFormat, winrt::Microsoft::Terminal::Control::CopyFormat, L"Globals_CopyFormat", L"Content");
|
||||
INITIALIZE_BINDABLE_ENUM_SETTING(ConfirmOnClose, ConfirmOnClose, Model::ConfirmOnClose, L"Globals_ConfirmOnClose", L"Content");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
|
||||
GETSET_BINDABLE_ENUM_SETTING(TabSwitcherMode, Model::TabSwitcherMode, _GlobalSettings.TabSwitcherMode);
|
||||
GETSET_BINDABLE_ENUM_SETTING(CopyFormat, winrt::Microsoft::Terminal::Control::CopyFormat, _GlobalSettings.CopyFormatting);
|
||||
GETSET_BINDABLE_ENUM_SETTING(ConfirmOnClose, Model::ConfirmOnClose, _GlobalSettings.ConfirmOnClose);
|
||||
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, CopyOnSelect);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, TrimBlockSelection);
|
||||
@@ -30,7 +31,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, DetectURLs);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, SearchWebDefaultQueryUrl);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, WordDelimiters);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ConfirmCloseAllTabs);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, InputServiceWarning);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, WarnAboutLargePaste);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, WarnAboutMultiLinePaste);
|
||||
|
||||
@@ -12,10 +12,13 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||
InteractionViewModel(Microsoft.Terminal.Settings.Model.GlobalAppSettings globalSettings);
|
||||
|
||||
IInspectable CurrentTabSwitcherMode;
|
||||
Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Editor.EnumEntry> TabSwitcherModeList { get; };
|
||||
Windows.Foundation.Collections.IObservableVector<EnumEntry> TabSwitcherModeList { get; };
|
||||
|
||||
IInspectable CurrentCopyFormat;
|
||||
Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Editor.EnumEntry> CopyFormatList { get; };
|
||||
Windows.Foundation.Collections.IObservableVector<EnumEntry> CopyFormatList { get; };
|
||||
|
||||
IInspectable CurrentConfirmOnClose;
|
||||
Windows.Foundation.Collections.IObservableVector<EnumEntry> ConfirmOnCloseList { get; };
|
||||
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, CopyOnSelect);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, TrimBlockSelection);
|
||||
@@ -27,7 +30,6 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, DetectURLs);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(String, SearchWebDefaultQueryUrl);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(String, WordDelimiters);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ConfirmCloseAllTabs);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, InputServiceWarning);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, WarnAboutLargePaste);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Microsoft.Terminal.Control.WarnAboutMultiLinePaste, WarnAboutMultiLinePaste);
|
||||
|
||||
@@ -106,6 +106,14 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
_NotifyChanges(L"CurrentPathTranslationStyle");
|
||||
}
|
||||
else if (viewModelProperty == L"NotifyOnActivity")
|
||||
{
|
||||
_NotifyChanges(L"IsNotifyOnActivityFlagSet", L"NotifyOnActivityPreview");
|
||||
}
|
||||
else if (viewModelProperty == L"NotifyOnNextPrompt")
|
||||
{
|
||||
_NotifyChanges(L"IsNotifyOnNextPromptFlagSet", L"NotifyOnNextPromptPreview");
|
||||
}
|
||||
else if (viewModelProperty == L"Padding")
|
||||
{
|
||||
_parsedPadding = StringToXamlThickness(_profile.Padding());
|
||||
@@ -571,10 +579,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
return iconPath.empty() || iconPath == IconPicker::HideIconValue;
|
||||
}
|
||||
|
||||
#pragma region BellStyle
|
||||
hstring ProfileViewModel::BellStylePreview() const
|
||||
{
|
||||
const auto bellStyle = BellStyle();
|
||||
if (WI_AreAllFlagsSet(bellStyle, BellStyle::Audible | BellStyle::Window | BellStyle::Taskbar))
|
||||
if (WI_AreAllFlagsSet(bellStyle, BellStyle::Audible | BellStyle::Window | BellStyle::Taskbar | BellStyle::Notification))
|
||||
{
|
||||
return RS_(L"Profile_BellStyleAll/Content");
|
||||
}
|
||||
@@ -584,7 +593,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
}
|
||||
|
||||
std::vector<hstring> resultList;
|
||||
resultList.reserve(3);
|
||||
resultList.reserve(4);
|
||||
if (WI_IsFlagSet(bellStyle, BellStyle::Audible))
|
||||
{
|
||||
resultList.emplace_back(RS_(L"Profile_BellStyleAudible/Content"));
|
||||
@@ -597,6 +606,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
resultList.emplace_back(RS_(L"Profile_BellStyleTaskbar/Content"));
|
||||
}
|
||||
if (WI_IsFlagSet(bellStyle, BellStyle::Notification))
|
||||
{
|
||||
resultList.emplace_back(RS_(L"Profile_BellStyleNotification/Content"));
|
||||
}
|
||||
|
||||
// add in the commas
|
||||
hstring result{};
|
||||
@@ -640,6 +653,154 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
BellStyle(currentStyle);
|
||||
}
|
||||
|
||||
void ProfileViewModel::SetBellStyleNotification(winrt::Windows::Foundation::IReference<bool> on)
|
||||
{
|
||||
auto currentStyle = BellStyle();
|
||||
WI_UpdateFlag(currentStyle, Model::BellStyle::Notification, winrt::unbox_value<bool>(on));
|
||||
BellStyle(currentStyle);
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region NotifyOnActivity
|
||||
hstring ProfileViewModel::NotifyOnActivityPreview() const
|
||||
{
|
||||
using Ons = Control::OutputNotificationStyle;
|
||||
const auto style = NotifyOnActivity();
|
||||
if (WI_AreAllFlagsSet(style, Ons::Taskbar | Ons::Audible | Ons::Tab | Ons::Notification))
|
||||
{
|
||||
return RS_(L"Profile_OutputNotificationStyleAll/Content");
|
||||
}
|
||||
else if (style == Ons::None)
|
||||
{
|
||||
return RS_(L"Profile_OutputNotificationStyleNone/Content");
|
||||
}
|
||||
|
||||
std::wstring result;
|
||||
const auto appendIfFlagSet = [&](Ons flag, std::wstring_view resource) {
|
||||
// WI_IsFlagSet requires a compile-time constant flag; `flag` is a runtime parameter here.
|
||||
if ((WI_EnumValue(style) & WI_EnumValue(flag)) != 0)
|
||||
{
|
||||
if (!result.empty())
|
||||
{
|
||||
result.append(L", ");
|
||||
}
|
||||
result.append(resource);
|
||||
}
|
||||
};
|
||||
|
||||
appendIfFlagSet(Ons::Taskbar, RS_(L"Profile_OutputNotificationStyleTaskbar/Content"));
|
||||
appendIfFlagSet(Ons::Audible, RS_(L"Profile_OutputNotificationStyleAudible/Content"));
|
||||
appendIfFlagSet(Ons::Tab, RS_(L"Profile_OutputNotificationStyleTab/Content"));
|
||||
appendIfFlagSet(Ons::Notification, RS_(L"Profile_OutputNotificationStyleNotification/Content"));
|
||||
|
||||
return hstring{ result };
|
||||
}
|
||||
|
||||
bool ProfileViewModel::IsNotifyOnActivityFlagSet(const uint32_t flag)
|
||||
{
|
||||
return (WI_EnumValue(NotifyOnActivity()) & flag) == flag;
|
||||
}
|
||||
|
||||
void ProfileViewModel::SetNotifyOnActivityTaskbar(winrt::Windows::Foundation::IReference<bool> on)
|
||||
{
|
||||
auto currentStyle = NotifyOnActivity();
|
||||
WI_UpdateFlag(currentStyle, Control::OutputNotificationStyle::Taskbar, winrt::unbox_value<bool>(on));
|
||||
NotifyOnActivity(currentStyle);
|
||||
}
|
||||
|
||||
void ProfileViewModel::SetNotifyOnActivityAudible(winrt::Windows::Foundation::IReference<bool> on)
|
||||
{
|
||||
auto currentStyle = NotifyOnActivity();
|
||||
WI_UpdateFlag(currentStyle, Control::OutputNotificationStyle::Audible, winrt::unbox_value<bool>(on));
|
||||
NotifyOnActivity(currentStyle);
|
||||
}
|
||||
|
||||
void ProfileViewModel::SetNotifyOnActivityTab(winrt::Windows::Foundation::IReference<bool> on)
|
||||
{
|
||||
auto currentStyle = NotifyOnActivity();
|
||||
WI_UpdateFlag(currentStyle, Control::OutputNotificationStyle::Tab, winrt::unbox_value<bool>(on));
|
||||
NotifyOnActivity(currentStyle);
|
||||
}
|
||||
|
||||
void ProfileViewModel::SetNotifyOnActivityNotification(winrt::Windows::Foundation::IReference<bool> on)
|
||||
{
|
||||
auto currentStyle = NotifyOnActivity();
|
||||
WI_UpdateFlag(currentStyle, Control::OutputNotificationStyle::Notification, winrt::unbox_value<bool>(on));
|
||||
NotifyOnActivity(currentStyle);
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region NotifyOnNextPrompt
|
||||
hstring ProfileViewModel::NotifyOnNextPromptPreview() const
|
||||
{
|
||||
using Ons = Control::OutputNotificationStyle;
|
||||
const auto style = NotifyOnNextPrompt();
|
||||
if (WI_AreAllFlagsSet(style, Ons::Taskbar | Ons::Audible | Ons::Tab | Ons::Notification))
|
||||
{
|
||||
return RS_(L"Profile_OutputNotificationStyleAll/Content");
|
||||
}
|
||||
else if (style == Ons::None)
|
||||
{
|
||||
return RS_(L"Profile_OutputNotificationStyleNone/Content");
|
||||
}
|
||||
|
||||
std::wstring result;
|
||||
const auto appendIfFlagSet = [&](Ons flag, std::wstring_view resource) {
|
||||
// WI_IsFlagSet requires a compile-time constant flag; `flag` is a runtime parameter here.
|
||||
if ((WI_EnumValue(style) & WI_EnumValue(flag)) != 0)
|
||||
{
|
||||
if (!result.empty())
|
||||
{
|
||||
result.append(L", ");
|
||||
}
|
||||
result.append(resource);
|
||||
}
|
||||
};
|
||||
|
||||
appendIfFlagSet(Ons::Taskbar, RS_(L"Profile_OutputNotificationStyleTaskbar/Content"));
|
||||
appendIfFlagSet(Ons::Audible, RS_(L"Profile_OutputNotificationStyleAudible/Content"));
|
||||
appendIfFlagSet(Ons::Tab, RS_(L"Profile_OutputNotificationStyleTab/Content"));
|
||||
appendIfFlagSet(Ons::Notification, RS_(L"Profile_OutputNotificationStyleNotification/Content"));
|
||||
|
||||
return hstring{ result };
|
||||
}
|
||||
|
||||
bool ProfileViewModel::IsNotifyOnNextPromptFlagSet(const uint32_t flag)
|
||||
{
|
||||
return (WI_EnumValue(NotifyOnNextPrompt()) & flag) == flag;
|
||||
}
|
||||
|
||||
void ProfileViewModel::SetNotifyOnNextPromptTaskbar(winrt::Windows::Foundation::IReference<bool> on)
|
||||
{
|
||||
auto currentStyle = NotifyOnNextPrompt();
|
||||
WI_UpdateFlag(currentStyle, Control::OutputNotificationStyle::Taskbar, winrt::unbox_value<bool>(on));
|
||||
NotifyOnNextPrompt(currentStyle);
|
||||
}
|
||||
|
||||
void ProfileViewModel::SetNotifyOnNextPromptAudible(winrt::Windows::Foundation::IReference<bool> on)
|
||||
{
|
||||
auto currentStyle = NotifyOnNextPrompt();
|
||||
WI_UpdateFlag(currentStyle, Control::OutputNotificationStyle::Audible, winrt::unbox_value<bool>(on));
|
||||
NotifyOnNextPrompt(currentStyle);
|
||||
}
|
||||
|
||||
void ProfileViewModel::SetNotifyOnNextPromptTab(winrt::Windows::Foundation::IReference<bool> on)
|
||||
{
|
||||
auto currentStyle = NotifyOnNextPrompt();
|
||||
WI_UpdateFlag(currentStyle, Control::OutputNotificationStyle::Tab, winrt::unbox_value<bool>(on));
|
||||
NotifyOnNextPrompt(currentStyle);
|
||||
}
|
||||
|
||||
void ProfileViewModel::SetNotifyOnNextPromptNotification(winrt::Windows::Foundation::IReference<bool> on)
|
||||
{
|
||||
auto currentStyle = NotifyOnNextPrompt();
|
||||
WI_UpdateFlag(currentStyle, Control::OutputNotificationStyle::Notification, winrt::unbox_value<bool>(on));
|
||||
NotifyOnNextPrompt(currentStyle);
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region BellSound
|
||||
|
||||
// Method Description:
|
||||
// - Construct _CurrentBellSounds by importing the _inherited_ value from the model
|
||||
// - Adds a PropertyChanged handler to each BellSoundViewModel to propagate changes to the model
|
||||
@@ -777,6 +938,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
_NotifyChanges(L"CurrentBellSounds");
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
void ProfileViewModel::DeleteProfile()
|
||||
{
|
||||
|
||||
@@ -46,6 +46,23 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
void SetBellStyleAudible(winrt::Windows::Foundation::IReference<bool> on);
|
||||
void SetBellStyleWindow(winrt::Windows::Foundation::IReference<bool> on);
|
||||
void SetBellStyleTaskbar(winrt::Windows::Foundation::IReference<bool> on);
|
||||
void SetBellStyleNotification(winrt::Windows::Foundation::IReference<bool> on);
|
||||
|
||||
// notify on activity bits
|
||||
hstring NotifyOnActivityPreview() const;
|
||||
bool IsNotifyOnActivityFlagSet(const uint32_t flag);
|
||||
void SetNotifyOnActivityTaskbar(winrt::Windows::Foundation::IReference<bool> on);
|
||||
void SetNotifyOnActivityAudible(winrt::Windows::Foundation::IReference<bool> on);
|
||||
void SetNotifyOnActivityTab(winrt::Windows::Foundation::IReference<bool> on);
|
||||
void SetNotifyOnActivityNotification(winrt::Windows::Foundation::IReference<bool> on);
|
||||
|
||||
// notify on next prompt bits
|
||||
hstring NotifyOnNextPromptPreview() const;
|
||||
bool IsNotifyOnNextPromptFlagSet(const uint32_t flag);
|
||||
void SetNotifyOnNextPromptTaskbar(winrt::Windows::Foundation::IReference<bool> on);
|
||||
void SetNotifyOnNextPromptAudible(winrt::Windows::Foundation::IReference<bool> on);
|
||||
void SetNotifyOnNextPromptTab(winrt::Windows::Foundation::IReference<bool> on);
|
||||
void SetNotifyOnNextPromptNotification(winrt::Windows::Foundation::IReference<bool> on);
|
||||
|
||||
hstring BellSoundPreview();
|
||||
void RequestAddBellSound(hstring path);
|
||||
@@ -142,10 +159,14 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AllowKittyKeyboardMode);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AllowVtChecksumReport);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AllowVtClipboardWrite);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AllowOscNotifications);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AnswerbackMessage);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, RainbowSuggestions);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, PathTranslationStyle);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, DragDropDelimiter);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, NotifyOnActivity);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, NotifyOnNextPrompt);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AutoDetectRunningCommand);
|
||||
|
||||
WINRT_PROPERTY(bool, IsBaseLayer, false);
|
||||
WINRT_PROPERTY(bool, FocusDeleteButton, false);
|
||||
|
||||
@@ -49,6 +49,21 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||
void SetBellStyleAudible(Windows.Foundation.IReference<Boolean> on);
|
||||
void SetBellStyleWindow(Windows.Foundation.IReference<Boolean> on);
|
||||
void SetBellStyleTaskbar(Windows.Foundation.IReference<Boolean> on);
|
||||
void SetBellStyleNotification(Windows.Foundation.IReference<Boolean> on);
|
||||
|
||||
String NotifyOnActivityPreview { get; };
|
||||
Boolean IsNotifyOnActivityFlagSet(UInt32 flag);
|
||||
void SetNotifyOnActivityTaskbar(Windows.Foundation.IReference<Boolean> on);
|
||||
void SetNotifyOnActivityAudible(Windows.Foundation.IReference<Boolean> on);
|
||||
void SetNotifyOnActivityTab(Windows.Foundation.IReference<Boolean> on);
|
||||
void SetNotifyOnActivityNotification(Windows.Foundation.IReference<Boolean> on);
|
||||
|
||||
String NotifyOnNextPromptPreview { get; };
|
||||
Boolean IsNotifyOnNextPromptFlagSet(UInt32 flag);
|
||||
void SetNotifyOnNextPromptTaskbar(Windows.Foundation.IReference<Boolean> on);
|
||||
void SetNotifyOnNextPromptAudible(Windows.Foundation.IReference<Boolean> on);
|
||||
void SetNotifyOnNextPromptTab(Windows.Foundation.IReference<Boolean> on);
|
||||
void SetNotifyOnNextPromptNotification(Windows.Foundation.IReference<Boolean> on);
|
||||
|
||||
String BellSoundPreview { get; };
|
||||
Windows.Foundation.Collections.IObservableVector<BellSoundViewModel> CurrentBellSounds { get; };
|
||||
@@ -141,5 +156,9 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||
OBSERVABLE_PROJECTED_PROFILE_SETTING(Microsoft.Terminal.Control.PathTranslationStyle, PathTranslationStyle);
|
||||
OBSERVABLE_PROJECTED_PROFILE_SETTING(String, DragDropDelimiter);
|
||||
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AllowVtClipboardWrite);
|
||||
OBSERVABLE_PROJECTED_PROFILE_SETTING(Microsoft.Terminal.Control.OutputNotificationStyle, NotifyOnActivity);
|
||||
OBSERVABLE_PROJECTED_PROFILE_SETTING(Microsoft.Terminal.Control.OutputNotificationStyle, NotifyOnNextPrompt);
|
||||
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AutoDetectRunningCommand);
|
||||
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AllowOscNotifications);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +111,8 @@
|
||||
IsChecked="{x:Bind Profile.IsBellStyleFlagSet(2), BindBack=Profile.SetBellStyleWindow, Mode=TwoWay}" />
|
||||
<CheckBox x:Uid="Profile_BellStyleTaskbar"
|
||||
IsChecked="{x:Bind Profile.IsBellStyleFlagSet(4), BindBack=Profile.SetBellStyleTaskbar, Mode=TwoWay}" />
|
||||
<CheckBox x:Uid="Profile_BellStyleNotification"
|
||||
IsChecked="{x:Bind Profile.IsBellStyleFlagSet(8), BindBack=Profile.SetBellStyleNotification, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
</local:SettingContainer>
|
||||
|
||||
@@ -196,6 +198,56 @@
|
||||
</StackPanel>
|
||||
</local:SettingContainer>
|
||||
|
||||
<!-- Notify On Activity -->
|
||||
<local:SettingContainer x:Name="NotifyOnActivity"
|
||||
x:Uid="Profile_NotifyOnActivity"
|
||||
ClearSettingValue="{x:Bind Profile.ClearNotifyOnActivity}"
|
||||
CurrentValue="{x:Bind Profile.NotifyOnActivityPreview, Mode=OneWay}"
|
||||
HasSettingValue="{x:Bind Profile.HasNotifyOnActivity, Mode=OneWay}"
|
||||
SettingOverrideSource="{x:Bind Profile.NotifyOnActivityOverrideSource, Mode=OneWay}"
|
||||
Style="{StaticResource ExpanderSettingContainerStyle}">
|
||||
<StackPanel>
|
||||
<CheckBox x:Uid="Profile_OutputNotificationStyleTaskbar"
|
||||
IsChecked="{x:Bind Profile.IsNotifyOnActivityFlagSet(1), BindBack=Profile.SetNotifyOnActivityTaskbar, Mode=TwoWay}" />
|
||||
<CheckBox x:Uid="Profile_OutputNotificationStyleAudible"
|
||||
IsChecked="{x:Bind Profile.IsNotifyOnActivityFlagSet(2), BindBack=Profile.SetNotifyOnActivityAudible, Mode=TwoWay}" />
|
||||
<CheckBox x:Uid="Profile_OutputNotificationStyleTab"
|
||||
IsChecked="{x:Bind Profile.IsNotifyOnActivityFlagSet(4), BindBack=Profile.SetNotifyOnActivityTab, Mode=TwoWay}" />
|
||||
<CheckBox x:Uid="Profile_OutputNotificationStyleNotification"
|
||||
IsChecked="{x:Bind Profile.IsNotifyOnActivityFlagSet(8), BindBack=Profile.SetNotifyOnActivityNotification, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
</local:SettingContainer>
|
||||
|
||||
<!-- Notify On Next Prompt -->
|
||||
<local:SettingContainer x:Name="NotifyOnNextPrompt"
|
||||
x:Uid="Profile_NotifyOnNextPrompt"
|
||||
ClearSettingValue="{x:Bind Profile.ClearNotifyOnNextPrompt}"
|
||||
CurrentValue="{x:Bind Profile.NotifyOnNextPromptPreview, Mode=OneWay}"
|
||||
HasSettingValue="{x:Bind Profile.HasNotifyOnNextPrompt, Mode=OneWay}"
|
||||
SettingOverrideSource="{x:Bind Profile.NotifyOnNextPromptOverrideSource, Mode=OneWay}"
|
||||
Style="{StaticResource ExpanderSettingContainerStyle}">
|
||||
<StackPanel>
|
||||
<CheckBox x:Uid="Profile_OutputNotificationStyleTaskbar"
|
||||
IsChecked="{x:Bind Profile.IsNotifyOnNextPromptFlagSet(1), BindBack=Profile.SetNotifyOnNextPromptTaskbar, Mode=TwoWay}" />
|
||||
<CheckBox x:Uid="Profile_OutputNotificationStyleAudible"
|
||||
IsChecked="{x:Bind Profile.IsNotifyOnNextPromptFlagSet(2), BindBack=Profile.SetNotifyOnNextPromptAudible, Mode=TwoWay}" />
|
||||
<CheckBox x:Uid="Profile_OutputNotificationStyleTab"
|
||||
IsChecked="{x:Bind Profile.IsNotifyOnNextPromptFlagSet(4), BindBack=Profile.SetNotifyOnNextPromptTab, Mode=TwoWay}" />
|
||||
<CheckBox x:Uid="Profile_OutputNotificationStyleNotification"
|
||||
IsChecked="{x:Bind Profile.IsNotifyOnNextPromptFlagSet(8), BindBack=Profile.SetNotifyOnNextPromptNotification, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
</local:SettingContainer>
|
||||
|
||||
<!-- Auto Detect Running Command -->
|
||||
<local:SettingContainer x:Name="AutoDetectRunningCommand"
|
||||
x:Uid="Profile_AutoDetectRunningCommand"
|
||||
ClearSettingValue="{x:Bind Profile.ClearAutoDetectRunningCommand}"
|
||||
HasSettingValue="{x:Bind Profile.HasAutoDetectRunningCommand, Mode=OneWay}"
|
||||
SettingOverrideSource="{x:Bind Profile.AutoDetectRunningCommandOverrideSource, Mode=OneWay}">
|
||||
<ToggleSwitch IsOn="{x:Bind Profile.AutoDetectRunningCommand, Mode=TwoWay}"
|
||||
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
|
||||
</local:SettingContainer>
|
||||
|
||||
<!-- RightClickContextMenu -->
|
||||
<local:SettingContainer x:Name="RightClickContextMenu"
|
||||
x:Uid="Profile_RightClickContextMenu"
|
||||
|
||||
@@ -81,6 +81,16 @@
|
||||
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
|
||||
</local:SettingContainer>
|
||||
|
||||
<!-- Allow OSC 777 Desktop Notifications -->
|
||||
<local:SettingContainer x:Name="AllowOscNotifications"
|
||||
x:Uid="Profile_AllowOscNotifications"
|
||||
ClearSettingValue="{x:Bind Profile.ClearAllowOscNotifications}"
|
||||
HasSettingValue="{x:Bind Profile.HasAllowOscNotifications, Mode=OneWay}"
|
||||
SettingOverrideSource="{x:Bind Profile.AllowOscNotificationsOverrideSource, Mode=OneWay}">
|
||||
<ToggleSwitch IsOn="{x:Bind Profile.AllowOscNotifications, Mode=TwoWay}"
|
||||
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
|
||||
</local:SettingContainer>
|
||||
|
||||
<!-- Answerback Message -->
|
||||
<local:SettingContainer x:Name="AnswerbackMessage"
|
||||
x:Uid="Profile_AnswerbackMessage"
|
||||
|
||||
@@ -573,6 +573,14 @@
|
||||
<value>Allow OSC 52 (Manipulate Selection Data) to write to the clipboard</value>
|
||||
<comment>{Locked="OSC 52"}{Locked="Manipulate Selection Data"}Header for a control to toggle support for applications to change the contents of the Windows system clipboard.</comment>
|
||||
</data>
|
||||
<data name="Profile_AllowOscNotifications.Header" xml:space="preserve">
|
||||
<value>Allow OSC 777 (Desktop Notification) to show toast notifications</value>
|
||||
<comment>{Locked="OSC 777"}{Locked="Desktop Notification"}Header for a control to toggle support for applications to display desktop toast notifications via the OSC 777 escape sequence.</comment>
|
||||
</data>
|
||||
<data name="Profile_AllowOscNotifications.HelpText" xml:space="preserve">
|
||||
<value>When enabled, applications can send the OSC 777 escape sequence to trigger a desktop notification with a custom title and body.</value>
|
||||
<comment>{Locked="OSC 777"}Help text for the OSC 777 desktop notification toggle.</comment>
|
||||
</data>
|
||||
<data name="Globals_AllowHeadless.Header" xml:space="preserve">
|
||||
<value>Allow Windows Terminal to run in the background</value>
|
||||
<comment>Header for a control to toggle support for Windows Terminal to run in the background.</comment>
|
||||
@@ -1553,6 +1561,58 @@
|
||||
<value>Flash window</value>
|
||||
<comment>An option to choose from for the "bell style" setting. When selected, a visual notification is used to notify the user. In this case, the window is flashed.</comment>
|
||||
</data>
|
||||
<data name="Profile_OutputNotificationStyleNone.Content" xml:space="preserve">
|
||||
<value>None</value>
|
||||
<comment>An option to choose from for the notification style setting. When selected, no notification is sent.</comment>
|
||||
</data>
|
||||
<data name="Profile_OutputNotificationStyleAll.Content" xml:space="preserve">
|
||||
<value>All</value>
|
||||
<comment>An option to choose from for the notification style setting. When selected, all notification methods are used.</comment>
|
||||
</data>
|
||||
<data name="Profile_OutputNotificationStyleTaskbar.Content" xml:space="preserve">
|
||||
<value>Flash taskbar</value>
|
||||
<comment>An option to choose from for the notification style setting. Flashes the taskbar icon.</comment>
|
||||
</data>
|
||||
<data name="Profile_OutputNotificationStyleAudible.Content" xml:space="preserve">
|
||||
<value>Play sound</value>
|
||||
<comment>An option to choose from for the notification style setting. Plays an audible notification sound.</comment>
|
||||
</data>
|
||||
<data name="Profile_OutputNotificationStyleTab.Content" xml:space="preserve">
|
||||
<value>Show tab indicator</value>
|
||||
<comment>An option to choose from for the notification style setting. Shows an activity indicator on the tab.</comment>
|
||||
</data>
|
||||
<data name="Profile_OutputNotificationStyleNotification.Content" xml:space="preserve">
|
||||
<value>Desktop notification</value>
|
||||
<comment>An option to choose from for the notification style setting. Sends a Windows desktop notification (toast).</comment>
|
||||
</data>
|
||||
<data name="Profile_NotifyOnActivity.Header" xml:space="preserve">
|
||||
<value>Notify on activity</value>
|
||||
<comment>Header for a control to set the notification style when a background tab has new activity (output).</comment>
|
||||
</data>
|
||||
<data name="Profile_NotifyOnActivity.HelpText" xml:space="preserve">
|
||||
<value>Choose how to be notified when a background tab produces new output.</value>
|
||||
<comment>Help text for the notify on activity setting.</comment>
|
||||
</data>
|
||||
<data name="Profile_NotifyOnNextPrompt.Header" xml:space="preserve">
|
||||
<value>Notify on next prompt</value>
|
||||
<comment>Header for a control to set the notification style when a new shell prompt is detected (requires shell integration).</comment>
|
||||
</data>
|
||||
<data name="Profile_NotifyOnNextPrompt.HelpText" xml:space="preserve">
|
||||
<value>Choose how to be notified when a command finishes and a new prompt appears. Requires shell integration.</value>
|
||||
<comment>Help text for the notify on next prompt setting.</comment>
|
||||
</data>
|
||||
<data name="Profile_AutoDetectRunningCommand.Header" xml:space="preserve">
|
||||
<value>Auto-detect running command</value>
|
||||
<comment>Header for a control to configure automatic detection of a running command's progress state.</comment>
|
||||
</data>
|
||||
<data name="Profile_AutoDetectRunningCommand.HelpText" xml:space="preserve">
|
||||
<value>Automatically show a progress indicator when a command is running. Requires shell integration.</value>
|
||||
<comment>Help text for the auto-detect running command setting.</comment>
|
||||
</data>
|
||||
<data name="Profile_BellStyleNotification.Content" xml:space="preserve">
|
||||
<value>Desktop notification</value>
|
||||
<comment>An option to choose from for the "bell style" setting. When selected, a Windows desktop notification (toast) is sent to notify the user.</comment>
|
||||
</data>
|
||||
<data name="ColorScheme_AddNewButton.Text" xml:space="preserve">
|
||||
<value>Add new</value>
|
||||
<comment>Button label that creates a new color scheme.</comment>
|
||||
@@ -2197,6 +2257,26 @@
|
||||
<value>Warn when closing more than one tab</value>
|
||||
<comment>Header for a control to toggle whether to show a confirm dialog box when closing the application with multiple tabs open.</comment>
|
||||
</data>
|
||||
<data name="Globals_ConfirmOnClose.Header" xml:space="preserve">
|
||||
<value>Warn when closing</value>
|
||||
<comment>Header for a dropdown controlling when to show a confirmation dialog before closing.</comment>
|
||||
</data>
|
||||
<data name="Globals_ConfirmOnClose.HelpText" xml:space="preserve">
|
||||
<value>Controls when a confirmation dialog appears before closing tabs or windows. "Always" presents the dialog when closing any pane.</value>
|
||||
<comment>Help text associated with Globals_ConfirmOnClose. "Always" refers to Globals_ConfirmOnCloseAlways.Content.</comment>
|
||||
</data>
|
||||
<data name="Globals_ConfirmOnCloseNever.Content" xml:space="preserve">
|
||||
<value>Never</value>
|
||||
<comment>Option associated with Globals_ConfirmOnClose. "Never" means that the system will never display a warning when closing.</comment>
|
||||
</data>
|
||||
<data name="Globals_ConfirmOnCloseAlways.Content" xml:space="preserve">
|
||||
<value>Always</value>
|
||||
<comment>Option associated with Globals_ConfirmOnClose. "Always" means that the system will always display a warning when closing.</comment>
|
||||
</data>
|
||||
<data name="Globals_ConfirmOnCloseAutomatic.Content" xml:space="preserve">
|
||||
<value>Multiple tabs or panes</value>
|
||||
<comment>Option associated with Globals_ConfirmOnClose. The system will display a warning when multiple tabs or panes are present.</comment>
|
||||
</data>
|
||||
<data name="Globals_InputServiceWarning.Header" xml:space="preserve">
|
||||
<value>Warn when "Touch Keyboard and Handwriting Panel Service" is disabled</value>
|
||||
</data>
|
||||
@@ -2593,6 +2673,14 @@
|
||||
<value>When enabled, the tab bar will be visible when the app is full screen.</value>
|
||||
<comment>A description for what the "show tabs in full screen" setting does.</comment>
|
||||
</data>
|
||||
<data name="Globals_ShowPaneHeaders.Header" xml:space="preserve">
|
||||
<value>Show pane title headers</value>
|
||||
<comment>Header for a control to toggle if the app should show title headers above each pane when multiple panes are open.</comment>
|
||||
</data>
|
||||
<data name="Globals_ShowPaneHeaders.HelpText" xml:space="preserve">
|
||||
<value>When enabled, a title header is shown above each pane when multiple panes are open.</value>
|
||||
<comment>A description for what the "show pane headers" setting does. Presented near "Globals_ShowPaneHeaders.Header".</comment>
|
||||
</data>
|
||||
<data name="Profile_PathTranslationStyle.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
||||
<value>Path translation</value>
|
||||
<comment>Name for a control to select how file and directory paths are translated.</comment>
|
||||
|
||||
@@ -73,6 +73,8 @@ static constexpr std::string_view NewWindowKey{ "newWindow" };
|
||||
static constexpr std::string_view IdentifyWindowKey{ "identifyWindow" };
|
||||
static constexpr std::string_view IdentifyWindowsKey{ "identifyWindows" };
|
||||
static constexpr std::string_view RenameWindowKey{ "renameWindow" };
|
||||
static constexpr std::string_view OpenWorkspaceKey{ "openWorkspace" };
|
||||
|
||||
static constexpr std::string_view OpenWindowRenamerKey{ "openWindowRenamer" };
|
||||
static constexpr std::string_view DisplayWorkingDirectoryKey{ "debugTerminalCwd" };
|
||||
static constexpr std::string_view SearchForTextKey{ "searchWeb" };
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "PrevTabArgs.g.cpp"
|
||||
#include "NextTabArgs.g.cpp"
|
||||
#include "RenameWindowArgs.g.cpp"
|
||||
#include "OpenWorkspaceArgs.g.cpp"
|
||||
#include "SearchForTextArgs.g.cpp"
|
||||
#include "GlobalSummonArgs.g.cpp"
|
||||
#include "FocusPaneArgs.g.cpp"
|
||||
@@ -795,6 +796,15 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
return RS_switchable_(L"ResetWindowNameCommandKey");
|
||||
}
|
||||
|
||||
winrt::hstring OpenWorkspaceArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
|
||||
{
|
||||
if (!Name().empty())
|
||||
{
|
||||
return winrt::hstring{ RS_switchable_fmt(L"OpenWorkspaceCommandKey", Name()) };
|
||||
}
|
||||
return RS_switchable_(L"OpenWorkspaceDefaultCommandKey");
|
||||
}
|
||||
|
||||
winrt::hstring SearchForTextArgs::GenerateName(const winrt::WARC::ResourceContext& context) const
|
||||
{
|
||||
if (QueryUrl().empty())
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "PrevTabArgs.g.h"
|
||||
#include "NextTabArgs.g.h"
|
||||
#include "RenameWindowArgs.g.h"
|
||||
#include "OpenWorkspaceArgs.g.h"
|
||||
#include "SearchForTextArgs.g.h"
|
||||
#include "GlobalSummonArgs.g.h"
|
||||
#include "FocusPaneArgs.g.h"
|
||||
@@ -246,6 +247,10 @@ protected: \
|
||||
#define RENAME_WINDOW_ARGS(X) \
|
||||
X(winrt::hstring, Name, "name", false, ArgTypeHint::None, L"")
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#define OPEN_WORKSPACE_ARGS(X) \
|
||||
X(winrt::hstring, Name, "name", false, ArgTypeHint::None, L"")
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#define SEARCH_FOR_TEXT_ARGS(X) \
|
||||
X(winrt::hstring, QueryUrl, "queryUrl", false, ArgTypeHint::None, L"")
|
||||
@@ -940,6 +945,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
|
||||
ACTION_ARGS_STRUCT(RenameWindowArgs, RENAME_WINDOW_ARGS);
|
||||
|
||||
ACTION_ARGS_STRUCT(OpenWorkspaceArgs, OPEN_WORKSPACE_ARGS);
|
||||
|
||||
ACTION_ARGS_STRUCT(SearchForTextArgs, SEARCH_FOR_TEXT_ARGS);
|
||||
|
||||
struct GlobalSummonArgs : public GlobalSummonArgsT<GlobalSummonArgs>
|
||||
@@ -1059,6 +1066,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::factory_implementation
|
||||
BASIC_FACTORY(SetMaximizedArgs);
|
||||
BASIC_FACTORY(SetColorSchemeArgs);
|
||||
BASIC_FACTORY(RenameWindowArgs);
|
||||
BASIC_FACTORY(OpenWorkspaceArgs);
|
||||
BASIC_FACTORY(ExecuteCommandlineArgs);
|
||||
BASIC_FACTORY(CloseOtherTabsArgs);
|
||||
BASIC_FACTORY(CloseTabsAfterArgs);
|
||||
|
||||
@@ -420,6 +420,12 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
String Name { get; };
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass OpenWorkspaceArgs : IActionArgs, IActionArgsDescriptorAccess
|
||||
{
|
||||
OpenWorkspaceArgs(String name);
|
||||
String Name { get; };
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass SearchForTextArgs : IActionArgs, IActionArgsDescriptorAccess
|
||||
{
|
||||
String QueryUrl { get; };
|
||||
|
||||
@@ -113,7 +113,8 @@
|
||||
ON_ALL_ACTIONS(OpenScratchpad) \
|
||||
ON_ALL_ACTIONS(OpenAbout) \
|
||||
ON_ALL_ACTIONS(QuickFix) \
|
||||
ON_ALL_ACTIONS(OpenCWD)
|
||||
ON_ALL_ACTIONS(OpenCWD) \
|
||||
ON_ALL_ACTIONS(OpenWorkspace)
|
||||
|
||||
#define ALL_SHORTCUT_ACTIONS_WITH_ARGS \
|
||||
ON_ALL_ACTIONS_WITH_ARGS(AdjustFontSize) \
|
||||
@@ -158,7 +159,8 @@
|
||||
ON_ALL_ACTIONS_WITH_ARGS(Suggestions) \
|
||||
ON_ALL_ACTIONS_WITH_ARGS(SelectCommand) \
|
||||
ON_ALL_ACTIONS_WITH_ARGS(SelectOutput) \
|
||||
ON_ALL_ACTIONS_WITH_ARGS(ColorSelection)
|
||||
ON_ALL_ACTIONS_WITH_ARGS(ColorSelection) \
|
||||
ON_ALL_ACTIONS_WITH_ARGS(OpenWorkspace)
|
||||
|
||||
// These two macros here are for actions that we only use as internal currency.
|
||||
// They don't need to be parsed by the settings model, or saved as actions to
|
||||
|
||||
@@ -20,6 +20,7 @@ static constexpr std::string_view TabLayoutKey{ "tabLayout" };
|
||||
static constexpr std::string_view InitialPositionKey{ "initialPosition" };
|
||||
static constexpr std::string_view InitialSizeKey{ "initialSize" };
|
||||
static constexpr std::string_view LaunchModeKey{ "launchMode" };
|
||||
static constexpr std::string_view PersistedWorkspacesKey{ "persistedWorkspaces" };
|
||||
|
||||
namespace Microsoft::Terminal::Settings::Model::JsonUtils
|
||||
{
|
||||
@@ -276,6 +277,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
|
||||
MTSM_APPLICATION_STATE_FIELDS(MTSM_APPLICATION_STATE_GEN)
|
||||
#undef MTSM_APPLICATION_STATE_GEN
|
||||
|
||||
// Manually handled because IMap<K,V> has a comma that breaks the X-macro.
|
||||
if (WI_IsFlagSet(parseSource, FileSource::Local))
|
||||
state->PersistedWorkspaces = JsonUtils::GetValueForKey<std::optional<Windows::Foundation::Collections::IMap<hstring, Model::WindowLayout>>>(root, PersistedWorkspacesKey);
|
||||
}
|
||||
|
||||
Json::Value ApplicationState::ToJson(FileSource parseSource) const noexcept
|
||||
@@ -298,6 +303,10 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
|
||||
MTSM_APPLICATION_STATE_FIELDS(MTSM_APPLICATION_STATE_GEN)
|
||||
#undef MTSM_APPLICATION_STATE_GEN
|
||||
|
||||
// Manually handled because IMap<K,V> has a comma that breaks the X-macro.
|
||||
if (WI_IsFlagSet(parseSource, FileSource::Local))
|
||||
JsonUtils::SetValueForKey(root, PersistedWorkspacesKey, state->PersistedWorkspaces);
|
||||
}
|
||||
return root;
|
||||
}
|
||||
@@ -341,6 +350,114 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
return false;
|
||||
}
|
||||
|
||||
void ApplicationState::SaveWorkspace(const hstring& name, const Model::WindowLayout& layout)
|
||||
{
|
||||
{
|
||||
const auto state = _state.lock();
|
||||
if (!state->PersistedWorkspaces || !*state->PersistedWorkspaces)
|
||||
{
|
||||
state->PersistedWorkspaces = winrt::single_threaded_map<hstring, Model::WindowLayout>();
|
||||
}
|
||||
(*state->PersistedWorkspaces).Insert(name, layout);
|
||||
}
|
||||
_throttler();
|
||||
}
|
||||
|
||||
bool ApplicationState::RemoveWorkspace(const hstring& name)
|
||||
{
|
||||
bool removed{ false };
|
||||
{
|
||||
const auto state = _state.lock();
|
||||
if (state->PersistedWorkspaces && *state->PersistedWorkspaces)
|
||||
{
|
||||
auto map = *state->PersistedWorkspaces;
|
||||
if (map.HasKey(name))
|
||||
{
|
||||
map.Remove(name);
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (removed)
|
||||
{
|
||||
_throttler();
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Rename a persisted workspace entry from oldName to newName. If there
|
||||
// was no entry for oldName, this is a no-op. If an entry for newName
|
||||
// already exists, it will be overwritten with the layout from oldName.
|
||||
// Return Value:
|
||||
// - true if an entry was renamed, false otherwise.
|
||||
bool ApplicationState::RenameWorkspace(const hstring& oldName, const hstring& newName)
|
||||
{
|
||||
if (oldName == newName || oldName.empty() || newName.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool renamed{ false };
|
||||
{
|
||||
const auto state = _state.lock();
|
||||
if (state->PersistedWorkspaces && *state->PersistedWorkspaces)
|
||||
{
|
||||
auto map = *state->PersistedWorkspaces;
|
||||
if (map.HasKey(oldName))
|
||||
{
|
||||
const auto layout = map.Lookup(oldName);
|
||||
map.Insert(newName, layout);
|
||||
map.Remove(oldName);
|
||||
renamed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (renamed)
|
||||
{
|
||||
_throttler();
|
||||
}
|
||||
return renamed;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Atomically remove and return a persisted workspace entry. This is the
|
||||
// intended API for the startup path that restores a named workspace,
|
||||
// because it guarantees only one caller can claim a given workspace.
|
||||
// Return Value:
|
||||
// - The layout that was stored under `name`, or nullptr if there was none.
|
||||
Model::WindowLayout ApplicationState::TakeWorkspace(const hstring& name)
|
||||
{
|
||||
Model::WindowLayout result{ nullptr };
|
||||
{
|
||||
const auto state = _state.lock();
|
||||
if (state->PersistedWorkspaces && *state->PersistedWorkspaces)
|
||||
{
|
||||
auto map = *state->PersistedWorkspaces;
|
||||
if (map.HasKey(name))
|
||||
{
|
||||
result = map.Lookup(name);
|
||||
map.Remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
_throttler();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Windows::Foundation::Collections::IMapView<hstring, Model::WindowLayout> ApplicationState::AllPersistedWorkspaces()
|
||||
{
|
||||
const auto state = _state.lock_shared();
|
||||
if (state->PersistedWorkspaces && *state->PersistedWorkspaces)
|
||||
{
|
||||
return (*state->PersistedWorkspaces).GetView();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Generate all getter/setters
|
||||
#define MTSM_APPLICATION_STATE_GEN(source, type, name, key, ...) \
|
||||
type ApplicationState::name() const noexcept \
|
||||
|
||||
@@ -16,7 +16,7 @@ Abstract:
|
||||
#include "WindowLayout.g.h"
|
||||
|
||||
#include <inc/cppwinrt_utils.h>
|
||||
#include <JsonUtils.h>
|
||||
#include "JsonUtils.h"
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
{
|
||||
@@ -75,6 +75,12 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
bool DismissBadge(const hstring& badgeId);
|
||||
bool BadgeDismissed(const hstring& badgeId) const;
|
||||
|
||||
void SaveWorkspace(const hstring& name, const Model::WindowLayout& layout);
|
||||
bool RemoveWorkspace(const hstring& name);
|
||||
bool RenameWorkspace(const hstring& oldName, const hstring& newName);
|
||||
Model::WindowLayout TakeWorkspace(const hstring& name);
|
||||
Windows::Foundation::Collections::IMapView<hstring, Model::WindowLayout> AllPersistedWorkspaces();
|
||||
|
||||
// State getters/setters
|
||||
#define MTSM_APPLICATION_STATE_GEN(source, type, name, key, ...) \
|
||||
type name() const noexcept; \
|
||||
@@ -88,6 +94,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
#define MTSM_APPLICATION_STATE_GEN(source, type, name, key, ...) std::optional<type> name{ __VA_ARGS__ };
|
||||
MTSM_APPLICATION_STATE_FIELDS(MTSM_APPLICATION_STATE_GEN)
|
||||
#undef MTSM_APPLICATION_STATE_GEN
|
||||
// Manually declared because IMap<K,V> has a comma that breaks the macro.
|
||||
std::optional<Windows::Foundation::Collections::IMap<hstring, Model::WindowLayout>> PersistedWorkspaces;
|
||||
};
|
||||
til::shared_mutex<state_t> _state;
|
||||
std::filesystem::path _sharedPath;
|
||||
|
||||
@@ -36,6 +36,12 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
Boolean DismissBadge(String badgeId);
|
||||
Boolean BadgeDismissed(String badgeId);
|
||||
|
||||
void SaveWorkspace(String name, WindowLayout layout);
|
||||
Boolean RemoveWorkspace(String name);
|
||||
Boolean RenameWorkspace(String oldName, String newName);
|
||||
WindowLayout TakeWorkspace(String name);
|
||||
Windows.Foundation.Collections.IMapView<String, WindowLayout> AllPersistedWorkspaces();
|
||||
|
||||
String SettingsHash;
|
||||
Windows.Foundation.Collections.IVector<WindowLayout> PersistedWindowLayouts;
|
||||
Windows.Foundation.Collections.IVector<String> RecentCommands;
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
DEFINE_ENUM_MAP(Microsoft::Terminal::Control::TextMeasurement, TextMeasurement);
|
||||
DEFINE_ENUM_MAP(Microsoft::Terminal::Control::AmbiguousWidth, AmbiguousWidth);
|
||||
DEFINE_ENUM_MAP(Microsoft::Terminal::Control::WarnAboutMultiLinePaste, WarnAboutMultiLinePaste);
|
||||
DEFINE_ENUM_MAP(Model::ConfirmOnClose, ConfirmOnClose);
|
||||
|
||||
// Profile Settings
|
||||
DEFINE_ENUM_MAP(Model::CloseOnExitMode, CloseOnExitMode);
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
static winrt::Windows::Foundation::Collections::IMap<winrt::hstring, winrt::Microsoft::Terminal::Control::TextMeasurement> TextMeasurement();
|
||||
static winrt::Windows::Foundation::Collections::IMap<winrt::hstring, winrt::Microsoft::Terminal::Control::AmbiguousWidth> AmbiguousWidth();
|
||||
static winrt::Windows::Foundation::Collections::IMap<winrt::hstring, winrt::Microsoft::Terminal::Control::WarnAboutMultiLinePaste> WarnAboutMultiLinePaste();
|
||||
static winrt::Windows::Foundation::Collections::IMap<winrt::hstring, ConfirmOnClose> ConfirmOnClose();
|
||||
|
||||
// Profile Settings
|
||||
static winrt::Windows::Foundation::Collections::IMap<winrt::hstring, CloseOnExitMode> CloseOnExitMode();
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
static Windows.Foundation.Collections.IMap<String, Microsoft.Terminal.Control.TextMeasurement> TextMeasurement { get; };
|
||||
static Windows.Foundation.Collections.IMap<String, Microsoft.Terminal.Control.AmbiguousWidth> AmbiguousWidth { get; };
|
||||
static Windows.Foundation.Collections.IMap<String, Microsoft.Terminal.Control.WarnAboutMultiLinePaste> WarnAboutMultiLinePaste { get; };
|
||||
static Windows.Foundation.Collections.IMap<String, Microsoft.Terminal.Settings.Model.ConfirmOnClose> ConfirmOnClose { get; };
|
||||
|
||||
// Profile Settings
|
||||
static Windows.Foundation.Collections.IMap<String, Microsoft.Terminal.Settings.Model.CloseOnExitMode> CloseOnExitMode { get; };
|
||||
|
||||
@@ -160,7 +160,16 @@ void GlobalAppSettings::LayerJson(const Json::Value& json, const OriginTag origi
|
||||
_fixupsAppliedDuringLoad = JsonUtils::GetValueForKey(json, LegacyInputServiceWarningKey, _InputServiceWarning) || _fixupsAppliedDuringLoad;
|
||||
_fixupsAppliedDuringLoad = JsonUtils::GetValueForKey(json, LegacyWarnAboutLargePasteKey, _WarnAboutLargePaste) || _fixupsAppliedDuringLoad;
|
||||
_fixupsAppliedDuringLoad = JsonUtils::GetValueForKey(json, LegacyWarnAboutMultiLinePasteKey, _WarnAboutMultiLinePaste) || _fixupsAppliedDuringLoad;
|
||||
_fixupsAppliedDuringLoad = JsonUtils::GetValueForKey(json, LegacyConfirmCloseAllTabsKey, _ConfirmCloseAllTabs) || _fixupsAppliedDuringLoad;
|
||||
// GH#6549 - Migrate legacy "confirmCloseAllTabs" boolean to the new
|
||||
// "confirmOnClose" enum. true -> Automatic, false -> Never.
|
||||
{
|
||||
std::optional<bool> legacyConfirmClose;
|
||||
if (JsonUtils::GetValueForKey(json, LegacyConfirmCloseAllTabsKey, legacyConfirmClose))
|
||||
{
|
||||
_ConfirmOnClose = legacyConfirmClose.value() ? ConfirmOnClose::Automatic : ConfirmOnClose::Never;
|
||||
_fixupsAppliedDuringLoad = true;
|
||||
}
|
||||
}
|
||||
|
||||
#define GLOBAL_SETTINGS_LAYER_JSON(type, name, jsonKey, ...) \
|
||||
JsonUtils::GetValueForKey(json, jsonKey, _##name); \
|
||||
|
||||
@@ -50,6 +50,13 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
AfterCurrentTab,
|
||||
};
|
||||
|
||||
enum ConfirmOnClose
|
||||
{
|
||||
Never = 0,
|
||||
Automatic = 1,
|
||||
Always = 2,
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass GlobalAppSettings {
|
||||
Guid DefaultProfile;
|
||||
|
||||
@@ -59,9 +66,10 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
INHERITABLE_SETTING(Int32, InitialCols);
|
||||
INHERITABLE_SETTING(Boolean, AlwaysShowTabs);
|
||||
INHERITABLE_SETTING(Boolean, ShowTabsFullscreen);
|
||||
INHERITABLE_SETTING(Boolean, ShowPaneHeaders);
|
||||
INHERITABLE_SETTING(NewTabPosition, NewTabPosition);
|
||||
INHERITABLE_SETTING(Boolean, ShowTitleInTitlebar);
|
||||
INHERITABLE_SETTING(Boolean, ConfirmCloseAllTabs);
|
||||
INHERITABLE_SETTING(ConfirmOnClose, ConfirmOnClose);
|
||||
INHERITABLE_SETTING(String, Language);
|
||||
INHERITABLE_SETTING(Microsoft.UI.Xaml.Controls.TabViewWidthMode, TabWidthMode);
|
||||
INHERITABLE_SETTING(Boolean, UseAcrylicInTabRow);
|
||||
|
||||
@@ -38,7 +38,7 @@ Author(s):
|
||||
X(bool, AlwaysShowTabs, "alwaysShowTabs", true) \
|
||||
X(Model::NewTabPosition, NewTabPosition, "newTabPosition", Model::NewTabPosition::AfterLastTab) \
|
||||
X(bool, ShowTitleInTitlebar, "showTerminalTitleInTitlebar", true) \
|
||||
X(bool, ConfirmCloseAllTabs, "warning.confirmCloseAllTabs", true) \
|
||||
X(Model::ConfirmOnClose, ConfirmOnClose, "warning.confirmOnClose", Model::ConfirmOnClose::Automatic) \
|
||||
X(Model::ThemePair, Theme, "theme") \
|
||||
X(hstring, Language, "language") \
|
||||
X(winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, TabWidthMode, "tabWidthMode", winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::Equal) \
|
||||
@@ -71,7 +71,8 @@ Author(s):
|
||||
X(winrt::Windows::Foundation::Collections::IVector<Model::NewTabMenuEntry>, NewTabMenu, "newTabMenu", winrt::single_threaded_vector<Model::NewTabMenuEntry>({ Model::RemainingProfilesEntry{} })) \
|
||||
X(bool, AllowHeadless, "compatibility.allowHeadless", false) \
|
||||
X(hstring, SearchWebDefaultQueryUrl, "searchWebDefaultQueryUrl", L"https://www.bing.com/search?q=%22%s%22") \
|
||||
X(bool, ShowTabsFullscreen, "showTabsFullscreen", false)
|
||||
X(bool, ShowTabsFullscreen, "showTabsFullscreen", false) \
|
||||
X(bool, ShowPaneHeaders, "showPaneHeaders", true)
|
||||
|
||||
// Also add these settings to:
|
||||
// * Profile.idl
|
||||
@@ -79,37 +80,41 @@ Author(s):
|
||||
// * TerminalSettings.cpp: TerminalSettings::_ApplyProfileSettings
|
||||
// * IControlSettings.idl or ICoreSettings.idl
|
||||
// * ControlProperties.h
|
||||
#define MTSM_PROFILE_SETTINGS(X) \
|
||||
X(int32_t, HistorySize, "historySize", DEFAULT_HISTORY_SIZE) \
|
||||
X(bool, SnapOnInput, "snapOnInput", true) \
|
||||
X(bool, AltGrAliasing, "altGrAliasing", true) \
|
||||
X(hstring, AnswerbackMessage, "answerbackMessage") \
|
||||
X(hstring, Commandline, "commandline", L"%SystemRoot%\\System32\\cmd.exe") \
|
||||
X(Microsoft::Terminal::Control::ScrollbarState, ScrollState, "scrollbarState", Microsoft::Terminal::Control::ScrollbarState::Visible) \
|
||||
X(Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, "antialiasingMode", Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale) \
|
||||
X(hstring, StartingDirectory, "startingDirectory") \
|
||||
X(IMediaResource, Icon, "icon", implementation::MediaResource::FromString(L"\uE756")) \
|
||||
X(bool, SuppressApplicationTitle, "suppressApplicationTitle", false) \
|
||||
X(guid, ConnectionType, "connectionType") \
|
||||
X(CloseOnExitMode, CloseOnExit, "closeOnExit", CloseOnExitMode::Automatic) \
|
||||
X(hstring, TabTitle, "tabTitle") \
|
||||
X(Model::BellStyle, BellStyle, "bellStyle", BellStyle::Audible) \
|
||||
X(IEnvironmentVariableMap, EnvironmentVariables, "environment", nullptr) \
|
||||
X(bool, RightClickContextMenu, "rightClickContextMenu", false) \
|
||||
X(Windows::Foundation::Collections::IVector<IMediaResource>, BellSound, "bellSound", nullptr) \
|
||||
X(bool, Elevate, "elevate", false) \
|
||||
X(bool, AutoMarkPrompts, "autoMarkPrompts", true) \
|
||||
X(bool, ShowMarks, "showMarksOnScrollbar", false) \
|
||||
X(bool, RepositionCursorWithMouse, "experimental.repositionCursorWithMouse", false) \
|
||||
X(bool, ReloadEnvironmentVariables, "compatibility.reloadEnvironmentVariables", true) \
|
||||
X(bool, RainbowSuggestions, "experimental.rainbowSuggestions", false) \
|
||||
X(bool, ForceVTInput, "compatibility.input.forceVT", false) \
|
||||
X(bool, AllowKittyKeyboardMode, "compatibility.kittyKeyboardMode", true) \
|
||||
X(bool, AllowVtChecksumReport, "compatibility.allowDECRQCRA", false) \
|
||||
X(bool, AllowVtClipboardWrite, "compatibility.allowOSC52", true) \
|
||||
X(bool, AllowKeypadMode, "compatibility.allowDECNKM", false) \
|
||||
X(hstring, DragDropDelimiter, "dragDropDelimiter", L" ") \
|
||||
X(Microsoft::Terminal::Control::PathTranslationStyle, PathTranslationStyle, "pathTranslationStyle", Microsoft::Terminal::Control::PathTranslationStyle::None)
|
||||
#define MTSM_PROFILE_SETTINGS(X) \
|
||||
X(int32_t, HistorySize, "historySize", DEFAULT_HISTORY_SIZE) \
|
||||
X(bool, SnapOnInput, "snapOnInput", true) \
|
||||
X(bool, AltGrAliasing, "altGrAliasing", true) \
|
||||
X(hstring, AnswerbackMessage, "answerbackMessage") \
|
||||
X(hstring, Commandline, "commandline", L"%SystemRoot%\\System32\\cmd.exe") \
|
||||
X(Microsoft::Terminal::Control::ScrollbarState, ScrollState, "scrollbarState", Microsoft::Terminal::Control::ScrollbarState::Visible) \
|
||||
X(Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode, "antialiasingMode", Microsoft::Terminal::Control::TextAntialiasingMode::Grayscale) \
|
||||
X(hstring, StartingDirectory, "startingDirectory") \
|
||||
X(IMediaResource, Icon, "icon", implementation::MediaResource::FromString(L"\uE756")) \
|
||||
X(bool, SuppressApplicationTitle, "suppressApplicationTitle", false) \
|
||||
X(guid, ConnectionType, "connectionType") \
|
||||
X(CloseOnExitMode, CloseOnExit, "closeOnExit", CloseOnExitMode::Automatic) \
|
||||
X(hstring, TabTitle, "tabTitle") \
|
||||
X(Model::BellStyle, BellStyle, "bellStyle", BellStyle::Audible) \
|
||||
X(IEnvironmentVariableMap, EnvironmentVariables, "environment", nullptr) \
|
||||
X(bool, RightClickContextMenu, "rightClickContextMenu", false) \
|
||||
X(Windows::Foundation::Collections::IVector<IMediaResource>, BellSound, "bellSound", nullptr) \
|
||||
X(bool, Elevate, "elevate", false) \
|
||||
X(bool, AutoMarkPrompts, "autoMarkPrompts", true) \
|
||||
X(bool, ShowMarks, "showMarksOnScrollbar", false) \
|
||||
X(bool, RepositionCursorWithMouse, "experimental.repositionCursorWithMouse", false) \
|
||||
X(bool, ReloadEnvironmentVariables, "compatibility.reloadEnvironmentVariables", true) \
|
||||
X(bool, RainbowSuggestions, "experimental.rainbowSuggestions", false) \
|
||||
X(bool, ForceVTInput, "compatibility.input.forceVT", false) \
|
||||
X(bool, AllowKittyKeyboardMode, "compatibility.kittyKeyboardMode", true) \
|
||||
X(bool, AllowVtChecksumReport, "compatibility.allowDECRQCRA", false) \
|
||||
X(bool, AllowVtClipboardWrite, "compatibility.allowOSC52", true) \
|
||||
X(bool, AllowOscNotifications, "compatibility.allowOSC777", false) \
|
||||
X(bool, AllowKeypadMode, "compatibility.allowDECNKM", false) \
|
||||
X(hstring, DragDropDelimiter, "dragDropDelimiter", L" ") \
|
||||
X(Microsoft::Terminal::Control::PathTranslationStyle, PathTranslationStyle, "pathTranslationStyle", Microsoft::Terminal::Control::PathTranslationStyle::None) \
|
||||
X(Microsoft::Terminal::Control::OutputNotificationStyle, NotifyOnActivity, "notifyOnActivity", Microsoft::Terminal::Control::OutputNotificationStyle::None) \
|
||||
X(Microsoft::Terminal::Control::OutputNotificationStyle, NotifyOnNextPrompt, "notifyOnNextPrompt", Microsoft::Terminal::Control::OutputNotificationStyle::None) \
|
||||
X(bool, AutoDetectRunningCommand, "autoDetectRunningCommand", false)
|
||||
|
||||
// Intentionally omitted Profile settings:
|
||||
// * Name
|
||||
@@ -160,7 +165,8 @@ Author(s):
|
||||
X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, Frame, "frame", nullptr) \
|
||||
X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, UnfocusedFrame, "unfocusedFrame", nullptr) \
|
||||
X(bool, RainbowFrame, "experimental.rainbowFrame", false) \
|
||||
X(bool, UseMica, "useMica", false)
|
||||
X(bool, UseMica, "useMica", false) \
|
||||
X(bool, ShowWindowsButton, "showWindowsButton", true)
|
||||
|
||||
#define MTSM_THEME_SETTINGS_SETTINGS(X) \
|
||||
X(winrt::Windows::UI::Xaml::ElementTheme, RequestedTheme, "theme", winrt::Windows::UI::Xaml::ElementTheme::Default)
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
Audible = 0x1,
|
||||
Window = 0x2,
|
||||
Taskbar = 0x4,
|
||||
Notification = 0x8,
|
||||
All = 0xffffffff
|
||||
};
|
||||
|
||||
@@ -92,8 +93,12 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
INHERITABLE_PROFILE_SETTING(Boolean, AllowVtChecksumReport);
|
||||
INHERITABLE_PROFILE_SETTING(Boolean, AllowKeypadMode);
|
||||
INHERITABLE_PROFILE_SETTING(Boolean, AllowVtClipboardWrite);
|
||||
INHERITABLE_PROFILE_SETTING(Boolean, AllowOscNotifications);
|
||||
|
||||
INHERITABLE_PROFILE_SETTING(Microsoft.Terminal.Control.PathTranslationStyle, PathTranslationStyle);
|
||||
INHERITABLE_PROFILE_SETTING(String, DragDropDelimiter);
|
||||
INHERITABLE_PROFILE_SETTING(Microsoft.Terminal.Control.OutputNotificationStyle, NotifyOnActivity);
|
||||
INHERITABLE_PROFILE_SETTING(Microsoft.Terminal.Control.OutputNotificationStyle, NotifyOnNextPrompt);
|
||||
INHERITABLE_PROFILE_SETTING(Boolean, AutoDetectRunningCommand);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,6 +518,13 @@
|
||||
<data name="ResetWindowNameCommandKey" xml:space="preserve">
|
||||
<value>Reset window name</value>
|
||||
</data>
|
||||
<data name="OpenWorkspaceCommandKey" xml:space="preserve">
|
||||
<value>Open workspace "{0}"</value>
|
||||
<comment>{0} will be replaced with the workspace name</comment>
|
||||
</data>
|
||||
<data name="OpenWorkspaceDefaultCommandKey" xml:space="preserve">
|
||||
<value>Open workspace</value>
|
||||
</data>
|
||||
<data name="OpenWindowRenamerCommandKey" xml:space="preserve">
|
||||
<value>Rename window...</value>
|
||||
</data>
|
||||
@@ -702,7 +709,7 @@
|
||||
<comment>When enabled, input will go to all panes in this tab simultaneously</comment>
|
||||
</data>
|
||||
<data name="RestartConnectionKey" xml:space="preserve">
|
||||
<value>Restart connection</value>
|
||||
<value>Restart session</value>
|
||||
</data>
|
||||
<data name="OpenScratchpadKey" xml:space="preserve">
|
||||
<value>Open scratchpad</value>
|
||||
|
||||
@@ -88,14 +88,34 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Core::MatchMode)
|
||||
};
|
||||
};
|
||||
|
||||
JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::ConfirmOnClose)
|
||||
{
|
||||
JSON_MAPPINGS(3) = {
|
||||
pair_type{ "never", ValueType::Never },
|
||||
pair_type{ "automatic", ValueType::Automatic },
|
||||
pair_type{ "always", ValueType::Always },
|
||||
};
|
||||
|
||||
auto FromJson(const Json::Value& json)
|
||||
{
|
||||
return BaseEnumMapper::FromJson(json);
|
||||
}
|
||||
|
||||
bool CanConvert(const Json::Value& json)
|
||||
{
|
||||
return BaseEnumMapper::CanConvert(json);
|
||||
}
|
||||
};
|
||||
|
||||
JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::BellStyle)
|
||||
{
|
||||
static constexpr std::array<pair_type, 6> mappings = {
|
||||
static constexpr std::array<pair_type, 7> mappings = {
|
||||
pair_type{ "none", AllClear },
|
||||
pair_type{ "audible", ValueType::Audible },
|
||||
pair_type{ "visual", ValueType::Window | ValueType::Taskbar },
|
||||
pair_type{ "window", ValueType::Window },
|
||||
pair_type{ "taskbar", ValueType::Taskbar },
|
||||
pair_type{ "notification", ValueType::Notification },
|
||||
pair_type{ "all", AllSet },
|
||||
};
|
||||
|
||||
@@ -119,6 +139,37 @@ JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::BellStyle)
|
||||
}
|
||||
};
|
||||
|
||||
JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Control::OutputNotificationStyle)
|
||||
{
|
||||
static constexpr std::array<pair_type, 6> mappings = {
|
||||
pair_type{ "none", AllClear },
|
||||
pair_type{ "taskbar", ValueType::Taskbar },
|
||||
pair_type{ "audible", ValueType::Audible },
|
||||
pair_type{ "tab", ValueType::Tab },
|
||||
pair_type{ "notification", ValueType::Notification },
|
||||
pair_type{ "all", AllSet },
|
||||
};
|
||||
|
||||
auto FromJson(const Json::Value& json)
|
||||
{
|
||||
if (json.isBool())
|
||||
{
|
||||
return json.asBool() ? ValueType::Tab : AllClear;
|
||||
}
|
||||
return BaseFlagMapper::FromJson(json);
|
||||
}
|
||||
|
||||
bool CanConvert(const Json::Value& json)
|
||||
{
|
||||
return BaseFlagMapper::CanConvert(json) || json.isBool();
|
||||
}
|
||||
|
||||
Json::Value ToJson(const ::winrt::Microsoft::Terminal::Control::OutputNotificationStyle& style)
|
||||
{
|
||||
return BaseFlagMapper::ToJson(style);
|
||||
}
|
||||
};
|
||||
|
||||
JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::ConvergedAlignment)
|
||||
{
|
||||
// reduce repetition
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
Windows.UI.Xaml.ElementTheme RequestedTheme { get; };
|
||||
Boolean UseMica { get; };
|
||||
Boolean RainbowFrame { get; };
|
||||
Boolean ShowWindowsButton { get; };
|
||||
ThemeColor Frame { get; };
|
||||
ThemeColor UnfocusedFrame { get; };
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
"showAdminShield": true,
|
||||
|
||||
// Miscellaneous
|
||||
"confirmCloseAllTabs": true,
|
||||
"warning.confirmOnClose": "automatic",
|
||||
"theme": "dark",
|
||||
"snapToGridOnResize": true,
|
||||
"disableAnimations": false,
|
||||
|
||||
127
src/cascadia/UnitTests_SettingsModel/ApplicationStateTests.cpp
Normal file
127
src/cascadia/UnitTests_SettingsModel/ApplicationStateTests.cpp
Normal file
@@ -0,0 +1,127 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
#include "../TerminalSettingsModel/ApplicationState.h"
|
||||
|
||||
using namespace Microsoft::Console;
|
||||
using namespace WEX::Logging;
|
||||
using namespace WEX::TestExecution;
|
||||
using namespace WEX::Common;
|
||||
using namespace winrt::Microsoft::Terminal::Settings::Model;
|
||||
|
||||
namespace SettingsModelUnitTests
|
||||
{
|
||||
// Covers the workspace-persistence APIs added to ApplicationState:
|
||||
// SaveWorkspace / RemoveWorkspace / RenameWorkspace / TakeWorkspace /
|
||||
// AllPersistedWorkspaces.
|
||||
// All tests operate on a throw-away ApplicationState instance pointed at
|
||||
// a temp directory, so they don't touch the real user state.
|
||||
class ApplicationStateTests
|
||||
{
|
||||
TEST_CLASS(ApplicationStateTests);
|
||||
|
||||
TEST_METHOD(SaveAndLookupWorkspace);
|
||||
TEST_METHOD(RemoveWorkspaceReturnsFalseWhenMissing);
|
||||
TEST_METHOD(RenameWorkspaceMigratesEntry);
|
||||
TEST_METHOD(RenameWorkspaceNoOpForEmptyOrEqualNames);
|
||||
TEST_METHOD(RenameWorkspaceNoOpForMissingEntry);
|
||||
TEST_METHOD(TakeWorkspaceRemovesAndReturns);
|
||||
TEST_METHOD(TakeWorkspaceReturnsNullWhenMissing);
|
||||
|
||||
private:
|
||||
static std::filesystem::path _tempRoot()
|
||||
{
|
||||
auto root = std::filesystem::temp_directory_path() / L"WT_ApplicationStateTests";
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(root, ec);
|
||||
// Best-effort clean of any leftover state.json from a prior run so
|
||||
// tests see an empty starting point.
|
||||
std::filesystem::remove(root / L"state.json", ec);
|
||||
std::filesystem::remove(root / L"elevated-state.json", ec);
|
||||
return root;
|
||||
}
|
||||
|
||||
static winrt::com_ptr<implementation::ApplicationState> _make()
|
||||
{
|
||||
return winrt::make_self<implementation::ApplicationState>(_tempRoot());
|
||||
}
|
||||
|
||||
static WindowLayout _makeLayout()
|
||||
{
|
||||
WindowLayout layout;
|
||||
layout.TabLayout(winrt::single_threaded_vector<ActionAndArgs>());
|
||||
return layout;
|
||||
}
|
||||
};
|
||||
|
||||
void ApplicationStateTests::SaveAndLookupWorkspace()
|
||||
{
|
||||
auto state = _make();
|
||||
const auto layout = _makeLayout();
|
||||
state->SaveWorkspace(L"win1", layout);
|
||||
|
||||
const auto all = state->AllPersistedWorkspaces();
|
||||
VERIFY_IS_NOT_NULL(all);
|
||||
VERIFY_IS_TRUE(all.HasKey(L"win1"));
|
||||
}
|
||||
|
||||
void ApplicationStateTests::RemoveWorkspaceReturnsFalseWhenMissing()
|
||||
{
|
||||
auto state = _make();
|
||||
VERIFY_IS_FALSE(state->RemoveWorkspace(L"does-not-exist"));
|
||||
|
||||
state->SaveWorkspace(L"win1", _makeLayout());
|
||||
VERIFY_IS_TRUE(state->RemoveWorkspace(L"win1"));
|
||||
VERIFY_IS_FALSE(state->RemoveWorkspace(L"win1"));
|
||||
}
|
||||
|
||||
void ApplicationStateTests::RenameWorkspaceMigratesEntry()
|
||||
{
|
||||
auto state = _make();
|
||||
state->SaveWorkspace(L"oldName", _makeLayout());
|
||||
|
||||
VERIFY_IS_TRUE(state->RenameWorkspace(L"oldName", L"newName"));
|
||||
|
||||
const auto all = state->AllPersistedWorkspaces();
|
||||
VERIFY_IS_NOT_NULL(all);
|
||||
VERIFY_IS_FALSE(all.HasKey(L"oldName"));
|
||||
VERIFY_IS_TRUE(all.HasKey(L"newName"));
|
||||
}
|
||||
|
||||
void ApplicationStateTests::RenameWorkspaceNoOpForEmptyOrEqualNames()
|
||||
{
|
||||
auto state = _make();
|
||||
state->SaveWorkspace(L"win1", _makeLayout());
|
||||
|
||||
VERIFY_IS_FALSE(state->RenameWorkspace(L"win1", L"win1"));
|
||||
VERIFY_IS_FALSE(state->RenameWorkspace(L"", L"win2"));
|
||||
VERIFY_IS_FALSE(state->RenameWorkspace(L"win1", L""));
|
||||
}
|
||||
|
||||
void ApplicationStateTests::RenameWorkspaceNoOpForMissingEntry()
|
||||
{
|
||||
auto state = _make();
|
||||
VERIFY_IS_FALSE(state->RenameWorkspace(L"missing", L"newName"));
|
||||
}
|
||||
|
||||
void ApplicationStateTests::TakeWorkspaceRemovesAndReturns()
|
||||
{
|
||||
auto state = _make();
|
||||
state->SaveWorkspace(L"win1", _makeLayout());
|
||||
|
||||
const auto taken = state->TakeWorkspace(L"win1");
|
||||
VERIFY_IS_NOT_NULL(taken);
|
||||
|
||||
// Subsequent Take for the same name must return null — this is the
|
||||
// atomicity guarantee the startup path relies on.
|
||||
VERIFY_IS_NULL(state->TakeWorkspace(L"win1"));
|
||||
}
|
||||
|
||||
void ApplicationStateTests::TakeWorkspaceReturnsNullWhenMissing()
|
||||
{
|
||||
auto state = _make();
|
||||
VERIFY_IS_NULL(state->TakeWorkspace(L"missing"));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user