Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a setting to flash the pane when BEL is emitted #9270

Merged
32 commits merged into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
370e0c0
initial
PankajBhojwani Feb 18, 2021
3d7c9db
optional timer
PankajBhojwani Feb 18, 2021
54a683d
add setting
PankajBhojwani Feb 19, 2021
b4ae30c
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani Feb 19, 2021
d59a432
change timer
PankajBhojwani Feb 24, 2021
c1172cd
format
PankajBhojwani Mar 1, 2021
e0c9f89
stash, lock
PankajBhojwani Mar 19, 2021
e89f273
weak this
PankajBhojwani Mar 19, 2021
f93c9e8
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani Mar 24, 2021
4c125c3
resw, schema
PankajBhojwani Mar 24, 2021
4b19b57
merge main, fix conflicts
PankajBhojwani May 7, 2021
76c182a
use xaml light
PankajBhojwani May 7, 2021
5ed7e93
spell
PankajBhojwani May 7, 2021
678cfb5
er what
PankajBhojwani May 7, 2021
cecc6d8
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani May 7, 2021
23dc1fd
move light to own file
PankajBhojwani May 10, 2021
9282a16
nits
PankajBhojwani May 10, 2021
eedb317
lazy load
PankajBhojwani May 10, 2021
5b72726
some cleanup
PankajBhojwani May 10, 2021
692ad14
animation
PankajBhojwani May 12, 2021
8a42804
Format
PankajBhojwani May 12, 2021
b3c50f8
small changes
PankajBhojwani May 13, 2021
ab0ce5f
ahhh
PankajBhojwani May 17, 2021
8026698
deprecate visual
PankajBhojwani May 19, 2021
fb27787
here and there
PankajBhojwani May 19, 2021
2f9bc61
spell
PankajBhojwani May 19, 2021
084ff79
fix crash, two-way binding
PankajBhojwani May 20, 2021
f1237d9
remove flag map
PankajBhojwani May 20, 2021
b675b2a
Cleanup
PankajBhojwani May 21, 2021
6c9d8ef
== flag
PankajBhojwani May 21, 2021
730cf09
Ternary
PankajBhojwani May 24, 2021
f5bb54e
Apply suggestions from code review
DHowett May 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/cascadia/TerminalApp/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,17 @@ void Pane::_ControlWarningBellHandler(const winrt::Windows::Foundation::IInspect
PlaySound(soundAlias, NULL, SND_ALIAS_ID | SND_ASYNC | SND_SENTRY);
}

// raise the event with the bool value corresponding to the visual flag
_PaneRaiseBellHandlers(nullptr, WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual));
if (WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual) ||
WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Window))
{
_control.InvertScreenColors();
}

const auto flashTaskbar = WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual) ||
WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Taskbar);

// raise the event with the bool value corresponding to the taskbar or visual flag
_PaneRaiseBellHandlers(nullptr, flashTaskbar);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the settings now look like this?

  • window: flash terminal
  • taskbar: add bell icon to tab
  • visual = [ "window", "taskbar" ]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taskbar flashes the taskbar icon at the toolbar (if the terminal window is not focused)! The others are correct

}
}
}
Expand Down
27 changes: 27 additions & 0 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
_touchAnchor{ std::nullopt },
_cursorTimer{},
_blinkTimer{},
_invertTimer{},
_lastMouseClickTimestamp{},
_lastMouseClickPos{},
_selectionNeedsToBeCopied{ false },
Expand Down Expand Up @@ -3254,6 +3255,32 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
return _terminal->GetTaskbarProgress();
}

winrt::fire_and_forget TermControl::InvertScreenColors()
{
if (!_invertTimer)
{
co_await winrt::resume_foreground(Dispatcher());

DispatcherTimer invertTimer;
invertTimer.Interval(std::chrono::milliseconds(2000));
invertTimer.Tick({ get_weak(), &TermControl::_InvertTimerTick });
invertTimer.Start();
_invertTimer.emplace(std::move(invertTimer));
_terminal->SetScreenMode(true);
PankajBhojwani marked this conversation as resolved.
Show resolved Hide resolved
}
}

void TermControl::_InvertTimerTick(Windows::Foundation::IInspectable const& /* sender */,
Windows::Foundation::IInspectable const& /* e */)
{
if (_invertTimer)
{
_terminal->SetScreenMode(false);
_invertTimer.value().Stop();
_invertTimer = std::nullopt;
}
}

// Method Description:
// - Checks whether the control is in a read-only mode (in this mode node input is sent to connection).
// Return Value:
Expand Down
4 changes: 4 additions & 0 deletions src/cascadia/TerminalControl/TermControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
const size_t TaskbarState() const noexcept;
const size_t TaskbarProgress() const noexcept;

winrt::fire_and_forget InvertScreenColors();

bool ReadOnly() const noexcept;
void ToggleReadOnly();

Expand Down Expand Up @@ -241,6 +243,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation

std::optional<Windows::UI::Xaml::DispatcherTimer> _cursorTimer;
std::optional<Windows::UI::Xaml::DispatcherTimer> _blinkTimer;
std::optional<Windows::UI::Xaml::DispatcherTimer> _invertTimer;

// If this is set, then we assume we are in the middle of panning the
// viewport via touch input.
Expand Down Expand Up @@ -297,6 +300,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation

void _CursorTimerTick(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e);
void _BlinkTimerTick(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e);
void _InvertTimerTick(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e);
void _SetEndSelectionPointAtCursor(Windows::Foundation::Point const& cursorPosition);
void _SendInputToConnection(const winrt::hstring& wstr);
void _SendInputToConnection(std::wstring_view wstr);
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalControl/TermControl.idl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ namespace Microsoft.Terminal.TerminalControl
UInt64 TaskbarState { get; };
UInt64 TaskbarProgress { get; };

void InvertScreenColors();

String WorkingDirectory { get; };

Windows.Foundation.IReference<Windows.UI.Color> TabColor { get; };
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsModel/Profile.idl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace Microsoft.Terminal.Settings.Model
{
DHowett marked this conversation as resolved.
Show resolved Hide resolved
Audible = 0x1,
Visual = 0x2,
DHowett marked this conversation as resolved.
Show resolved Hide resolved
Window = 0x4,
Taskbar = 0x8,
All = 0xffffffff
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::TerminalControl::ScrollbarState)

JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::BellStyle)
{
static constexpr std::array<pair_type, 4> mappings = {
static constexpr std::array<pair_type, 6> mappings = {
pair_type{ "none", AllClear },
pair_type{ "audible", ValueType::Audible },
pair_type{ "visual", ValueType::Visual },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to fake deprecate "visual", you'll probably want to keep this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Though it now maps to Window | Taskbar

pair_type{ "window", ValueType::Window },
pair_type{ "taskbar", ValueType::Taskbar },
pair_type{ "all", AllSet },
};

Expand Down