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

Offers a styled text ctrl with: More...

#include <wex/stc.h>

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

Public Types

enum  { MARGIN_DIVIDER = 0, MARGIN_FOLDING = 1, MARGIN_LINENUMBER = 2, MARGIN_TEXT = 3 }
 Margin flags. More...
 

Public Member Functions

 stc (const std::string &text=std::string(), const stc_data &data=stc_data())
 Constructors. More...
 
 stc (const path &file, const stc_data &data=stc_data())
 Constructor, opens the file if it exists.
 
bool CanCut () const override
 Virtual override methods. More...
 
bool CanPaste () const override
 Will a paste succeed?
 
void Clear () override
 Clear the selection.
 
void Copy () override
 Copies text to clipboard.
 
void Cut () override
 Cuts text to clipboard.
 
void Paste () override
 Paste text from clipboard.
 
void SelectNone () override
 Deselects selected text in the control.
 
void Undo () override
 If there is an undo facility and the last operation can be undone, undoes the last operation. More...
 
virtual bool process_char (int c)
 Virtual interface. More...
 
void add_text (const std::string &text)
 Other methods. More...
 
void append_text (const std::string &text)
 Appends text (to end).
 
auto & auto_complete ()
 Returns autocomplete.
 
bool auto_indentation (int c)
 After pressing enter, starts new line at same place as previous line.
 
void config_get ()
 Sets the configurable parameters to values currently in config.
 
const auto & data () const
 Returns associated data.
 
const std::string eol () const
 Returns EOL string. More...
 
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.
 
bool find_next (const std::string &text, int find_flags=-1, bool find_next=true)
 Finds next. More...
 
void fold (bool fold_all=false)
 Enables or disables folding depending on fold property. More...
 
auto & get_file ()
 Returns the file.
 
const auto & get_filename () const
 Returns the filename, as used by the file.
 
const std::string get_find_string ()
 Returns find string, from selected text or from config. More...
 
const auto & get_hexmode () const
 Returns hex mode component.
 
auto & get_hexmode ()
 Returns writable hex mode component.
 
const auto & get_lexer () const
 Returns the lexer.
 
auto & get_lexer ()
 Returns the lexer.
 
auto get_margin_text_click () const
 Returns line on which text margin was clicked, or -1 if not.
 
const std::string get_selected_text ()
 Returns selected text as a string.
 
const auto & get_vi () const
 Returns vi component.
 
auto & get_vi ()
 Returns writable vi component. More...
 
const std::string get_word_at_pos (int pos) const
 Returns word at position.
 
bool is_hexmode () const
 Returns true if we are in hex mode.
 
bool is_shown_line_numbers () const
 Returns true if line numbers are shown.
 
void keep_event_data (bool synced)
 Keeps event data.
 
bool link_open ()
 If selected text is a link, opens the link.
 
bool marker_delete_all_change ()
 Deletes all change markers. More...
 
bool open (const path &filename, const stc_data &data=stc_data())
 Opens the file, reads the content into the window, then closes the file and sets the lexer.
 
bool position_restore ()
 Restores saved position. More...
 
void position_save ()
 Saves position.
 
void print (bool prompt=true)
 Prints the document.
 
void print_preview (wxPreviewFrameModalityKind kind=wxPreviewFrame_AppModal)
 Shows a print preview.
 
void properties_message (path::status_t flags=0)
 Shows properties on the statusbar using specified flags.
 
int replace_all (const std::string &find_text, const std::string &replace_text)
 Replaces all text. More...
 
bool replace_next (bool stc_find_string=true)
 Replaces text and calls find next. More...
 
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. More...
 
void reset_margins (margin_t type=margin_t().set())
 Reset all margins. More...
 
bool set_indicator (const indicator &indicator, int start, int end)
 Sets an indicator at specified start and end pos.
 
void set_search_flags (int flags)
 search flags to be used: More...
 
void set_text (const std::string &value)
 Sets the text.
 
bool show_blame (const vcs_entry *vcs)
 Shows blame info for vcs in the text margin. More...
 
void show_line_numbers (bool show)
 Shows or hides line numbers.
 
void sync (bool start=true)
 Starts or stops syncing. More...
 
void use_modification_markers (bool use)
 Use and show modification markers in the margin. More...
 

Static Public Member Functions

static int config_dialog (const window_data &data=window_data())
 Static interface. More...
 
static item_dialogget_config_dialog ()
 Returns the config dialog.
 
static void on_exit ()
 Saves static data in cofig. More...
 
static void on_init ()
 Reads static data from config (e.g. More...
 

Detailed Description

Offers a styled text ctrl with:

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Margin flags.

Enumerator
MARGIN_DIVIDER 

divider margin

MARGIN_FOLDING 

folding margin

MARGIN_LINENUMBER 

line number margin

MARGIN_TEXT 

text margin

Constructor & Destructor Documentation

◆ stc()

wex::stc::stc ( const std::string &  text = std::string(),
const stc_data data = stc_data() 
)

Constructors.

Default constructor, sets text if not empty.

Member Function Documentation

◆ add_text()

void wex::stc::add_text ( const std::string &  text)

Other methods.

Adds text.

◆ CanCut()

bool wex::stc::CanCut ( ) const
override

Virtual override methods.

Will a cut succeed?

◆ config_dialog()

static int wex::stc::config_dialog ( const window_data data = window_data())
static

Static interface.

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.

◆ eol()

const std::string wex::stc::eol ( ) const

Returns EOL string.

If you only want to insert a newline, use NewLine() (from wxStyledTextCtrl).

◆ find_next()

bool wex::stc::find_next ( const std::string &  text,
int  find_flags = -1,
bool  find_next = true 
)

Finds next.

Parameters
texttext to find
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
find_nextfinds next or previous

◆ fold()

void wex::stc::fold ( bool  fold_all = false)

Enables or disables folding depending on fold property.

Parameters
fold_allif document contains more than 'Auto fold' lines, or if fold_all (and fold propertry is on) is specified, always all lines are folded.

◆ get_find_string()

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

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.

◆ get_vi()

auto& wex::stc::get_vi ( )
inline

Returns writable vi component.

This allows you to do vi 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 cofig.

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.

◆ position_restore()

bool wex::stc::position_restore ( )

Restores saved position.

Returns true if position was saved before.

◆ process_char()

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

Virtual interface.

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.

◆ 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

◆ reset_margins()

void wex::stc::reset_margins ( margin_t  type = margin_t().set())

Reset all margins.

Default also resets the divider margin.

◆ set_search_flags()

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

search 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

◆ show_blame()

bool wex::stc::show_blame ( const vcs_entry vcs)

Shows blame info for vcs in the text margin.

Returns true if info was added.

◆ sync()

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

Starts or stops syncing.

Default syncing is started during construction.

◆ Undo()

void wex::stc::Undo ( )
override

If there is an undo facility and the last operation can be undone, undoes the last operation.


◆ use_modification_markers()

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

Use and show modification markers in the margin.

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