forked from qt-creator/qt-creator
Terminal: Fix painting multi char preedit
Preedits on linux can often contain more than one character. Also changes the painting from white on black to painting with just an underline. Change-Id: I6769217ca80cf131aa3fb96b20e23b717f591467 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -974,6 +974,9 @@ void TerminalWidget::paintCursor(QPainter &p) const
|
|||||||
|
|
||||||
auto cursor = m_surface->cursor();
|
auto cursor = m_surface->cursor();
|
||||||
|
|
||||||
|
if (!m_preEditString.isEmpty())
|
||||||
|
cursor.shape = Internal::Cursor::Shape::Underline;
|
||||||
|
|
||||||
const bool blinkState = !cursor.blink || m_cursorBlinkState
|
const bool blinkState = !cursor.blink || m_cursorBlinkState
|
||||||
|| !TerminalSettings::instance().allowBlinkingCursor.value();
|
|| !TerminalSettings::instance().allowBlinkingCursor.value();
|
||||||
|
|
||||||
@@ -1019,9 +1022,13 @@ void TerminalWidget::paintPreedit(QPainter &p) const
|
|||||||
QRectF rect = QRectF(gridToGlobal(cursor.position),
|
QRectF rect = QRectF(gridToGlobal(cursor.position),
|
||||||
gridToGlobal({cursor.position.x(), cursor.position.y()}, true, true));
|
gridToGlobal({cursor.position.x(), cursor.position.y()}, true, true));
|
||||||
|
|
||||||
p.fillRect(rect, QColor::fromRgb(0, 0, 0));
|
rect.setWidth(viewport()->width() - rect.x());
|
||||||
p.setPen(Qt::white);
|
|
||||||
p.drawText(rect, m_preEditString);
|
p.setPen(toQColor(ColorIndex::Foreground));
|
||||||
|
QFont f = font();
|
||||||
|
f.setUnderline(true);
|
||||||
|
p.setFont(f);
|
||||||
|
p.drawText(rect, Qt::TextDontClip | Qt::TextWrapAnywhere, m_preEditString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user