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

chore: Make ratatui optional on tui-popups (Breaking / Help Wanted #52

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

joshka
Copy link
Owner

@joshka joshka commented Nov 28, 2024

Rely on ratatui-core types mainly except for the interaction with
crossterm.

The goal here was to remove the reliance on the unstable WidgetRef
and StatefulWidgetRef traits, which are in Ratatui, and replace it with
the stable Widget/StatefulWidget traits in Ratatui-core.

I haven't found a way (yet) to make this work for &W: Widget instead of
W: Widget + Clone. Leaving this open a bit for anyone that wants to
give feedback on the change / explore whether this is possible to fix.

This is the call that needs to work (render the body widget of the popup.

self.body.render_ref(inner_area, buf);

Rely on ratatui-core types mainly except for the interaction with
crossterm.

This change is a bit breaking, as it requires the widget passed in
to tui-popup to implement Clone. I can't find a clean way to replace
this otherwise such that this call works:
<https://github.com/joshka/tui-widgets/blob/83e45dbb31566ade6b323d05820c711561a1a46c/tui-popup/src/popup.rs#L147>
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.

Project coverage is 73.53%. Comparing base (83e45db) to head (b73e779).

Files with missing lines Patch % Lines
tui-popup/src/known_size_wrapper.rs 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #52      +/-   ##
==========================================
+ Coverage   73.34%   73.53%   +0.18%     
==========================================
  Files          14       14              
  Lines        2465     2441      -24     
==========================================
- Hits         1808     1795      -13     
+ Misses        657      646      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines -147 to +123
self.body.render_ref(inner_area, buf);
self.body.clone().render(inner_area, buf);
Copy link
Owner Author

Choose a reason for hiding this comment

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

This one line is the crux of this entire change. I can't get this to work with &Widget, the best I can do is Clone the inner body widget. I'm not sure if this would be better left using WidgetRef instead of requiring Clone

@joshka joshka added the help wanted Extra attention is needed label Nov 28, 2024
@joshka joshka requested a review from Copilot November 28, 2024 12:18

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 6 changed files in this pull request and generated no suggestions.

Files not reviewed (1)
  • Cargo.toml: Evaluated as low risk
@joshka joshka changed the title chore: Make ratatui optional on tui-popups chore: Make ratatui optional on tui-popups (Breaking / Help Wanted Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants