wex v24.10.0
Public Member Functions | List of all members
wex::hexmode Class Reference

Offers a hex mode. More...

#include <wex/stc/hexmode.h>

Inheritance diagram for wex::hexmode:
Inheritance graph
[legend]

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

Detailed Description

Offers a hex mode.

Constructor & Destructor Documentation

◆ hexmode()

wex::hexmode::hexmode ( factory::stc * stc,
size_t bytes_per_line = 16 )

Constructor.

Parameters
stcstc to view in hexmode
bytes_per_linebytes per line

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 = 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.

◆ replace()

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.

◆ 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.