diff --git a/src/EditProfileDialog.h b/src/EditProfileDialog.h --- a/src/EditProfileDialog.h +++ b/src/EditProfileDialog.h @@ -178,6 +178,7 @@ void toggleTrimTrailingSpacesInSelectedText(bool); void pasteFromX11Selection(); void pasteFromClipboard(); + void toggleAlternateScrolling(bool enable); void TripleClickModeChanged(int); void wordCharactersChanged(const QString &); diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp --- a/src/EditProfileDialog.cpp +++ b/src/EditProfileDialog.cpp @@ -653,6 +653,11 @@ 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 @@ _ui->dropUrlsAsText, Profile::DropUrlsAsText, SLOT(toggleDropUrlsAsText(bool)) }, + { + _ui->enableAlternateScrollingButton, Profile::AlternateScrolling, + SLOT(toggleAlternateScrolling(bool)) + }, { nullptr, Profile::Property(0), nullptr } }; setupCheckBoxes(options, profile); diff --git a/src/EditProfileDialog.ui b/src/EditProfileDialog.ui --- a/src/EditProfileDialog.ui +++ b/src/EditProfileDialog.ui @@ -1053,29 +1053,49 @@ true - - - + + + - Text recognized as a link or an email address will be underlined when hovered by the mouse pointer. + Text recognized as a file will be underlined when hovered by the mouse pointer. - Underline links + Underline files - - + + - Text recognized as a file will be underlined when hovered by the mouse pointer. + Selected text will require control key plus click to drag. - Underline files + Require Ctrl key for drag && drop - - + + + + Always paste dropped files and URLs as text without offering move, copy and link actions. + + + Disable drag && drop menu for files && URLs + + + + + + + Mouse scroll wheel will emulate up/down key presses in programs that use the Alternate Screen buffer (e.g. less) + + + Enable Alternate Screen buffer scrolling + + + + + @@ -1097,37 +1117,33 @@ false + + + 0 + 0 + + Text recognized as a file, link or an email address can be opened by direct mouse click. - Open files and links by direct click + Open by direct click - - - - Selected text will require control key plus click to drag. - - - Require Ctrl key for drag and drop - - - - - + + - Always paste dropped URLs as text without offering move, copy and link actions. + Text recognized as a link or an email address will be underlined when hovered by the mouse pointer. - Disable drag and drop menu for URLs and files + Underline links - + Pressing Ctrl+scrollwheel will increase/decrease the text size. diff --git a/src/Profile.h b/src/Profile.h --- a/src/Profile.h +++ b/src/Profile.h @@ -269,6 +269,19 @@ * 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 }; diff --git a/src/Profile.cpp b/src/Profile.cpp --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -121,6 +121,7 @@ , { 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 @@ 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 diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h --- a/src/TerminalDisplay.h +++ b/src/TerminalDisplay.h @@ -555,6 +555,9 @@ /** See setUsesMouse() */ bool usesMouse() const; + /** See setAlternateScrolling() */ + bool alternateScrolling() const; + public Q_SLOTS: /** * Scrolls current ScreenWindow @@ -628,6 +631,15 @@ */ 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 @@ bool _showTerminalSizeHint; bool _bidiEnabled; bool _mouseMarks; + bool _alternateScrolling; bool _isPrimaryScreen; bool _bracketedPasteMode; diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -372,6 +372,7 @@ , _showTerminalSizeHint(true) , _bidiEnabled(false) , _mouseMarks(false) + , _alternateScrolling(true) , _isPrimaryScreen(true) , _bracketedPasteMode(false) , _iPntSel(QPoint()) @@ -2780,7 +2781,7 @@ } 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 @@ return _mouseMarks; } +void TerminalDisplay::setAlternateScrolling(bool enable) +{ + _alternateScrolling = enable; +} +bool TerminalDisplay::alternateScrolling() const +{ + return _alternateScrolling; +} void TerminalDisplay::usingPrimaryScreen(bool use) { diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -972,6 +972,8 @@ // mouse wheel zoom view->setMouseWheelZoom(profile->mouseWheelZoomEnabled()); + + view->setAlternateScrolling(profile->property(Profile::AlternateScrolling)); } void ViewManager::updateViewsForSession(Session *session)