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

@ -3097,7 +3097,7 @@ QAsmView::QAsmView(QWidget *parent)
wheelPixelCounter = 0; wheelPixelCounter = 0;
//setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding ); //setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
clipboard = QGuiApplication::clipboard(); clipboard = QGuiApplication::clipboard();
@ -3533,7 +3533,7 @@ void QAsmView::loadHighlightToClipboard(void)
{ {
l = lineOffset + row; l = lineOffset + row;
if ( (l >= txtHlgtStartLine) && (l <= txtHlgtEndLine) ) if ( (l >= txtHlgtStartLine) && (l <= txtHlgtEndLine) )
{ {
int hlgtXs, hlgtXe, hlgtXd; int hlgtXs, hlgtXe, hlgtXd;
std::string s; std::string s;

File diff suppressed because it is too large Load Diff

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>
@ -113,10 +115,14 @@ class QHexEdit : public QWidget
void setForeGroundColor( QColor fg ); void setForeGroundColor( QColor fg );
void setBackGroundColor( QColor bg ); void setBackGroundColor( QColor bg );
void memModeUpdate(void); void memModeUpdate(void);
void openGotoAddrDialog(void); void openGotoAddrDialog(void);
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,
@ -128,17 +134,22 @@ class QHexEdit : public QWidget
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
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,12 +162,13 @@ 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;
uint64_t total_instructions_lp; uint64_t total_instructions_lp;
int viewMode; int viewMode;
int lineOffset; int lineOffset;
int pxCharWidth; int pxCharWidth;
int pxCharHeight; int pxCharHeight;
@ -176,10 +188,10 @@ class QHexEdit : public QWidget
int viewLines; int viewLines;
int viewWidth; int viewWidth;
int viewHeight; int viewHeight;
int maxLineOffset; int maxLineOffset;
int editAddr; int editAddr;
int editValue; int editValue;
int editMask; int editMask;
int jumpToRomValue; int jumpToRomValue;
int ctxAddr; int ctxAddr;
int frzRamAddr; int frzRamAddr;
@ -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,11 +279,12 @@ class HexEditorDialog_t : public QDialog
QAction *viewOAM; QAction *viewOAM;
QAction *viewROM; QAction *viewROM;
QAction *gotoAddrAct; QAction *gotoAddrAct;
QAction *undoEditAct;
private: private:
public slots: public slots:
void closeWindow(void); void closeWindow(void);
private slots: private slots:
void updatePeriodic(void); void updatePeriodic(void);
void vbarMoved(int value); void vbarMoved(int value);
@ -256,7 +301,10 @@ class HexEditorDialog_t : public QDialog
void pickForeGroundColor(void); void pickForeGroundColor(void);
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);