Added logic to highlight ASM view selected line.

This commit is contained in:
Matthew Budd 2020-09-19 14:38:10 -04:00
parent 59e4ca1ff9
commit abd4089cbb
2 changed files with 49 additions and 13 deletions

View File

@ -361,6 +361,7 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent)
bmFrame = new QGroupBox( tr("Address Bookmarks") );
bmTree = new QTreeWidget();
selBmAddr = new QLineEdit();
selBmAddrVal = 0;
bmTree->setColumnCount(2);
@ -383,15 +384,12 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent)
button = new QPushButton( tr("Add") );
vbox->addWidget( button );
button->setEnabled(false); // TODO
button = new QPushButton( tr("Delete") );
vbox->addWidget( button );
button->setEnabled(false); // TODO
button = new QPushButton( tr("Name") );
vbox->addWidget( button );
button->setEnabled(false); // TODO
hbox->addWidget( bmTree );
hbox->addLayout( vbox );
@ -1432,6 +1430,17 @@ void ConsoleDebugger::asmViewCtxMenuAddBP(void)
}
//----------------------------------------------------------------------------
void ConsoleDebugger::setBookmarkSelectedAddress( int addr )
{
char stmp[32];
sprintf( stmp, "%04X", addr );
selBmAddr->setText( tr(stmp) );
selBmAddrVal = addr;
}
//----------------------------------------------------------------------------
void ConsoleDebugger::asmViewCtxMenuAddSym(void)
{
openDebugSymbolEditWindow( asmView->getCtxMenuAddr() );
@ -2724,17 +2733,19 @@ void QAsmView::mouseMoveEvent(QMouseEvent * event)
//----------------------------------------------------------------------------
void QAsmView::mousePressEvent(QMouseEvent * event)
{
//int line;
//QPoint c = convPixToCursor( event->pos() );
int line;
QPoint c = convPixToCursor( event->pos() );
//line = lineOffset + c.y();
//
//if ( line < asmEntry.size() )
//{
// int addr;
line = lineOffset + c.y();
if ( line < asmEntry.size() )
{
int addr;
// addr = asmEntry[line]->addr;
//}
addr = asmEntry[line]->addr;
parent->setBookmarkSelectedAddress( addr );
}
}
//----------------------------------------------------------------------------
void QAsmView::contextMenuEvent(QContextMenuEvent *event)
@ -2769,7 +2780,7 @@ void QAsmView::contextMenuEvent(QContextMenuEvent *event)
//----------------------------------------------------------------------------
void QAsmView::paintEvent(QPaintEvent *event)
{
int x,y,l, row, nrow;
int x,y,l, row, nrow, selAddr;
QPainter painter(this);
painter.setFont(font);
@ -2801,6 +2812,7 @@ void QAsmView::paintEvent(QPaintEvent *event)
{
lineOffset = maxLineOffset;
}
selAddr = parent->getBookmarkSelectedAddress();
painter.fillRect( 0, 0, viewWidth, viewHeight, this->palette().color(QPalette::Background) );
@ -2827,6 +2839,27 @@ void QAsmView::paintEvent(QPaintEvent *event)
painter.fillRect( 0, y - pxLineSpacing + pxLineLead, viewWidth, pxLineSpacing, QColor("light blue") );
}
painter.drawText( x, y, tr(asmEntry[l]->text.c_str()) );
if ( selAddr == asmEntry[l]->addr )
{ // Highlight ASM line for selected address.
if ( asmEntry[l]->type == dbg_asm_entry_t::ASM_TEXT )
{
int ax;
char addrString[16];
ax = 4*pxCharWidth;
painter.fillRect( ax, y - pxLineSpacing + pxLineLead, 4*pxCharWidth, pxLineSpacing, QColor("blue") );
sprintf( addrString, "%04X", selAddr );
painter.setPen( this->palette().color(QPalette::Background));
painter.drawText( ax, y, tr(addrString) );
painter.setPen( this->palette().color(QPalette::WindowText));
}
}
}
y += pxLineSpacing;
}

View File

@ -134,6 +134,8 @@ class ConsoleDebugger : public QDialog
void breakPointNotify(int bpNum);
void openBpEditWindow(int editIdx = -1, watchpointinfo *wp = NULL );
void openDebugSymbolEditWindow( int addr );
void setBookmarkSelectedAddress( int addr );
int getBookmarkSelectedAddress(void){ return selBmAddrVal; };
QLabel *asmLineSelLbl;
protected:
@ -189,6 +191,7 @@ class ConsoleDebugger : public QDialog
QTimer *periodicTimer;
QFont font;
int selBmAddrVal;
bool windowUpdateReq;
private: