wex  v20.04.0
Public Member Functions | List of all members
wex::shell Class Reference

This class offers a stc with support for commands. More...

#include <wex/shell.h>

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

Public Member Functions

 shell (const stc_data &data=stc_data(), const std::string &prompt=">", const std::string &command_end=std::string(), bool echo=true, const std::string &lexer=std::string(), int commands_save_in_config=100)
 Default constructor. More...
 
virtual ~shell ()
 Destructor, keeps the commands in the config, if required.
 
void AppendText (const wxString &text) override
 Virtual interface. More...
 
void Undo () override
 Undo one action in the undo history.

 
bool process_char (int c) override
 Processes specified char. More...
 
void enable (bool enable=true)
 Other methods. More...
 
const std::string get_command () const
 Returns last entered command.
 
const std::string get_history () const
 Returns all history commands as a string, separated by a newline (for testing).
 
const auto & get_prompt () const
 Returns the prompt.
 
bool is_enabled () const
 Returns whether shell processing is enabled.
 
bool prompt (const std::string &text=std::string(), bool add_eol=true)
 Puts the text (if not empty) and a prompt at the end, goes to the end, and empties the undo buffer. More...
 
void set_process (process *process)
 Sets the process to which commands are sent. More...
 
bool set_prompt (const std::string &prompt, bool do_prompt=true)
 Sets the prompt, and prompts if asked for. More...
 
- Public Member Functions inherited from wex::stc
 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...
 
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...
 

Additional Inherited Members

- Public Types inherited from wex::stc
enum  { MARGIN_DIVIDER = 0, MARGIN_FOLDING = 1, MARGIN_LINENUMBER = 2, MARGIN_TEXT = 3 }
 Margin flags. More...
 
- Static Public Member Functions inherited from wex::stc
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

This class offers a stc with support for commands.

The commands are entered at the last line, and kept in a list of commands, by pressing key up and down you browse through the commands. If a command is entered, an ID_SHELL_COMMAND command event is sent to the event handler, with the command available as event.GetString(). Or, if you used set_process, commands are sent to the process.

Constructor & Destructor Documentation

◆ shell()

wex::shell::shell ( const stc_data data = stc_data(),
const std::string &  prompt = ">",
const std::string &  command_end = std::string(),
bool  echo = true,
const std::string &  lexer = std::string(),
int  commands_save_in_config = 100 
)

Default constructor.

Parameters
datadata
promptGive the command used to end a line. The default uses the eol.
command_endThe command used to end a line.
echoWill commands be echoed.
lexerThe lexer used by stc.
commands_save_in_configGive the number of commands that are kept in the config. If -1, no commands are kept.

Member Function Documentation

◆ AppendText()

void wex::shell::AppendText ( const wxString &  text)
override

Virtual interface.

Appends text, and updates the command start position. Only if the cursor was at the end, the cursos is repositioned at the end after appending the text,

◆ enable()

void wex::shell::enable ( bool  enable = true)

Other methods.

Enable/disable shell processing. Default (and after constructed) shell processing is enabled. When disabled, shell is a normal stc.

◆ process_char()

bool wex::shell::process_char ( int  c)
overridevirtual

Processes specified char.

Returns true if char was processed.

Reimplemented from wex::stc.

◆ prompt()

bool wex::shell::prompt ( const std::string &  text = std::string(),
bool  add_eol = true 
)

Puts the text (if not empty) and a prompt at the end, goes to the end, and empties the undo buffer.

Default it also adds an eol before the prompt. Returns false and does not prompt if the shell is not enabled.

◆ set_process()

void wex::shell::set_process ( process process)

Sets the process to which commands are sent.

If you do not set this, commands are sent to the parent.

◆ set_prompt()

bool wex::shell::set_prompt ( const std::string &  prompt,
bool  do_prompt = true 
)

Sets the prompt, and prompts if asked for.

Returns false and does not set the prompt if the shell is not enabled.