tawasuyu

tawasuyu/llimphi

Sovereign retained-mode GPU UI framework in Rust (wgpu+vello+taffy+parley), Elm loop, 40+ widgets.

Rust 660Markdown 302TOML 157RON 312382 Sutichaykuna

⎇ a3c2ea9ffa5a97812e9ec043374b756586210bfb widgets/text-editor/src/lib.rs Rust · 68 siq'ikuna · 3.0 KB Ñawpa willay Pi imata llamkarqan ch'uya

refresh: stack al día (vello 0.7 / wgpu 27 / parley 0.6) + motor 3D voxel ccab39f14 · Sergio ·

1//! `llimphi-widget-text-editor` — editor de código multilínea para Llimphi.
2//!
3//! Capa visual sobre el núcleo agnóstico [`llimphi_widget_text_editor_core`]:
4//!
5//! - El **núcleo** (`buffer`/`cursor`/`ops`/`undo`/`bracket`/`find`/
6//!   `diagnostics`/`clipboard`/`highlight`) es puro — sin IO, sin Llimphi,
7//!   sin GPU — y se re-exporta aquí tal cual, de modo que los consumidores
8//!   históricos (`crate::cursor::Pos`, `crate::Buffer`, …) siguen resolviendo
9//!   sin cambios.
10//! - [`state`] — el [`EditorState`] que une todo + `apply_key` para integrar
11//!   al `update` Elm (depende de los tipos de teclado de `llimphi-ui`).
12//! - [`view`] — renderizado multilínea con gutter, caret, selección, scroll.
13//!
14//! El split núcleo/widget permite tests amplios del core y reutilizar la
15//! lógica de edición desde un TUI, un `text-input` single-line, una
16//! mini-REPL o un backend web, sin arrastrar `wgpu`/`vello`.
17
18#![forbid(unsafe_code)]
19
20// Núcleo agnóstico re-exportado como módulos del crate: mantiene viva la
21// ruta `crate::<mod>::…` que usan `state`/`view` y los consumidores externos.
22pub use llimphi_widget_text_editor_core::{
23    bracket, buffer, clipboard, cursor, diagnostics, find, highlight, ops, undo,
24};
25
26// Capa Llimphi propia de este widget.
27pub mod state;
28pub mod view;
29
30pub use buffer::Buffer;
31pub use clipboard::{Clipboard, MemClipboard, NullClipboard};
32pub use cursor::{Cursor, Pos, Selection};
33pub use diagnostics::{Diagnostic, DiagnosticRange, Severity};
34pub use find::{all_matches, find_next, find_prev, FindState};
35pub use highlight::{Highlighter, Language, Span, SyntaxPalette, TokenKind};
36pub use ops::{indent_str, EditDelta};
37pub use state::{ApplyResult, EditorOptions, EditorState, Preedit};
38pub use undo::UndoStack;
39pub use view::{
40    text_editor_view, text_editor_view_colored, text_editor_view_full,
41    text_editor_view_highlighted, EditorMetrics, EditorPalette, GutterStyle, PointerEvent,
42};
43
44use llimphi_ui::llimphi_raster::peniko::Color;
45
46/// Paleta de syntax highlighting dark — deriva de un [`llimphi_theme::Theme`]
47/// + colores hardcoded para las categorías que el theme no expone como
48/// slots semánticos (string, number, keyword, …).
49///
50/// Vive en el widget (no en el núcleo) porque es el único punto que toca
51/// `llimphi-theme`; el núcleo se queda con el modelo de color puro.
52pub fn syntax_palette_dark(theme: &llimphi_theme::Theme) -> SyntaxPalette {
53    fn rgb(r: u8, g: u8, b: u8) -> Color {
54        Color::from_rgb8(r, g, b)
55    }
56    SyntaxPalette {
57        keyword: rgb(198, 120, 221),     // morado: keywords
58        typ: rgb(229, 192, 123),         // amarillo cálido: tipos
59        function: rgb(97, 175, 239),     // azul: funciones
60        string: rgb(152, 195, 121),      // verde: strings
61        number: rgb(209, 154, 102),      // naranja: números
62        comment: theme.fg_muted,         // muted: comentarios
63        operator: theme.fg_text,
64        punctuation: theme.fg_muted,
65        identifier: theme.fg_text,
66        other: theme.fg_text,
67    }
68}