Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Dirty Fix改为部分刷新光标后的显示问题 #320

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions 3rdparty/terminalwidget/lib/TerminalDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ void TerminalDisplay::setKeyboardCursorShape(QTermWidget::KeyboardCursorShape sh
{
_cursorShape = shape;

updateCursor();
update();
}
QTermWidget::KeyboardCursorShape TerminalDisplay::keyboardCursorShape() const
{
Expand Down Expand Up @@ -738,11 +738,13 @@ void TerminalDisplay::drawCursor(QPainter& painter,
painter.setPen(_cursorColor);
else
painter.setPen(foregroundColor);

// Todo (Archie Meng): 绘制偏移量用于很脏地修复光标显示问题,如果找到刷新问题的根因,应该改成不使用偏移量的形式。
if ( _cursorShape == Emulation::KeyboardCursorShape::BlockCursor )
{

if ( hasFocus() )
{
cursorRect.translate(1, 1);
painter.fillRect(cursorRect, _cursorColor.isValid() ? _cursorColor : foregroundColor);

if ( !_cursorColor.isValid() )
Expand All @@ -766,29 +768,29 @@ void TerminalDisplay::drawCursor(QPainter& painter,
}
else if ( _cursorShape == Emulation::KeyboardCursorShape::UnderlineCursor )
painter.drawLine(QLineF(
QPointF(cursorRect.left(),
QPointF(cursorRect.left() + 2,
cursorRect.bottom()),
QPointF(cursorRect.right(),
cursorRect.bottom())));
else if ( _cursorShape == Emulation::KeyboardCursorShape::IBeamCursor )
painter.drawLine(QLineF(
QPointF(cursorRect.left(),
cursorRect.top()),
QPointF(cursorRect.left(),
QPointF(cursorRect.left() + 2,
cursorRect.top() + 2),
QPointF(cursorRect.left() + 2,
cursorRect.bottom())));
else if ( _cursorShape == Emulation::KeyboardCursorShape::BoldUnderlineCursor )
{
if ( hasFocus() )
{
cursorRect.translate(0,cursorRect.height());
cursorRect.translate(1,cursorRect.height() - 4);
cursorRect.setHeight(4);
painter.fillRect(cursorRect, _cursorColor.isValid() ? _cursorColor : foregroundColor);
}
else
{
painter.drawRect(
cursorRect.left(),
cursorRect.bottom(),
cursorRect.bottom() - 4,
cursorRect.width(),
4);
}
Expand Down