Commit 9ae57f4e authored by Matan Ziv-Av's avatar Matan Ziv-Av Committed by Kurt Hindenburg
Browse files

Fix cursor position after drawing Sixel graphics

Moving all cursor and scroll handling to addPlacement.

This requires the moveCursor parameter to have three possible values,
since Sixel cursor movement is not the same as Kitty/iterm2. This also
unnecessitates addPlacement return value.

BUG: 452476
parent 01492356
Pipeline #165577 passed with stage
in 2 minutes and 14 seconds
......@@ -1837,23 +1837,23 @@ Konsole::EscapeSequenceUrlExtractor *Konsole::Screen::urlExtractor() const
return _escapeSequenceUrlExtractor.get();
}
int Screen::addPlacement(QPixmap pixmap,
int &rows,
int &cols,
int row,
int col,
bool scrolling,
bool moveCursor,
bool leaveText,
int z,
int id,
int pid,
qreal opacity,
int X,
int Y)
void Screen::addPlacement(QPixmap pixmap,
int &rows,
int &cols,
int row,
int col,
bool scrolling,
int moveCursor,
bool leaveText,
int z,
int id,
int pid,
qreal opacity,
int X,
int Y)
{
if (pixmap.isNull()) {
return -1;
return;
}
std::unique_ptr<TerminalGraphicsPlacement_t> p(new TerminalGraphicsPlacement_t);
......@@ -1888,23 +1888,21 @@ int Screen::addPlacement(QPixmap pixmap,
eraseBlock(row, col, rows, cols);
}
addPlacement(p);
int needScroll = qBound(0, row + rows - _lines + 1, rows);
if (moveCursor && scrolling && needScroll > moveCursor) {
scrollUp(needScroll - moveCursor);
int needScroll = qBound(0, row + rows - _lines, rows);
if (moveCursor && scrolling && needScroll > 0) {
scrollUp(needScroll);
}
if (moveCursor) {
if (rows - needScroll - 1 > 0) {
cursorDown(rows - needScroll - 1);
}
if (_cuX + cols >= _columns) {
if (moveCursor == 2 || _cuX + cols >= _columns) {
toStartOfLine();
newLine();
} else {
cursorRight(cols);
}
}
return qBound(0, row + rows - _lines + 1, rows);
}
void Screen::addPlacement(std::unique_ptr<TerminalGraphicsPlacement_t> &placement)
......
......@@ -612,20 +612,20 @@ public:
void setReflowLines(bool enable);
/* Graphics display functions */
int addPlacement(QPixmap pixmap,
int &rows,
int &cols,
int row = -1,
int col = -1,
bool scrolling = true,
bool moveCursor = true,
bool leaveText = false,
int z = -1000,
int id = -1,
int pid = -1,
qreal opacity = 1.0,
int X = 0,
int Y = 0);
void addPlacement(QPixmap pixmap,
int &rows,
int &cols,
int row = -1,
int col = -1,
bool scrolling = true,
int moveCursor = 1,
bool leaveText = false,
int z = -1000,
int id = -1,
int pid = -1,
qreal opacity = 1.0,
int X = 0,
int Y = 0);
TerminalGraphicsPlacement_t *getGraphicsPlacement(unsigned int i);
void scrollUpVisiblePlacements(int n);
void delPlacements(int = 'a', qint64 = 0, qint64 = -1, int = 0, int = 0, int = 0);
......
......@@ -2323,12 +2323,7 @@ void Vt102Emulation::SixelModeDisable()
pixmap = pixmap.scaled(pixmap.width(), m_aspect.first * pixmap.height() / m_aspect.second);
}
int rows = -1, cols = -1;
int needScroll = _currentScreen->addPlacement(pixmap, rows, cols, row, col, m_SixelScrolling, m_SixelScrolling, false);
if (m_SixelScrolling) {
if (rows - needScroll > 0) {
_currentScreen->cursorDown(rows - needScroll);
}
}
_currentScreen->addPlacement(pixmap, rows, cols, row, col, m_SixelScrolling, m_SixelScrolling * 2, false);
}
void Vt102Emulation::SixelColorChangeRGB(const int index, int red, int green, int blue)
......
Supports Markdown
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