Skip to content
Permalink
Browse files

DisassemblerTextView: Fixed Hit Testing, check cursor bounds

  • Loading branch information...
Dax89 committed May 14, 2019
1 parent f653da9 commit 97f786d7980051a69f313f0b3242d42f5fd2198d
Showing with 13 additions and 3 deletions.
  1. +13 −3 widgets/disassemblerlistingview/disassemblertextview.cpp
@@ -213,7 +213,11 @@ void DisassemblerTextView::mouseMoveEvent(QMouseEvent *e)
{
e->accept();
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
QAbstractScrollArea::mouseMoveEvent(e);
@@ -268,17 +272,23 @@ void DisassemblerTextView::keyPressEvent(QKeyEvent *e)
{
size_t len = m_renderer->getLastColumn(cur->currentLine());

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

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

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
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))
{

0 comments on commit 97f786d

Please sign in to comment.
You can’t perform that action at this time.