1
0
зеркало из https://github.com/glebtv/tui-textarea.git synced 2026-09-03 14:26:17 +03:00

improve block titles to examples and simplify crossterm example

Этот коммит содержится в:
rhysd
2022-06-12 17:47:02 +09:00
родитель ebc3eb8e6f
Коммит c59bff2d26
2 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@@ -7,7 +7,7 @@ use tui::backend::CrosstermBackend;
use tui::layout::{Constraint, Direction, Layout};
use tui::widgets::{Block, Borders};
use tui::Terminal;
use tui_textarea::{Input, TextArea};
use tui_textarea::TextArea;
fn main() -> io::Result<()> {
let stdout = io::stdout();
@@ -18,7 +18,11 @@ fn main() -> io::Result<()> {
let mut term = Terminal::new(backend)?;
let mut textarea = TextArea::default();
textarea.set_block(Block::default().borders(Borders::ALL).title("EXAMPLE"));
textarea.set_block(
Block::default()
.borders(Borders::ALL)
.title("Crossterm Minimal Example"),
);
let layout = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Min(1)].as_ref());
@@ -33,7 +37,7 @@ fn main() -> io::Result<()> {
if key.code == KeyCode::Esc {
break;
}
textarea.input(Input::from(key));
textarea.input(key);
}
}

Просмотреть файл

@@ -42,7 +42,11 @@ fn main() -> Result<(), Box<dyn Error>> {
};
let mut textarea = TextArea::default();
textarea.set_block(Block::default().borders(Borders::ALL).title("EXAMPLE"));
textarea.set_block(
Block::default()
.borders(Borders::ALL)
.title("Termion Minimal Example"),
);
let layout = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Min(1)].as_ref());
@@ -60,6 +64,7 @@ fn main() -> Result<(), Box<dyn Error>> {
})?;
}
drop(term); // Leave terminal raw mode to print the following line
println!("Lines: {:?}", textarea.lines());
Ok(())
}