From 3cd4d2e44031cfbbb84e6cda2fbdebf5c02042d6 Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Sun, 24 Feb 2013 12:03:46 -0500 Subject: [PATCH] Add profile option to scroll full/half height via Page Up/Down keys The default is still half page - there is no GUI to change this; either use konsoleprofile or change the .profile manually. CCBUG: 280637 --- src/Profile.cpp | 2 ++ src/Profile.h | 4 ++++ src/ScreenWindow.cpp | 7 +++++-- src/ScreenWindow.h | 3 ++- src/TerminalDisplay.cpp | 13 ++++++++++++- src/TerminalDisplay.h | 4 ++++ src/ViewManager.cpp | 3 +++ 7 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/Profile.cpp b/src/Profile.cpp index 4995d904..14946ce6 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -87,6 +87,7 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = { , { HistoryMode , "HistoryMode" , SCROLLING_GROUP , QVariant::Int } , { HistorySize , "HistorySize" , SCROLLING_GROUP , QVariant::Int } , { ScrollBarPosition , "ScrollBarPosition" , SCROLLING_GROUP , QVariant::Int } + , { ScrollFullPage , "ScrollFullPage" , SCROLLING_GROUP , QVariant::Bool } // Terminal Features , { BlinkingTextEnabled , "BlinkingTextEnabled" , TERMINAL_GROUP , QVariant::Bool } @@ -169,6 +170,7 @@ FallbackProfile::FallbackProfile() setProperty(HistoryMode, Enum::FixedSizeHistory); setProperty(HistorySize, 1000); setProperty(ScrollBarPosition, Enum::ScrollBarRight); + setProperty(ScrollFullPage, false); setProperty(FlowControlEnabled, true); setProperty(BlinkingTextEnabled, true); diff --git a/src/Profile.h b/src/Profile.h index fea0d73a..596f78ac 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -151,6 +151,10 @@ public: * See Enum::ScrollBarPositionEnum */ ScrollBarPosition, + /** (bool) Specifies whether the PageUp/Down will scroll the full + * height or half height. + */ + ScrollFullPage, /** (bool) Specifies whether the terminal will enable Bidirectional * text display */ diff --git a/src/ScreenWindow.cpp b/src/ScreenWindow.cpp index bafc6a04..daa025c5 100644 --- a/src/ScreenWindow.cpp +++ b/src/ScreenWindow.cpp @@ -211,12 +211,15 @@ int ScreenWindow::currentLine() const return qBound(0, _currentLine, lineCount() - windowLines()); } -void ScreenWindow::scrollBy(RelativeScrollMode mode , int amount) +void ScreenWindow::scrollBy(RelativeScrollMode mode, int amount, bool fullPage) { if (mode == ScrollLines) { scrollTo(currentLine() + amount); } else if (mode == ScrollPages) { - scrollTo(currentLine() + amount * (windowLines() / 2)); + if (fullPage) + scrollTo(currentLine() + amount * (windowLines())); + else + scrollTo(currentLine() + amount * (windowLines() / 2)); } } diff --git a/src/ScreenWindow.h b/src/ScreenWindow.h index 1aa938a0..89fe7bed 100644 --- a/src/ScreenWindow.h +++ b/src/ScreenWindow.h @@ -201,8 +201,9 @@ public: * @param amount The number of lines or pages ( depending on @p mode ) to scroll by. If * this number is positive, the view is scrolled down. If this number is negative, the view * is scrolled up. + * @param fullPage Specifies whether to scroll by full page or half page. */ - void scrollBy(RelativeScrollMode mode , int amount); + void scrollBy(RelativeScrollMode mode, int amount, bool fullPage); /** * Specifies whether the window should automatically move to the bottom diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index 91856f53..8016c1ea 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -318,6 +318,7 @@ TerminalDisplay::TerminalDisplay(QWidget* parent) , _autoCopySelectedText(false) , _middleClickPasteMode(Enum::PasteFromX11Selection) , _scrollbarLocation(Enum::ScrollBarRight) + , _scrollFullPage(false) , _wordCharacters(":@-./_~") , _bellMode(Enum::NotifyBell) , _allowBlinkingText(true) @@ -1805,6 +1806,16 @@ void TerminalDisplay::setScroll(int cursor, int slines) connect(_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollBarPositionChanged(int))); } +void TerminalDisplay::setScrollFullPage(bool fullPage) +{ + _scrollFullPage = fullPage; +} + +bool TerminalDisplay::scrollFullPage() const +{ + return _scrollFullPage; +} + /* ------------------------------------------------------------------------- */ /* */ /* Mouse */ @@ -2795,7 +2806,7 @@ void TerminalDisplay::outputSuspended(bool suspended) void TerminalDisplay::scrollScreenWindow(enum ScreenWindow::RelativeScrollMode mode, int amount) { - _screenWindow->scrollBy(mode, amount); + _screenWindow->scrollBy(mode, amount, _scrollFullPage); _screenWindow->setTrackOutput(_screenWindow->atEndOfOutput()); updateLineProperties(); updateImage(); diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h index 1747f1b6..46058beb 100644 --- a/src/TerminalDisplay.h +++ b/src/TerminalDisplay.h @@ -105,6 +105,9 @@ public: */ void setScroll(int cursor, int lines); + void setScrollFullPage(bool fullPage); + bool scrollFullPage() const; + /** * Returns the display's filter chain. When the image for the display is updated, * the text is passed through each filter in the chain. Each filter can define @@ -801,6 +804,7 @@ private: QScrollBar* _scrollBar; Enum::ScrollBarPositionEnum _scrollbarLocation; + bool _scrollFullPage; QString _wordCharacters; int _bellMode; diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index 4071b8bc..355365aa 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -791,6 +791,9 @@ void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr else if (scrollBarPosition == Enum::ScrollBarHidden) view->setScrollBarPosition(Enum::ScrollBarHidden); + bool scrollFullPage = profile->property(Profile::ScrollFullPage); + view->setScrollFullPage(scrollFullPage); + // show hint about terminal size after resizing view->setShowTerminalSizeHint(profile->showTerminalSizeHint());