From c1fca59e74c980cc7e64ec7c8dcbb1d0b0681a8a Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Sat, 17 Oct 2020 22:41:29 -0400 Subject: [PATCH] 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. --- src/drivers/Qt/ConsoleDebugger.cpp | 40 +++++++++++++++++++++++++++--- src/drivers/Qt/ConsoleDebugger.h | 5 ++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/drivers/Qt/ConsoleDebugger.cpp b/src/drivers/Qt/ConsoleDebugger.cpp index 408bb21c..073b81c9 100644 --- a/src/drivers/Qt/ConsoleDebugger.cpp +++ b/src/drivers/Qt/ConsoleDebugger.cpp @@ -3254,6 +3254,7 @@ DebuggerStackDisplay::DebuggerStackDisplay(QWidget *parent) : QPlainTextEdit(parent) { stackBytesPerLine = 4; + showAddrs = true; } //---------------------------------------------------------------------------- DebuggerStackDisplay::~DebuggerStackDisplay(void) @@ -3270,16 +3271,28 @@ void DebuggerStackDisplay::keyPressEvent(QKeyEvent *event) stackBytesPerLine = event->key() - Qt::Key_0; updateText(); } + else if ( event->key() == Qt::Key_A ) + { + showAddrs = !showAddrs; + updateText(); + } } //---------------------------------------------------------------------------- void DebuggerStackDisplay::contextMenuEvent(QContextMenuEvent *event) { - //QAction *act; + QAction *act; QMenu menu(this); QMenu *subMenu; QActionGroup *group; 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")); group = new QActionGroup(this); @@ -3308,6 +3321,13 @@ void DebuggerStackDisplay::contextMenuEvent(QContextMenuEvent *event) menu.exec(event->globalPos()); } //---------------------------------------------------------------------------- +void DebuggerStackDisplay::toggleShowAddr(void) +{ + showAddrs = !showAddrs; + + updateText(); +} +//---------------------------------------------------------------------------- void DebuggerStackDisplay::sel1BytePerLine(void) { stackBytesPerLine = 1; @@ -3342,7 +3362,14 @@ void DebuggerStackDisplay::updateText(void) if ( stackPtr <= 0x01FF ) { - sprintf( stmp, " $%04X : %02X", stackPtr, GetMem(stackPtr) ); + if ( showAddrs || (stackBytesPerLine <= 1) ) + { + sprintf( stmp, " $%04X : %02X", stackPtr, GetMem(stackPtr) ); + } + else + { + sprintf( stmp, " %02X", GetMem(stackPtr) ); + } stackLine.assign( stmp ); @@ -3357,7 +3384,14 @@ void DebuggerStackDisplay::updateText(void) { if ((i % stackBytesPerLine) == 0) { - sprintf( stmp, "\n $%04X : %02X", stackPtr, GetMem(stackPtr) ); + if ( showAddrs ) + { + sprintf( stmp, "\n $%04X : %02X", stackPtr, GetMem(stackPtr) ); + } + else + { + sprintf( stmp, "\n %02X", GetMem(stackPtr) ); + } } else { diff --git a/src/drivers/Qt/ConsoleDebugger.h b/src/drivers/Qt/ConsoleDebugger.h index 533f62fa..8b71c345 100644 --- a/src/drivers/Qt/ConsoleDebugger.h +++ b/src/drivers/Qt/ConsoleDebugger.h @@ -163,14 +163,15 @@ class DebuggerStackDisplay : public QPlainTextEdit void updateText(void); - int stackBytesPerLine; - protected: void keyPressEvent(QKeyEvent *event); void contextMenuEvent(QContextMenuEvent *event); + int stackBytesPerLine; + bool showAddrs; private slots: + void toggleShowAddr(void); void sel1BytePerLine(void); void sel2BytesPerLine(void); void sel3BytesPerLine(void);