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

Why doesn't TextArea implement Widget trait #78

Closed
fmorroni opened this issue Aug 1, 2024 · 8 comments
Closed

Why doesn't TextArea implement Widget trait #78

fmorroni opened this issue Aug 1, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@fmorroni
Copy link
Contributor

fmorroni commented Aug 1, 2024

Hi, why doesn't TextArea implement the Widget trait? I know we have the widget() method but that seems kind of unnecessary to me. Is there an advantage to having it that way?

@rhysd
Copy link
Owner

rhysd commented Aug 2, 2024

because Widget::render requires to move out self

@rhysd rhysd closed this as completed Aug 2, 2024
@rhysd
Copy link
Owner

rhysd commented Aug 2, 2024

I noticed that &TextArea can implement Widget. It might be smarter.

impl<'a> Widget for &'a TextArea<'a> {
    // ...
}

// Usage
term.draw(|f| {
    f.render_widget(&textarea, f.size());
})?;

@fmorroni
Copy link
Contributor Author

fmorroni commented Aug 2, 2024

I noticed that &TextArea can implement Widget. It might be smarter.

impl<'a> Widget for &'a TextArea<'a> {
    // ...
}

// Usage
term.draw(|f| {
    f.render_widget(&textarea, f.size());
})?;

Yeah that's basically what I did for a vim input widget I'm making. Seems to work fine.

@rhysd
Copy link
Owner

rhysd commented Aug 2, 2024

@fmorroni Thanks for clarification. I'll consider this.

@rhysd rhysd reopened this Aug 2, 2024
@rhysd rhysd closed this as completed in c99108b Aug 2, 2024
@rhysd rhysd added the enhancement New feature or request label Aug 3, 2024
@rhysd
Copy link
Owner

rhysd commented Aug 3, 2024

This was included in v0.5.3 release.

@fmorroni
Copy link
Contributor Author

fmorroni commented Aug 3, 2024

This was included in v0.5.3 release.

Great thanks!

@evbo
Copy link

evbo commented Nov 24, 2024

@rhysd did this break again recently?:

error[E0277]: the trait bound `&tui_textarea::textarea::TextArea<'_>: Widget` is not satisfied
  --> src/main.rs:72:30
   |
72 |         frame.render_widget(&self.state.text_area, area);
   |               -------------  ^^^^^^^^^^^^^^^^^^^^ the trait `widgets::WidgetRef` is not implemented for `&tui_textarea::textarea::TextArea<'_>`, which is required by `&tui_textarea::textarea::TextArea<'_>: Widget`
   |               |
   |               required by a bound introduced by this call

@rhysd
Copy link
Owner

rhysd commented Nov 24, 2024

@evbo This issue is a feature request and already closed. Could you create new one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants