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

View File

@ -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);