Skip to content

Commit

Permalink
DisassemblerTextView: Fixed Hit Testing, check cursor bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Dax89 committed May 14, 2019
1 parent f653da9 commit 97f786d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions widgets/disassemblerlistingview/disassemblertextview.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ void DisassemblerTextView::mouseMoveEvent(QMouseEvent *e)
{ {
e->accept(); e->accept();
this->currentDocument()->cursor()->disable(); this->currentDocument()->cursor()->disable();
m_renderer->select(e->pos());
QPoint pos = e->pos();
pos.rx() = std::max(0, pos.x());
pos.ry() = std::max(0, pos.y());
m_renderer->select(pos);
} }
else else
QAbstractScrollArea::mouseMoveEvent(e); QAbstractScrollArea::mouseMoveEvent(e);
Expand Down Expand Up @@ -268,17 +272,23 @@ void DisassemblerTextView::keyPressEvent(QKeyEvent *e)
{ {
size_t len = m_renderer->getLastColumn(cur->currentLine()); size_t len = m_renderer->getLastColumn(cur->currentLine());


if(len == cur->currentColumn())
return;

if(e->matches(QKeySequence::MoveToNextChar)) if(e->matches(QKeySequence::MoveToNextChar))
cur->moveTo(cur->currentLine(), std::min(len, cur->currentColumn() + 1)); cur->moveTo(cur->currentLine(), std::min(len, cur->currentColumn() + 1));
else else
cur->select(cur->currentLine(), std::min(len, cur->currentColumn() + 1)); cur->select(cur->currentLine(), std::min(len, cur->currentColumn() + 1));
} }
else if(e->matches(QKeySequence::MoveToPreviousChar) || e->matches(QKeySequence::SelectPreviousChar)) else if(e->matches(QKeySequence::MoveToPreviousChar) || e->matches(QKeySequence::SelectPreviousChar))
{ {
if(!cur->currentColumn())
return;

if(e->matches(QKeySequence::MoveToPreviousChar)) if(e->matches(QKeySequence::MoveToPreviousChar))
cur->moveTo(cur->currentLine(), std::max(static_cast<u64>(0), cur->currentColumn() - 1)); cur->moveTo(cur->currentLine(), std::max(size_t(0), cur->currentColumn() - 1));
else else
cur->select(cur->currentLine(), std::max(static_cast<u64>(0), cur->currentColumn() - 1)); cur->select(cur->currentLine(), std::max(size_t(0), cur->currentColumn() - 1));
} }
else if(e->matches(QKeySequence::MoveToNextLine) || e->matches(QKeySequence::SelectNextLine)) else if(e->matches(QKeySequence::MoveToNextLine) || e->matches(QKeySequence::SelectNextLine))
{ {
Expand Down

0 comments on commit 97f786d

Please sign in to comment.