![dependabot[bot]](/assets/img/avatar_default.png)
Bumps [ratatui](https://github.com/ratatui-org/ratatui) from 0.26.2 to 0.26.3. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/ratatui-org/ratatui/releases">ratatui's releases</a>.</em></p> <blockquote> <h2>v0.26.3</h2> <!-- raw HTML omitted --> <h2><a href="https://github.com/ratatui-org/ratatui/releases/tag/v0.26.3">0.26.3</a> - 2024-05-19</h2> <p>We are happy to announce a brand new <a href="https://forum.ratatui.rs"><strong>Ratatui Forum</strong></a> 🐭 for Rust & TUI enthusiasts.</p> <p>This is a patch release that fixes the unicode truncation bug, adds performance and quality of life improvements.</p> <p>✨ <strong>Release highlights</strong>: <a href="https://ratatui.rs/highlights/v0263/">https://ratatui.rs/highlights/v0263/</a></p> <h3>Features</h3> <ul> <li> <p><a href="97ee102f17
">97ee102</a> <em>(buffer)</em> Track_caller for index_of by <a href="https://github.com/EdJoPaTo"><code>@EdJoPaTo</code></a> in <a href="https://redirect.github.com/ratatui-org/ratatui/pull/1046">#1046</a> **</p> <pre lang="text"><code>The caller put in the wrong x/y -> the caller is the cause. </code></pre> </li> <li> <p><a href="bf0923473c
">bf09234</a> <em>(table)</em> Make TableState::new const by <a href="https://github.com/EdJoPaTo"><code>@EdJoPaTo</code></a> in <a href="https://redirect.github.com/ratatui-org/ratatui/pull/1040">#1040</a></p> </li> <li> <p><a href="eb281df974
">eb281df</a> <em>(uncategorized)</em> Use inner Display implementation by <a href="https://github.com/EdJoPaTo"><code>@EdJoPaTo</code></a> in <a href="https://redirect.github.com/ratatui-org/ratatui/pull/1097">#1097</a></p> </li> <li> <p><a href="ec763af851
">ec763af</a> <em>(uncategorized)</em> Make Stylize's <code>.bg(color)</code> generic by <a href="https://github.com/kdheepak"><code>@kdheepak</code></a> in <a href="https://redirect.github.com/ratatui-org/ratatui/pull/1099">#1099</a></p> <pre lang="text"><code>This PR makes `.bg(color)` generic accepting anything that can be converted into `Color`; similar to the `.fg(color)` method on the same trait </code></pre> </li> <li> <p><a href="4d1784f2de
">4d1784f</a> <em>(uncategorized)</em> Re-export ParseColorError as style::ParseColorError by <a href="https://github.com/joshka"><code>@joshka</code></a> in <a href="https://redirect.github.com/ratatui-org/ratatui/pull/1086">#1086</a></p> <p>Fixes:<a href="https://redirect.github.com/ratatui-org/ratatui/issues/1085">ratatui-org/ratatui#1085</a></p> </li> </ul> <h3>Bug Fixes</h3> <ul> <li> <p><a href="366cbae09f
">366cbae</a> <em>(buffer)</em> Fix Debug panic and fix formatting of overridden parts by <a href="https://github.com/EdJoPaTo"><code>@EdJoPaTo</code></a> in <a href="https://redirect.github.com/ratatui-org/ratatui/pull/1098">#1098</a></p> <pre lang="text"><code>Fix panic in `Debug for Buffer` when `width == 0`. Also corrects the output when symbols are overridden. </code></pre> </li> <li> <p><a href="4392759501
">4392759</a> <em>(examples)</em> Changed user_input example to work with multi-byte unicode chars by <a href="https://github.com/OkieOth"><code>@OkieOth</code></a> in <a href="https://redirect.github.com/ratatui-org/ratatui/pull/1069">#1069</a></p> <pre lang="text"><code>This is the proposed solution for issue [#1068](https://github.com/ratatui-org/ratatui/issues/1068). It solves the bug in the user_input example with multi-byte UTF-8 characters as input. </code></pre> </li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/ratatui-org/ratatui/blob/main/CHANGELOG.md">ratatui's changelog</a>.</em></p> <blockquote> <h2><a href="https://github.com/ratatui-org/ratatui/releases/tag/v0.26.3">0.26.3</a> - 2024-05-19</h2> <p>We are happy to announce a brand new <a href="https://forum.ratatui.rs"><strong>Ratatui Forum</strong></a> 🐭 for Rust & TUI enthusiasts.</p> <p>This is a patch release that fixes the unicode truncation bug, adds performance and quality of life improvements.</p> <p>✨ <strong>Release highlights</strong>: <a href="https://ratatui.rs/highlights/v0263/">https://ratatui.rs/highlights/v0263/</a></p> <h3>Features</h3> <ul> <li> <p><a href="97ee102f17
">97ee102</a> <em>(buffer)</em> Track_caller for index_of by <a href="https://github.com/EdJoPaTo"><code>@EdJoPaTo</code></a> in <a href="https://redirect.github.com/ratatui-org/ratatui/pull/1046">#1046</a> **</p> <pre lang="text"><code>The caller put in the wrong x/y -> the caller is the cause. </code></pre> </li> <li> <p><a href="bf0923473c
">bf09234</a> <em>(table)</em> Make TableState::new const by <a href="https://github.com/EdJoPaTo"><code>@EdJoPaTo</code></a> in <a href="https://redirect.github.com/ratatui-org/ratatui/pull/1040">#1040</a></p> </li> <li> <p><a href="eb281df974
">eb281df</a> <em>(uncategorized)</em> Use inner Display implementation by <a href="https://github.com/EdJoPaTo"><code>@EdJoPaTo</code></a> in <a href="https://redirect.github.com/ratatui-org/ratatui/pull/1097">#1097</a></p> </li> <li> <p><a href="ec763af851
">ec763af</a> <em>(uncategorized)</em> Make Stylize's <code>.bg(color)</code> generic by <a href="https://github.com/kdheepak"><code>@kdheepak</code></a> in <a href="https://redirect.github.com/ratatui-org/ratatui/pull/1099">#1099</a></p> <pre lang="text"><code>This PR makes `.bg(color)` generic accepting anything that can be converted into `Color`; similar to the `.fg(color)` method on the same trait </code></pre> </li> <li> <p><a href="4d1784f2de
">4d1784f</a> <em>(uncategorized)</em> Re-export ParseColorError as style::ParseColorError by <a href="https://github.com/joshka"><code>@joshka</code></a> in <a href="https://redirect.github.com/ratatui-org/ratatui/pull/1086">#1086</a></p> <p>Fixes:<a href="https://redirect.github.com/ratatui-org/ratatui/issues/1085">ratatui-org/ratatui#1085</a></p> </li> </ul> <h3>Bug Fixes</h3> <ul> <li> <p><a href="366cbae09f
">366cbae</a> <em>(buffer)</em> Fix Debug panic and fix formatting of overridden parts by <a href="https://github.com/EdJoPaTo"><code>@EdJoPaTo</code></a> in <a href="https://redirect.github.com/ratatui-org/ratatui/pull/1098">#1098</a></p> <pre lang="text"><code>Fix panic in `Debug for Buffer` when `width == 0`. Also corrects the output when symbols are overridden. </code></pre> </li> <li> <p><a href="4392759501
">4392759</a> <em>(examples)</em> Changed user_input example to work with multi-byte unicode chars by <a href="https://github.com/OkieOth"><code>@OkieOth</code></a> in <a href="https://redirect.github.com/ratatui-org/ratatui/pull/1069">#1069</a></p> <pre lang="text"><code>This is the proposed solution for issue [#1068](https://github.com/ratatui-org/ratatui/issues/1068). It solves the bug in the user_input example with multi-byte UTF-8 characters as input. </code></pre> <p>Fixes:<a href="https://redirect.github.com/ratatui-org/ratatui/issues/1068">#1068</a></p> </li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="fadc73d62e
"><code>fadc73d</code></a> chore(release): prepare for 0.26.3 (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/1118">#1118</a>)</li> <li><a href="fcb5d589bb
"><code>fcb5d58</code></a> fix: make cargo test --doc work with unstable-widget-ref examples (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/1117">#1117</a>)</li> <li><a href="4955380932
"><code>4955380</code></a> build: remove pre-push hooks (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/1115">#1115</a>)</li> <li><a href="828d17a3f5
"><code>828d17a</code></a> docs: add minimal example (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/1114">#1114</a>)</li> <li><a href="9bd89c218a
"><code>9bd89c2</code></a> refactor(clippy): enable breaking lint checks (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/988">#988</a>)</li> <li><a href="2cfe82a47e
"><code>2cfe82a</code></a> refactor(buffer): deprecate assert_buffer_eq! in favor of assert_eq! (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/1007">#1007</a>)</li> <li><a href="1a4bb1cbb8
"><code>1a4bb1c</code></a> perf(layout): avoid allocating memory when using split ergonomic utils (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/1105">#1105</a>)</li> <li><a href="839cca20bf
"><code>839cca2</code></a> docs(table): Fix typo in docs for highlight_symbol (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/1108">#1108</a>)</li> <li><a href="f945a0bcff
"><code>f945a0b</code></a> docs(test): fix typo in TestBackend documentation (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/1107">#1107</a>)</li> <li><a href="eb281df974
"><code>eb281df</code></a> feat: use inner Display implementation (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/1097">#1097</a>)</li> <li>Additional commits viewable in <a href="https://github.com/ratatui-org/ratatui/compare/v0.26.2...v0.26.3">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Ratatui Macros
ratatui-macros
is a Rust crate that provides easy-to-use macros for simplifying boilerplate
associated with creating UI using Ratatui.
This is an experimental playground for us to explore macros that would be useful to have in Ratatui proper.
Features
- Constraint-based Layouts: Easily define layout constraints such as fixed, percentage, minimum, and maximum sizes, as well as ratios.
- Directional Layouts: Specify layouts as either horizontal or vertical with simple macro commands.
- Span and Line macros: Make it easier to create spans and lines with styling.
Getting Started
To use ratatui-macros
in your Rust project, add it as a dependency in your Cargo.toml
:
cargo add ratatui-macros
Then, import the macros in your Rust file:
use ratatui_macros::{
constraint,
constraints,
horizontal,
vertical,
span,
line,
};
Layout
If you are new to Ratatui, check out the Layout concepts article on the Ratatui website before proceeding.
Use the constraints!
macro to define layout constraints:
use ratatui::prelude::*;
use ratatui_macros::constraints;
assert_eq!(
constraints![==50, ==30%, >=3, <=1, ==1/2, *=1],
[
Constraint::Length(50),
Constraint::Percentage(30),
Constraint::Min(3),
Constraint::Max(1),
Constraint::Ratio(1, 2),
Constraint::Fill(1),
]
)
use ratatui::prelude::*;
use ratatui_macros::constraints;
assert_eq!(
constraints![==1/4; 4],
[
Constraint::Ratio(1, 4),
Constraint::Ratio(1, 4),
Constraint::Ratio(1, 4),
Constraint::Ratio(1, 4),
]
)
Use the constraint!
macro to define individual constraints:
use ratatui::prelude::*;
use ratatui_macros::constraint;
assert_eq!(
constraint!(==50),
Constraint::Length(50),
)
Create vertical and horizontal layouts using the vertical!
and horizontal!
macros:
use ratatui::prelude::*;
use ratatui_macros::{vertical, horizontal};
let area = Rect { x: 0, y: 0, width: 10, height: 10 };
let [main, bottom] = vertical![==100%, >=3].areas(area);
assert_eq!(bottom.y, 7);
assert_eq!(bottom.height, 3);
let [left, main, right] = horizontal![>=3, ==100%, >=3].areas(area);
assert_eq!(left.width, 3);
assert_eq!(right.width, 3);
Spans
The span!
macro create raw and styled Span
s. They each take a format string and arguments. span!
accepts as the first parameter any value that can be converted to a Style
followed by a ;
followed by the format string and arguments.
use ratatui::prelude::*;
use ratatui_macros::span;
let name = "world!";
let raw_greeting = span!("hello {name}");
let styled_greeting = span!(Style::new().green(); "hello {name}");
let styled_greeting = span!(Color::Green; "hello {name}");
let styled_greeting = span!(Modifier::BOLD; "hello {name}");
Line
The line!
macro creates a Line
that contains a sequence of spans. It is similar to the vec!
macro.
use ratatui::prelude::*;
use ratatui_macros::line;
let name = "world!";
let line = line!["hello", format!("{name}")];
let line = line!["bye"; 2];
Text
The text!
macro creates a Text
that contains a sequence of lines. It is similar to the vec!
macro.
use ratatui::prelude::*;
use ratatui_macros::{span, line, text};
let name = "world!";
let text = text!["hello", format!("{name}")];
let text = text!["bye"; 2];
It is even possible to use span!
and line!
in the text!
macro:
use ratatui::prelude::*;
use ratatui_macros::{span, line, text};
let name = "Bye!!!";
let text = text![line!["hello", "world".bold()], span!(Modifier::BOLD; "{name}")];
Contributing
Contributions to ratatui-macros
are welcome! Whether it's submitting a bug report, a feature
request, or a pull request, all forms of contributions are valued and appreciated.