rhysd/tui-textarea

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

fmorroni opened this issue · 8 comments

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?

because Widget::render requires to move out self

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());
})?;

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.

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

This was included in v0.5.3 release.

This was included in v0.5.3 release.

Great thanks!