Changeset View
Changeset View
Standalone View
Standalone View
src/TerminalDisplay.cpp
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | 124 | if (!_screenWindow.isNull()) { | |||
---|---|---|---|---|---|
125 | connect(_screenWindow.data() , &Konsole::ScreenWindow::outputChanged , this , &Konsole::TerminalDisplay::updateLineProperties); | 125 | connect(_screenWindow.data() , &Konsole::ScreenWindow::outputChanged , this , &Konsole::TerminalDisplay::updateLineProperties); | ||
126 | connect(_screenWindow.data() , &Konsole::ScreenWindow::outputChanged , this , &Konsole::TerminalDisplay::updateImage); | 126 | connect(_screenWindow.data() , &Konsole::ScreenWindow::outputChanged , this , &Konsole::TerminalDisplay::updateImage); | ||
127 | connect(_screenWindow.data() , &Konsole::ScreenWindow::currentResultLineChanged , this , &Konsole::TerminalDisplay::updateImage); | 127 | connect(_screenWindow.data() , &Konsole::ScreenWindow::currentResultLineChanged , this , &Konsole::TerminalDisplay::updateImage); | ||
128 | connect(_screenWindow.data(), &Konsole::ScreenWindow::outputChanged, this, [this]() { | 128 | connect(_screenWindow.data(), &Konsole::ScreenWindow::outputChanged, this, [this]() { | ||
129 | _filterUpdateRequired = true; | 129 | _filterUpdateRequired = true; | ||
130 | }); | 130 | }); | ||
131 | connect(_screenWindow.data(), &Konsole::ScreenWindow::scrolled, this, [this]() { | 131 | connect(_screenWindow.data(), &Konsole::ScreenWindow::scrolled, this, [this]() { | ||
132 | _filterUpdateRequired = true; | 132 | _filterUpdateRequired = true; | ||
133 | _needToHighlightLines = true; | ||||
133 | }); | 134 | }); | ||
134 | _screenWindow->setWindowLines(_lines); | 135 | _screenWindow->setWindowLines(_lines); | ||
135 | } | 136 | } | ||
136 | } | 137 | } | ||
137 | 138 | | |||
138 | const ColorEntry* TerminalDisplay::colorTable() const | 139 | const ColorEntry* TerminalDisplay::colorTable() const | ||
139 | { | 140 | { | ||
140 | return _colorTable; | 141 | return _colorTable; | ||
▲ Show 20 Lines • Show All 337 Lines • ▼ Show 20 Line(s) | 404 | TerminalDisplay::TerminalDisplay(QWidget* parent) | |||
478 | , _centerContents(false) | 479 | , _centerContents(false) | ||
479 | , _readOnlyMessageWidget(nullptr) | 480 | , _readOnlyMessageWidget(nullptr) | ||
480 | , _readOnly(false) | 481 | , _readOnly(false) | ||
481 | , _opacity(1.0) | 482 | , _opacity(1.0) | ||
482 | , _dimWhenInactive(false) | 483 | , _dimWhenInactive(false) | ||
483 | , _scrollWheelState(ScrollState()) | 484 | , _scrollWheelState(ScrollState()) | ||
484 | , _searchBar(new IncrementalSearchBar(this)) | 485 | , _searchBar(new IncrementalSearchBar(this)) | ||
485 | , _searchResultRect(QRect()) | 486 | , _searchResultRect(QRect()) | ||
487 | , _highlightScrolledLines(false) | ||||
488 | , _needToHighlightLines(false) | ||||
489 | , _highlightScrolledLinesRect(QRect()) | ||||
490 | , _previousScrollCount(0) | ||||
486 | { | 491 | { | ||
487 | // terminal applications are not designed with Right-To-Left in mind, | 492 | // terminal applications are not designed with Right-To-Left in mind, | ||
488 | // so the layout is forced to Left-To-Right | 493 | // so the layout is forced to Left-To-Right | ||
489 | setLayoutDirection(Qt::LeftToRight); | 494 | setLayoutDirection(Qt::LeftToRight); | ||
490 | 495 | | |||
491 | _contentRect = QRect(_margin, _margin, 1, 1); | 496 | _contentRect = QRect(_margin, _margin, 1, 1); | ||
492 | 497 | | |||
493 | // create scroll bar for scrolling output up and down | 498 | // create scroll bar for scrolling output up and down | ||
▲ Show 20 Lines • Show All 701 Lines • ▼ Show 20 Line(s) | 1033 | { | |||
1195 | 1200 | | |||
1196 | if ((_screenWindow->currentResultLine() != -1) && (_screenWindow->scrollCount() != 0)) { | 1201 | if ((_screenWindow->currentResultLine() != -1) && (_screenWindow->scrollCount() != 0)) { | ||
1197 | // De-highlight previous result region | 1202 | // De-highlight previous result region | ||
1198 | dirtyRegion |= _searchResultRect; | 1203 | dirtyRegion |= _searchResultRect; | ||
1199 | // Highlight new result region | 1204 | // Highlight new result region | ||
1200 | dirtyRegion |= QRect(0, _contentRect.top() + (_screenWindow->currentResultLine() - _screenWindow->currentLine()) * _fontHeight, | 1205 | dirtyRegion |= QRect(0, _contentRect.top() + (_screenWindow->currentResultLine() - _screenWindow->currentLine()) * _fontHeight, | ||
1201 | _columns * _fontWidth, _fontHeight); | 1206 | _columns * _fontWidth, _fontHeight); | ||
1202 | } | 1207 | } | ||
1203 | _screenWindow->resetScrollCount(); | | |||
1204 | 1208 | | |||
1209 | if (_highlightScrolledLines && _needToHighlightLines) { | ||||
1210 | if (_previousScrollCount != 0) { | ||||
1211 | const int nb_lines = abs(_previousScrollCount); | ||||
1212 | int start = 0; | ||||
1213 | if (_screenWindow->scrollCount() * _previousScrollCount < 0) { | ||||
1214 | start = _previousScrollCount > 0 ? _screenWindow->windowLines() - _previousScrollCount : 0; | ||||
1215 | } else { | ||||
1216 | start = _screenWindow->scrollCount() < 0 ? abs(_screenWindow->scrollCount()) : | ||||
1217 | _screenWindow->windowLines() - _screenWindow->scrollCount() - _previousScrollCount; | ||||
1218 | } | ||||
1219 | dirtyRegion |= QRect(0, _contentRect.top() + start * _fontHeight, _columns * _fontWidth, nb_lines * _fontHeight); | ||||
1220 | } | ||||
1221 | if (_screenWindow->scrollCount() != 0) { | ||||
1222 | const int nb_lines = abs(_screenWindow->scrollCount()); | ||||
1223 | const int start = _screenWindow->scrollCount() > 0 ? _screenWindow->windowLines() - _screenWindow->scrollCount() : 0; | ||||
1224 | _highlightScrolledLinesRect.setRect(0, _contentRect.top() + start * _fontHeight, _columns * _fontWidth, nb_lines * _fontHeight); | ||||
1225 | dirtyRegion |= _highlightScrolledLinesRect; | ||||
1226 | } else { | ||||
1227 | _highlightScrolledLinesRect.setRect(0, 0, 0, 0); | ||||
1228 | } | ||||
1229 | _previousScrollCount = _screenWindow->scrollCount(); | ||||
1230 | } | ||||
1231 | _screenWindow->resetScrollCount(); | ||||
1205 | 1232 | | |||
1206 | // update the parts of the display which have changed | 1233 | // update the parts of the display which have changed | ||
1207 | update(dirtyRegion); | 1234 | update(dirtyRegion); | ||
1208 | 1235 | | |||
1209 | if (_allowBlinkingText && _hasTextBlinker && !_blinkTextTimer->isActive()) { | 1236 | if (_allowBlinkingText && _hasTextBlinker && !_blinkTextTimer->isActive()) { | ||
1210 | _blinkTextTimer->start(); | 1237 | _blinkTextTimer->start(); | ||
1211 | } | 1238 | } | ||
1212 | if (!_hasTextBlinker && _blinkTextTimer->isActive()) { | 1239 | if (!_hasTextBlinker && _blinkTextTimer->isActive()) { | ||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 1279 | { | |||
1260 | } | 1287 | } | ||
1261 | 1288 | | |||
1262 | paint.setRenderHint(QPainter::Antialiasing, _antialiasText); | 1289 | paint.setRenderHint(QPainter::Antialiasing, _antialiasText); | ||
1263 | 1290 | | |||
1264 | foreach(const QRect & rect, dirtyImageRegion.rects()) { | 1291 | foreach(const QRect & rect, dirtyImageRegion.rects()) { | ||
1265 | drawContents(paint, rect); | 1292 | drawContents(paint, rect); | ||
1266 | } | 1293 | } | ||
1267 | drawCurrentResultRect(paint); | 1294 | drawCurrentResultRect(paint); | ||
1295 | highlightScrolledLinesRect(paint); | ||||
1268 | drawInputMethodPreeditString(paint, preeditRect()); | 1296 | drawInputMethodPreeditString(paint, preeditRect()); | ||
1269 | paintFilters(paint); | 1297 | paintFilters(paint); | ||
1270 | 1298 | | |||
1271 | const bool drawDimmed = _dimWhenInactive && !hasFocus(); | 1299 | const bool drawDimmed = _dimWhenInactive && !hasFocus(); | ||
1272 | const QColor dimColor(0, 0, 0, 128); | 1300 | const QColor dimColor(0, 0, 0, 128); | ||
1273 | foreach(const QRect & rect, (pe->region() & contentsRect()).rects()) { | 1301 | foreach(const QRect & rect, (pe->region() & contentsRect()).rects()) { | ||
1274 | if (drawDimmed) { | 1302 | if (drawDimmed) { | ||
1275 | paint.fillRect(rect, dimColor); | 1303 | paint.fillRect(rect, dimColor); | ||
▲ Show 20 Lines • Show All 401 Lines • ▼ Show 20 Line(s) | 1704 | if(_screenWindow->currentResultLine() == -1) { | |||
1677 | return; | 1705 | return; | ||
1678 | } | 1706 | } | ||
1679 | 1707 | | |||
1680 | _searchResultRect.setRect(0, _contentRect.top() + (_screenWindow->currentResultLine() - _screenWindow->currentLine()) * _fontHeight, | 1708 | _searchResultRect.setRect(0, _contentRect.top() + (_screenWindow->currentResultLine() - _screenWindow->currentLine()) * _fontHeight, | ||
1681 | _columns * _fontWidth, _fontHeight); | 1709 | _columns * _fontWidth, _fontHeight); | ||
1682 | painter.fillRect(_searchResultRect, QColor(0, 0, 255, 80)); | 1710 | painter.fillRect(_searchResultRect, QColor(0, 0, 255, 80)); | ||
1683 | } | 1711 | } | ||
1684 | 1712 | | |||
1713 | void TerminalDisplay::highlightScrolledLinesRect(QPainter& painter) | ||||
1714 | { | ||||
1715 | if (!_highlightScrolledLines || !_needToHighlightLines) { | ||||
1716 | return; | ||||
1717 | } | ||||
1718 | | ||||
1719 | _needToHighlightLines = false; | ||||
1720 | | ||||
1721 | QColor color = QColor(_colorTable[DEFAULT_FORE_COLOR]); | ||||
1722 | color.setAlpha(20); | ||||
1723 | painter.fillRect(_highlightScrolledLinesRect, color); | ||||
1724 | } | ||||
1725 | | ||||
1685 | QRect TerminalDisplay::imageToWidget(const QRect& imageArea) const | 1726 | QRect TerminalDisplay::imageToWidget(const QRect& imageArea) const | ||
1686 | { | 1727 | { | ||
1687 | QRect result; | 1728 | QRect result; | ||
1688 | result.setLeft(_contentRect.left() + _fontWidth * imageArea.left()); | 1729 | result.setLeft(_contentRect.left() + _fontWidth * imageArea.left()); | ||
1689 | result.setTop(_contentRect.top() + _fontHeight * imageArea.top()); | 1730 | result.setTop(_contentRect.top() + _fontHeight * imageArea.top()); | ||
1690 | result.setWidth(_fontWidth * imageArea.width()); | 1731 | result.setWidth(_fontWidth * imageArea.width()); | ||
1691 | result.setHeight(_fontHeight * imageArea.height()); | 1732 | result.setHeight(_fontHeight * imageArea.height()); | ||
1692 | 1733 | | |||
▲ Show 20 Lines • Show All 352 Lines • ▼ Show 20 Line(s) | 2085 | { | |||
2045 | _scrollFullPage = fullPage; | 2086 | _scrollFullPage = fullPage; | ||
2046 | } | 2087 | } | ||
2047 | 2088 | | |||
2048 | bool TerminalDisplay::scrollFullPage() const | 2089 | bool TerminalDisplay::scrollFullPage() const | ||
2049 | { | 2090 | { | ||
2050 | return _scrollFullPage; | 2091 | return _scrollFullPage; | ||
2051 | } | 2092 | } | ||
2052 | 2093 | | |||
2094 | | ||||
2095 | void TerminalDisplay::setHighlightScrolledLines(bool highlight) | ||||
2096 | { | ||||
2097 | _highlightScrolledLines = highlight; | ||||
2098 | } | ||||
2099 | | ||||
2053 | /* ------------------------------------------------------------------------- */ | 2100 | /* ------------------------------------------------------------------------- */ | ||
2054 | /* */ | 2101 | /* */ | ||
2055 | /* Mouse */ | 2102 | /* Mouse */ | ||
2056 | /* */ | 2103 | /* */ | ||
2057 | /* ------------------------------------------------------------------------- */ | 2104 | /* ------------------------------------------------------------------------- */ | ||
2058 | void TerminalDisplay::mousePressEvent(QMouseEvent* ev) | 2105 | void TerminalDisplay::mousePressEvent(QMouseEvent* ev) | ||
2059 | { | 2106 | { | ||
2060 | if (_possibleTripleClick && (ev->button() == Qt::LeftButton)) { | 2107 | if (_possibleTripleClick && (ev->button() == Qt::LeftButton)) { | ||
▲ Show 20 Lines • Show All 624 Lines • ▼ Show 20 Line(s) | 2694 | } else if (!_readOnly) { | |||
2685 | } | 2732 | } | ||
2686 | } | 2733 | } | ||
2687 | } | 2734 | } | ||
2688 | 2735 | | |||
2689 | void TerminalDisplay::viewScrolledByUser() | 2736 | void TerminalDisplay::viewScrolledByUser() | ||
2690 | { | 2737 | { | ||
2691 | Q_ASSERT(_sessionController != nullptr); | 2738 | Q_ASSERT(_sessionController != nullptr); | ||
2692 | _sessionController->setSearchStartToWindowCurrentLine(); | 2739 | _sessionController->setSearchStartToWindowCurrentLine(); | ||
2740 | _needToHighlightLines = true; | ||||
2693 | } | 2741 | } | ||
2694 | 2742 | | |||
2695 | /* Moving left/up from the line containing pnt, return the starting | 2743 | /* Moving left/up from the line containing pnt, return the starting | ||
2696 | offset point which the given line is continuously wrapped | 2744 | offset point which the given line is continuously wrapped | ||
2697 | (top left corner = 0,0; previous line not visible = 0,-1). | 2745 | (top left corner = 0,0; previous line not visible = 0,-1). | ||
2698 | */ | 2746 | */ | ||
2699 | QPoint TerminalDisplay::findLineStart(const QPoint &pnt) | 2747 | QPoint TerminalDisplay::findLineStart(const QPoint &pnt) | ||
2700 | { | 2748 | { | ||
▲ Show 20 Lines • Show All 1198 Lines • ▼ Show 20 Line(s) | 3894 | { | |||
3899 | setWordCharacters(profile->wordCharacters()); | 3947 | setWordCharacters(profile->wordCharacters()); | ||
3900 | 3948 | | |||
3901 | // bell mode | 3949 | // bell mode | ||
3902 | setBellMode(profile->property<int>(Profile::BellMode)); | 3950 | setBellMode(profile->property<int>(Profile::BellMode)); | ||
3903 | 3951 | | |||
3904 | // mouse wheel zoom | 3952 | // mouse wheel zoom | ||
3905 | _mouseWheelZoom = profile->mouseWheelZoomEnabled(); | 3953 | _mouseWheelZoom = profile->mouseWheelZoomEnabled(); | ||
3906 | setAlternateScrolling(profile->property<bool>(Profile::AlternateScrolling)); | 3954 | setAlternateScrolling(profile->property<bool>(Profile::AlternateScrolling)); | ||
3955 | | ||||
3956 | // hightlight lines scrolled in view | ||||
3957 | setHighlightScrolledLines(profile->property<bool>(Profile::HighlightScrolledLines)); | ||||
3907 | } | 3958 | } |