Mercurial > octave
changeset 27548:35f9ffb13fd6
do not emulate cursor movements for mouse clicks in terminal (bug #55854)
* TerminalView.cpp (TerminalView::mousePressEvent, TerminalView::keyPressEvent):
Revert changes from changeset 976e7346abf4.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Wed, 23 Oct 2019 12:50:42 -0700 |
parents | 56e8c41fb6d3 |
children | 5189bfa8ad2a |
files | libgui/qterminal/libqterminal/unix/TerminalView.cpp |
diffstat | 1 files changed, 1 insertions(+), 91 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/qterminal/libqterminal/unix/TerminalView.cpp Wed Oct 23 08:19:45 2019 -0700 +++ b/libgui/qterminal/libqterminal/unix/TerminalView.cpp Wed Oct 23 12:50:42 2019 -0700 @@ -1570,46 +1570,6 @@ getCharacterPosition(ev->pos(),charLine,charColumn); QPoint pos = QPoint(charColumn,charLine); - // reposition cursor if mouseclick happens in the currently editable line - QVector<LineProperty> lineprop = _screenWindow->getLineProperties (); - int lineStart = _screenWindow->cursorPosition ().y (); - if (lineStart > 0) - { - while (lineprop[lineStart-1] & LINE_WRAPPED) - lineStart--; - } - - if (charLine >= lineStart) - { - int posInLineCursor = _screenWindow->cursorPosition ().x () - + qMax (0,(_screenWindow->cursorPosition ().y ()-lineStart)) - * _screenWindow->windowColumns (); - int posInLineClick = charColumn - + qMax (0, (charLine - lineStart)) - * _screenWindow->windowColumns (); - - if (posInLineCursor > posInLineClick) - { - QKeyEvent *event = new QKeyEvent (QEvent::KeyPress,Qt::Key_Left, - Qt::NoModifier,QString ("")); - - for (int i = 0; i < posInLineCursor - posInLineClick; i++) - emit keyPressedSignal (event); - - delete event; - } - else if (posInLineClick > posInLineCursor) - { - QKeyEvent *event = new QKeyEvent (QEvent::KeyPress,Qt::Key_Right, - Qt::NoModifier,QString ("")); - - for (int i = 0; i < posInLineClick - posInLineCursor; i++) - emit keyPressedSignal (event); - - delete event; - } - } - if ( ev->button() == Qt::LeftButton) { @@ -2458,56 +2418,7 @@ } if ( emitKeyPressSignal && !_readonly ) - { - // Clear selection if the cursor is moved with arrow keys - bool emitKey = true; - if ((event->modifiers() == Qt::NoModifier) - && (event->key() == Qt::Key_Right || event->key() == Qt::Key_Left)) - _screenWindow->clearSelection(); - - // Delete selected text if printable key is pressed - if ( !event->text ().isEmpty () ) - { - int lineStart, colStart, lineEnd, colEnd; - _screenWindow->getSelectionStart (colStart, lineStart); - _screenWindow->getSelectionEnd (colEnd, lineEnd); - int cursorLoc = loc (_screenWindow->cursorPosition ().x (), - _screenWindow->cursorPosition ().y ()); - - //Check if there is a selection in the current line - if ((loc (colStart,lineStart) != loc (colEnd, lineEnd)) - && (cursorLoc >=loc (colStart,lineStart)) - && (cursorLoc-1 <= loc (colEnd,lineEnd))) - { - QKeyEvent *ev = new QKeyEvent (QEvent::KeyPress,Qt::Key_Backspace, - Qt::NoModifier,QString ("")); - - if (cursorLoc < loc (colEnd, lineEnd)) - { - QKeyEvent *ev_right = new QKeyEvent (QEvent::KeyPress,Qt::Key_Right, - Qt::NoModifier,QString ("")); - for (int i = 0; i < loc (colEnd,lineEnd) - cursorLoc + 1; i++) - emit keyPressedSignal (ev_right); - delete ev_right; - } - - for (int i = 0; i < loc (colEnd, lineEnd) - loc (colStart, lineStart) + 1; i++) - emit keyPressedSignal (ev); - - delete ev; - - // Backspace deleted the selected text and has done its duty, no need to call it again - if (event->key() == Qt::Key_Backspace) - { - _screenWindow->clearSelection (); - emitKey = false; - } - } - } - - if (emitKey) - emit keyPressedSignal (event); - } + emit keyPressedSignal(event); if (_readonly) { event->ignore(); @@ -2515,7 +2426,6 @@ else { event->accept(); } - } void TerminalView::inputMethodEvent( QInputMethodEvent* event )