SourceModule syntax_highlighting
Syntax highlighting for code.
Turn on the syntect feature for great syntax highlighting of any language.
Otherwise, a very simple fallback will be used, that works okish for C, C++, Rust, and Python.
Classes§
| CodeTheme |
Functions§
| code_view_ui | View some code with syntax highlighting and selection. |
| highlight | Add syntax highlighting to a code string. |
SourceFunction code_view_ui§
from egui.syntax_highlighting import code_view_uidef code_view_ui(ui: Ui, theme: CodeTheme, code: str, language: str) -> ResponseView some code with syntax highlighting and selection.
SourceFunction highlight§
from egui.syntax_highlighting import highlightdef highlight(ctx: Context, style: Style, theme: CodeTheme, code: str, language: str) -> LayoutJobAdd syntax highlighting to a code string.
The results are memoized, so you can call this every frame without performance penalty.