wex  v21.04.0
Public Member Functions | List of all members
wex::hexmode Class Reference

Offers a hex mode. More...

#include <wex/hexmode.h>

Public Member Functions

 hexmode (stc *stc, size_t bytesPerLine=16)
 Constructor. More...
 
void append_text (const std::string &text)
 If hex mode is on, appends hex mode lines to stc component. More...
 
void control_char_dialog (const std::string &caption)
 Shows a control char dialog.
 
bool erase (int count=1, int pos=-1)
 Deletes chars at current index at current line for both ascii and hex field.
 
const auto & buffer () const
 Returns the buffer. More...
 
const std::string get_info ()
 Returns info about current index, depending on which field is current.
 
auto * get_stc ()
 Returns stc component.
 
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=-1)
 Inserts text at position. More...
 
bool is_active () const
 Returns true if hex mode is on.
 
bool replace (char c, int pos=-1)
 Replaces current line at current index (if pos -1) with char for both ascii and hex field. More...
 
bool replace_target (const std::string &replacement, bool settext=true)
 Replaces target with replacement text. More...
 
bool set (bool on, bool use_modification_markers=true)
 Sets hex mode. More...
 
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. More...
 
void undo ()
 Undo change, sets the buffer to the original buffer.
 

Detailed Description

Offers a hex mode.

Constructor & Destructor Documentation

◆ hexmode()

wex::hexmode::hexmode ( stc stc,
size_t  bytesPerLine = 16 
)

Constructor.

Parameters
stcstc to view in hexmode
bytesPerLine
hex field ascii field
23 69 6e 63 6c 75 64 65 20 3c 77 78 2f 63 6d 64 #include <wx/cmd
6c 69 6e 65 2e 68 3e 20 2f 2f 20 66 6f 72 20 77 line.h> // for w
78 43 6d 64 4c 69 6e 65 50 61 72 73 65 72 0a 23 xCmdLineParser #
<---------------------------------------------> bytesPerLine

Member Function Documentation

◆ append_text()

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.

◆ buffer()

const auto& wex::hexmode::buffer ( ) const
inline

Returns the buffer.

The buffer contains the normal text, without hex info.

◆ insert()

bool wex::hexmode::insert ( const std::string &  text,
int  pos = -1 
)

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.

◆ replace()

bool wex::hexmode::replace ( char  c,
int  pos = -1 
)

Replaces current line at current index (if pos -1) with char for both ascii and hex field.

Otherwise at specified pos.

◆ replace_target()

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.

Parameters
replacementshould contain hex codes (uppercase): 303AFF.
settextinvokes SetText after replacing.

◆ set()

bool wex::hexmode::set ( bool  on,
bool  use_modification_markers = true 
)

Sets hex mode.

Returns true if mode is changed.

◆ set_text()

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.