Add profile property to toggle alternate scrolling

Summary:
Konsole sends up/down key press events to programs running in the shell
if they indicate they are not interested in mouse events. This adds a
profile property to toggle this behaviour.

BUG: 170582
FIXED-IN: 18.08

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D12139
wilder-portage
Ahmad Samir 8 years ago committed by Kurt Hindenburg
parent 8254dd07d9
commit 6b1d799a51
  1. 9
      src/EditProfileDialog.cpp
  2. 1
      src/EditProfileDialog.h
  3. 70
      src/EditProfileDialog.ui
  4. 2
      src/Profile.cpp
  5. 13
      src/Profile.h
  6. 11
      src/TerminalDisplay.cpp
  7. 13
      src/TerminalDisplay.h
  8. 2
      src/ViewManager.cpp

@ -653,6 +653,11 @@ void EditProfileDialog::toggleMouseWheelZoom(bool enable)
updateTempProfileProperty(Profile::MouseWheelZoomEnabled, enable);
}
void EditProfileDialog::toggleAlternateScrolling(bool enable)
{
updateTempProfileProperty(Profile::AlternateScrolling, enable);
}
void EditProfileDialog::updateColorSchemeList(const QString &selectedColorSchemeName)
{
if (_ui->colorSchemeList->model() == nullptr) {
@ -1398,6 +1403,10 @@ void EditProfileDialog::setupMousePage(const Profile::Ptr profile)
_ui->dropUrlsAsText, Profile::DropUrlsAsText,
SLOT(toggleDropUrlsAsText(bool))
},
{
_ui->enableAlternateScrollingButton, Profile::AlternateScrolling,
SLOT(toggleAlternateScrolling(bool))
},
{ nullptr, Profile::Property(0), nullptr }
};
setupCheckBoxes(options, profile);

@ -178,6 +178,7 @@ private Q_SLOTS:
void toggleTrimTrailingSpacesInSelectedText(bool);
void pasteFromX11Selection();
void pasteFromClipboard();
void toggleAlternateScrolling(bool enable);
void TripleClickModeChanged(int);
void wordCharactersChanged(const QString &);

@ -1053,29 +1053,49 @@
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="underlineLinksButton">
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="underlineFilesButton">
<property name="toolTip">
<string>Text recognized as a link or an email address will be underlined when hovered by the mouse pointer.</string>
<string>Text recognized as a file will be underlined when hovered by the mouse pointer.</string>
</property>
<property name="text">
<string>Underline links</string>
<string>Underline files</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="underlineFilesButton">
<item row="0" column="2">
<widget class="QCheckBox" name="ctrlRequiredForDragButton">
<property name="toolTip">
<string>Text recognized as a file will be underlined when hovered by the mouse pointer.</string>
<string>Selected text will require control key plus click to drag.</string>
</property>
<property name="text">
<string>Underline files</string>
<string>Require Ctrl key for drag &amp;&amp; drop</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item row="1" column="2">
<widget class="QCheckBox" name="dropUrlsAsText">
<property name="toolTip">
<string>Always paste dropped files and URLs as text without offering move, copy and link actions.</string>
</property>
<property name="text">
<string>Disable drag &amp;&amp; drop menu for files &amp;&amp; URLs</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="enableAlternateScrollingButton">
<property name="toolTip">
<string>Mouse scroll wheel will emulate up/down key presses in programs that use the Alternate Screen buffer (e.g. less)</string>
</property>
<property name="text">
<string>Enable Alternate Screen buffer scrolling</string>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -1097,37 +1117,33 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Text recognized as a file, link or an email address can be opened by direct mouse click.</string>
</property>
<property name="text">
<string>Open files and links by direct click</string>
<string>Open by direct click</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="ctrlRequiredForDragButton">
<property name="toolTip">
<string>Selected text will require control key plus click to drag.</string>
</property>
<property name="text">
<string>Require Ctrl key for drag and drop</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="dropUrlsAsText">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="underlineLinksButton">
<property name="toolTip">
<string>Always paste dropped URLs as text without offering move, copy and link actions.</string>
<string>Text recognized as a link or an email address will be underlined when hovered by the mouse pointer.</string>
</property>
<property name="text">
<string>Disable drag and drop menu for URLs and files</string>
<string>Underline links</string>
</property>
</widget>
</item>
<item>
<item row="2" column="2">
<widget class="QCheckBox" name="enableMouseWheelZoomButton">
<property name="toolTip">
<string>Pressing Ctrl+scrollwheel will increase/decrease the text size.</string>

@ -121,6 +121,7 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = {
, { PasteFromClipboardEnabled , "PasteFromClipboardEnabled" , INTERACTION_GROUP , QVariant::Bool }
, { MiddleClickPasteMode, "MiddleClickPasteMode" , INTERACTION_GROUP , QVariant::Int }
, { MouseWheelZoomEnabled, "MouseWheelZoomEnabled", INTERACTION_GROUP, QVariant::Bool }
, { AlternateScrolling, "AlternateScrolling", INTERACTION_GROUP, QVariant::Bool }
// Encoding
, { DefaultEncoding , "DefaultEncoding" , ENCODING_GROUP , QVariant::String }
@ -172,6 +173,7 @@ void Profile::useFallback()
setProperty(TerminalMargin, 1);
setProperty(TerminalCenter, false);
setProperty(MouseWheelZoomEnabled, true);
setProperty(AlternateScrolling, true);
setProperty(KeyBindings, QStringLiteral("default"));
setProperty(ColorScheme, QStringLiteral("Linux")); //use DarkPastels when is start support blue ncurses UI properly

@ -269,6 +269,19 @@ public:
* increases/decreases the terminal font size.
*/
MouseWheelZoomEnabled,
/** (bool) Specifies whether emulated up/down key presses are sent
* for mouse scroll wheel events, to programs using the Alternate
* Screen buffer if those programs indicate they're not interested
* in mouse events (check _usesMouse in the Emulation header); this
* is mainly for the benefit of programs that are never interested
* in mouse events (e.g. less).
* Some programs, such as vim, can tell the terminal whether they
* are interested in mouse events or not. Consequently, this option
* affects vim only if it indicates that it's not interested in
* mouse events.
* Default value is true.
*/
AlternateScrolling,
/** (int) Keyboard modifiers to show URL hints */
UrlHintsModifiers
};

@ -372,6 +372,7 @@ TerminalDisplay::TerminalDisplay(QWidget* parent)
, _showTerminalSizeHint(true)
, _bidiEnabled(false)
, _mouseMarks(false)
, _alternateScrolling(true)
, _isPrimaryScreen(true)
, _bracketedPasteMode(false)
, _iPntSel(QPoint())
@ -2780,7 +2781,7 @@ void TerminalDisplay::wheelEvent(QWheelEvent* ev)
} else if (!_readOnly) {
_scrollWheelState.addWheelEvent(ev);
if(_mouseMarks && !_isPrimaryScreen) {
if(_mouseMarks && !_isPrimaryScreen && _alternateScrolling) {
// Send simulated up / down key presses to the terminal program
// for the benefit of programs such as 'less' (which use the alternate screen)
@ -3147,6 +3148,14 @@ bool TerminalDisplay::usesMouse() const
return _mouseMarks;
}
void TerminalDisplay::setAlternateScrolling(bool enable)
{
_alternateScrolling = enable;
}
bool TerminalDisplay::alternateScrolling() const
{
return _alternateScrolling;
}
void TerminalDisplay::usingPrimaryScreen(bool use)
{

@ -555,6 +555,9 @@ public:
/** See setUsesMouse() */
bool usesMouse() const;
/** See setAlternateScrolling() */
bool alternateScrolling() const;
public Q_SLOTS:
/**
* Scrolls current ScreenWindow
@ -628,6 +631,15 @@ public Q_SLOTS:
*/
void setUsesMouse(bool on);
/**
* Sets the AlternateScrolling profile property which controls whether
* to emulate up/down key presses for mouse scroll wheel events.
* For more details, check the documentation of that property in the
* Profile header.
* Enabled by default.
*/
void setAlternateScrolling(bool enable);
/**
* Sets _isPrimaryScreen depending on which screen is currently in
* use, primary or alternate
@ -926,6 +938,7 @@ private:
bool _showTerminalSizeHint;
bool _bidiEnabled;
bool _mouseMarks;
bool _alternateScrolling;
bool _isPrimaryScreen;
bool _bracketedPasteMode;

@ -972,6 +972,8 @@ void ViewManager::applyProfileToView(TerminalDisplay *view, const Profile::Ptr p
// mouse wheel zoom
view->setMouseWheelZoom(profile->mouseWheelZoomEnabled());
view->setAlternateScrolling(profile->property<bool>(Profile::AlternateScrolling));
}
void ViewManager::updateViewsForSession(Session *session)

Loading…
Cancel
Save