Skip to content

Commit e31202b

Browse files
committed
Merge commit '6a10ea5' into dev/migrie/fhl/non-terminal-panes-2023
2 parents e6dc314 + 6a10ea5 commit e31202b

22 files changed

+417
-36
lines changed

.github/actions/spelling/expect/expect.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,7 @@ WDDMCONSOLECONTEXT
21322132
wdm
21332133
webpage
21342134
websites
2135+
websockets
21352136
wekyb
21362137
wex
21372138
wextest

src/cascadia/TerminalApp/App.xaml

+9
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@
174174

175175
<SolidColorBrush x:Key="SettingsUiTabBrush"
176176
Color="#0c0c0c" />
177+
178+
<SolidColorBrush x:Key="BroadcastPaneBorderColor"
179+
Color="{StaticResource SystemAccentColorDark2}" />
177180
</ResourceDictionary>
178181

179182
<ResourceDictionary x:Key="Light">
@@ -190,6 +193,9 @@
190193

191194
<SolidColorBrush x:Key="SettingsUiTabBrush"
192195
Color="#ffffff" />
196+
197+
<SolidColorBrush x:Key="BroadcastPaneBorderColor"
198+
Color="{StaticResource SystemAccentColorLight2}" />
193199
</ResourceDictionary>
194200

195201
<ResourceDictionary x:Key="HighContrast">
@@ -210,6 +216,9 @@
210216

211217
<StaticResource x:Key="SettingsUiTabBrush"
212218
ResourceKey="SystemControlBackgroundBaseLowBrush" />
219+
220+
<SolidColorBrush x:Key="BroadcastPaneBorderColor"
221+
Color="{StaticResource SystemColorHighlightColor}" />
213222
</ResourceDictionary>
214223

215224
</ResourceDictionary.ThemeDictionaries>

src/cascadia/TerminalApp/AppActionHandlers.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,17 @@ namespace winrt::TerminalApp::implementation
12721272
}
12731273
}
12741274

1275+
void TerminalPage::_HandleToggleBroadcastInput(const IInspectable& /*sender*/,
1276+
const ActionEventArgs& args)
1277+
{
1278+
if (const auto activeTab{ _GetFocusedTabImpl() })
1279+
{
1280+
activeTab->ToggleBroadcastInput();
1281+
args.Handled(true);
1282+
}
1283+
// If the focused tab wasn't a TerminalTab, then leave handled=false
1284+
}
1285+
12751286
void TerminalPage::_HandleRestartConnection(const IInspectable& /*sender*/,
12761287
const ActionEventArgs& args)
12771288
{
@@ -1301,4 +1312,5 @@ namespace winrt::TerminalApp::implementation
13011312
}
13021313
args.Handled(true);
13031314
}
1315+
13041316
}

src/cascadia/TerminalApp/CommandPalette.xaml

+7
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@
205205
Glyph="&#xE72E;"
206206
Visibility="{x:Bind Item.(local:TabPaletteItem.TabStatus).IsReadOnlyActive, Mode=OneWay}" />
207207

208+
<FontIcon x:Name="HeaderBroadcastIcon"
209+
Margin="0,0,8,0"
210+
FontFamily="Segoe MDL2 Assets"
211+
FontSize="12"
212+
Glyph="&#xEC05;"
213+
Visibility="{x:Bind Item.(local:TabPaletteItem.TabStatus).IsInputBroadcastActive, Mode=OneWay}" />
214+
208215
</StackPanel>
209216
</Grid>
210217
</DataTemplate>

src/cascadia/TerminalApp/Pane.cpp

+79-2
Original file line numberDiff line numberDiff line change
@@ -1221,8 +1221,9 @@ void Pane::UpdateVisuals()
12211221
{
12221222
_UpdateBorders();
12231223
}
1224-
_borderFirst.BorderBrush(_lastActive ? _themeResources.focusedBorderBrush : _themeResources.unfocusedBorderBrush);
1225-
_borderSecond.BorderBrush(_lastActive ? _themeResources.focusedBorderBrush : _themeResources.unfocusedBorderBrush);
1224+
const auto& brush{ _ComputeBorderColor() };
1225+
_borderFirst.BorderBrush(brush);
1226+
_borderSecond.BorderBrush(brush);
12261227
}
12271228

12281229
// Method Description:
@@ -2963,3 +2964,79 @@ void Pane::CollectTaskbarStates(std::vector<winrt::TerminalApp::TaskbarState>& s
29632964
_secondChild->CollectTaskbarStates(states);
29642965
}
29652966
}
2967+
2968+
void Pane::EnableBroadcast(bool enabled)
2969+
{
2970+
if (_IsLeaf())
2971+
{
2972+
_broadcastEnabled = enabled;
2973+
UpdateVisuals();
2974+
}
2975+
else
2976+
{
2977+
_firstChild->EnableBroadcast(enabled);
2978+
_secondChild->EnableBroadcast(enabled);
2979+
}
2980+
}
2981+
2982+
void Pane::BroadcastKey(const winrt::Microsoft::Terminal::Control::TermControl& sourceControl,
2983+
const WORD vkey,
2984+
const WORD scanCode,
2985+
const winrt::Microsoft::Terminal::Core::ControlKeyStates modifiers,
2986+
const bool keyDown)
2987+
{
2988+
WalkTree([&](const auto& pane) {
2989+
if (const auto& termControl{ pane->GetTerminalControl() })
2990+
{
2991+
if (termControl != sourceControl && !termControl.ReadOnly())
2992+
{
2993+
termControl.RawWriteKeyEvent(vkey, scanCode, modifiers, keyDown);
2994+
}
2995+
}
2996+
});
2997+
}
2998+
2999+
void Pane::BroadcastChar(const winrt::Microsoft::Terminal::Control::TermControl& sourceControl,
3000+
const wchar_t character,
3001+
const WORD scanCode,
3002+
const winrt::Microsoft::Terminal::Core::ControlKeyStates modifiers)
3003+
{
3004+
WalkTree([&](const auto& pane) {
3005+
if (const auto& termControl{ pane->GetTerminalControl() })
3006+
{
3007+
if (termControl != sourceControl && !termControl.ReadOnly())
3008+
{
3009+
termControl.RawWriteChar(character, scanCode, modifiers);
3010+
}
3011+
}
3012+
});
3013+
}
3014+
3015+
void Pane::BroadcastString(const winrt::Microsoft::Terminal::Control::TermControl& sourceControl,
3016+
const winrt::hstring& text)
3017+
{
3018+
WalkTree([&](const auto& pane) {
3019+
if (const auto& termControl{ pane->GetTerminalControl() })
3020+
{
3021+
if (termControl != sourceControl && !termControl.ReadOnly())
3022+
{
3023+
termControl.RawWriteString(text);
3024+
}
3025+
}
3026+
});
3027+
}
3028+
3029+
winrt::Windows::UI::Xaml::Media::SolidColorBrush Pane::_ComputeBorderColor()
3030+
{
3031+
if (_lastActive)
3032+
{
3033+
return _themeResources.focusedBorderBrush;
3034+
}
3035+
3036+
if (_broadcastEnabled && (_IsLeaf() && !_content.ReadOnly()))
3037+
{
3038+
return _themeResources.broadcastBorderBrush;
3039+
}
3040+
3041+
return _themeResources.unfocusedBorderBrush;
3042+
}

src/cascadia/TerminalApp/Pane.h

+8
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct PaneResources
5656
{
5757
winrt::Windows::UI::Xaml::Media::SolidColorBrush focusedBorderBrush{ nullptr };
5858
winrt::Windows::UI::Xaml::Media::SolidColorBrush unfocusedBorderBrush{ nullptr };
59+
winrt::Windows::UI::Xaml::Media::SolidColorBrush broadcastBorderBrush{ nullptr };
5960
};
6061

6162
class Pane : public std::enable_shared_from_this<Pane>
@@ -147,6 +148,11 @@ class Pane : public std::enable_shared_from_this<Pane>
147148

148149
bool ContainsReadOnly() const;
149150

151+
void EnableBroadcast(bool enabled);
152+
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);
153+
void BroadcastChar(const winrt::Microsoft::Terminal::Control::TermControl& sourceControl, const wchar_t vkey, const WORD scanCode, const winrt::Microsoft::Terminal::Core::ControlKeyStates modifiers);
154+
void BroadcastString(const winrt::Microsoft::Terminal::Control::TermControl& sourceControl, const winrt::hstring& text);
155+
150156
void UpdateResources(const PaneResources& resources);
151157

152158
// Method Description:
@@ -255,6 +261,7 @@ class Pane : public std::enable_shared_from_this<Pane>
255261
Borders _borders{ Borders::None };
256262

257263
bool _zoomed{ false };
264+
bool _broadcastEnabled{ false };
258265

259266
bool _IsLeaf() const noexcept;
260267
bool _HasFocusedChild() const noexcept;
@@ -274,6 +281,7 @@ class Pane : public std::enable_shared_from_this<Pane>
274281
void _SetupEntranceAnimation();
275282
void _UpdateBorders();
276283
Borders _GetCommonBorders();
284+
winrt::Windows::UI::Xaml::Media::SolidColorBrush _ComputeBorderColor();
277285

278286
bool _Resize(const winrt::Microsoft::Terminal::Settings::Model::ResizeDirection& direction);
279287

src/cascadia/TerminalApp/TabHeaderControl.xaml

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
FontSize="12"
4444
Glyph="&#xE72E;"
4545
Visibility="{x:Bind TabStatus.IsReadOnlyActive, Mode=OneWay}" />
46+
<FontIcon x:Name="HeaderBroadcastIcon"
47+
Margin="0,0,8,0"
48+
FontFamily="{ThemeResource SymbolThemeFontFamily}"
49+
FontSize="12"
50+
Glyph="&#xEC05;"
51+
Visibility="{x:Bind TabStatus.IsInputBroadcastActive, Mode=OneWay}" />
4652
<TextBlock x:Name="HeaderTextBlock"
4753
Text="{x:Bind Title, Mode=OneWay}"
4854
Visibility="Visible" />

src/cascadia/TerminalApp/TerminalPage.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -2792,6 +2792,24 @@ namespace winrt::TerminalApp::implementation
27922792
// - Paste text from the Windows Clipboard to the focused terminal
27932793
void TerminalPage::_PasteText()
27942794
{
2795+
// First, check if we're in broadcast input mode. If so, let's tell all
2796+
// the controls to paste.
2797+
if (const auto& tab{ _GetFocusedTabImpl() })
2798+
{
2799+
if (tab->TabStatus().IsInputBroadcastActive())
2800+
{
2801+
tab->GetRootPane()->WalkTree([](auto&& pane) {
2802+
if (auto control = pane->GetTerminalControl())
2803+
{
2804+
control.PasteTextFromClipboard();
2805+
}
2806+
});
2807+
return;
2808+
}
2809+
}
2810+
2811+
// The focused tab wasn't in broadcast mode. No matter. Just ask the
2812+
// current one to paste.
27952813
if (const auto& control{ _GetActiveControl() })
27962814
{
27972815
control.PasteTextFromClipboard();
@@ -4578,6 +4596,21 @@ namespace winrt::TerminalApp::implementation
45784596
// will eat focus.
45794597
_paneResources.unfocusedBorderBrush = SolidColorBrush{ Colors::Black() };
45804598
}
4599+
4600+
const auto broadcastColorKey = winrt::box_value(L"BroadcastPaneBorderColor");
4601+
if (res.HasKey(broadcastColorKey))
4602+
{
4603+
// MAKE SURE TO USE ThemeLookup
4604+
auto obj = ThemeLookup(res, requestedTheme, broadcastColorKey);
4605+
_paneResources.broadcastBorderBrush = obj.try_as<winrt::Windows::UI::Xaml::Media::SolidColorBrush>();
4606+
}
4607+
else
4608+
{
4609+
// DON'T use Transparent here - if it's "Transparent", then it won't
4610+
// be able to hittest for clicks, and then clicking on the border
4611+
// will eat focus.
4612+
_paneResources.broadcastBorderBrush = SolidColorBrush{ Colors::Black() };
4613+
}
45814614
}
45824615

45834616
void TerminalPage::WindowActivated(const bool activated)

src/cascadia/TerminalApp/TerminalPaneContent.h

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ namespace winrt::TerminalApp::implementation
7979
void _ControlConnectionStateChangedHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& /*args*/);
8080
void _ControlWarningBellHandler(const winrt::Windows::Foundation::IInspectable& sender,
8181
const winrt::Windows::Foundation::IInspectable& e);
82+
void _ControlReadOnlyChangedHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& e);
8283

8384
void _controlTitleChanged(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args);
8485
void _controlTabColorChanged(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args);

0 commit comments

Comments
 (0)