[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [konsole] src: Allow view-controlling keys in read-only mode
From: Kurt Hindenburg <null () kde ! org>
Date: 2018-03-25 13:45:16
Message-ID: E1f05xU-0001yh-Il () code ! kde ! org
[Download RAW message or body]
Git commit 6635190c1295743e6db3c796892c9fc90fb1f791 by Kurt Hindenburg, on behalf of \
Mariusz Glebocki. Committed on 25/03/2018 at 13:45.
Pushed by hindenburg into branch 'master'.
Allow view-controlling keys in read-only mode
Summary:
Allow to use scrolling (Shift+Up/Down/PgUp/PgDown/Home/End) and a key
for showing URL hints when the view is in read-only mode.
Test Plan:
* Prepare
* Turn on scrollback
* Set at least one modifier key for "Show URL hints" (edit profile → advanced)
* Generate a few screens of text in Konsole
* Display some URL (e.g. `echo 'www.kde.org'`)
* Display current time every second: `while sleep 1; do printf '\r%s' "$(date)"; \
done`
* Turn on read-only mode
* Patch tests
* Scroll the view with Shift+Up/Down/PgUp/PgDown/Home/End - the view should scroll
* Hold down URL hint key - the URL should be underlined with square and a digit on \
the left
* Press <URL-hint-key>+1 - the URL should open in a web browser
* Regressions tests
* Press different keys (including Ctrl+C, Ctrl+Z, etc; skip those mapped to Konsole \
actions) - nothing in terminal should happen
* Press Ctrl+S - the time should not stop updating
Reviewers: #konsole, hindenburg
Reviewed By: #konsole, hindenburg
Subscribers: hindenburg, #konsole
Tags: #konsole
Differential Revision: https://phabricator.kde.org/D11668
M +5 -1 src/SessionController.cpp
M +15 -17 src/TerminalDisplay.cpp
M +20 -14 src/Vt102Emulation.cpp
https://commits.kde.org/konsole/6635190c1295743e6db3c796892c9fc90fb1f791
diff --git a/src/SessionController.cpp b/src/SessionController.cpp
index d1a747ba..dfb6a587 100644
--- a/src/SessionController.cpp
+++ b/src/SessionController.cpp
@@ -1578,7 +1578,11 @@ void SessionController::updateReadOnlyActionStates()
bool SessionController::isReadOnly() const
{
- return _session->isReadOnly();
+ if (!_session.isNull()) {
+ return _session->isReadOnly();
+ } else {
+ return false;
+ }
}
void SessionController::sessionTitleChanged()
diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp
index ca02dd55..2f2af66b 100644
--- a/src/TerminalDisplay.cpp
+++ b/src/TerminalDisplay.cpp
@@ -3421,12 +3421,6 @@ void TerminalDisplay::scrollScreenWindow(enum \
ScreenWindow::RelativeScrollMode m
void TerminalDisplay::keyPressEvent(QKeyEvent* event)
{
-
- if (_readOnly) {
- event->accept();
- return;
- }
-
if ((_urlHintsModifiers != 0u) && event->modifiers() == _urlHintsModifiers) {
int hintSelected = event->key() - 0x31;
if (hintSelected >= 0 && hintSelected < 10 && hintSelected < \
_filterChain->hotSpots().count()) { @@ -3443,25 +3437,29 @@ void \
TerminalDisplay::keyPressEvent(QKeyEvent* event) }
}
- _screenWindow->screen()->setCurrentTerminalDisplay(this);
+ if (!_readOnly) {
+ _screenWindow->screen()->setCurrentTerminalDisplay(this);
- _actSel = 0; // Key stroke implies a screen update, so TerminalDisplay won't
- // know where the current selection is.
+ _actSel = 0; // Key stroke implies a screen update, so TerminalDisplay won't
+ // know where the current selection is.
- if (_allowBlinkingCursor) {
- _blinkCursorTimer->start();
- if (_cursorBlinking) {
- // if cursor is blinking(hidden), blink it again to show it
- blinkCursorEvent();
+ if (_allowBlinkingCursor) {
+ _blinkCursorTimer->start();
+ if (_cursorBlinking) {
+ // if cursor is blinking(hidden), blink it again to show it
+ blinkCursorEvent();
+ }
+ Q_ASSERT(!_cursorBlinking);
}
- Q_ASSERT(!_cursorBlinking);
}
emit keyPressedSignal(event);
#ifndef QT_NO_ACCESSIBILITY
- QAccessibleTextCursorEvent textCursorEvent(this, _usedColumns * \
screenWindow()->screen()->getCursorY() + \
screenWindow()->screen()->getCursorX());
- QAccessible::updateAccessibility(&textCursorEvent);
+ if (!_readOnly) {
+ QAccessibleTextCursorEvent textCursorEvent(this, _usedColumns * \
screenWindow()->screen()->getCursorY() + screenWindow()->screen()->getCursorX()); + \
QAccessible::updateAccessibility(&textCursorEvent); + }
#endif
event->accept();
diff --git a/src/Vt102Emulation.cpp b/src/Vt102Emulation.cpp
index 79369088..efaaf1df 100644
--- a/src/Vt102Emulation.cpp
+++ b/src/Vt102Emulation.cpp
@@ -37,6 +37,7 @@
// Konsole
#include "KeyboardTranslator.h"
+#include "SessionController.h"
#include "TerminalDisplay.h"
using Konsole::Vt102Emulation;
@@ -1042,6 +1043,9 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent *event)
const Qt::KeyboardModifiers modifiers = event->modifiers();
KeyboardTranslator::States states = KeyboardTranslator::NoState;
+ TerminalDisplay * currentView = _currentScreen->currentTerminalDisplay();
+ const bool isReadOnly = currentView->sessionController()->isReadOnly();
+
// get current states
if (getMode(MODE_NewLine)) {
states |= KeyboardTranslator::NewLineState;
@@ -1059,16 +1063,18 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent *event)
states |= KeyboardTranslator::ApplicationKeypadState;
}
- // check flow control state
- if ((modifiers &Qt::ControlModifier) != 0u) {
- switch (event->key()) {
- case Qt::Key_S:
- emit flowControlKeyPressed(true);
- break;
- case Qt::Key_Q:
- case Qt::Key_C: // cancel flow control
- emit flowControlKeyPressed(false);
- break;
+ if (!isReadOnly) {
+ // check flow control state
+ if ((modifiers &Qt::ControlModifier) != 0u) {
+ switch (event->key()) {
+ case Qt::Key_S:
+ emit flowControlKeyPressed(true);
+ break;
+ case Qt::Key_Q:
+ case Qt::Key_C: // cancel flow control
+ emit flowControlKeyPressed(false);
+ break;
+ }
}
}
@@ -1104,8 +1110,6 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent *event)
if ( entry.command() != KeyboardTranslator::NoCommand )
{
- TerminalDisplay * currentView = \
_currentScreen->currentTerminalDisplay();
-
if ((entry.command() & KeyboardTranslator::EraseCommand) != 0) {
textToSend += eraseChar();
} else if ((entry.command() & KeyboardTranslator::ScrollPageUpCommand) \
!= 0) { @@ -1128,8 +1132,10 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent *event)
textToSend += _codec->fromUnicode(event->text());
}
- emit sendData(textToSend);
- } else {
+ if (!isReadOnly) {
+ emit sendData(textToSend);
+ }
+ } else if (!isReadOnly) {
// print an error message to the terminal if no key translator has been
// set
QString translatorError = i18n("No keyboard translator available. "
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic