tbl crate tbl documentation GitHub license

TBL

Terminal Bar (time)Line (WIP)

cargo run --example datetime

Example

```rust use tbl::Renderer;

let data = vec![(0., 2.), (3., 4.)]; let rendered = Renderer::new(data.asslice(), &|&e| e, &|| None::) // explicit type for Option

Custom Data and Renderer

```rust use tbl::{Block, RenderBlock, Renderer, TBLError, Bound};

struct CustomData { bounds: (usize, usize), label: String // must be Clone + Debug }

fn bounds(cd: &CustomData)-> Bound { let (a, b) = cd.bounds; (a as f64, b as f64) }

fn label(cd: &CustomData)-> Option { Some(cd.label.clone()) }

fn render(b: &Block) -> RenderBlock { match b { Block::Space(length) => RenderBlock::Space("\u{2606}".repeat(length)), Block::Segment(length, label) => { let mut truncated = label.clone().unwrap_or_default(); truncated.truncate(length); RenderBlock::Block(format!( "{}{}", truncated, "\u{2605}".repeat(*length - truncated.len()) )) } } }

let data = vec![CustomData{bounds: (0, 2), label: "hello".tostring()}, CustomData{bounds: (3, 4), label: "world!".tostring()}]; let rendered = Renderer::new(data.asslice(), &bounds, &label) .withlength(60) .withrenderer(&render) .render().unwrap(); for line in rendered { asserteq!(line, "hello★★★★★★★★★★★★★★★★★★★★★★★★★☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆world!★★★★★★★★★"); } ```

See examples folder for more examples.

Changelog

Please see the CHANGELOG for a release history.

TODO