dependabot[bot] f28b973006
build(deps): bump trybuild from 1.0.97 to 1.0.98 in the cargo-dependencies group (#62)
Bumps the cargo-dependencies group with 1 update:
[trybuild](https://github.com/dtolnay/trybuild).

Updates `trybuild` from 1.0.97 to 1.0.98
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/dtolnay/trybuild/releases">trybuild's
releases</a>.</em></p>
<blockquote>
<h2>1.0.98</h2>
<ul>
<li>Fix enabling of default features for workspace dependencies (<a
href="https://redirect.github.com/dtolnay/trybuild/issues/282">#282</a>,
thanks <a
href="https://github.com/gui1117"><code>@​gui1117</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="a4f4171e55"><code>a4f4171</code></a>
Release 1.0.98</li>
<li><a
href="aa567ec542"><code>aa567ec</code></a>
Merge pull request <a
href="https://redirect.github.com/dtolnay/trybuild/issues/282">#282</a>
from gui1117/gui-fix-default-features</li>
<li><a
href="c08e3f76e6"><code>c08e3f7</code></a>
remove unused</li>
<li><a
href="cd88ca2bb4"><code>cd88ca2</code></a>
Fix default features</li>
<li>See full diff in <a
href="https://github.com/dtolnay/trybuild/compare/1.0.97...1.0.98">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=trybuild&package-manager=cargo&previous-version=1.0.97&new-version=1.0.98)](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 <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-03 23:15:55 -04:00
2024-01-05 14:34:40 -05:00
2024-07-22 03:53:13 -07:00
2024-01-05 14:34:40 -05:00

Ratatui Macros

Crates.io badge License badge Docs.rs badge CI Badge Crate Downloads badge

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 Spans. 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}")];

Row

The row! macro creates a Row that contains a sequence of Cell. It is similar to the vec! macro. A Row represents a sequence of Cells in a single row of a table.

use ratatui::prelude::*;
use ratatui_macros::row;

let rows = [
    row!["hello", "world"],
    row!["goodbye", "world"],
];

It is even possible to use span!, line! and text! in the row! macro:

use ratatui::prelude::*;
use ratatui_macros::{span, line, text, row};
let name = "Bye!!!";
let text = row![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.

Description
A Rust crate for cooking up terminal user interfaces (TUIs) 👨‍🍳🐀 https://ratatui.rs
Readme MIT 153 MiB
Languages
Rust 100%