mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:27:45 +00:00
HexEditor: Use size_t where applicable
File positions as well as selection positions should be size_t, as they are never negative and can become quite big.
This commit is contained in:
parent
6b5456f132
commit
4aab6ff839
3 changed files with 131 additions and 117 deletions
|
@ -32,30 +32,30 @@ public:
|
|||
bool is_readonly() const { return m_readonly; }
|
||||
void set_readonly(bool);
|
||||
|
||||
int buffer_size() const { return m_buffer.size(); }
|
||||
size_t buffer_size() const { return m_buffer.size(); }
|
||||
void set_buffer(const ByteBuffer&);
|
||||
void fill_selection(u8 fill_byte);
|
||||
bool write_to_file(const String& path);
|
||||
bool write_to_file(int fd);
|
||||
|
||||
void select_all();
|
||||
bool has_selection() const { return !(m_selection_start == -1 || m_selection_end == -1 || (m_selection_end - m_selection_start) <= 0 || m_buffer.is_empty()); }
|
||||
bool has_selection() const { return !((m_selection_end < m_selection_start) || m_buffer.is_empty()); }
|
||||
size_t selection_size();
|
||||
int selection_start_offset() const { return m_selection_start; }
|
||||
size_t selection_start_offset() const { return m_selection_start; }
|
||||
bool copy_selected_text_to_clipboard();
|
||||
bool copy_selected_hex_to_clipboard();
|
||||
bool copy_selected_hex_to_clipboard_as_c_code();
|
||||
|
||||
int bytes_per_row() const { return m_bytes_per_row; }
|
||||
void set_bytes_per_row(int);
|
||||
size_t bytes_per_row() const { return m_bytes_per_row; }
|
||||
void set_bytes_per_row(size_t);
|
||||
|
||||
void set_position(int position);
|
||||
void highlight(int start, int end);
|
||||
int find(ByteBuffer& needle, int start = 0);
|
||||
int find_and_highlight(ByteBuffer& needle, int start = 0);
|
||||
Vector<Match> find_all(ByteBuffer& needle, int start = 0);
|
||||
void set_position(size_t position);
|
||||
void highlight(size_t start, size_t end);
|
||||
Optional<size_t> find(ByteBuffer& needle, size_t start = 0);
|
||||
Optional<size_t> find_and_highlight(ByteBuffer& needle, size_t start = 0);
|
||||
Vector<Match> find_all(ByteBuffer& needle, size_t start = 0);
|
||||
Vector<Match> find_all_strings(size_t min_length = 4);
|
||||
Function<void(int, EditMode, int, int)> on_status_change; // position, edit mode, selection start, selection end
|
||||
Function<void(size_t, EditMode, size_t, size_t)> on_status_change; // position, edit mode, selection start, selection end
|
||||
Function<void()> on_change;
|
||||
|
||||
protected:
|
||||
|
@ -69,31 +69,31 @@ protected:
|
|||
|
||||
private:
|
||||
bool m_readonly { false };
|
||||
int m_line_spacing { 4 };
|
||||
int m_content_length { 0 };
|
||||
int m_bytes_per_row { 16 };
|
||||
size_t m_line_spacing { 4 };
|
||||
size_t m_content_length { 0 };
|
||||
size_t m_bytes_per_row { 16 };
|
||||
ByteBuffer m_buffer;
|
||||
bool m_in_drag_select { false };
|
||||
int m_selection_start { 0 };
|
||||
int m_selection_end { 0 };
|
||||
HashMap<int, u8> m_tracked_changes;
|
||||
int m_position { 0 };
|
||||
int m_byte_position { 0 }; // 0 or 1
|
||||
size_t m_selection_start { 0 };
|
||||
size_t m_selection_end { 0 };
|
||||
HashMap<size_t, u8> m_tracked_changes;
|
||||
size_t m_position { 0 };
|
||||
bool m_cursor_at_low_nibble { false };
|
||||
EditMode m_edit_mode { Hex };
|
||||
NonnullRefPtr<Core::Timer> m_blink_timer;
|
||||
bool m_cursor_blink_active { false };
|
||||
|
||||
void scroll_position_into_view(int position);
|
||||
void scroll_position_into_view(size_t position);
|
||||
|
||||
int total_rows() const { return ceil_div(m_content_length, m_bytes_per_row); }
|
||||
int line_height() const { return font().glyph_height() + m_line_spacing; }
|
||||
int character_width() const { return font().glyph_width('W'); }
|
||||
int offset_margin_width() const { return 80; }
|
||||
size_t total_rows() const { return ceil_div(m_content_length, m_bytes_per_row); }
|
||||
size_t line_height() const { return font().glyph_height() + m_line_spacing; }
|
||||
size_t character_width() const { return font().glyph_width('W'); }
|
||||
size_t offset_margin_width() const { return 80; }
|
||||
|
||||
void hex_mode_keydown_event(GUI::KeyEvent&);
|
||||
void text_mode_keydown_event(GUI::KeyEvent&);
|
||||
|
||||
void set_content_length(int); // I might make this public if I add fetching data on demand.
|
||||
void set_content_length(size_t); // I might make this public if I add fetching data on demand.
|
||||
void update_status();
|
||||
void did_change();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue