wex v24.10.0
|
Offers a hex mode. More...
#include <wex/stc/hexmode.h>
Public Member Functions | |
hexmode (factory::stc *stc, size_t bytes_per_line=16) | |
Constructor. | |
void | append_text (const std::string &text) |
If hex mode is on, appends hex mode lines to stc component. | |
const auto & | buffer () const |
Returns the buffer. | |
void | control_char_dialog (const std::string &caption) |
Shows a control char dialog. | |
bool | erase (int count=1, int pos=wxSTC_INVALID_POSITION) |
Deletes chars at current index at current line for both ascii and hex field. | |
const std::string | get_info () |
Returns info about current index, depending on which field is current. | |
bool | goto_dialog () |
Asks for a byte offset goes to that byte. | |
bool | highlight_other () |
Highlights the corresponding char for the other field for the current position. | |
bool | highlight_other (int pos) |
Highlights the corresponding char for the other field. | |
bool | insert (const std::string &text, int pos=wxSTC_INVALID_POSITION) |
Inserts text at position. | |
bool | replace (char c, int pos=wxSTC_INVALID_POSITION) |
Replaces current line at current index (if pos wxSTC_INVALID_POSITION) with char for both ascii and hex field. | |
bool | replace_target (const std::string &replacement, bool settext=true) |
Replaces target with replacement text. | |
bool | set (bool on, bool use_modification_markers=true) |
Sets hex mode. | |
void | set_pos (const wxKeyEvent &event) |
Sets caret pos on stc, depending on event and where we are. | |
void | set_text (const std::string &text) |
Sets text, if hex mode is on. | |
void | set_text_from_buffer () |
Sets text from buffer, if hex mode is on. | |
bool | sync () |
Sync, set text with buffer. | |
void | undo () |
Undo change, sets the buffer to the original buffer. | |
Public Member Functions inherited from wex::factory::hexmode | |
hexmode (factory::stc *stc, size_t bytes_per_line=16) | |
Constructor. | |
virtual | ~hexmode ()=default |
Destructor. | |
auto | bytes_per_line () const |
Returns number of bytes per line. | |
auto | each_hex_field () const |
Returns each hex field. | |
auto * | get_stc () |
Returns stc component. | |
bool | is_active () const |
Returns true if hex mode is on. | |
const std::string | lines (const std::string &text) const |
Converts text into hex lines. | |
void | make_active (bool on) |
Make hex mode active. | |
char | printable (unsigned int c) const |
Returns a printable char. | |
Additional Inherited Members |
Offers a hex mode.
wex::hexmode::hexmode | ( | factory::stc * | stc, |
size_t | bytes_per_line = 16 ) |
Constructor.
stc | stc to view in hexmode |
bytes_per_line | bytes per line |
void wex::hexmode::append_text | ( | const std::string & | text | ) |
If hex mode is on, appends hex mode lines to stc component.
The text should be normal ascii text, it is encoded while appending.
|
inline |
Returns the buffer.
The buffer contains the normal text, without hex info.
bool wex::hexmode::insert | ( | const std::string & | text, |
int | pos = wxSTC_INVALID_POSITION ) |
Inserts text at position.
Insert at ascii field or at hex field, at hex field you should provide the ascii hex codes, e.g. "30" inserts one byte space.
bool wex::hexmode::replace | ( | char | c, |
int | pos = wxSTC_INVALID_POSITION ) |
Replaces current line at current index (if pos wxSTC_INVALID_POSITION) with char for both ascii and hex field.
Otherwise at specified pos.
bool wex::hexmode::replace_target | ( | const std::string & | replacement, |
bool | settext = true ) |
Replaces target with replacement text.
This is only possible for hex the field, therefore the target start and target end should be within the hex field. Returns false if target outside area, or replacement text has invalid chars, or doc is readonly.
replacement | should contain hex codes (uppercase): 303AFF. |
settext | invokes SetText after replacing. |
bool wex::hexmode::set | ( | bool | on, |
bool | use_modification_markers = true ) |
Sets hex mode.
Returns true if mode is changed.
void wex::hexmode::set_text | ( | const std::string & | text | ) |
Sets text, if hex mode is on.
The text should be normal ascii text, it is encoded while appending.