From 3ced4fba535e6912dedfd18bdc87fca5567ad5c9 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Wed, 26 Jun 2024 21:38:07 +0300 Subject: [PATCH] Add key binding disabled indicator --- metainfo.xml | 1 + src/contour/TerminalSession.cpp | 11 ++++++++++- src/vtbackend/Terminal.cpp | 14 ++++++++++++++ src/vtbackend/Terminal.h | 3 +++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/metainfo.xml b/metainfo.xml index abb8363d5a..e8c5553698 100644 --- a/metainfo.xml +++ b/metainfo.xml @@ -120,6 +120,7 @@
  • Add shell integration for bash shell.
  • Add better bell sound (#1378)
  • Add config entry to configure behaviour on exit from search mode
  • +
  • Add key bindings disabled indicator for status line (#783)
  • Update of contour.desktop file (#1423)
  • Fixes forwarding of input while in normal mode (#1468)
  • Fixes OSC-8 link id collision (#1499)
  • diff --git a/src/contour/TerminalSession.cpp b/src/contour/TerminalSession.cpp index 7504d2a41a..52ad59d582 100644 --- a/src/contour/TerminalSession.cpp +++ b/src/contour/TerminalSession.cpp @@ -1241,7 +1241,7 @@ bool TerminalSession::operator()(actions::ScrollUp) bool TerminalSession::operator()(actions::SearchReverse) { - _terminal.inputHandler().startSearchExternally(); + terminal().inputHandler().startSearchExternally(); return true; } @@ -1259,6 +1259,15 @@ bool TerminalSession::operator()(actions::ToggleAllKeyMaps) { _allowKeyMappings = !_allowKeyMappings; inputLog()("{} key mappings.", _allowKeyMappings ? "Enabling" : "Disabling"); + + if (!_allowKeyMappings) + { + terminal().changeStatusLineDefinition( + parseStatusLineDefinition("{}", "{Text:text=key bindings disabled,Left= « ,Right= » }", "{}")); + terminal().setStatusDisplay(StatusDisplayType::Indicator); + } + else + terminal().resetStatusLineDefinition(); return true; } diff --git a/src/vtbackend/Terminal.cpp b/src/vtbackend/Terminal.cpp index f00cfd8520..c05601e5c2 100644 --- a/src/vtbackend/Terminal.cpp +++ b/src/vtbackend/Terminal.cpp @@ -679,6 +679,20 @@ void Terminal::triggerWordWiseSelection(CellLocation startPos, TheSelectionHelpe } } +void Terminal::changeStatusLineDefinition(StatusLineDefinition&& definition) +{ + _indicatorStatusLineDefinition = std::move(definition); + updateIndicatorStatusLine(); +} + +void Terminal::resetStatusLineDefinition() +{ + _indicatorStatusLineDefinition = parseStatusLineDefinition(_settings.indicatorStatusLine.left, + _settings.indicatorStatusLine.middle, + _settings.indicatorStatusLine.right); + updateIndicatorStatusLine(); +} + bool Terminal::handleMouseSelection(Modifiers modifiers) { verifyState(); diff --git a/src/vtbackend/Terminal.h b/src/vtbackend/Terminal.h index b603f3ae47..743d88a746 100644 --- a/src/vtbackend/Terminal.h +++ b/src/vtbackend/Terminal.h @@ -955,6 +955,9 @@ class Terminal void triggerWordWiseSelectionWithCustomDelimiters(std::string const& delimiters); + void changeStatusLineDefinition(StatusLineDefinition && definition); + void resetStatusLineDefinition(); + private: void mainLoop(); void fillRenderBufferInternal(RenderBuffer& output, bool includeSelection);