wex v24.10.0
|
This class defines a lexer using file extensions, syntax colouring and comment definitions. More...
#include <wex/syntax/lexer.h>
Public Member Functions | |
lexer (const std::string &lexer=std::string()) | |
Default constructor. | |
lexer (syntax::stc *stc) | |
Constructor using syntax stc. | |
lexer (const pugi::xml_node *node) | |
Constructor using xml node. | |
bool | add_keywords (const std::string &text, int setno=0) |
Adds keywords (public for testing only). | |
const std::string | 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 |
Aligns text. | |
bool | apply () const |
Applies this lexer to stc component (and colours the component). | |
int | attrib (const std::string &name) const |
Returns specified config attrib. | |
const auto & | attribs () const |
Returns all the attribs. | |
void | clear () |
Clears lexer and applies it to stc if available. | |
const std::string | comment_complete (const std::string &comment) const |
Returns a string that completes specified comment, by adding spaces and a comment end at the end. | |
const auto & | comment_begin () const |
Returns the comment begin. | |
const auto & | comment_begin2 () const |
Returns the comment begin 2. | |
const auto & | comment_end () const |
Returns the comment end. | |
const auto & | comment_end2 () const |
Returns the comment end 2. | |
const auto & | display_lexer () const |
Returns the display lexer (as shown in dialog). | |
const auto & | extensions () const |
Returns the extensions. | |
auto * | get_stc () |
Returns the stc. | |
bool | is_keyword (const std::string &word) const |
Is this word a keyword (always all keywords), case sensitive. | |
bool | is_ok () const |
Is this lexer valid. | |
bool | keyword_starts_with (const std::string &word) const |
Does any keyword (always all keywords) start with this word, case insensitive. | |
const auto & | keywords () const |
Returns the keywords. | |
const std::string | keywords_string (int keyword_set=-1, size_t min_size=0, const std::string &prefix=std::string()) const |
Returns the keywords as one large string,. | |
const auto & | language () const |
Returns the language. | |
size_t | line_size () const |
Returns the line size. | |
std::stringstream | log () const |
Logs info about this class. | |
const std::string | make_comment (const std::string &text, bool fill_out_with_space=true, bool fill_out=true) const |
Returns a lexer comment string with text formatted. | |
const std::string | make_comment (const std::string &prefix, const std::string &text) const |
Returns a lexer comment string with prefix. | |
const std::string | make_single_line_comment (const std::string_view &text, bool fill_out_with_space=true, bool fill_out=true) const |
Returns a lexer comment string filled out over one line. | |
bool | is_previewable () const |
Returns true if the stc component associated with this lexer can be previewed. | |
const auto & | properties () const |
Returns the properties. | |
const auto & | scintilla_lexer () const |
Returns the scintilla lexer. | |
bool | set (const std::string &lexer, bool fold=false) |
Sets lexer to specified lexer (finds by name from lexers), Shows error message when lexer could not be set. | |
bool | set (const lexer &lexer, bool fold=false) |
Sets lexer to specified lexer, and applies it to stc if present. | |
void | set_property (const std::string &name, const std::string &value) |
Overrides a local property. | |
const auto & | styles () const |
Returns the styles. | |
size_t | usable_chars_per_line () const |
Returns number of chars that fit on a line, skipping comment chars. | |
This class defines a lexer using file extensions, syntax colouring and comment definitions.
This lexer is one of the Scintilla lexers. The lexers are read by and kept in the wex::lexers class.
const std::string wex::lexer::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 |
Aligns text.
Fills out over lexer comment lines If the lexer has no comment end character, fill out with spaces is not done.
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 |
int wex::lexer::attrib | ( | const std::string & | name | ) | const |
Returns specified config attrib.
The value depends on attrib, but is -1 if not present.
void wex::lexer::clear | ( | ) |
Clears lexer and applies it to stc if available.
The is ok member is set to false.
const std::string wex::lexer::comment_complete | ( | const std::string & | comment | ) | const |
Returns a string that completes specified comment, by adding spaces and a comment end at the end.
If the comment end string is empty, it returns empty string.
const std::string wex::lexer::keywords_string | ( | int | keyword_set = -1, |
size_t | min_size = 0, | ||
const std::string & | prefix = std::string() ) const |
Returns the keywords as one large string,.
keyword_set | if keyword_set -1 take all the sets, otherwise take the specified set. |
min_size | if min_size 0, use all keywords, otherwise use keywords with minimum size |
prefix | prefix keyword should start with |
bool wex::lexer::set | ( | const lexer & | lexer, |
bool | fold = false ) |
Sets lexer to specified lexer, and applies it to stc if present.
Returns true if a scintilla lexer has been set.