shiny
Values
pub const align_text: fn(String, Int, alignment.Alignment) -> String
Align text within a width using an alignment.
let s = shiny.align_text("hi", 6, shiny.right)
pub const clear_screen: fn() -> Nil
Clear the terminal screen and move cursor to home.
pub const confirm: fn(String) -> Bool
Yes/No prompt, returns True
on yes.
let ok = shiny.confirm("Proceed?")
pub const countdown: fn(Int) -> Nil
Animated countdown: prints remaining seconds.
shiny.countdown(3)
pub const draw_box: fn(Int, Int, Int, Int, box_style.BoxStyle) -> Nil
Draw an empty box at position.
shiny.draw_box(2, 2, 20, 5, shiny.single)
pub const draw_box_with_title: fn(
Int,
Int,
Int,
Int,
box_style.BoxStyle,
String,
) -> Nil
Draw a box with a centered title.
shiny.draw_box_with_title(2, 2, 24, 5, shiny.double, "Demo")
pub const draw_info_panel: fn(
Int,
Int,
Int,
Int,
String,
List(#(String, String)),
box_style.BoxStyle,
) -> Nil
Convenience info panel.
pub const draw_menu_box: fn(
Int,
Int,
Int,
String,
List(String),
Int,
box_style.BoxStyle,
) -> Nil
Draw a simple vertical menu; selected
is the index.
shiny.draw_menu_box(2, 2, 20, "Menu", ["One", "Two"], 0, shiny.single)
pub const draw_progress_box: fn(
Int,
Int,
Int,
String,
Int,
Int,
box_style.BoxStyle,
) -> Nil
Draw a progress box with a percentage bar.
shiny.draw_progress_box(2, 2, 30, "Build", 7, 10, shiny.rounded)
pub const draw_text_in_box: fn(
Int,
Int,
Int,
Int,
box_style.BoxStyle,
String,
List(String),
alignment.Alignment,
) -> Nil
Draw text inside a box with alignment.
shiny.draw_text_in_box(2, 2, 28, 6, shiny.single, "Info", ["Line 1", "Line 2"], shiny.center)
pub const fill_box: fn(Int, Int, Int, Int, String) -> Nil
Fill a rectangular area with a character.
shiny.fill_box(2, 3, 10, 2, ".")
pub const get_box_chars: fn(box_style.BoxStyle) -> #(
String,
String,
String,
String,
String,
String,
)
Box-drawing characters for a given style.
pub const loading_animation: fn(String, Int) -> Nil
Spinner animation next to a message.
shiny.loading_animation("Loading", 1200)
pub const loading_loop: fn(String, List(String), Int, Int) -> Nil
Internal loading loop used by loading_animation
.
pub fn new() -> state.TuiState
Shiny: a tiny TUI toolkit for Gleam.
Import shiny
to access the most common building blocks re-exported
from submodules: types, box drawing, prompts, animations, and utils.
import shiny
pub fn main() {
shiny.clear_screen()
shiny.draw_box(2, 2, 20, 5, shiny.single)
}
Construct a fresh TUI state.
let state = shiny.new()
pub const overwrite_line: fn(String) -> Nil
Replace the current line with new text.
pub const overwrite_with_padding: fn(String, String) -> Nil
Overwrite a line, padding to hide old characters.
pub const progress_bar: fn(Int, Int, Int) -> String
Build a progress bar string like “[██░░] 50%”.
let bar = shiny.progress_bar(5, 10, 10)
pub const prompt_user: fn(String) -> String
Ask the user for input; trims the result.
let name = shiny.prompt_user("Name")
pub const select_option: fn(String, List(String)) -> String
Select an option by number; returns the chosen string or empty.
let choice = shiny.select_option("Pick", ["A", "B"])
pub const tui_state: fn(String, List(String)) -> state.TuiState
Shorthand for the TuiState
record.
pub const typewriter_effect: fn(String, Int) -> Nil
Typewriter effect for a line of text.
shiny.typewriter_effect("Hello", 30)