Loading...
Searching...
No Matches
ml::BasicSyntaxHighlighter Class Reference

Built-in generic highlighter for C-like and scripting languages. More...

#include <Malena/Graphics/Text/CodeEditor.h>

Inheritance diagram for ml::BasicSyntaxHighlighter:
[legend]

Public Member Functions

 BasicSyntaxHighlighter (CodeLanguage lang=CodeLanguage::Cpp)
CodeLanguage language () const
void setLanguage (CodeLanguage lang)
std::vector< SyntaxTokentokenize (const std::string &text) const override

Public Attributes

sf::Color commentColor { 106, 153, 85 }
sf::Color keywordColor { 197, 134, 192 }
sf::Color numberColor { 181, 206, 168 }
sf::Color stringColor { 206, 145, 120 }

Detailed Description

Built-in generic highlighter for C-like and scripting languages.

Recognizes line comments (// and, for Python, #), block comments, single/double-quoted strings, numbers, and a per-language keyword set. Colors are public and tweakable (defaults approximate a dark theme).

Definition at line 54 of file CodeEditor.h.

Constructor & Destructor Documentation

◆ BasicSyntaxHighlighter()

ml::BasicSyntaxHighlighter::BasicSyntaxHighlighter ( CodeLanguage lang = CodeLanguage::Cpp)
explicit

Member Function Documentation

◆ language()

CodeLanguage ml::BasicSyntaxHighlighter::language ( ) const
inlinenodiscard

Definition at line 60 of file CodeEditor.h.

◆ setLanguage()

void ml::BasicSyntaxHighlighter::setLanguage ( CodeLanguage lang)

◆ tokenize()

std::vector< SyntaxToken > ml::BasicSyntaxHighlighter::tokenize ( const std::string & text) const
nodiscardoverridevirtual

Return colored spans for text (only the spans that need coloring; everything else is left at the editor's default text color).

Implements ml::SyntaxHighlighter.

Member Data Documentation

◆ commentColor

sf::Color ml::BasicSyntaxHighlighter::commentColor { 106, 153, 85 }

Definition at line 67 of file CodeEditor.h.

◆ keywordColor

sf::Color ml::BasicSyntaxHighlighter::keywordColor { 197, 134, 192 }

Definition at line 65 of file CodeEditor.h.

◆ numberColor

sf::Color ml::BasicSyntaxHighlighter::numberColor { 181, 206, 168 }

Definition at line 68 of file CodeEditor.h.

◆ stringColor

sf::Color ml::BasicSyntaxHighlighter::stringColor { 206, 145, 120 }

Definition at line 66 of file CodeEditor.h.


The documentation for this class was generated from the following file: