ratatui / ratatui-macros

Macros for simplifying boilerplate for creating UI using Ratatui.
https://ratatui.rs
MIT License
24 stars 2 forks source link

feat: Add row! macro #52

Closed kdheepak closed 2 months ago

kdheepak commented 2 months ago

This PR adds a row! macro similar to the existing text! and line! macro.

This will allow code like this:

let rows = [
    Row::new([
        Cell::from("\u{f002}"),
        Cell::from("Find File"),
        Cell::from(Text::raw("ctrl+f").alignment(ratatui::layout::Alignment::Right)),
    ]),
    Row::new([
        Cell::from("\u{f021a}"),
        Cell::from("Open recent"),
        Cell::from(Text::raw("ctrl+r").alignment(ratatui::layout::Alignment::Right)),
    ]),
    Row::new([
        Cell::from("\u{f0493}"),
        Cell::from("Open config"),
        Cell::from(Text::raw("ctrl+k").alignment(ratatui::layout::Alignment::Right)),
    ]),
];

to be written like

let rows = [
    row!["\u{f002}", "Find File", text!["ctrl+f"].right_aligned()],
    row!["\u{f021a}", "Open recent", text!["ctrl+r"].right_aligned()],
    row!["\u{f0493}", "Open config", text!["ctrl+k"].right_aligned()],
];
kdheepak commented 2 months ago

I'm going to merge and address the comments here in another PR that makes these changes across all the files.