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

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

chore: refresco desde el monorepo — 27 crates nuevos (anim, lottie, svg, mesh, image, layer, test, wire-view, widgets rag-sidebar/router/lazy-list/rive-button) y sync de los 95 existentes 93253cc22 · 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, tsedit, 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, text_editor_view_styled, EditorMetrics, EditorPalette,
42    GutterStyle, PointerEvent, StyledSpan,
43};
44
45use llimphi_ui::llimphi_raster::peniko::Color;
46
47/// Paleta de syntax highlighting dark — deriva de un [`llimphi_theme::Theme`]
48/// + colores hardcoded para las categorías que el theme no expone como
49/// slots semánticos (string, number, keyword, …).
50///
51/// Vive en el widget (no en el núcleo) porque es el único punto que toca
52/// `llimphi-theme`; el núcleo se queda con el modelo de color puro.
53pub fn syntax_palette_dark(theme: &llimphi_theme::Theme) -> SyntaxPalette {
54    fn rgb(r: u8, g: u8, b: u8) -> Color {
55        Color::from_rgb8(r, g, b)
56    }
57    SyntaxPalette {
58        keyword: rgb(198, 120, 221),     // morado: keywords
59        typ: rgb(229, 192, 123),         // amarillo cálido: tipos
60        function: rgb(97, 175, 239),     // azul: funciones
61        string: rgb(152, 195, 121),      // verde: strings
62        number: rgb(209, 154, 102),      // naranja: números
63        comment: theme.fg_muted,         // muted: comentarios
64        operator: theme.fg_text,
65        punctuation: theme.fg_muted,
66        identifier: theme.fg_text,
67        other: theme.fg_text,
68    }
69}