1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! A terminal-based lib to make pretty command-line ui -> prettui
//!
//! # Features
//!
//! - Configurable list with items per row, rows per page, and cell width
//! - Arrow and page list navigation
//! - Real-time multi-digit numeric list input with live feedback
//! - Customizable colors
//!
//! # Example
//!
//! ```rust
//! use prettui::prelude::*;
//!
//! fn main() -> anyhow::Result<()> {
//! let items: Vec<String> = (1..=100).map(|i| format!("Item {}", i)).collect();
//! let config = ListConfig::default()
//! .items_per_row(1)
//! .rows_per_page(10)
//! .cell_width(30)
//! .normal_fg(Color::DarkGrey)
//! .highlight_fg(Color::Green);
//!
//! println!("Example of using");
//! println!(
//! "Use arrows/PageUp/PageDown to navigate, type digits, Backspace to delete, Enter to confirm, Esc to cancel."
//! );
//! if let Some(idx) = choose_from_list(&items, &config)? {
//! println!("You chose: {}", items[idx]);
//! } else {
//! println!("Selection cancelled.");
//! }
//!
//! let ic = InputConfig {
//! input_text_color: Color::Blue,
//! ..Default::default()
//! };
//! let name = read_input(&ic)?;
//! // Without log level:
//! let oc = OutputConfig {
//! log_level: None,
//! ..Default::default()
//! };
//! write_output(&oc, &format!("Hello, {}!", name))?;
//! // With log level:
//! let oc2 = OutputConfig {
//! log_level: Some("DEBUG".into()),
//! ..Default::default()
//! };
//! write_output(&oc2, "This is a debug message.")?;
//!
//! Ok(())
//! }
//! ```