rhysd / tui-textarea

Simple yet powerful multi-line text editor widget for ratatui and tui-rs
https://crates.io/crates/tui-textarea
MIT License
323 stars 61 forks source link

Why doesn't `TextArea` implement `Widget` trait #78

Closed fmorroni closed 2 months ago

fmorroni commented 2 months ago

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 commented 2 months ago

because Widget::render requires to move out self

rhysd commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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

rhysd commented 1 month ago

This was included in v0.5.3 release.

fmorroni commented 1 month ago

This was included in v0.5.3 release.

Great thanks!