-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhex_editor.h
More file actions
123 lines (105 loc) · 3.75 KB
/
hex_editor.h
File metadata and controls
123 lines (105 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef HEX_EDITOR_H
#define HEX_EDITOR_H
#include "events/event_types.h"
#include "selection.h"
#include "rom_buffer.h"
#include "panels/bookmark_panel.h"
class hex_display;
class ascii_display;
class address_display;
class hex_editor : public QWidget
{
Q_OBJECT
public:
explicit hex_editor(QWidget *parent, QString file_name, QUndoGroup *undo_group, bool new_file = false);
~hex_editor();
void set_focus();
void compare(QString file);
void close_compare();
void goto_diff(bool direction);
QString generate_patch();
bool follow_selection(bool type);
ROM_buffer *get_buffer(){ return buffer; }
QVector<selection> *get_diff(){ return diffs; }
QString load_error() { return ROM_error; }
QString get_file_name() { return buffer->get_file_name(); }
int get_relative_position(int address){ return cursor_nibble / 2 + address; }
void save(QString path) { buffer->save(path); update_save_state(-save_state); }
bool can_save(){ return save_state; }
bool new_file(){ return is_new; }
bool is_comparing(){ return comparing; }
bool is_selecting(){ return selection_area.is_active(); }
bool is_pasteable(){ return buffer->check_paste_data(); }
int get_offset(){ return offset; }
void set_offset(int o);
int get_cursor_nibble(){ return cursor_nibble; }
void set_cursor_nibble(int byte){ cursor_nibble = byte; update_window(); }
selection get_selection(){ return selection_area; }
void set_selection(selection s){ selection_area = s; update_window(); }
signals:
void update_slider(int position);
void update_range(int value);
void update_status_text(QString text);
void toggle_scroll_mode(bool mode);
void save_state_changed(bool save);
void send_disassemble_data(selection selection_area, const ROM_buffer *buffer);
void send_bookmark_data(int start, int end, const ROM_buffer *buffer);
public slots:
void update_window();
void handle_typed_character(unsigned char key, bool update_byte = false);
void update_undo_action(bool direction);
void goto_offset(int address);
void select_range(int start, int end);
void slider_update(int position);
void scroll_mode_changed();
void context_menu(const QPoint& position);
void cut();
void copy();
void paste(bool raw = false);
void delete_text();
void select_all();
void branch();
void jump();
void disassemble();
void create_bookmark();
void count(QString find, bool mode);
void search(QString find, bool direction, bool mode);
void replace(QString find, QString replace, bool direction, bool mode);
void replace_all(QString find, QString replace, bool mode);
protected:
virtual void keyPressEvent(QKeyEvent *event);
virtual void wheelEvent(QWheelEvent *event);
virtual bool event(QEvent *event);
private:
ROM_buffer *buffer;
int offset = 0;
hex_display *hex;
ascii_display *ascii;
address_display *address;
bool comparing = false;
ROM_buffer *compare_buffer = new ROM_buffer();
address_display *compare_address;
hex_display *compare_hex;
ascii_display *compare_ascii;
QVector<selection> *diffs = nullptr;
QLabel *hex_header = new QLabel("00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
QLabel *address_header = new QLabel("Offset");
bool scroll_mode = false;
int save_state = 0;
bool is_new;
QString ROM_error = "";
int cursor_nibble = 0;
selection selection_area;
static bool wheel_cursor;
static bool prompt_resize;
void handle_search_result(QString target, int result, bool mode);
void calculate_diff();
void update_save_state(int direction);
QString get_status_text();
void move_cursor_nibble(int delta);
void update_nibble(char byte);
void search_error(int error, QString find = "", QString replace_with = "");
int get_max_lines();
bool validate_resize();
};
#endif // HEX_EDITOR_H