Page Key Navigation in Disassembly (Fix #167)

This commit is contained in:
Florian Märkl 2017-12-17 15:11:27 +01:00
parent 0abcf20566
commit 6fa0e0d147

View File

@ -454,10 +454,43 @@ void DisassemblyWidget::moveCursorRelative(bool up, bool page)
{
if (page)
{
// TODO: implement page up/down
return;
RVA offset;
if (!up)
{
offset = Core()->nextOpAddr(bottomOffset, 1);
}
else
{
offset = Core()->prevOpAddr(topOffset, maxLines);
// disassembly from calculated offset may have more than maxLines lines
// move some instructions down if necessary.
auto lines = Core()->disassembleLines(offset, maxLines).toVector();
int oldTopLine;
for (oldTopLine=lines.length(); oldTopLine>0; oldTopLine--)
{
if (lines[oldTopLine - 1].offset < topOffset)
{
break;
}
}
int overflowLines = oldTopLine - maxLines;
if(overflowLines > 0)
{
while (lines[overflowLines-1].offset == lines[overflowLines].offset
&& overflowLines < lines.length()-1)
{
overflowLines++;
}
offset = lines[overflowLines].offset;
}
}
refreshDisasm(offset);
}
else // normal arrow keys
{
int blockCount = mDisasTextEdit->blockCount();
if (blockCount < 1)
{
@ -484,6 +517,7 @@ void DisassemblyWidget::moveCursorRelative(bool up, bool page)
Core()->seek(offset);
highlightCurrentLine();
}
}
}
bool DisassemblyWidget::eventFilter(QObject *obj, QEvent *event)