wex  v21.04.0
Enumerations | Functions
core.h File Reference
#include <bitset>
#include <set>
#include <vector>
#include <wex/lexer.h>
#include <wex/style.h>
Include dependency graph for core.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.
 
std::tuple< bool, const std::string, const std::vector< std::string > > wex::auto_complete_filename (const std::string &text)
 Tries to auto_complete filename, the result is stored in the tuple. More...
 
bool wex::auto_complete_text (const std::string &text, const std::vector< std::string > &v, std::string &s)
 Tries to auto_complete 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 (const std::string &url)
 Launch default browser. More...
 
bool wex::browser_search (const std::string &text)
 Browse 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.
 
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.
 
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.
 
int wex::match (const std::string &regex, 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.
 
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::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 (core::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...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
FIRST_OF_AFTER_FROM_BEGIN 

substring after match, from begin

FIRST_OF_BEFORE 

substring before match

FIRST_OF_FROM_END 

substring from end

◆ anonymous enum

anonymous enum
Enumerator
STRING_SORT_DESCENDING 

sort descending order

STRING_SORT_UNIQUE 

flag to remove doubles

◆ anonymous enum

anonymous enum
Enumerator
TRIM_LEFT 

skip space at left

TRIM_MID 

skip space at mid

TRIM_RIGHT 

skip space at right

Function Documentation

◆ auto_complete_filename()

std::tuple< bool, const std::string, const std::vector<std::string> > wex::auto_complete_filename ( const std::string &  text)

Tries to auto_complete filename, the result is stored in the tuple.

Parameters
texttext containing start of a filename

◆ auto_complete_text()

bool wex::auto_complete_text ( const std::string &  text,
const std::vector< std::string > &  v,
std::string &  s 
)

Tries to auto_complete text from a vector of strings, result stored in the string.

Returns true if a unique match was found.

Parameters
texttext to be completed
vvector with completed text
sexpansion of text to one of the strings from the vector

◆ browser()

bool wex::browser ( const std::string &  url)

Launch default browser.

Returns false if no browser configured.

◆ browser_search()

bool wex::browser_search ( const std::string &  text)

Browse and search for text.

Returns false if search engine is empty.

◆ ellipsed()

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

◆ firstof()

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.

Parameters
texttext to be searched
charschars to be found
start_posstart pos (from start or end of text, depending on flags)
flagsstart searching at begin, or at end

◆ get_iconid()

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))

◆ get_number_of_lines()

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.

◆ match()

int wex::match ( const std::string &  regex,
const std::string &  text,
std::vector< std::string > &  v 
)

Regular expression match.

Returns:

  • -1 if text does not match or there is an error
  • 0 if text matches, but no submatches present, v is untouched
  • submatches, it fills v with the submatches
Parameters
regexregular expression
texttext to match
vvector is filled with submatches

◆ replace_all()

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.

Parameters
texttext to be replaced
searchtext to replace (no regex)
replacereplacement
match_posif not nullptr, position of first match in text

◆ sort()

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.

Parameters
inputtext to sort
sort_tsort type
posposition of the first character to be replaced
eoleol to split lines
lennumber of characters to replace string::npos indicates all characters until eol

◆ sort_selection()

bool wex::sort_selection ( core::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.

Parameters
stcComponent with selected text to be sorted
sort_tsort type
posposition of the first character to be replaced
lennumber of characters to replace string::npos indicates all characters until eol

◆ trim()

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.

Parameters
texttext with white space to be skipped
type_tkind of skip
replace_withreplace with (only for TRIM_MID)