diff --git a/README.md b/README.md index 176b19cf..d779b6b6 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ Status](https://deps.rs/repo/github/tui-rs-revival/ratatui/status.svg?style=for- [![Codecov](https://img.shields.io/codecov/c/github/tui-rs-revival/ratatui?logo=codecov&style=for-the-badge&token=BAQ8SOKEST)](https://app.codecov.io/gh/tui-rs-revival/ratatui) [![Discord](https://img.shields.io/discord/1070692720437383208?label=discord&logo=discord&style=for-the-badge)](https://discord.gg/pMCEU9hNEj) -![Demo of ratatui](./assets/demo.gif) + +![Demo of Ratatui](https://vhs.charm.sh/vhs-IZKj0x97pI2LAJwxCpu1Y.gif)
Table of Contents diff --git a/RELEASE.md b/RELEASE.md index 8aa82b94..2fea3b87 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,10 +1,29 @@ # Creating a Release -[crates.io](https://crates.io/crates/ratatui) releases are automated via [GitHub actions](.github/workflows/cd.yml) and triggered by pushing a tag. +[crates.io](https://crates.io/crates/ratatui) releases are automated via [GitHub +actions](.github/workflows/cd.yml) and triggered by pushing a tag. + +1. Record a new demo gif. I found the best tool for this was [ttyrec](http://0xcc.net/ttyrec/) and + [ttygif](https://github.com/icholy/ttygif). Asciinema handles block character height poorly, + termanilizer takes forever to render, [vhs](https://github.com/charmbracelet/vhs) handles braille + characters poorly (though if is fixed, then + it's probably the best option). + + ```shell + cargo build --example demo + ttyrec -e 'cargo --quiet run --release --example demo -- --tick-rate 100' demo.rec + ttygif demo.rec + ``` + + Then upload it somewhere (e.g. use `vhs publish tty.gif` to publish it or upload it to a github + wiki page as an attachment). Avoid adding the gif to the git repo as binary files tend to bloat + repositories. 1. Bump the version in [Cargo.toml](Cargo.toml). -2. Ensure [CHANGELOG.md](CHANGELOG.md) is updated. [git-cliff](https://github.com/orhun/git-cliff) can be used for generating the entries. -3. Commit and push the changes. -4. Create a new tag: `git tag -a v[X.Y.Z]` -5. Push the tag: `git push --tags` -6. Wait for [Continuous Deployment](https://github.com/tui-rs-revival/ratatui/actions) workflow to finish. +1. Ensure [CHANGELOG.md](CHANGELOG.md) is updated. [git-cliff](https://github.com/orhun/git-cliff) + can be used for generating the entries. +1. Commit and push the changes. +1. Create a new tag: `git tag -a v[X.Y.Z]` +1. Push the tag: `git push --tags` +1. Wait for [Continuous Deployment](https://github.com/tui-rs-revival/ratatui/actions) workflow to + finish. diff --git a/assets/demo.gif b/assets/demo.gif deleted file mode 100644 index 7289ebfe..00000000 Binary files a/assets/demo.gif and /dev/null differ diff --git a/examples/demo/ui.rs b/examples/demo/ui.rs index b1a669d7..7481ec69 100644 --- a/examples/demo/ui.rs +++ b/examples/demo/ui.rs @@ -82,6 +82,7 @@ where .bg(Color::Black) .add_modifier(Modifier::ITALIC | Modifier::BOLD), ) + .use_unicode(app.enhanced_graphics) .label(label) .ratio(app.progress); f.render_widget(gauge, chunks[0]); diff --git a/src/widgets/gauge.rs b/src/widgets/gauge.rs index 5b8ee2bc..9f5d9939 100644 --- a/src/widgets/gauge.rs +++ b/src/widgets/gauge.rs @@ -127,18 +127,26 @@ impl<'a> Widget for Gauge<'a> { for y in gauge_area.top()..gauge_area.bottom() { // render the filled area (left to end) for x in gauge_area.left()..end { - // spaces are needed to apply the background styling - buf.get_mut(x, y) - .set_symbol(" ") - .set_fg(self.gauge_style.bg.unwrap_or(Color::Reset)) - .set_bg(self.gauge_style.fg.unwrap_or(Color::Reset)); + let cell = buf.get_mut(x, y); + if self.use_unicode { + cell.set_symbol(symbols::block::FULL) + .set_fg(self.gauge_style.fg.unwrap_or(Color::Reset)) + .set_bg(self.gauge_style.bg.unwrap_or(Color::Reset)); + } else { + // spaces are needed to apply the background styling. + // note that the background and foreground colors are swapped + // otherwise the gauge will be inverted + cell.set_symbol(" ") + .set_fg(self.gauge_style.bg.unwrap_or(Color::Reset)) + .set_bg(self.gauge_style.fg.unwrap_or(Color::Reset)); + } } if self.use_unicode && self.ratio < 1.0 { buf.get_mut(end, y) .set_symbol(get_unicode_block(filled_width % 1.0)); } } - // set the line + // render the label buf.set_span(label_col, label_row, &label, clamped_label_width); } } diff --git a/tests/widgets_gauge.rs b/tests/widgets_gauge.rs index 2731dd1e..fbf6d468 100644 --- a/tests/widgets_gauge.rs +++ b/tests/widgets_gauge.rs @@ -39,10 +39,10 @@ fn widgets_gauge_renders() { " ", " ", " ┌Percentage────────────────────────┐ ", - " │ ▋43% │ ", + " │██████████████▋43% │ ", " └──────────────────────────────────┘ ", " ┌Ratio─────────────────────────────┐ ", - " │ 51% │ ", + " │███████████████51% │ ", " └──────────────────────────────────┘ ", " ", " ", @@ -51,8 +51,8 @@ fn widgets_gauge_renders() { for i in 3..17 { expected .get_mut(i, 3) - .set_bg(Color::Red) - .set_fg(Color::Blue); + .set_bg(Color::Blue) + .set_fg(Color::Red); } for i in 17..37 { expected @@ -64,8 +64,8 @@ fn widgets_gauge_renders() { for i in 3..20 { expected .get_mut(i, 6) - .set_bg(Color::Red) - .set_fg(Color::Blue); + .set_bg(Color::Blue) + .set_fg(Color::Red); } for i in 20..37 { expected