diff --git a/kate/ollie_ghost.cpp b/kate/ollie_ghost.cpp index 93fdf0d..1e49165 100644 --- a/kate/ollie_ghost.cpp +++ b/kate/ollie_ghost.cpp @@ -22,7 +22,6 @@ GhostOverlay::GhostOverlay(QWidget *parent) : QWidget(parent) { setAttribute(Qt::WA_TransparentForMouseEvents); - setAttribute(Qt::WA_TranslucentBackground); setAutoFillBackground(false); hide(); } @@ -44,8 +43,8 @@ void GhostOverlay::setLines(const QStringList &lines, const QFont &font) if (w > maxWidth) maxWidth = w; } - int height = qRound(fm.lineSpacing() * m_lines.size()); - int width = qRound(maxWidth) + 4; + int height = qRound(fm.lineSpacing() * m_lines.size()) + 4; + int width = qRound(maxWidth) + 8; setFixedSize(width, height); show(); raise(); @@ -64,16 +63,29 @@ void GhostOverlay::paintEvent(QPaintEvent *event) if (m_lines.isEmpty()) return; QPainter painter(this); - painter.setFont(m_font); + // Draw background — editor base color with a tint to distinguish from real text + QColor bgColor = QApplication::palette().color(QPalette::Base); + // Shift slightly toward highlight color to signal "this is a suggestion" + QColor tint = QApplication::palette().color(QPalette::Highlight); + bgColor = QColor( + (bgColor.red() * 4 + tint.red()) / 5, + (bgColor.green() * 4 + tint.green()) / 5, + (bgColor.blue() * 4 + tint.blue()) / 5 + ); + bgColor.setAlphaF(0.92); + painter.fillRect(rect(), bgColor); + + // Draw ghost text + painter.setFont(m_font); QColor ghostColor = QApplication::palette().color(QPalette::Text); - ghostColor.setAlphaF(0.4); + ghostColor.setAlphaF(0.6); painter.setPen(ghostColor); QFontMetricsF fm(m_font); qreal y = fm.ascent(); for (const QString &line : m_lines) { - painter.drawText(QPointF(0, y), line); + painter.drawText(QPointF(2, y), line); y += fm.lineSpacing(); } } @@ -368,18 +380,9 @@ void OllieGhostProvider::onCompletionReply(const QString &result) // Notify Kate to repaint the first line (inline note) emit inlineNotesChanged(m_suggestionStartLine); - // Show overlay for continuation lines only if they won't overlap - // existing document content (i.e. cursor is at or near EOF). + // Show overlay for continuation lines (multi-line suggestions) if (m_suggestionLines.size() > 1) { - auto *doc = m_view->document(); - int linesBelow = doc->lines() - 1 - m_suggestionStartLine; - int continuationLines = m_suggestionLines.size() - 1; - - // Only show overlay if there's enough empty space below - // (cursor line is within continuationLines of EOF) - if (linesBelow <= continuationLines) { - showOverlay(); - } + showOverlay(); } } @@ -449,12 +452,7 @@ void OllieGhostProvider::showSuggestionFromHistory() emit inlineNotesChanged(m_suggestionStartLine); if (m_suggestionLines.size() > 1) { - auto *doc = m_view->document(); - int linesBelow = doc->lines() - 1 - m_suggestionStartLine; - int continuationLines = m_suggestionLines.size() - 1; - if (linesBelow <= continuationLines) { - showOverlay(); - } + showOverlay(); } }