Expand description
Code block widget with syntax highlighting
A code display/editing widget that supports:
- Syntax highlighting via regex-based token matching
- Optional line numbers in the gutter
- Read-only by default, editable with
.edit(true) - All Div layout methods via Deref
§Example
ⓘ
use blinc_layout::prelude::*;
use blinc_layout::syntax::{SyntaxConfig, RustHighlighter};
// Read-only code block
code(r#"fn main() { println!("Hello"); }"#)
.syntax(SyntaxConfig::new(RustHighlighter::new()))
.line_numbers(true)
.font_size(14.0)
.rounded(8.0)
// Editable code block with change callback
code("let x = 42;")
.edit(true)
.on_change(|new_content| {
println!("Content changed: {}", new_content);
})Structs§
- Code
- Code block widget
- Code
Config - Code block configuration