Added logic to update hex editor title with view mode and selected address included in text.

This commit is contained in:
Matthew Budd 2020-09-20 21:03:41 -04:00
parent c2ca5dc9d8
commit a458f7526b
3 changed files with 61 additions and 7 deletions

View File

@ -2967,19 +2967,19 @@ void QAsmView::contextMenuEvent(QContextMenuEvent *event)
ctxMenuAddr = addr = asmEntry[line]->addr;
act = new QAction(tr("Add Breakpoint"), this);
menu.addAction(act);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuAddBP(void)) );
act = new QAction(tr("Add Symbolic Debug Marker"), this);
menu.addAction(act);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuAddSym(void)) );
act = new QAction(tr("Add Bookmark"), this);
menu.addAction(act);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuAddBM(void)) );
act = new QAction(tr("Open Hex Editor"), this);
menu.addAction(act);
menu.addAction(act);
connect( act, SIGNAL(triggered(void)), parent, SLOT(asmViewCtxMenuOpenHexEdit(void)) );
menu.exec(event->globalPos());
@ -3050,7 +3050,7 @@ void QAsmView::paintEvent(QPaintEvent *event)
if ( selAddr == asmEntry[l]->addr )
{ // Highlight ASM line for selected address.
if ( asmEntry[l]->type == dbg_asm_entry_t::ASM_TEXT )
if ( !displayROMoffsets && (asmEntry[l]->type == dbg_asm_entry_t::ASM_TEXT) )
{
int ax;
char addrString[16];

View File

@ -538,12 +538,11 @@ HexEditorDialog_t::HexEditorDialog_t(QWidget *parent)
QMenuBar *menuBar;
QMenu *fileMenu, *viewMenu, *colorMenu;
QAction *saveROM, *closeAct;
QAction *viewRAM, *viewPPU, *viewOAM, *viewROM;
QAction *actHlgt, *actHlgtRV, *actColorFG, *actColorBG;
QActionGroup *group;
int useNativeMenuBar;
setWindowTitle("Hex Editor");
QDialog::setWindowTitle( tr("Hex Editor") );
resize( 512, 512 );
@ -738,6 +737,19 @@ HexEditorDialog_t::~HexEditorDialog_t(void)
}
}
//----------------------------------------------------------------------------
void HexEditorDialog_t::setWindowTitle(void)
{
const char *modeString;
char stmp[128];
modeString = memViewNames[ editor->getMode() ];
sprintf( stmp, "Hex Editor - %s: 0x%04X", modeString, editor->getAddr() );
QDialog::setWindowTitle( tr(stmp) );
}
//----------------------------------------------------------------------------
void HexEditorDialog_t::removeAllBookmarks(void)
{
int ret;
@ -957,6 +969,36 @@ void HexEditorDialog_t::updatePeriodic(void)
editor->memModeUpdate();
editor->update();
setWindowTitle();
switch ( editor->getMode() )
{
case QHexEdit::MODE_NES_RAM:
if ( !viewRAM->isChecked() )
{
viewRAM->setChecked(true);
}
break;
case QHexEdit::MODE_NES_PPU:
if ( !viewPPU->isChecked() )
{
viewPPU->setChecked(true);
}
break;
case QHexEdit::MODE_NES_OAM:
if ( !viewOAM->isChecked() )
{
viewOAM->setChecked(true);
}
break;
case QHexEdit::MODE_NES_ROM:
if ( !viewROM->isChecked() )
{
viewROM->setChecked(true);
}
break;
}
}
//----------------------------------------------------------------------------
QHexEdit::QHexEdit(QWidget *parent)
@ -993,6 +1035,7 @@ QHexEdit::QHexEdit(QWidget *parent)
lineOffset = 0;
cursorPosX = 0;
cursorPosY = 0;
cursorAddr = 0;
cursorBlink = true;
cursorBlinkCount = 0;
maxLineOffset = 0;
@ -1733,6 +1776,9 @@ void QHexEdit::memModeUpdate(void)
printf("Error: Failed to allocate memview buffer size\n");
return;
}
maxLineOffset = mb.numLines() - viewLines + 1;
vbar->setMaximum( memSize / 16 );
}
}
//----------------------------------------------------------------------------
@ -1808,6 +1854,7 @@ void QHexEdit::paintEvent(QPaintEvent *event)
ca = 16*(lineOffset + cursorPosY) + a;
}
cursorAddr = ca;
if ( cursorBlink )
{

View File

@ -114,6 +114,7 @@ class QHexEdit : public QWidget
void setBackGroundColor( QColor bg );
void memModeUpdate(void);
int checkMemActivity(void);
int getAddr(void){ return cursorAddr; };
enum {
MODE_NES_RAM = 0,
@ -164,6 +165,7 @@ class QHexEdit : public QWidget
int pxHexAscii;
int cursorPosX;
int cursorPosY;
int cursorAddr;
int cursorBlinkCount;
int viewLines;
int viewWidth;
@ -195,6 +197,7 @@ class HexEditorDialog_t : public QDialog
void gotoAddress(int newAddr);
void populateBookmarkMenu(void);
void setWindowTitle(void);
QHexEdit *editor;
protected:
@ -205,6 +208,10 @@ class HexEditorDialog_t : public QDialog
QScrollBar *hbar;
QTimer *periodicTimer;
QMenu *bookmarkMenu;
QAction *viewRAM;
QAction *viewPPU;
QAction *viewOAM;
QAction *viewROM;
private: