Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add row! macro #52

Merged
merged 4 commits into from
Jun 28, 2024
Merged

feat: Add row! macro #52

merged 4 commits into from
Jun 28, 2024

Conversation

kdheepak
Copy link
Collaborator

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 kdheepak requested review from joshka and EdJoPaTo June 27, 2024 07:39
Copy link
Member

@joshka joshka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking

src/row.rs Show resolved Hide resolved
src/row.rs Outdated Show resolved Hide resolved
src/row.rs Show resolved Hide resolved
src/row.rs Outdated Show resolved Hide resolved
src/row.rs Show resolved Hide resolved
src/row.rs Outdated Show resolved Hide resolved
src/row.rs Show resolved Hide resolved
src/row.rs Show resolved Hide resolved
src/row.rs Show resolved Hide resolved
@kdheepak
Copy link
Collaborator Author

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

@kdheepak kdheepak merged commit c764957 into main Jun 28, 2024
3 checks passed
@kdheepak kdheepak deleted the kd/row-macro branch June 28, 2024 04:15
@github-actions github-actions bot mentioned this pull request Jun 28, 2024
kdheepak added a commit that referenced this pull request Jun 28, 2024
This PR uses `::ratatui` to ensure it doesn't clash with a module named
`ratatui` in an app, per comment
#52 (comment)

This PR also refactors some tests.
kdheepak added a commit that referenced this pull request Jun 28, 2024
kdheepak pushed a commit that referenced this pull request Jun 29, 2024
## 🤖 New release
* `ratatui-macros`: 0.4.1 -> 0.4.2

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.4.2](v0.4.1...v0.4.2)
- 2024-06-29

### Added
- Use `::ratatui` instead of `ratatui`
([#54](#54))
- Add row! macro
([#52](#52))

### Other
- Update README with row! documentation
([#56](#56))
- Make doc examples shorter by removing duplicate imports
([#55](#55))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants