feat: add Go TUI rendering and terminal helper functions
7 funciones Go del dominio tui: apply_gradient (gradiente de color en texto), draw_box y draw_separator (renderizado de cajas y separadores con box_chars), load_ascii_art (carga de arte ASCII desde archivos), normalize_terminal_output y strip_ansi (limpieza de salida de terminal), read_dir_autocomplete (autocompletado de rutas de directorio). Incluye box_chars.go como helper de caracteres Unicode para bordes.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
---
|
||||
name: load_ascii_art
|
||||
kind: function
|
||||
lang: go
|
||||
domain: tui
|
||||
version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "func LoadASCIIArt(staticPath string, colors []lipgloss.Color) string"
|
||||
description: "Lee un archivo .txt aleatorio de un directorio y lo renderiza con degradado de colores. Util para headers de TUIs con ASCII art variado."
|
||||
tags: [tui, ascii, art, header, gradient, random, file]
|
||||
uses_functions: [apply_gradient_go_tui]
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: "error_go_core"
|
||||
imports: [bufio, math/rand, os, path/filepath, strings, time, github.com/charmbracelet/lipgloss]
|
||||
params:
|
||||
- name: staticPath
|
||||
desc: "directorio con archivos .txt de ASCII art"
|
||||
- name: colors
|
||||
desc: "paleta de colores para el degradado; nil usa DefaultGradientColors"
|
||||
output: "string con ASCII art coloreado, o vacio si no hay archivos o hay error"
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
file_path: "functions/tui/load_ascii_art.go"
|
||||
source_repo: "https://gitea-dgg044oo04woo4ggcsws4gk0.organic-machine.com/egutierrez/DevLauncher.git"
|
||||
source_license: "MIT"
|
||||
source_file: "launcher/middleware/assets.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```go
|
||||
// Cada app pone sus archivos .txt en un directorio static/
|
||||
header := tui.LoadASCIIArt("./static", nil)
|
||||
if header != "" {
|
||||
fmt.Print(header)
|
||||
}
|
||||
|
||||
// Con paleta custom
|
||||
palette := []lipgloss.Color{
|
||||
lipgloss.Color("#ff6b6b"),
|
||||
lipgloss.Color("#feca57"),
|
||||
lipgloss.Color("#48dbfb"),
|
||||
}
|
||||
header = tui.LoadASCIIArt("./static", palette)
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
Patron de uso: cada app TUI mantiene un directorio `static/` con archivos `.txt` de ASCII art. Al iniciar, `LoadASCIIArt` elige uno al azar y le aplica el degradado de colores. Esto da variedad visual en cada ejecucion.
|
||||
|
||||
Fallback silencioso: si el directorio no existe, no tiene .txt, o hay error de lectura, retorna "" sin error. El caller decide si mostrar un fallback.
|
||||
Reference in New Issue
Block a user