wex
v20.04.0
|
#include <bitset>
#include <list>
#include <vector>
#include <wx/combobox.h>
#include <wx/filedlg.h>
#include <wex/dir.h>
#include <wex/stc-data.h>
Enumerations | |
enum | { wex::FIRST_OF_AFTER_FROM_BEGIN = 0, wex::FIRST_OF_BEFORE = 1, wex::FIRST_OF_FROM_END = 2 } |
enum | { wex::STRING_SORT_DESCENDING = 0, wex::STRING_SORT_UNIQUE = 1 } |
enum | { wex::TRIM_LEFT = 0, wex::TRIM_MID = 1, wex::TRIM_RIGHT = 2 } |
Functions | |
const std::string | wex::after (const std::string &text, char c, bool first=true) |
Returns string after first or last occurrence of c Returns the whole string if c is not found. | |
const std::string | wex::align_text (const std::string_view &lines, const std::string_view &header=std::string(), bool fill_out_with_space=true, bool fill_out=false, const lexer &l=lexer()) |
Aligns text. More... | |
std::tuple< bool, const std::string, const std::vector< std::string > > | wex::autocomplete_filename (const std::string &text) |
Tries to autocomplete filename, the result is stored in the tuple. More... | |
bool | wex::autocomplete_text (const std::string &text, const std::vector< std::string > &v, std::string &s) |
Tries to autocomplete text from a vector of strings, result stored in the string. More... | |
const std::string | wex::before (const std::string &text, char c, bool first=true) |
Returns string before first or last occurrence of c Returns the whole string if c is not found. | |
bool | wex::browser_search (const std::string &text) |
Launch default browser and search for text. More... | |
bool | wex::clipboard_add (const std::string &text) |
Adds data to the clipboard. | |
const std::string | wex::clipboard_get () |
Returns data from the clipboard. | |
template<typename T > | |
void | wex::combobox_as (wxComboBox *cb, const T &t) |
Adds entries to a combobox from a container. | |
void | wex::combobox_from_list (wxComboBox *cb, const std::list< std::string > &text) |
Adds entries to a combobox from a list with strings. | |
bool | wex::comparefile (const path &file1, const path &file2) |
Compares the files, using comparator set in the config. | |
const std::string | wex::ellipsed (const std::string &text, const std::string &control=std::string(), bool ellipse=true) |
Adds an ellipses after text. More... | |
const std::string | wex::firstof (const std::string &text, const std::string &chars, const size_t start_pos=0, firstof_t flags=firstof_t().set(FIRST_OF_AFTER_FROM_BEGIN)) |
Returns substring after (or before) first occurrence of one of specified chars. More... | |
const std::string | wex::get_endoftext (const std::string &text, size_t max_chars=15) |
If text length exceeds max_chars, returns an ellipse prefix followed by the last max_chars from the text, otherwise just returns the text. | |
const std::string | wex::get_find_result (const std::string &find_text, bool find_next, bool recursive) |
Returns a search result, that might be shown in the statusbar. | |
int | wex::get_iconid (const path &filename) |
Returns the icon index for this filename (uses the file extension to get it). More... | |
int | wex::get_number_of_lines (const std::string &text, bool trimmed=false) |
Returns the number of lines in a (trimmed) string. More... | |
const std::string | wex::get_string_set (const std::set< std::string > &kset, size_t min_size=0, const std::string &prefix=std::string()) |
Returns string from set. | |
std::tuple< bool, time_t > | wex::get_time (const std::string &text, const std::string &format=file_stat::MOD_TIME_FORMAT) |
Converts time string into time_t. More... | |
const std::string | wex::get_word (std::string &text) |
Returns a word from a string. | |
bool | wex::is_brace (int c) |
Returns true if char is a brace open or close character. | |
bool | wex::is_codeword_separator (int c) |
Returns true if char is a code word separator. | |
long | wex::make (const path &makefile) |
Runs make on specified makefile. More... | |
bool | wex::marker_and_register_expansion (const ex *ex, std::string &command) |
Expands all markers and registers in command. More... | |
int | wex::match (const std::string ®ex, const std::string &text, std::vector< std::string > &v) |
Regular expression match. More... | |
bool | wex::matches_one_of (const std::string &fullname, const std::string &patterns) |
Returns true if filename (fullname) matches one of the fields in specified pattern (fields separated by ; sign). | |
void | wex::node_properties (const pugi::xml_node *node, std::vector< property > &properties) |
Parses properties node. | |
void | wex::node_styles (const pugi::xml_node *node, const std::string &lexer, std::vector< style > &styles) |
Parses style node. | |
bool | wex::one_letter_after (const std::string &text, const std::string &letter) |
Returns whether there is one letter after. | |
int | wex::open_files (frame *frame, const std::vector< path > &files, const stc_data &data=stc_data(), dir::type_t type=dir::type_t().set()) |
Opens all files specified by files. More... | |
void | wex::open_files_dialog (frame *frame, long style=wxFD_OPEN|wxFD_MULTIPLE|wxFD_CHANGE_DIR, const std::string &wildcards=wxFileSelectorDefaultWildcardStr, bool ask_for_continue=false, const stc_data &data=stc_data(), dir::type_t type=dir::type_t().set()) |
Shows a dialog and opens selected files (calls open_files). More... | |
const std::string | wex::print_caption (const path &filename) |
Adds a caption. | |
const std::string | wex::print_footer () |
You can use macros in PrintFooter and in PrintHeader: @PAGENUM@ is replaced by page number @PAGESCNT@ is replaced by total number of pages. | |
const std::string | wex::print_header (const path &filename) |
Adds a header. | |
const std::string | wex::quoted (const std::string &text) |
Returns quotes around the text. | |
bool | wex::regafter (const std::string &text, const std::string &letter) |
Returns true if a register is specified after letter in text. | |
int | wex::replace_all (std::string &text, const std::string &search, const std::string &replace, int *match_pos=nullptr) |
Replaces all substrings in text with replace. More... | |
bool | wex::shell_expansion (std::string &command) |
Executes all process between backquotes in command, and changes command with replaced match with output from process. More... | |
bool | wex::single_choice_dialog (wxWindow *parent, const std::string &title, const wxArrayString &s, std::string &selection) |
Presents a dialog to choose one string out of an array. | |
const std::string | wex::sort (const std::string &input, string_sort_t sort_t, size_t pos, const std::string &eol, size_t len=std::string::npos) |
Sorts specified text, returns string with sorted text. More... | |
bool | wex::sort_selection (stc *stc, string_sort_t sort_t=0, size_t pos=0, size_t len=std::string::npos) |
Sorts specified component, returns true if sorted ok. More... | |
const std::string | wex::translate (const std::string &text, int pageNum, int numPages) |
This takes care of the translation. | |
const std::string | wex::trim (const std::string &text, skip_t type_t=skip_t().set(TRIM_LEFT).set(TRIM_RIGHT), const std::string &replace_with=" ") |
Returns a string without all white space in specified input. More... | |
void | wex::vcs_command_stc (const vcs_command &command, const lexer &lexer, stc *stc) |
Use specified vcs command to set lexer on stc document. More... | |
void | wex::vcs_execute (frame *frame, int id, const std::vector< path > &files) |
Executes VCS command id for specified files and opens component if necessary. More... | |
void | wex::xml_error (const path &filename, const pugi::xml_parse_result *result, stc *stc=nullptr) |
Shows xml error. More... | |
anonymous enum |
anonymous enum |
anonymous enum |
const std::string wex::align_text | ( | const std::string_view & | lines, |
const std::string_view & | header = std::string() , |
||
bool | fill_out_with_space = true , |
||
bool | fill_out = false , |
||
const lexer & | l = lexer() |
||
) |
Aligns text.
lines | lines to align |
header | The header is used as a prefix for the line, directly followed by the lines, and if necessary on the next line the header is repeated as a string of spaces. |
fill_out_with_space | if fill out, then use space |
fill_out | fill out |
l | if lexer is specified fills out over lexer comment lines If the lexer has no comment end character, fill out with spaces is not done. |
std::tuple< bool, const std::string, const std::vector<std::string> > wex::autocomplete_filename | ( | const std::string & | text | ) |
Tries to autocomplete filename, the result is stored in the tuple.
text | text containing start of a filename |
bool wex::autocomplete_text | ( | const std::string & | text, |
const std::vector< std::string > & | v, | ||
std::string & | s | ||
) |
Tries to autocomplete text from a vector of strings, result stored in the string.
Returns true if a unique match was found.
text | text to be completed |
v | vector with completed text |
s | expansion of text to one of the strings from the vector |
bool wex::browser_search | ( | const std::string & | text | ) |
Launch default browser and search for text.
Returns false if search engine is empty.
const std::string wex::ellipsed | ( | const std::string & | text, |
const std::string & | control = std::string() , |
||
bool | ellipse = true |
||
) |
Adds an ellipses after text.
The control, if present is postfixed, after a tab character (for accels).
const std::string wex::firstof | ( | const std::string & | text, |
const std::string & | chars, | ||
const size_t | start_pos = 0 , |
||
firstof_t | flags = firstof_t().set(FIRST_OF_AFTER_FROM_BEGIN) |
||
) |
Returns substring after (or before) first occurrence of one of specified chars.
text | text to be searched |
chars | chars to be found |
start_pos | start pos (from start or end of text, depending on flags) |
flags | start searching at begin, or at end |
int wex::get_iconid | ( | const path & | filename | ) |
Returns the icon index for this filename (uses the file extension to get it).
The return value is an index in wxTheFileIconsTable. You can use this index as a bitmap using: wxTheFileIconsTable->GetSmallImageList()->GetBitmap(get_iconid(file))
int wex::get_number_of_lines | ( | const std::string & | text, |
bool | trimmed = false |
||
) |
Returns the number of lines in a (trimmed) string.
If text is empty, 0 is returned, otherwise at least 1.
std::tuple< bool, time_t> wex::get_time | ( | const std::string & | text, |
const std::string & | format = file_stat::MOD_TIME_FORMAT |
||
) |
Converts time string into time_t.
The result is stored in the tuple.
text | text to be converted |
format | format to be used for cnoversion |
long wex::make | ( | const path & | makefile | ) |
Runs make on specified makefile.
Returns value from executing the make process.
makefile | the makefile |
bool wex::marker_and_register_expansion | ( | const ex * | ex, |
std::string & | command | ||
) |
Expands all markers and registers in command.
Returns false if a marker could not be found.
int wex::match | ( | const std::string & | regex, |
const std::string & | text, | ||
std::vector< std::string > & | v | ||
) |
Regular expression match.
Returns:
regex | regular expression |
text | text to match |
v | vector is filled with submatches |
int wex::open_files | ( | frame * | frame, |
const std::vector< path > & | files, | ||
const stc_data & | data = stc_data() , |
||
dir::type_t | type = dir::type_t().set() |
||
) |
Opens all files specified by files.
Returns number of files opened.
frame | frame on which open_file for each file is called, and open_file_dir for each dir |
files | array with files |
data | data to be used with open_file |
type | flags to be used with open_file_dir |
void wex::open_files_dialog | ( | frame * | frame, |
long | style = wxFD_OPEN|wxFD_MULTIPLE|wxFD_CHANGE_DIR , |
||
const std::string & | wildcards = wxFileSelectorDefaultWildcardStr , |
||
bool | ask_for_continue = false , |
||
const stc_data & | data = stc_data() , |
||
dir::type_t | type = dir::type_t().set() |
||
) |
Shows a dialog and opens selected files (calls open_files).
frame | frame |
style | style for file_dialog dialog |
wildcards | wilcards for file_dialog dialog |
ask_for_continue | flags to be used with file_dialog |
data | data to be used with open_file |
type | flags to be used with open_file_dir |
int wex::replace_all | ( | std::string & | text, |
const std::string & | search, | ||
const std::string & | replace, | ||
int * | match_pos = nullptr |
||
) |
Replaces all substrings in text with replace.
Returns number of replacements.
text | text to be replaced |
search | text to replace (no regex) |
replace | replacement |
match_pos | if not nullptr, position of first match in text |
bool wex::shell_expansion | ( | std::string & | command | ) |
Executes all process between backquotes in command, and changes command with replaced match with output from process.
Returns false if process could not be executed.
const std::string wex::sort | ( | const std::string & | input, |
string_sort_t | sort_t, | ||
size_t | pos, | ||
const std::string & | eol, | ||
size_t | len = std::string::npos |
||
) |
Sorts specified text, returns string with sorted text.
input | text to sort |
sort_t | sort type |
pos | position of the first character to be replaced |
eol | eol to split lines |
len | number of characters to replace string::npos indicates all characters until eol |
bool wex::sort_selection | ( | stc * | stc, |
string_sort_t | sort_t = 0 , |
||
size_t | pos = 0 , |
||
size_t | len = std::string::npos |
||
) |
Sorts specified component, returns true if sorted ok.
stc | Component with selected text to be sorted |
sort_t | sort type |
pos | position of the first character to be replaced |
len | number of characters to replace string::npos indicates all characters until eol |
const std::string wex::trim | ( | const std::string & | text, |
skip_t | type_t = skip_t().set(TRIM_LEFT).set(TRIM_RIGHT) , |
||
const std::string & | replace_with = " " |
||
) |
Returns a string without all white space in specified input.
text | text with white space to be skipped |
type_t | kind of skip |
replace_with | replace with (only for TRIM_MID) |
void wex::vcs_command_stc | ( | const vcs_command & | command, |
const lexer & | lexer, | ||
stc * | stc | ||
) |
Use specified vcs command to set lexer on stc document.
command | VCS command, used to check for diff or open command |
lexer | lexer to be used |
stc | stc on which lexer is set |
Executes VCS command id for specified files and opens component if necessary.
frame | frame on which open_file is called |
id | VCS menu id to execute |
files | files on which to operate |