wex v24.04.0
Public Member Functions | Static Public Member Functions | List of all members
wex::stc Class Reference

Offers a syntax stc with: More...

#include <wex/stc/stc.h>

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

Public Member Functions

 stc (const std::string &text=std::string(), const data::stc &data=data::stc())
 Default constructor, sets text if not empty.
 
 stc (const wex::path &p, const data::stc &data=data::stc())
 Constructor, opens the file if it exists.
 
 ~stc () override
 Destructor.
 
virtual bool process_char (int c)
 Processes specified char.
 
auto * auto_complete ()
 Returns auto_complete.
 
void config_get ()
 Sets the configurable parameters to values currently in config.
 
const auto & data () const
 Returns associated data.
 
void filetype_menu ()
 Shows a menu with current line type checked, and allows you to change it.
 
bool find_next (bool stc_find_string=true)
 Finds next with settings from find replace data.
 
auto & get_file ()
 Returns the file.
 
auto get_frame ()
 Returns frame.
 
const auto & get_hexmode () const
 Returns hex mode component.
 
auto & get_hexmode ()
 Returns writable hex mode component.
 
const viget_vi () const
 Returns vi component.
 
viget_vi ()
 Returns writable vi component.
 
bool is_shown_line_numbers () const
 Returns true if line numbers are shown.
 
void keep_event_data (bool synced)
 Keeps event data.
 
bool marker_delete_all_change ()
 Deletes all change markers.
 
int replace_all (const std::string &find_text, const std::string &replace_text)
 Replaces all text.
 
bool replace_next (bool stc_find_string=true)
 Replaces text and calls find next.
 
bool replace_next (const std::string &find_text, const std::string &replace_text, int find_flags=0, bool stc_find_string=true)
 Replaces text and calls find next.
 
void add_text (const std::string &text) override
 Adds text.
 
void add_text_block (const std::string &text) override
 Adds text block mode.
 
void append_text (const std::string &text) override
 Appends text (to end).
 
bool auto_indentation (int c) override
 After pressing enter, starts new line at same place as previous line.
 
bool find (const std::string &text, int find_flags=-1, bool find_next=true) override
 Override methods from text_window.
 
wex::data::stcget_data () override
 Returns stc data.
 
const ex_commandget_ex_command () const override
 Returns the ex command.
 
const std::string get_find_string () const override
 Returns find string, from selected text or from config.
 
bool get_hexmode_erase (int begin, int end) override
 Hex erase.
 
bool get_hexmode_insert (const std::string &command, int pos) override
 Hex insert.
 
std::string get_hexmode_lines (const std::string &text) const override
 Hex lines.
 
bool get_hexmode_replace (char) override
 Hex replace.
 
bool get_hexmode_replace_target (const std::string &replacement, bool set_text) override
 Hex replace target.
 
bool get_hexmode_sync () override
 Hex sync.
 
int get_current_line () const override
 Returns current line no.
 
int get_line_count () const override
 Returns number of lines.
 
int get_line_count_request () override
 Request for number of lines.
 
void goto_line (int line) override
 Goes to specified line.
 
bool inject (const data::control &data) override
 Injects data.
 
bool is_hexmode () const override
 Returns true if we are in hex mode (default false).
 
bool is_visual () const override
 Returns true if we are in visual mode (not ex mode) (default true).
 
bool link_open () override
 If selected text is a link, opens the link.
 
bool open (const wex::path &p, const data::stc &data=data::stc()) override
 Opens the file, reads the content into the window, then closes the file and sets the lexer.
 
const wex::pathpath () const override
 Returns the path, as used by the file.
 
void print (bool prompt=true) override
 Prints the document.
 
void print_preview (wxPreviewFrameModalityKind kind=wxPreviewFrame_AppModal) override
 Shows a print preview.
 
void properties_message (path::log_t t=path::log_t().set(path::LOG_MOD)) override
 Shows properties on the statusbar using specified flags.
 
bool set_hexmode (bool on) override
 Sets hex mode (default false).
 
void set_search_flags (int flags) override
 Sets search flags, default invokes SetSearchFlags.
 
void set_text (const std::string &value) override
 Sets the text.
 
void show_ascii_value () override
 Shows decimal or hex info of word under cursor.
 
void show_line_numbers (bool show) override
 Shows or hides line numbers.
 
void sync (bool start=true) override
 Starts or stops syncing.
 
void use_modification_markers (bool use) override
 Use and show modification markers in the margin.
 
bool vi_command (const line_data &data) override
 Runs a vi command on this stc (default false).
 
bool vi_command_finish (bool user_input) override
 Finish last vi command (default false).
 
void vi_record (const std::string &command) override
 Records a macro.
 
bool vi_is_visual () const override
 Returns true if we are in vi visual mode (default false).
 
std::string vi_register (char c) const override
 Returns vi register.
 
int vi_search_flags () const override
 Returns vi search flags.
 
const std::string vi_mode () const override
 Returns vi mode as a string.
 
void visual (bool on) override
 Sets using visual vi (on) or ex mode (!on).
 
- Public Member Functions inherited from wex::syntax::stc
 stc (const data::window &data=data::window())
 Default constructor.
 
virtual bool lexer_is_previewable () const final
 Returns whether lexer is previewable.
 
virtual std::string lexer_name () const final
 Returns the name of the lexer.
 
void blame_margin (const blame *blame)
 Blames margin.
 
void fold (bool fold_all=false)
 Enables or disables folding depending on fold property (default not implemented).
 
const auto & get_lexer () const
 Returns the lexer.
 
auto & get_lexer ()
 Returns the lexer.
 
std::string margin_get_revision_renamed () const
 Returns renamed revision.
 
bool set_indicator (const indicator &indicator, int start=-1, int end=-1)
 Sets an indicator at specified start and end pos.
 
- Public Member Functions inherited from wex::factory::stc
 stc (const data::window &data=data::window())
 Default constructor.
 
void bind_wx ()
 Binds wx methods.
 
void clear (bool set_savepoint=true)
 Clears the component: all text is cleared and all styles are reset.
 
const std::string eol () const
 Returns EOL string.
 
size_t get_fold_level () const
 Returns current line fold level.
 
int get_margin_text_click () const
 Returns line on which text margin was clicked, or -1 if not.
 
const std::string get_selected_text () const
 Returns selected text as a string.
 
const std::string get_text () const
 Returns the text.
 
const std::string get_word_at_pos (int pos) const
 Returns word at position.
 
std::string margin_get_revision_id () const
 When clicked on a line with a text margin, returns revision id on the text margin, otherwise returns empty string.
 
bool margin_text_is_shown () const
 Returns true if margin text is shown.
 
void margin_text_show ()
 Shows text margin.
 
bool position_restore ()
 Restores saved position.
 
void position_save ()
 Saves position.
 
void reset_margins (margin_t type=margin_t().set())
 Resets (all) margins.
 
void set_margin_text_click (int line)
 Sets the margin line that is clicked (for testing).
 
auto & vcs_renamed () const
 Returns renamed.
 
- Public Member Functions inherited from wex::factory::text_window
virtual ~text_window ()=default
 Destructor.
 

Static Public Member Functions

static int config_dialog (const data::window &data=data::window())
 Shows a dialog with options, returns dialog return code.
 
static auto * config_items ()
 Returns config items.
 
static auto * get_config_dialog ()
 Returns the config dialog.
 
static void on_exit ()
 Saves static data in config.
 
static void on_init ()
 Reads static data from config (e.g.
 

Additional Inherited Members

- Public Types inherited from wex::factory::stc
enum  { MARGIN_DIVIDER = 0 , MARGIN_FOLDING = 1 , MARGIN_LINENUMBER = 2 , MARGIN_TEXT = 3 }
 Margin flags. More...
 
typedef std::bitset< 4 > margin_t
 A typedef containing margin flags.
 

Detailed Description

Offers a syntax stc with:

Member Function Documentation

◆ config_dialog()

static int wex::stc::config_dialog ( const data::window & data = data::window())
static

Shows a dialog with options, returns dialog return code.

If used modeless, it uses the dialog id as specified, so you can use that id in frame::on_command_item_dialog.

◆ get_find_string()

const std::string wex::stc::get_find_string ( ) const
overridevirtual

Returns find string, from selected text or from config.

The search flags are taken from frd. If text is selected, it also sets the find string.

Reimplemented from wex::factory::stc.

◆ get_vi()

vi & wex::stc::get_vi ( )

Returns writable vi component.

This allows you to do ex like editing:

  • get_vi().Command(":1,$s/xx/yy/g")
  • get_vi().Command(":w") to replace all xx by yy, and save the file.

◆ marker_delete_all_change()

bool wex::stc::marker_delete_all_change ( )

Deletes all change markers.

Returns false if marker change is not loaded.

◆ on_exit()

static void wex::stc::on_exit ( )
static

Saves static data in config.

Invoked once during app::on_exit.

◆ on_init()

static void wex::stc::on_init ( )
static

Reads static data from config (e.g.

zooming). Invoked once during app::OnInit.

◆ path()

const wex::path & wex::stc::path ( ) const
inlineoverridevirtual

Returns the path, as used by the file.

Pure virtual, must be overridden.

Implements wex::factory::stc.

◆ process_char()

virtual bool wex::stc::process_char ( int c)
inlinevirtual

Processes specified char.

Default does nothing, but is invoked during control_char_dialog, allowing you to add your own processing. Return true if char was processed.

Reimplemented in wex::shell.

◆ properties_message()

void wex::stc::properties_message ( path::log_t flags = path::log_t().set(path::LOG_MOD))
overridevirtual

Shows properties on the statusbar using specified flags.

Default not implemented.

Reimplemented from wex::factory::stc.

◆ replace_all()

int wex::stc::replace_all ( const std::string & find_text,
const std::string & replace_text )

Replaces all text.

It there is a selection, it replaces in the selection, otherwise in the entire document. Returns the number of replacements.

◆ replace_next() [1/2]

bool wex::stc::replace_next ( bool stc_find_string = true)

Replaces text and calls find next.

Uses settings from find replace data.

◆ replace_next() [2/2]

bool wex::stc::replace_next ( const std::string & find_text,
const std::string & replace_text,
int find_flags = 0,
bool stc_find_string = true )

Replaces text and calls find next.

It there is a selection, it replaces in the selection, otherwise it starts at current position.

Parameters
find_texttext to find
replace_texttext to replace with
find_flagssearch flags to be used:
  • wxSTC_FIND_WHOLEWORD
  • wxSTC_FIND_MATCHCASE
  • wxSTC_FIND_WORDSTART
  • wxSTC_FIND_REGEXP
  • wxSTC_FIND_POSIX
  • if -1, use flags from find replace data
stc_find_stringargument passed on to find_next

◆ set_search_flags()

void wex::stc::set_search_flags ( int flags)
overridevirtual

Sets search flags, default invokes SetSearchFlags.

search flags to be used:

  • wxSTC_FIND_WHOLEWORD
  • wxSTC_FIND_MATCHCASE
  • wxSTC_FIND_WORDSTART
  • wxSTC_FIND_REGEXP
  • wxSTC_FIND_POSIX

Reimplemented from wex::factory::stc.

◆ sync()

void wex::stc::sync ( bool start = true)
inlineoverridevirtual

Starts or stops syncing.

Default syncing is started during construction.

Reimplemented from wex::factory::stc.

◆ use_modification_markers()

void wex::stc::use_modification_markers ( bool use)
overridevirtual

Use and show modification markers in the margin.

If you open a file, the modification markers are used.

Reimplemented from wex::factory::stc.