wex
v20.04.0
|
This class defines a lexer using file extensions, syntax colouring and comment definitions. More...
#include <wex/lexer.h>
Public Member Functions | |
lexer (const std::string &lexer=std::string()) | |
Default constructor. | |
lexer (stc *stc) | |
Constructor using stc. | |
lexer (const pugi::xml_node *node) | |
Constructor using xml node. | |
lexer & | operator= (const lexer &l) |
Assignment operator. More... | |
bool | add_keywords (const std::string &text, int setno=0) |
Adds keywords (public for testing only). | |
bool | apply () const |
Applies this lexer to stc component (and colours the component). | |
int | attrib (const std::string &name) const |
Returns specified config attrib. More... | |
const auto & | attribs () const |
Returns all the attribs. | |
void | clear () |
Clears lexer and applies it to stc if available. More... | |
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. More... | |
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. | |
bool | is_keyword (const std::string &word) const |
Is this word a keyword (allways all keywords), case sensitive. | |
bool | is_ok () const |
Is this lexer valid. | |
bool | keyword_starts_with (const std::string &word) const |
Does any keyword (allways 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,. More... | |
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 | 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. More... | |
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.
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 minimim size |
prefix | prefix keyword should start with |
Assignment operator.
The stc component is assigned only if it is nullptr.
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.