|
|
|
|
@ -196,6 +196,7 @@ TerminalDisplay::TerminalDisplay(QWidget *parent) |
|
|
|
|
, _showTerminalSizeHint(true) |
|
|
|
|
, _bidiEnabled(false) |
|
|
|
|
, _usesMouseTracking(false) |
|
|
|
|
, _allowMouseTracking(true) |
|
|
|
|
, _bracketedPasteMode(false) |
|
|
|
|
, _iPntSel(QPoint(-1, -1)) |
|
|
|
|
, _pntSel(QPoint(-1, -1)) |
|
|
|
|
@ -1155,7 +1156,7 @@ void TerminalDisplay::mousePressEvent(QMouseEvent *ev) |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(ev->pos(), !_usesMouseTracking); |
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(ev->pos(), !usesMouseTracking()); |
|
|
|
|
QPoint pos = QPoint(charColumn, charLine); |
|
|
|
|
|
|
|
|
|
processFilters(); |
|
|
|
|
@ -1202,23 +1203,23 @@ void TerminalDisplay::mousePressEvent(QMouseEvent *ev) |
|
|
|
|
//
|
|
|
|
|
// Alternate buffer when using Mouse Tracking and with Shift pressed:
|
|
|
|
|
// select text or columnSelection
|
|
|
|
|
if (!_usesMouseTracking && ((ev->modifiers() == Qt::ShiftModifier) || (((ev->modifiers() & Qt::ShiftModifier) != 0u) && _columnSelectionMode))) { |
|
|
|
|
if (!usesMouseTracking() && ((ev->modifiers() == Qt::ShiftModifier) || (((ev->modifiers() & Qt::ShiftModifier) != 0u) && _columnSelectionMode))) { |
|
|
|
|
extendSelection(ev->pos()); |
|
|
|
|
} else if ((!_usesMouseTracking && !((ev->modifiers() & Qt::ShiftModifier))) |
|
|
|
|
|| (_usesMouseTracking && ((ev->modifiers() & Qt::ShiftModifier) != 0u))) { |
|
|
|
|
} else if ((!usesMouseTracking() && !((ev->modifiers() & Qt::ShiftModifier))) |
|
|
|
|
|| (usesMouseTracking() && ((ev->modifiers() & Qt::ShiftModifier) != 0u))) { |
|
|
|
|
_screenWindow->clearSelection(); |
|
|
|
|
|
|
|
|
|
pos.ry() += _scrollBar->value(); |
|
|
|
|
_iPntSel = _pntSel = pos; |
|
|
|
|
_actSel = 1; // left mouse button pressed but nothing selected yet.
|
|
|
|
|
} else if (_usesMouseTracking && !_readOnly) { |
|
|
|
|
} else if (usesMouseTracking() && !_readOnly) { |
|
|
|
|
Q_EMIT mouseSignal(0, charColumn + 1, charLine + 1 + _scrollBar->value() - _scrollBar->maximum(), 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (ev->button() == Qt::MiddleButton) { |
|
|
|
|
processMidButtonClick(ev); |
|
|
|
|
} else if (ev->button() == Qt::RightButton) { |
|
|
|
|
if (!_usesMouseTracking || ((ev->modifiers() & Qt::ShiftModifier) != 0u)) { |
|
|
|
|
if (!usesMouseTracking() || ((ev->modifiers() & Qt::ShiftModifier) != 0u)) { |
|
|
|
|
Q_EMIT configureRequest(ev->pos()); |
|
|
|
|
} else { |
|
|
|
|
if (!_readOnly) { |
|
|
|
|
@ -1245,7 +1246,7 @@ void TerminalDisplay::mouseMoveEvent(QMouseEvent *ev) |
|
|
|
|
setFocus(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(ev->pos(), !_usesMouseTracking); |
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(ev->pos(), !usesMouseTracking()); |
|
|
|
|
|
|
|
|
|
// Ignore mouse movements that don't change the character position,
|
|
|
|
|
// but don't ignore the ones generated by AutoScrollHandler (which
|
|
|
|
|
@ -1265,7 +1266,7 @@ void TerminalDisplay::mouseMoveEvent(QMouseEvent *ev) |
|
|
|
|
// if the program running in the terminal is interested in Mouse Tracking
|
|
|
|
|
// events then emit a mouse movement signal, unless the shift key is
|
|
|
|
|
// being held down, which overrides this.
|
|
|
|
|
if (_usesMouseTracking && !(ev->modifiers() & Qt::ShiftModifier)) { |
|
|
|
|
if (usesMouseTracking() && !(ev->modifiers() & Qt::ShiftModifier)) { |
|
|
|
|
if (!_readOnly) { |
|
|
|
|
int button = 3; |
|
|
|
|
if ((ev->buttons() & Qt::LeftButton) != 0u) { |
|
|
|
|
@ -1489,7 +1490,7 @@ void TerminalDisplay::mouseReleaseEvent(QMouseEvent *ev) |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(ev->pos(), !_usesMouseTracking); |
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(ev->pos(), !usesMouseTracking()); |
|
|
|
|
|
|
|
|
|
if (ev->button() == Qt::LeftButton) { |
|
|
|
|
if (_dragInfo.state == diPending) { |
|
|
|
|
@ -1506,14 +1507,14 @@ void TerminalDisplay::mouseReleaseEvent(QMouseEvent *ev) |
|
|
|
|
// outside the range. The procedure used in `mouseMoveEvent'
|
|
|
|
|
// applies here, too.
|
|
|
|
|
|
|
|
|
|
if (_usesMouseTracking && !(ev->modifiers() & Qt::ShiftModifier) && !_readOnly) { |
|
|
|
|
if (usesMouseTracking() && !(ev->modifiers() & Qt::ShiftModifier) && !_readOnly) { |
|
|
|
|
Q_EMIT mouseSignal(0, charColumn + 1, charLine + 1 + _scrollBar->value() - _scrollBar->maximum(), 2); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
_dragInfo.state = diNone; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (_usesMouseTracking && !_readOnly && (ev->button() == Qt::RightButton || ev->button() == Qt::MiddleButton) && !(ev->modifiers() & Qt::ShiftModifier)) { |
|
|
|
|
if (usesMouseTracking() && !_readOnly && (ev->button() == Qt::RightButton || ev->button() == Qt::MiddleButton) && !(ev->modifiers() & Qt::ShiftModifier)) { |
|
|
|
|
Q_EMIT mouseSignal(ev->button() == Qt::MiddleButton ? 1 : 2, charColumn + 1, charLine + 1 + _scrollBar->value() - _scrollBar->maximum(), 2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1546,7 +1547,7 @@ void TerminalDisplay::setExpandedMode(bool expand) |
|
|
|
|
|
|
|
|
|
void TerminalDisplay::processMidButtonClick(QMouseEvent *ev) |
|
|
|
|
{ |
|
|
|
|
if (!_usesMouseTracking || ((ev->modifiers() & Qt::ShiftModifier) != 0u)) { |
|
|
|
|
if (!usesMouseTracking() || ((ev->modifiers() & Qt::ShiftModifier) != 0u)) { |
|
|
|
|
const bool appendEnter = (ev->modifiers() & Qt::ControlModifier) != 0u; |
|
|
|
|
|
|
|
|
|
if (_middleClickPasteMode == Enum::PasteFromX11Selection) { |
|
|
|
|
@ -1558,7 +1559,7 @@ void TerminalDisplay::processMidButtonClick(QMouseEvent *ev) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (!_readOnly) { |
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(ev->pos(), !_usesMouseTracking); |
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(ev->pos(), !usesMouseTracking()); |
|
|
|
|
Q_EMIT mouseSignal(1, charColumn + 1, charLine + 1 + _scrollBar->value() - _scrollBar->maximum(), 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -1576,12 +1577,12 @@ void TerminalDisplay::mouseDoubleClickEvent(QMouseEvent *ev) |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(ev->pos(), !_usesMouseTracking); |
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(ev->pos(), !usesMouseTracking()); |
|
|
|
|
|
|
|
|
|
QPoint pos(qMin(charColumn, _columns - 1), qMin(charLine, _lines - 1)); |
|
|
|
|
|
|
|
|
|
// pass on double click as two clicks.
|
|
|
|
|
if (_usesMouseTracking && !(ev->modifiers() & Qt::ShiftModifier)) { |
|
|
|
|
if (usesMouseTracking() && !(ev->modifiers() & Qt::ShiftModifier)) { |
|
|
|
|
if (!_readOnly) { |
|
|
|
|
// Send just _ONE_ click event, since the first click of the double click
|
|
|
|
|
// was already sent by the click handler
|
|
|
|
|
@ -1651,7 +1652,7 @@ void TerminalDisplay::wheelEvent(QWheelEvent *ev) |
|
|
|
|
_terminalFont->decreaseFontSize(); |
|
|
|
|
} |
|
|
|
|
return; |
|
|
|
|
} else if (!_usesMouseTracking && (_scrollBar->maximum() > 0)) { |
|
|
|
|
} else if (!usesMouseTracking() && (_scrollBar->maximum() > 0)) { |
|
|
|
|
// If the program running in the terminal is not interested in Mouse
|
|
|
|
|
// Tracking events, send the event to the scrollbar if the slider
|
|
|
|
|
// has room to move
|
|
|
|
|
@ -1674,7 +1675,7 @@ void TerminalDisplay::wheelEvent(QWheelEvent *ev) |
|
|
|
|
|
|
|
|
|
Q_ASSERT(!_sessionController->session().isNull()); |
|
|
|
|
|
|
|
|
|
if (!_usesMouseTracking && !_sessionController->session()->isPrimaryScreen() && _scrollBar->alternateScrolling()) { |
|
|
|
|
if (!usesMouseTracking() && !_sessionController->session()->isPrimaryScreen() && _scrollBar->alternateScrolling()) { |
|
|
|
|
// Send simulated up / down key presses to the terminal program
|
|
|
|
|
// for the benefit of programs such as 'less' (which use the alternate screen)
|
|
|
|
|
|
|
|
|
|
@ -1693,10 +1694,10 @@ void TerminalDisplay::wheelEvent(QWheelEvent *ev) |
|
|
|
|
for (int i = 0; i < abs(lines); i++) { |
|
|
|
|
Q_EMIT keyPressedSignal(&keyEvent); |
|
|
|
|
} |
|
|
|
|
} else if (_usesMouseTracking) { |
|
|
|
|
} else if (usesMouseTracking()) { |
|
|
|
|
// terminal program wants notification of mouse activity
|
|
|
|
|
|
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(ev->position().toPoint(), !_usesMouseTracking); |
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(ev->position().toPoint(), !usesMouseTracking()); |
|
|
|
|
const int steps = _scrollWheelState.consumeLegacySteps(ScrollState::DEFAULT_ANGLE_SCROLL_LINE); |
|
|
|
|
const int button = (steps > 0) ? 4 : 5; |
|
|
|
|
for (int i = 0; i < abs(steps); ++i) { |
|
|
|
|
@ -2067,20 +2068,27 @@ void TerminalDisplay::setUsesMouseTracking(bool on) |
|
|
|
|
resetCursor(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void TerminalDisplay::setAllowMouseTracking(bool allow) |
|
|
|
|
{ |
|
|
|
|
_allowMouseTracking = allow; |
|
|
|
|
resetCursor(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void TerminalDisplay::resetCursor() |
|
|
|
|
{ |
|
|
|
|
setCursor(_usesMouseTracking ? Qt::ArrowCursor : Qt::IBeamCursor); |
|
|
|
|
setCursor(usesMouseTracking() ? Qt::ArrowCursor : Qt::IBeamCursor); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool TerminalDisplay::usesMouseTracking() const |
|
|
|
|
{ |
|
|
|
|
return _usesMouseTracking; |
|
|
|
|
return _usesMouseTracking && _allowMouseTracking; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void TerminalDisplay::setBracketedPasteMode(bool on) |
|
|
|
|
{ |
|
|
|
|
_bracketedPasteMode = on; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool TerminalDisplay::bracketedPasteMode() const |
|
|
|
|
{ |
|
|
|
|
return _bracketedPasteMode; |
|
|
|
|
@ -2510,7 +2518,7 @@ void TerminalDisplay::updateReadOnlyState(bool readonly) |
|
|
|
|
void TerminalDisplay::keyPressEvent(QKeyEvent *event) |
|
|
|
|
{ |
|
|
|
|
{ |
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(mapFromGlobal(QCursor::pos()), !_usesMouseTracking); |
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(mapFromGlobal(QCursor::pos()), !usesMouseTracking()); |
|
|
|
|
|
|
|
|
|
// Don't process it if the filterchain handled it for us
|
|
|
|
|
if (_filterChain->keyPressEvent(this, event, charLine, charColumn)) { |
|
|
|
|
@ -2556,7 +2564,7 @@ void TerminalDisplay::keyReleaseEvent(QKeyEvent *event) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(mapFromGlobal(QCursor::pos()), !_usesMouseTracking); |
|
|
|
|
auto [charLine, charColumn] = getCharacterPosition(mapFromGlobal(QCursor::pos()), !usesMouseTracking()); |
|
|
|
|
_filterChain->keyReleaseEvent(this, event, charLine, charColumn); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|