From de79549e8ff8a0c0798731d053e721337edf5e29 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Fri, 1 Jun 2007 14:27:26 +0000 Subject: [PATCH] Prevent scrolling of views which are not following the latest output when new output is received from the terminal and the history is full. svn path=/trunk/KDE/kdebase/apps/konsole/; revision=670451 --- src/Emulation.cpp | 1 + src/Screen.cpp | 17 +++++++++++++++-- src/Screen.h | 19 +++++++++++++++++++ src/ScreenWindow.cpp | 10 ++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/Emulation.cpp b/src/Emulation.cpp index 123e1ecbe..41199262d 100644 --- a/src/Emulation.cpp +++ b/src/Emulation.cpp @@ -435,6 +435,7 @@ void Emulation::showBulk() emit outputChanged(); _currentScreen->resetScrolledLines(); + _currentScreen->resetDroppedLines(); } void Emulation::bufferedUpdate() diff --git a/src/Screen.cpp b/src/Screen.cpp index e485883f2..a15bb9286 100644 --- a/src/Screen.cpp +++ b/src/Screen.cpp @@ -69,6 +69,7 @@ Screen::Screen(int l, int c) columns(c), screenLines(new ImageLine[lines+1] ), _scrolledLines(0), + _droppedLines(0), hist(new HistoryScrollNone()), cuX(0), cuY(0), cu_re(0), @@ -835,7 +836,14 @@ int Screen::scrolledLines() const { return _scrolledLines; } - +int Screen::droppedLines() const +{ + return _droppedLines; +} +void Screen::resetDroppedLines() +{ + _droppedLines = 0; +} void Screen::resetScrolledLines() { //qDebug() << "scrolled lines reset"; @@ -1524,7 +1532,7 @@ QString Screen::getHistoryLine(int no) void Screen::addHistLine() { - // add to hist buffer + // add line to history buffer // we have to take care about scrolling, too... if (hasScroll()) @@ -1538,6 +1546,11 @@ void Screen::addHistLine() bool beginIsTL = (sel_begin == sel_TL); + // If the history is full, increment the count + // of dropped lines + if ( newHistLines == oldHistLines ) + _droppedLines++; + // Adjust selection for the new point of reference if (newHistLines > oldHistLines) { diff --git a/src/Screen.h b/src/Screen.h index 023b19aff..d7b3f1260 100644 --- a/src/Screen.h +++ b/src/Screen.h @@ -344,6 +344,23 @@ public: // these are all `Screen' operations */ void resetScrolledLines(); + /** + * Returns the number of lines of output which have been + * dropped from the history since the last call + * to resetDroppedLines() + * + * If the history is not unlimited then it will drop + * the oldest lines of output if new lines are added when + * it is full. + */ + int droppedLines() const; + + /** + * Resets the count of the number of lines dropped from + * the history. + */ + void resetDroppedLines(); + private: // helper //copies a line of text from the screen or history into a stream using a specified character decoder @@ -403,6 +420,8 @@ private: // helper int _scrolledLines; QRect _lastScrolledRegion; + int _droppedLines; + QVarLengthArray lineProperties; // history buffer --------------- diff --git a/src/ScreenWindow.cpp b/src/ScreenWindow.cpp index 4fcced14e..201bad062 100644 --- a/src/ScreenWindow.cpp +++ b/src/ScreenWindow.cpp @@ -217,6 +217,16 @@ void ScreenWindow::notifyOutputChanged() _scrollCount -= _screen->scrolledLines(); _currentLine = _screen->getHistLines(); } + else + { + // if the history is not unlimited then it may + // have run out of space and dropped the oldest + // lines of output - in this case the screen + // window's current line number will need to + // be adjusted - otherwise the output will scroll + _currentLine = qMax(0,_currentLine - + _screen->droppedLines()); + } emit outputChanged(); }