For Qt GUI debugger window, added logic to allow for display of stack addresses to be toggle-able on/off via either context menu or A key when widget has focus.

This commit is contained in:
mjbudd77 2020-10-17 22:41:29 -04:00
parent fffa78b507
commit c1fca59e74
2 changed files with 40 additions and 5 deletions

View File

@ -3254,6 +3254,7 @@ DebuggerStackDisplay::DebuggerStackDisplay(QWidget *parent)
: QPlainTextEdit(parent) : QPlainTextEdit(parent)
{ {
stackBytesPerLine = 4; stackBytesPerLine = 4;
showAddrs = true;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
DebuggerStackDisplay::~DebuggerStackDisplay(void) DebuggerStackDisplay::~DebuggerStackDisplay(void)
@ -3270,16 +3271,28 @@ void DebuggerStackDisplay::keyPressEvent(QKeyEvent *event)
stackBytesPerLine = event->key() - Qt::Key_0; stackBytesPerLine = event->key() - Qt::Key_0;
updateText(); updateText();
} }
else if ( event->key() == Qt::Key_A )
{
showAddrs = !showAddrs;
updateText();
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void DebuggerStackDisplay::contextMenuEvent(QContextMenuEvent *event) void DebuggerStackDisplay::contextMenuEvent(QContextMenuEvent *event)
{ {
//QAction *act; QAction *act;
QMenu menu(this); QMenu menu(this);
QMenu *subMenu; QMenu *subMenu;
QActionGroup *group; QActionGroup *group;
QAction *bytesPerLineAct[4]; QAction *bytesPerLineAct[4];
act = new QAction(tr("Show Addresses"), &menu);
act->setCheckable(true);
act->setChecked(showAddrs);
connect( act, SIGNAL(triggered(void)), this, SLOT(toggleShowAddr(void)) );
menu.addAction( act );
subMenu = menu.addMenu(tr("Display Bytes Per Line")); subMenu = menu.addMenu(tr("Display Bytes Per Line"));
group = new QActionGroup(this); group = new QActionGroup(this);
@ -3308,6 +3321,13 @@ void DebuggerStackDisplay::contextMenuEvent(QContextMenuEvent *event)
menu.exec(event->globalPos()); menu.exec(event->globalPos());
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void DebuggerStackDisplay::toggleShowAddr(void)
{
showAddrs = !showAddrs;
updateText();
}
//----------------------------------------------------------------------------
void DebuggerStackDisplay::sel1BytePerLine(void) void DebuggerStackDisplay::sel1BytePerLine(void)
{ {
stackBytesPerLine = 1; stackBytesPerLine = 1;
@ -3341,8 +3361,15 @@ void DebuggerStackDisplay::updateText(void)
stackPtr++; stackPtr++;
if ( stackPtr <= 0x01FF ) if ( stackPtr <= 0x01FF )
{
if ( showAddrs || (stackBytesPerLine <= 1) )
{ {
sprintf( stmp, " $%04X : %02X", stackPtr, GetMem(stackPtr) ); sprintf( stmp, " $%04X : %02X", stackPtr, GetMem(stackPtr) );
}
else
{
sprintf( stmp, " %02X", GetMem(stackPtr) );
}
stackLine.assign( stmp ); stackLine.assign( stmp );
@ -3356,10 +3383,17 @@ void DebuggerStackDisplay::updateText(void)
if ( stackBytesPerLine > 1 ) if ( stackBytesPerLine > 1 )
{ {
if ((i % stackBytesPerLine) == 0) if ((i % stackBytesPerLine) == 0)
{
if ( showAddrs )
{ {
sprintf( stmp, "\n $%04X : %02X", stackPtr, GetMem(stackPtr) ); sprintf( stmp, "\n $%04X : %02X", stackPtr, GetMem(stackPtr) );
} }
else else
{
sprintf( stmp, "\n %02X", GetMem(stackPtr) );
}
}
else
{ {
sprintf( stmp, ",%02X", GetMem(stackPtr) ); sprintf( stmp, ",%02X", GetMem(stackPtr) );
} }

View File

@ -163,14 +163,15 @@ class DebuggerStackDisplay : public QPlainTextEdit
void updateText(void); void updateText(void);
int stackBytesPerLine;
protected: protected:
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
void contextMenuEvent(QContextMenuEvent *event); void contextMenuEvent(QContextMenuEvent *event);
int stackBytesPerLine;
bool showAddrs;
private slots: private slots:
void toggleShowAddr(void);
void sel1BytePerLine(void); void sel1BytePerLine(void);
void sel2BytesPerLine(void); void sel2BytesPerLine(void);
void sel3BytesPerLine(void); void sel3BytesPerLine(void);