Commit d47baac5 authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark Committed by Tomaz Canabrava
Browse files

Fix painting of search result

Current code was neither updating the search result rect (so the dirty
calculation missed it), nor did it correctly stick to the content rect
and left random blue rects at the edges.
parent 0a6bcae5
Pipeline #98789 passed with stage
in 1 minute and 55 seconds
......@@ -726,7 +726,16 @@ void TerminalDisplay::paintEvent(QPaintEvent *pe)
for (const QRect &rect : qAsConst(dirtyImageRegion)) {
Q_EMIT drawContents(_image, paint, rect, false, _imageSize, _bidiEnabled, _lineProperties);
}
Q_EMIT drawCurrentResultRect(paint, _searchResultRect);
if (screenWindow()->currentResultLine() != -1) {
_searchResultRect.setRect(0,
contentRect().top() + (screenWindow()->currentResultLine() - screenWindow()->currentLine()) * _terminalFont->fontHeight(),
columns() * terminalFont()->fontWidth(),
_terminalFont->fontHeight()
);
Q_EMIT drawCurrentResultRect(paint, _searchResultRect);
}
if (_scrollBar->highlightScrolledLines().isEnabled()) {
Q_EMIT highlightScrolledLines(paint, _scrollBar->highlightScrolledLines().isTimerActive(), _scrollBar->highlightScrolledLines().rect());
}
......
......@@ -499,7 +499,7 @@ Q_SIGNALS:
int imageSize,
bool bidiEnabled,
QVector<LineProperty> lineProperties);
void drawCurrentResultRect(QPainter &painter, QRect searchResultRect);
void drawCurrentResultRect(QPainter &painter, const QRect &searchResultRect);
void highlightScrolledLines(QPainter &painter, bool isTimerActive, QRect rect);
QRegion highlightScrolledLinesRegion(bool nothingChanged, TerminalScrollBar *scrollBar);
......
......@@ -222,20 +222,8 @@ void TerminalPainter::drawContents(Character *image,
}
}
void TerminalPainter::drawCurrentResultRect(QPainter &painter, QRect searchResultRect)
void TerminalPainter::drawCurrentResultRect(QPainter &painter, const QRect &searchResultRect)
{
const auto display = qobject_cast<TerminalDisplay *>(sender());
if (display->screenWindow()->currentResultLine() == -1) {
return;
}
searchResultRect.setRect(0,
display->contentRect().top()
+ (display->screenWindow()->currentResultLine() - display->screenWindow()->currentLine())
* display->terminalFont()->fontHeight(),
display->columns() * display->terminalFont()->fontWidth(),
display->terminalFont()->fontHeight());
painter.fillRect(searchResultRect, QColor(0, 0, 255, 80));
}
......
......@@ -57,7 +57,7 @@ public Q_SLOTS:
QVector<LineProperty> lineProperties);
// draw a transparent rectangle over the line of the current match
void drawCurrentResultRect(QPainter &painter, QRect searchResultRect);
void drawCurrentResultRect(QPainter &painter, const QRect &searchResultRect);
// draw a thin highlight on the left of the screen for lines that have been scrolled into view
void highlightScrolledLines(QPainter &painter, bool isTimerActive, QRect rect);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment