throbber_widgets_tui/lib.rs
1/*!
2# Throbber widget of [ratatui]
3
4[ratatui]: https://github.com/ratatui-org/ratatui
5[tui-rs]: https://github.com/fdehau/tui-rs
6
7> **_NOTE:_** If you want to use [tui-rs] instead of [ratatui], please use 0.4.1 or older version.
8
9`throbber-widgets-tui` is a [ratatui] widget that displays throbber.
10
11A throbber may also be called:
12
13- activity indicator
14- indeterminate progress bar
15- loading icon
16- spinner
17- guru guru
18
19## Demo
20
21
22
23The demo shown in the gif can be run with all available symbols.
24
25```sh
26cargo run --example demo --release
27```
28
29## Features
30
31- Render throbber
32- With label
33- Random or specified step, also negative is possible.
34
35## Getting Started
36
37MSRV: `throbber-widgets-tui` requires rustc 1.86.0 or newer.
38
39```sh
40cargo add throbber-widgets-tui
41```
42
43Example code:
44
45```rust
46// :
47// :
48struct App {
49 throbber_state: throbber_widgets_tui::ThrobberState,
50}
51impl App {
52 fn on_tick(&mut self) {
53 self.throbber_state.calc_next();
54 }
55}
56// :
57// :
58fn ui(f: &mut ratatui::Frame, app: &mut App) {
59 let chunks = ratatui::layout::Layout::default()
60 .direction(ratatui::layout::Direction::Horizontal)
61 .margin(1)
62 .constraints(
63 [
64 ratatui::layout::Constraint::Percentage(50),
65 ratatui::layout::Constraint::Percentage(50),
66 ]
67 .as_ref(),
68 )
69 .split(f.area());
70
71 // Simple random step
72 let simple = throbber_widgets_tui::Throbber::default();
73 f.render_widget(simple, chunks[0]);
74
75 // Set full with state
76 let full = throbber_widgets_tui::Throbber::default()
77 .label("Running...")
78 .style(ratatui::style::Style::default().fg(ratatui::style::Color::Cyan))
79 .throbber_style(ratatui::style::Style::default().fg(ratatui::style::Color::Red).add_modifier(ratatui::style::Modifier::BOLD))
80 .throbber_set(throbber_widgets_tui::CLOCK)
81 .use_type(throbber_widgets_tui::WhichUse::Spin);
82 f.render_stateful_widget(full, chunks[1], &mut app.throbber_state);
83}
84```
85
86## Apps using throbber-widgets-tui
87
88- [mntime](https://github.com/arkbig/mntime): Execute "m" commands "n" times to calculate mean of usage time and memory. As an alternative to "time", "gnu-time" is used internally.
89
90## Dependencies (By default)
91
92Direct dependencies crates:
93
94|License|crate|
95|-|-|
96|Apache-2.0 OR MIT (1)| rand|
97|MIT (1)| ratatui|
98|Zlib (1)| throbber-widgets-tui|
99
100Chain dependencies crates:
101
102|License|crate|
103|-|-|
104|(Apache-2.0 OR MIT) AND Unicode-3.0 (1)| unicode-ident|
105|(Apache-2.0 OR MIT) AND Unicode-DFS-2016 (1)| finl_unicode|
106|Apache-2.0 OR Apache-2.0 WITH LLVM-exception OR MIT (5)| linux-raw-sys, rustix, wasi, wasip2, wit-bindgen|
107|Apache-2.0 OR BSL-1.0 (1)| ryu|
108|Apache-2.0 OR LGPL-2.1-or-later OR MIT (1)| r-efi|
109|Apache-2.0 OR MIT (99)| allocator-api2, anyhow, atomic, base64, bit-set, bit-vec, bitflags, bitflags, block-buffer, bumpalo, cfg-if, cpufeatures, crypto-common, csscolorparser, deranged, digest, document-features, either, equivalent, errno, euclid, fixedbitset, fnv, getrandom, hashbrown, heck, hex, ident_case, indoc, itertools, itertools, itoa, js-sys, kasuari, lazy_static, libc, line-clipping, litrs, lock_api, log, mac_address, memmem, minimal-lexical, num-conv, num-derive, num-traits, num_threads, once_cell, parking_lot, parking_lot_core, pest, pest_derive, pest_generator, pest_meta, portable-atomic, powerfmt, proc-macro2, quote, rand, rand_core, regex, regex-automata, regex-syntax, rustversion, scopeguard, serde, serde_core, serde_derive, sha2, signal-hook, signal-hook-mio, signal-hook-registry, siphasher, smallvec, static_assertions, syn, syn, thiserror, thiserror, thiserror-impl, thiserror-impl, time, time-core, typenum, ucd-trie, unicode-segmentation, unicode-truncate, unicode-width, utf8parse, uuid, wasm-bindgen, wasm-bindgen-macro, wasm-bindgen-macro-support, wasm-bindgen-shared, winapi, winapi-i686-pc-windows-gnu, winapi-x86_64-pc-windows-gnu, windows-link, windows-sys|
110|Apache-2.0 OR MIT OR Zlib (1)| bytemuck|
111|MIT (44)| castaway, compact_str, convert_case, crossterm, crossterm_winapi, darling, darling_core, darling_macro, deltae, derive_more, derive_more-impl, fancy-regex, filedescriptor, generic-array, instability, lab, lru, memoffset, mio, nix, nom, ordered-float, phf, phf_generator, phf_macros, phf_shared, ratatui, ratatui-core, ratatui-crossterm, ratatui-macros, ratatui-termwiz, ratatui-widgets, redox_syscall, strsim, strum, strum_macros, termios, termwiz, vtparse, wezterm-blob-leases, wezterm-color-types, wezterm-dynamic, wezterm-dynamic-derive, wezterm-input-types|
112|MIT AND Unicode-DFS-2016 (1)| wezterm-bidi|
113|MIT OR Unlicense (2)| aho-corasick, memchr|
114|WTFPL (1)| terminfo|
115|Zlib (2)| foldhash, throbber-widgets-tui|
116
117## License
118
119This repository's license is zlib. Please feel free to use this, but no warranty.
120*/
121
122pub mod symbols;
123pub mod widgets;
124
125pub use self::symbols::throbber::*;
126pub use self::widgets::*;