Skip to content

Commit

Permalink
Add key binding disabled indicator
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Parpart <christian@parpart.family>
  • Loading branch information
Yaraslaut authored and christianparpart committed Jun 30, 2024
1 parent 55dc1d8 commit 421f22c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
<li>Add better bell sound (#1378)</li>
<li>Add config entry to configure behaviour on exit from search mode</li>
<li>Add handling of different input commands (#629)</li>
<li>Add key bindings disabled indicator for status line (#783)</li>
<li>When switching to normal mode screen will stay in same position (#808)</li>
<li>Update of contour.desktop file (#1423)</li>
<li>Changed configuration entry values for `font_locator` down to `native` and `mock` only (#1538).</li>
Expand Down
11 changes: 10 additions & 1 deletion src/contour/TerminalSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ bool TerminalSession::operator()(actions::ScrollUp)

bool TerminalSession::operator()(actions::SearchReverse)
{
_terminal.inputHandler().startSearchExternally();
terminal().inputHandler().startSearchExternally();

return true;
}
Expand All @@ -1259,6 +1259,15 @@ bool TerminalSession::operator()(actions::ToggleAllKeyMaps)
{
_allowKeyMappings = !_allowKeyMappings;
inputLog()("{} key mappings.", _allowKeyMappings ? "Enabling" : "Disabling");

if (!_allowKeyMappings)
{
terminal().setStatusLineDefinition(
parseStatusLineDefinition("{}", "{Text:text=key bindings disabled,Left= « ,Right= » }", "{}"));
terminal().setStatusDisplay(StatusDisplayType::Indicator);
}
else
terminal().resetStatusLineDefinition();
return true;
}

Expand Down
14 changes: 14 additions & 0 deletions src/vtbackend/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,20 @@ void Terminal::triggerWordWiseSelection(CellLocation startPos, TheSelectionHelpe
}
}

void Terminal::setStatusLineDefinition(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();
Expand Down
3 changes: 3 additions & 0 deletions src/vtbackend/Terminal.h
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,9 @@ class Terminal

void triggerWordWiseSelectionWithCustomDelimiters(std::string const& delimiters);

void setStatusLineDefinition(StatusLineDefinition&& definition);
void resetStatusLineDefinition();

private:
void mainLoop();
void fillRenderBufferInternal(RenderBuffer& output, bool includeSelection);
Expand Down

0 comments on commit 421f22c

Please sign in to comment.