use ratatui::widgets::Widget;
use tui_textarea::{Input, Key, TextArea};
#[derive(Default)]
pub struct LineEditor<'a>(TextArea<'a>);
impl<'a> LineEditor<'a> {
pub fn widget(&'a self) -> impl Widget + 'a {
self.0.widget()
}
pub fn input(&mut self, input: impl Into<Input>) -> bool {
match input.into() {
Input {
key: Key::Char('m'),
ctrl: true,
..
}
| Input {
key: Key::Enter, ..
} => false,
input => {
self.0.input(input)
}
}
}
pub fn line(&self) -> String {
self.0.lines()[0].clone()
}
}