Merge pull request #240 from mjbudd77/master

Added edit copy, paste, and find functions to Qt Hex Editor
This commit is contained in:
mjbudd77 2020-11-17 00:27:40 -05:00 committed by GitHub
commit 3f5d479f44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 834 additions and 234 deletions

View File

@ -50,8 +50,8 @@ Name Table Viewer | YES | NO
Memory Hex Editor | YES | YES | Memory Hex Editor | YES | YES |
Trace Logger | YES | NO | Trace Logger | YES | NO |
Code/Data Logger | YES | NO | Code/Data Logger | YES | NO |
Game Genie Encoder/Decoder | NO | NO | Game Genie Encoder/Decoder | YES | NO |
iNES Header Editor | NO | NO | iNES Header Editor | YES | NO |
Built in help pages | NO | NO | Built in help pages | NO | NO |
Network play (who actually uses this???) | NO | NO | Network play (who actually uses this???) | NO | NO |
-----------------------------------------------------|-------------|-------------| -----------------------------------------------------|-------------|-------------|

View File

@ -14,6 +14,7 @@
#include <QColorDialog> #include <QColorDialog>
#include <QInputDialog> #include <QInputDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton>
#include "../../types.h" #include "../../types.h"
#include "../../fceu.h" #include "../../fceu.h"
@ -535,15 +536,154 @@ void HexBookMarkMenuAction::activateCB(void)
qedit->setAddr( bm->addr ); qedit->setAddr( bm->addr );
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
HexEditorFindDialog_t::HexEditorFindDialog_t(QWidget *parent)
: QDialog( parent )
{
QVBoxLayout *mainLayout, *vbox;
QHBoxLayout *hbox;
QPushButton *nextBtn;
QGroupBox *dirGroup, *typeGroup;
QDialog::setWindowTitle( tr("Find") );
this->parent = (HexEditorDialog_t*)parent;
mainLayout = new QVBoxLayout();
hbox = new QHBoxLayout();
searchBox = new QLineEdit();
nextBtn = new QPushButton( tr("Find Next") );
dirGroup = new QGroupBox( tr("Direction") );
typeGroup = new QGroupBox( tr("Type") );
hbox->addWidget( new QLabel( tr("Find What:") ) );
hbox->addWidget( searchBox );
hbox->addWidget( nextBtn );
nextBtn->setDefault(true);
mainLayout->addLayout( hbox );
hbox = new QHBoxLayout();
hbox->addWidget( dirGroup );
hbox->addWidget( typeGroup );
mainLayout->addLayout( hbox );
vbox = new QVBoxLayout();
upBtn = new QRadioButton( tr("Up") );
dnBtn = new QRadioButton( tr("Down") );
dnBtn->setChecked(true);
vbox->addWidget( upBtn );
vbox->addWidget( dnBtn );
dirGroup->setLayout( vbox );
vbox = new QVBoxLayout();
hexBtn = new QRadioButton( tr("Hex") );
txtBtn = new QRadioButton( tr("Text") );
vbox->addWidget( hexBtn );
vbox->addWidget( txtBtn );
hexBtn->setChecked(true);
typeGroup->setLayout( vbox );
setLayout( mainLayout );
connect( nextBtn, SIGNAL(clicked(void)), this, SLOT(runSearch(void)) );
}
//----------------------------------------------------------------------------
HexEditorFindDialog_t::~HexEditorFindDialog_t(void)
{
parent->findDialog = NULL;
}
//----------------------------------------------------------------------------
void HexEditorFindDialog_t::closeEvent(QCloseEvent *event)
{
printf("Hex Editor Close Window Event\n");
done(0);
deleteLater();
event->accept();
}
//----------------------------------------------------------------------------
void HexEditorFindDialog_t::closeWindow(void)
{
//printf("Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------------------------------
void HexEditorFindDialog_t::runSearch(void)
{
int i=0;
unsigned char v;
std::string s = searchBox->text().toStdString();
std::vector <unsigned char> varray;
if ( s.size() == 0 )
{
return;
}
//printf("Run Search: '%s'\n", s.c_str() );
if ( hexBtn->isChecked() )
{
i=0;
while ( s[i] != 0 )
{
while ( isspace(s[i]) ) i++;
v = 0;
if ( isxdigit(s[i]) )
{
v = convFromXchar(s[i]) << 4; i++;
}
else
{
return;
}
if ( isxdigit(s[i]) )
{
v |= convFromXchar(s[i]); i++;
}
else
{
return;
}
varray.push_back(v);
while ( isspace(s[i]) ) i++;
}
}
else
{
i=0;
while ( s[i] != 0 )
{
v = s[i];
varray.push_back(v);
i++;
}
}
fceuWrapperLock();
parent->editor->findPattern( varray, upBtn->isChecked() );
fceuWrapperUnLock();
}
//----------------------------------------------------------------------------
HexEditorDialog_t::HexEditorDialog_t(QWidget *parent) HexEditorDialog_t::HexEditorDialog_t(QWidget *parent)
: QDialog( parent, Qt::Window ) : QDialog( parent, Qt::Window )
{ {
//QVBoxLayout *mainLayout; //QVBoxLayout *mainLayout;
QGridLayout *grid; QGridLayout *grid;
QMenuBar *menuBar; QMenuBar *menuBar;
QMenu *fileMenu, *viewMenu, *colorMenu; QMenu *fileMenu, *editMenu, *viewMenu, *colorMenu;
QAction *saveROM, *closeAct; QAction *saveROM, *closeAct;
QAction *actHlgt, *actHlgtRV, *actColorFG, *actColorBG; QAction *act, *actHlgt, *actHlgtRV, *actColorFG, *actColorBG;
QActionGroup *group; QActionGroup *group;
int useNativeMenuBar; int useNativeMenuBar;
@ -597,6 +737,44 @@ HexEditorDialog_t::HexEditorDialog_t(QWidget *parent)
fileMenu->addAction(closeAct); fileMenu->addAction(closeAct);
// Edit
editMenu = menuBar->addMenu(tr("Edit"));
// Edit -> Undo
undoEditAct = new QAction(tr("Undo"), this);
undoEditAct->setShortcut(QKeySequence(tr("U")));
undoEditAct->setStatusTip(tr("Undo Edit"));
undoEditAct->setEnabled(false);
//connect(undoEditAct, SIGNAL(triggered()), this, SLOT(saveRomFile(void)) );
editMenu->addAction(undoEditAct);
editMenu->addSeparator();
// Edit -> Copy
act = new QAction(tr("Copy"), this);
act->setShortcut(QKeySequence(tr("Ctrl+C")));
act->setStatusTip(tr("Copy"));
connect(act, SIGNAL(triggered()), this, SLOT(copyToClipboard(void)) );
editMenu->addAction(act);
// Edit -> Paste
act = new QAction(tr("Paste"), this);
act->setShortcut(QKeySequence(tr("Ctrl+V")));
act->setStatusTip(tr("Paste"));
connect(act, SIGNAL(triggered()), this, SLOT(pasteFromClipboard(void)) );
editMenu->addAction(act);
editMenu->addSeparator();
// Edit -> Find
act = new QAction(tr("Find"), this);
act->setShortcut(QKeySequence(tr("Ctrl+F")));
act->setStatusTip(tr("Find"));
connect(act, SIGNAL(triggered()), this, SLOT(openFindDialog(void)) );
editMenu->addAction(act);
// View // View
viewMenu = menuBar->addMenu(tr("View")); viewMenu = menuBar->addMenu(tr("View"));
@ -718,6 +896,8 @@ HexEditorDialog_t::HexEditorDialog_t(QWidget *parent)
connect( hbar, SIGNAL(valueChanged(int)), this, SLOT(hbarChanged(int)) ); connect( hbar, SIGNAL(valueChanged(int)), this, SLOT(hbarChanged(int)) );
connect( vbar, SIGNAL(valueChanged(int)), this, SLOT(vbarChanged(int)) ); connect( vbar, SIGNAL(valueChanged(int)), this, SLOT(vbarChanged(int)) );
findDialog = NULL;
editor->memModeUpdate(); editor->memModeUpdate();
periodicTimer = new QTimer( this ); periodicTimer = new QTimer( this );
@ -1169,11 +1349,31 @@ void HexEditorDialog_t::updatePeriodic(void)
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void HexEditorDialog_t::openFindDialog(void)
{
if ( findDialog == NULL )
{
findDialog = new HexEditorFindDialog_t(this);
findDialog->show();
}
}
//----------------------------------------------------------------------------
void HexEditorDialog_t::openGotoAddrDialog(void) void HexEditorDialog_t::openGotoAddrDialog(void)
{ {
editor->openGotoAddrDialog(); editor->openGotoAddrDialog();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void HexEditorDialog_t::copyToClipboard(void)
{
editor->loadHighlightToClipboard();
}
//----------------------------------------------------------------------------
void HexEditorDialog_t::pasteFromClipboard(void)
{
editor->pasteFromClipboard();
}
//----------------------------------------------------------------------------
QHexEdit::QHexEdit(QWidget *parent) QHexEdit::QHexEdit(QWidget *parent)
: QWidget( parent ) : QWidget( parent )
{ {
@ -1264,6 +1464,19 @@ QHexEdit::QHexEdit(QWidget *parent)
} }
rvActvTextColor[i].setRgbF( grayScale, grayScale, grayScale ); rvActvTextColor[i].setRgbF( grayScale, grayScale, grayScale );
} }
mouseLeftBtnDown = false;
txtHlgtAnchorChar = -1;
txtHlgtAnchorLine = -1;
txtHlgtStartChar = -1;
txtHlgtStartLine = -1;
txtHlgtStartAddr = -1;
txtHlgtEndChar = -1;
txtHlgtEndLine = -1;
txtHlgtEndAddr = -1;
clipboard = QGuiApplication::clipboard();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
QHexEdit::~QHexEdit(void) QHexEdit::~QHexEdit(void)
@ -1336,6 +1549,7 @@ void QHexEdit::setMode( int mode )
{ {
viewMode = mode; viewMode = mode;
memModeUpdate(); memModeUpdate();
clearHighlight();
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -1446,6 +1660,170 @@ void QHexEdit::resetCursor(void)
editMask = 0; editMask = 0;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void QHexEdit::clearHighlight(void)
{
txtHlgtAnchorChar = -1;
txtHlgtAnchorLine = -1;
txtHlgtStartChar = -1;
txtHlgtStartLine = -1;
txtHlgtStartAddr = -1;
txtHlgtEndChar = -1;
txtHlgtEndLine = -1;
txtHlgtEndAddr = -1;
}
//----------------------------------------------------------------------------
void QHexEdit::loadClipboard( const char *txt )
{
//printf("Load Clipboard: '%s'\n", txt );
clipboard->setText( tr(txt), QClipboard::Clipboard );
if ( clipboard->supportsSelection() )
{
clipboard->setText( tr(txt), QClipboard::Selection );
}
}
//----------------------------------------------------------------------------
void QHexEdit::pasteFromClipboard(void)
{
int i, val, addr;
std::string s = clipboard->text().toStdString();
const char *c;
fceuWrapperLock();
//printf("Paste: '%s'\n", s.c_str() );
addr = cursorAddr;
c = s.c_str();
i=0;
while ( c[i] != 0 )
{
while ( isspace(c[i]) ) i++;
val = 0;
if ( isxdigit(c[i]) )
{
val = convFromXchar(c[i]) << 4; i++;
}
else
{
break;
}
if ( isxdigit(c[i]) )
{
val |= convFromXchar(c[i]); i++;
}
else
{
break;
}
writeMem( viewMode, addr, val );
addr++;
}
fceuWrapperUnLock();
}
//----------------------------------------------------------------------------
void QHexEdit::loadHighlightToClipboard(void)
{
int a, startAddr, endAddr;
std::string s;
char c[8];
fceuWrapperLock();
startAddr = (txtHlgtStartLine*16) + txtHlgtStartChar;
endAddr = (txtHlgtEndLine *16) + txtHlgtEndChar;
for (a=startAddr; a<=endAddr; a++)
{
sprintf( c, "%02X ", memAccessFunc(a) );
s.append(c);
}
fceuWrapperUnLock();
loadClipboard( s.c_str() );
}
//----------------------------------------------------------------------------
int QHexEdit::findPattern( std::vector <unsigned char> &varray, int dir )
{
int addr, inc, match;
inc = dir ? -1 : 1;
addr = cursorAddr;
match = 0;
//printf("Looking for pattern %zi\n", varray.size() );
while ( !match )
{
addr = (addr + inc);
if ( addr < 0 )
{
addr = mb.size() - 1;
}
else if ( addr >= mb.size() )
{
addr = 0;
}
if ( addr == cursorAddr )
{
return -1;
}
match = 1;
for (int i=0; i<varray.size(); i++)
{
if ( (addr+i) >= mb.size() )
{
match = 0; break;
}
if ( memAccessFunc(addr+i) != varray[i] )
{
match = 0; break;
}
}
}
if ( match )
{
int endAddr = addr + varray.size() - 1;
//printf("Found Match at $%04X\n", addr );
txtHlgtStartChar = (addr%16);
txtHlgtStartLine = (addr/16);
txtHlgtStartAddr = addr;
txtHlgtEndChar = (endAddr%16);
txtHlgtEndLine = (endAddr/16);
txtHlgtEndAddr = (endAddr);
cursorAddr = addr;
cursorPosX = txtHlgtStartChar*2;
if ( txtHlgtStartLine < lineOffset )
{
lineOffset = txtHlgtStartLine;
vbar->setValue( lineOffset );
}
else if ( txtHlgtStartLine >= (lineOffset+viewLines-3) )
{
lineOffset = txtHlgtStartLine - viewLines + 3;
if ( lineOffset >= maxLineOffset )
{
lineOffset = maxLineOffset;
}
vbar->setValue( lineOffset );
}
cursorPosY = txtHlgtStartLine - lineOffset;
}
return 0;
}
//----------------------------------------------------------------------------
QPoint QHexEdit::convPixToCursor( QPoint p ) QPoint QHexEdit::convPixToCursor( QPoint p )
{ {
QPoint c(0,0); QPoint c(0,0);
@ -1681,7 +2059,10 @@ void QHexEdit::keyPressEvent(QKeyEvent *event)
{ {
openGotoAddrDialog(); openGotoAddrDialog();
} }
else if ( event->key() == Qt::Key_F ) }
else if (Qt::ShiftModifier == event->modifiers())
{
if ( event->key() == Qt::Key_F )
{ {
frzRamAddr = ctxAddr = cursorAddr; frzRamAddr = ctxAddr = cursorAddr;
frzRamToggle(); frzRamToggle();
@ -1764,10 +2145,90 @@ void QHexEdit::keyReleaseEvent(QKeyEvent *event)
//printf("Hex Window Key Release: 0x%x \n", event->key() ); //printf("Hex Window Key Release: 0x%x \n", event->key() );
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool QHexEdit::textIsHighlighted(void)
{
bool set = false;
if ( txtHlgtStartLine == txtHlgtEndLine )
{
set = (txtHlgtStartChar != txtHlgtEndChar);
}
else
{
set = true;
}
return set;
}
//----------------------------------------------------------------------------
void QHexEdit::setHighlightEndCoord( int x, int y )
{
if ( txtHlgtAnchorLine < y )
{
txtHlgtStartLine = txtHlgtAnchorLine;
txtHlgtStartChar = txtHlgtAnchorChar;
txtHlgtEndLine = y;
txtHlgtEndChar = x;
}
else if ( txtHlgtAnchorLine > y )
{
txtHlgtStartLine = y;
txtHlgtStartChar = x;
txtHlgtEndLine = txtHlgtAnchorLine;
txtHlgtEndChar = txtHlgtAnchorChar;
}
else
{
txtHlgtStartLine = txtHlgtAnchorLine;
txtHlgtEndLine = txtHlgtAnchorLine;
if ( txtHlgtAnchorChar < x )
{
txtHlgtStartChar = txtHlgtAnchorChar;
txtHlgtEndChar = x;
}
else if ( txtHlgtAnchorChar > x )
{
txtHlgtStartChar = x;
txtHlgtEndChar = txtHlgtAnchorChar;
}
else
{
txtHlgtStartChar = txtHlgtAnchorChar;
txtHlgtEndChar = txtHlgtAnchorChar;
}
}
txtHlgtStartAddr = (txtHlgtStartLine*16) + txtHlgtStartChar;
txtHlgtEndAddr = (txtHlgtEndLine *16) + txtHlgtEndChar;
//printf(" (%i,%i) -> (%i,%i) \n", txtHlgtStartChar, txtHlgtStartLine, txtHlgtEndChar, txtHlgtEndLine );
return;
}
//----------------------------------------------------------------------------
void QHexEdit::mouseMoveEvent(QMouseEvent * event)
{
//int line;
//QPoint c = convPixToCursor( event->pos() );
int addr = convPixToAddr( event->pos() );
//line = lineOffset + c.y();
//printf("Move c: %ix%i \n", c.x(), c.y() );
if ( mouseLeftBtnDown )
{
//printf("Left Button Move: (%i,%i)\n", c.x(), c.y() );
setHighlightEndCoord( addr % 16, addr / 16 );
}
}
//----------------------------------------------------------------------------
void QHexEdit::mousePressEvent(QMouseEvent * event) void QHexEdit::mousePressEvent(QMouseEvent * event)
{ {
int addr;
QPoint c = convPixToCursor( event->pos() ); QPoint c = convPixToCursor( event->pos() );
addr = convPixToAddr( event->pos() );
//line = lineOffset + c.y();
//printf("c: %ix%i \n", c.x(), c.y() ); //printf("c: %ix%i \n", c.x(), c.y() );
if ( event->button() == Qt::LeftButton ) if ( event->button() == Qt::LeftButton )
@ -1775,6 +2236,34 @@ void QHexEdit::mousePressEvent(QMouseEvent * event)
cursorPosX = c.x(); cursorPosX = c.x();
cursorPosY = c.y(); cursorPosY = c.y();
resetCursor(); resetCursor();
mouseLeftBtnDown = true;
txtHlgtAnchorChar = addr % 16;
txtHlgtAnchorLine = addr / 16;
setHighlightEndCoord( txtHlgtAnchorChar, txtHlgtAnchorLine );
}
}
//----------------------------------------------------------------------------
void QHexEdit::mouseReleaseEvent(QMouseEvent * event)
{
//int line;
//QPoint c = convPixToCursor( event->pos() );
int addr = convPixToAddr( event->pos() );
//line = lineOffset + c.y();
//printf("c: %ix%i \n", c.x(), c.y() );
if ( event->button() == Qt::LeftButton )
{
mouseLeftBtnDown = false;
setHighlightEndCoord( addr % 16, addr / 16 );
if ( textIsHighlighted() )
{
loadHighlightToClipboard();
}
} }
} }
@ -1855,7 +2344,7 @@ void QHexEdit::contextMenuEvent(QContextMenuEvent *event)
subMenu = menu.addMenu(tr("Freeze/Unfreeze Address")); subMenu = menu.addMenu(tr("Freeze/Unfreeze Address"));
act = new QAction(tr("Toggle State"), &menu); act = new QAction(tr("Toggle State"), &menu);
act->setShortcut( QKeySequence(tr("Ctrl+F"))); act->setShortcut( QKeySequence(tr("Shift+F")));
subMenu->addAction(act); subMenu->addAction(act);
connect( act, SIGNAL(triggered(void)), this, SLOT(frzRamToggle(void)) ); connect( act, SIGNAL(triggered(void)), this, SLOT(frzRamToggle(void)) );
@ -2343,6 +2832,12 @@ int QHexEdit::getRomAddrColor( int addr, QColor &fg, QColor &bg )
{ {
return -1; return -1;
} }
if ( (txtHlgtStartAddr != txtHlgtEndAddr) && (addr >= txtHlgtStartAddr) && (addr <= txtHlgtEndAddr) )
{
fg = QColor("white");
bg = QColor("blue");
return 0;
}
if (cdloggerdataSize == 0) if (cdloggerdataSize == 0)
{ {
return -1; return -1;
@ -2480,10 +2975,11 @@ void QHexEdit::memModeUpdate(void)
void QHexEdit::paintEvent(QPaintEvent *event) void QHexEdit::paintEvent(QPaintEvent *event)
{ {
int x, y, w, h, row, col, nrow, addr; int x, y, w, h, row, col, nrow, addr;
int c, cx, cy, ca; int c, cx, cy, ca, l;
char txt[32], asciiTxt[4]; char txt[32], asciiTxt[4];
QPainter painter(this); QPainter painter(this);
QColor white("white"), black("black"), blue("blue"); QColor white("white"), black("black"), blue("blue");
bool txtHlgtSet;
painter.setFont(font); painter.setFont(font);
w = event->rect().width(); w = event->rect().width();
@ -2559,12 +3055,15 @@ void QHexEdit::paintEvent(QPaintEvent *event)
painter.setPen( this->palette().color(QPalette::WindowText)); painter.setPen( this->palette().color(QPalette::WindowText));
//painter.setPen( QColor("white") );
addr = lineOffset * 16; addr = lineOffset * 16;
y = pxYoffset; y = pxYoffset;
txtHlgtSet = textIsHighlighted();
for ( row=0; row < nrow; row++) for ( row=0; row < nrow; row++)
{ {
l = lineOffset + row;
x = pxXoffset - pxLineXScroll; x = pxXoffset - pxLineXScroll;
painter.setPen( this->palette().color(QPalette::WindowText)); painter.setPen( this->palette().color(QPalette::WindowText));
@ -2573,6 +3072,59 @@ void QHexEdit::paintEvent(QPaintEvent *event)
x = pxHexOffset - pxLineXScroll; x = pxHexOffset - pxLineXScroll;
if ( txtHlgtSet && (l >= txtHlgtStartLine) && (l <= txtHlgtEndLine) )
{
int hlgtXs, hlgtXe, hlgtXd;
if ( l == txtHlgtStartLine )
{
hlgtXs = txtHlgtStartChar*3;
}
else
{
hlgtXs = 0;
}
if ( l == txtHlgtEndLine )
{
hlgtXe = (txtHlgtEndChar+1)*3;
}
else
{
hlgtXe = 16*3;
}
hlgtXd = hlgtXe - hlgtXs;
x = pxHexOffset - pxLineXScroll;
painter.fillRect( x + (hlgtXs*pxCharWidth), y - pxLineSpacing + pxLineLead, hlgtXd*pxCharWidth, pxLineSpacing, blue );
if ( l == txtHlgtStartLine )
{
hlgtXs = txtHlgtStartChar;
}
else
{
hlgtXs = 0;
}
if ( l == txtHlgtEndLine )
{
hlgtXe = (txtHlgtEndChar+1);
}
else
{
hlgtXe = 16;
}
hlgtXd = hlgtXe - hlgtXs;
x = pxHexAscii - pxLineXScroll;
painter.fillRect( x + (hlgtXs*pxCharWidth), y - pxLineSpacing + pxLineLead, hlgtXd*pxCharWidth, pxLineSpacing, blue );
}
x = pxHexOffset - pxLineXScroll;
for (col=0; col<16; col++) for (col=0; col<16; col++)
{ {
if ( addr < mb.size() ) if ( addr < mb.size() )

View File

@ -14,7 +14,9 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QComboBox> #include <QComboBox>
#include <QCheckBox> #include <QCheckBox>
#include <QLineEdit>
#include <QPushButton> #include <QPushButton>
#include <QRadioButton>
#include <QLabel> #include <QLabel>
#include <QMenu> #include <QMenu>
#include <QFrame> #include <QFrame>
@ -117,6 +119,10 @@ class QHexEdit : public QWidget
int checkMemActivity(void); int checkMemActivity(void);
int getAddr(void){ return cursorAddr; }; int getAddr(void){ return cursorAddr; };
int FreezeRam( const char *name, uint32_t a, uint8_t v, int c, int s, int type ); int FreezeRam( const char *name, uint32_t a, uint8_t v, int c, int s, int type );
void loadHighlightToClipboard(void);
void pasteFromClipboard(void);
void clearHighlight(void);
int findPattern( std::vector <unsigned char> &varray, int dir );
enum { enum {
MODE_NES_RAM = 0, MODE_NES_RAM = 0,
@ -130,15 +136,20 @@ class QHexEdit : public QWidget
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event);
void mousePressEvent(QMouseEvent * event); void mousePressEvent(QMouseEvent * event);
void mouseReleaseEvent(QMouseEvent * event);
void mouseMoveEvent(QMouseEvent * event);
void wheelEvent(QWheelEvent *event); void wheelEvent(QWheelEvent *event);
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
void contextMenuEvent(QContextMenuEvent *event); void contextMenuEvent(QContextMenuEvent *event);
void calcFontData(void); void calcFontData(void);
void resetCursor(void); void resetCursor(void);
bool textIsHighlighted(void);
void setHighlightEndCoord( int x, int y );
QPoint convPixToCursor( QPoint p ); QPoint convPixToCursor( QPoint p );
int convPixToAddr( QPoint p ); int convPixToAddr( QPoint p );
bool frzRamAddrValid( int addr ); bool frzRamAddrValid( int addr );
void loadClipboard( const char *txt );
QFont font; QFont font;
@ -151,6 +162,7 @@ class QHexEdit : public QWidget
QScrollBar *hbar; QScrollBar *hbar;
QColor highLightColor[ HIGHLIGHT_ACTIVITY_NUM_COLORS ]; QColor highLightColor[ HIGHLIGHT_ACTIVITY_NUM_COLORS ];
QColor rvActvTextColor[ HIGHLIGHT_ACTIVITY_NUM_COLORS ]; QColor rvActvTextColor[ HIGHLIGHT_ACTIVITY_NUM_COLORS ];
QClipboard *clipboard;
HexEditorDialog_t *parent; HexEditorDialog_t *parent;
@ -187,10 +199,19 @@ class QHexEdit : public QWidget
int frzRamMode; int frzRamMode;
int frzIdx; int frzIdx;
int wheelPixelCounter; int wheelPixelCounter;
int txtHlgtAnchorChar;
int txtHlgtAnchorLine;
int txtHlgtStartChar;
int txtHlgtStartLine;
int txtHlgtStartAddr;
int txtHlgtEndChar;
int txtHlgtEndLine;
int txtHlgtEndAddr;
bool cursorBlink; bool cursorBlink;
bool reverseVideo; bool reverseVideo;
bool actvHighlightEnable; bool actvHighlightEnable;
bool mouseLeftBtnDown;
private slots: private slots:
void jumpToROM(void); void jumpToROM(void);
@ -208,6 +229,28 @@ class QHexEdit : public QWidget
}; };
class HexEditorFindDialog_t : public QDialog
{
Q_OBJECT
public:
HexEditorFindDialog_t(QWidget *parent = 0);
~HexEditorFindDialog_t(void);
QLineEdit *searchBox;
QRadioButton *upBtn;
QRadioButton *dnBtn;
QRadioButton *hexBtn;
QRadioButton *txtBtn;
protected:
void closeEvent(QCloseEvent *bar);
HexEditorDialog_t *parent;
public slots:
void closeWindow(void);
void runSearch(void);
};
class HexEditorDialog_t : public QDialog class HexEditorDialog_t : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -222,8 +265,9 @@ class HexEditorDialog_t : public QDialog
void openDebugSymbolEditWindow( int addr ); void openDebugSymbolEditWindow( int addr );
QHexEdit *editor; QHexEdit *editor;
protected: HexEditorFindDialog_t *findDialog;
protected:
void closeEvent(QCloseEvent *bar); void closeEvent(QCloseEvent *bar);
QScrollBar *vbar; QScrollBar *vbar;
@ -235,6 +279,7 @@ class HexEditorDialog_t : public QDialog
QAction *viewOAM; QAction *viewOAM;
QAction *viewROM; QAction *viewROM;
QAction *gotoAddrAct; QAction *gotoAddrAct;
QAction *undoEditAct;
private: private:
@ -257,6 +302,9 @@ class HexEditorDialog_t : public QDialog
void pickBackGroundColor(void); void pickBackGroundColor(void);
void removeAllBookmarks(void); void removeAllBookmarks(void);
void openGotoAddrDialog(void); void openGotoAddrDialog(void);
void copyToClipboard(void);
void pasteFromClipboard(void);
void openFindDialog(void);
}; };
int hexEditorNumWindows(void); int hexEditorNumWindows(void);