diff --git a/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp b/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp index 655ce3603..8f9cf4448 100644 --- a/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp +++ b/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp @@ -655,14 +655,16 @@ Int32 TerminalDisplay::getCurrentSearchMatch() const { bool TerminalDisplay::getVisibleCurrentSearchMatch( Vector2i& start, Vector2i& end ) const { if ( !mSnapshot ) return false; + bool found = false; for ( const auto& match : mSnapshot->visibleSearchMatches ) { if ( match.active ) { - start = match.start; + if ( !found ) + start = match.start; end = match.end; - return true; + found = true; } } - return false; + return found; } Uint64 TerminalDisplay::getSearchRequestId() const { @@ -1265,6 +1267,18 @@ static inline Color termColor( unsigned int terminalColor, const std::vector> 25 ) & 0xFF ) ) & 0xFF ); } +static inline void applySearchHighlight( Int32 mode, const std::vector& colors, Color& fg, + Color& bg ) { + if ( mode & ATTR_SEARCH_ACTIVE ) { + fg = termColor( 0, colors ); + bg = termColor( 3, colors ); + } else if ( mode & ATTR_SEARCH_MATCH ) { + Color highlight = termColor( 3, colors ); + highlight.a = 90; + bg = Color::blend( highlight, bg ); + } +} + void TerminalDisplay::drawrect( const Color& col, const float& x, const float& y, const float& w, const float& h ) { if ( mVBStyles.empty() ) { @@ -1484,11 +1498,7 @@ void TerminalDisplay::drawGrid( const Vector2f& pos ) { if ( glyph.mode & ATTR_REVERSE ) bg = fg; - if ( glyph.mode & ( ATTR_SEARCH_MATCH | ATTR_SEARCH_ACTIVE ) ) { - Color highlight = mColorScheme.getCursor(); - highlight.a = glyph.mode & ATTR_SEARCH_ACTIVE ? 190 : 90; - bg = Color::blend( highlight, bg ); - } + applySearchHighlight( glyph.mode, mColors, fg, bg ); bool isWide = glyph.mode & ATTR_WIDE; @@ -1543,11 +1553,7 @@ void TerminalDisplay::drawGrid( const Vector2f& pos ) { } if ( glyph.mode & ATTR_REVERSE ) background = foreground; - if ( glyph.mode & ( ATTR_SEARCH_MATCH | ATTR_SEARCH_ACTIVE ) ) { - Color highlight = mColorScheme.getCursor(); - highlight.a = glyph.mode & ATTR_SEARCH_ACTIVE ? 190 : 90; - background = Color::blend( highlight, background ); - } + applySearchHighlight( glyph.mode, mColors, foreground, background ); const bool wide = glyph.mode & ATTR_WIDE; const Float advance = spaceCharAdvanceX * ( wide ? 2.0f : 1.0f ); if ( background != defaultBg ) { @@ -1605,11 +1611,7 @@ void TerminalDisplay::drawGrid( const Vector2f& pos ) { fg = bg; bg = temp; } - if ( glyph.mode & ( ATTR_SEARCH_MATCH | ATTR_SEARCH_ACTIVE ) ) { - Color highlight = mColorScheme.getCursor(); - highlight.a = glyph.mode & ATTR_SEARCH_ACTIVE ? 190 : 90; - bg = Color::blend( highlight, bg ); - } + applySearchHighlight( glyph.mode, mColors, fg, bg ); if ( glyph.mode & ATTR_BLINK && ( mMode & MODE_BLINK ) ) fg = bg; diff --git a/src/modules/eterm/src/eterm/ui/uiterminalfind.cpp b/src/modules/eterm/src/eterm/ui/uiterminalfind.cpp index 30db98a00..a4d2cc689 100644 --- a/src/modules/eterm/src/eterm/ui/uiterminalfind.cpp +++ b/src/modules/eterm/src/eterm/ui/uiterminalfind.cpp @@ -198,13 +198,10 @@ void UITerminalFind::updatePosition() { Vector2i start; Vector2i end; auto term = mTerminal->getTerm(); - if ( term->getVisibleCurrentSearchMatch( start, end ) && start.y == 0 ) { + if ( term->getVisibleCurrentSearchMatch( start, end ) && start.y <= 1 ) { const Sizei cellSize = term->getCellPixelSize(); const Rectf& padding = term->getPadding(); - const Float matchLeft = padding.Left + start.x * cellSize.getWidth(); - const Float matchRight = padding.Left + ( end.x + 1 ) * cellSize.getWidth(); - if ( matchRight > x && matchLeft < x + getSize().getWidth() ) - y = padding.Top + cellSize.getHeight(); + y = padding.Top + ( end.y + 1 ) * cellSize.getHeight(); } const Vector2f position( x, y ); if ( getPosition() != position )