CodeEditor
A standalone code (and text) editor for people like me who write their own user interfaces utilizing crates like pixels.
CodeEditor renders its display into a Vec<u8>
and is completely independent from any UI crate. It utilizes fontdue for rendering fonts.
Example App
A standalone pixels
and winit
based example app is included in the repository.
Usage
And than implement it in your app.
use *;
let mut code_editor = new;
code_editor.set_font;
code_editor.set_mode;
code_editor.set_font_size;
code_editor.set_text;
You can get the edited text via get_text()
. You will also need to connect mouse and keyboard events to the code editor, see the example app.
Syntax Highlighting
The syntax highlighting is right now not configurable but is pretty universal. Supported modes are right now Rhai and Text (which has no highlighting). I will try to make the syntax highlighting more configurable in the future, in the meantime you can tweak the source code to your needs.
Themes
The default theme has this implementation:
You can tweak it in the theme property of the CodeEditor struct or you can set a new theme via the set_theme(theme);
function.
Disclaimer
CodeEditor is actively maintained and I will improve it over time as I use it for my own applications.