Put text in box for testing
This commit is contained in:
parent
ef019dc887
commit
9a32792686
1 changed files with 18 additions and 2 deletions
|
|
@ -11,6 +11,8 @@ use crossterm::execute;
|
||||||
use crossterm::terminal::{EnterAlternateScreen, LeaveAlternateScreen};
|
use crossterm::terminal::{EnterAlternateScreen, LeaveAlternateScreen};
|
||||||
use textline::{TextLine, TextLineState};
|
use textline::{TextLine, TextLineState};
|
||||||
use tui::backend::{Backend, CrosstermBackend};
|
use tui::backend::{Backend, CrosstermBackend};
|
||||||
|
use tui::layout::{Constraint, Direction, Layout, Margin, Rect};
|
||||||
|
use tui::widgets::{Block, Borders};
|
||||||
use tui::{Frame, Terminal};
|
use tui::{Frame, Terminal};
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
|
@ -20,8 +22,22 @@ struct Ui {
|
||||||
|
|
||||||
impl Ui {
|
impl Ui {
|
||||||
fn draw<B: Backend>(&mut self, f: &mut Frame<B>) {
|
fn draw<B: Backend>(&mut self, f: &mut Frame<B>) {
|
||||||
f.render_stateful_widget(TextLine, f.size(), &mut self.text);
|
let outer = Rect {
|
||||||
self.text.set_cursor(f, f.size());
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
width: 50 + 2,
|
||||||
|
height: 1 + 2,
|
||||||
|
};
|
||||||
|
let inner = Rect {
|
||||||
|
x: 1,
|
||||||
|
y: 1,
|
||||||
|
width: 50,
|
||||||
|
height: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
f.render_widget(Block::default().borders(Borders::ALL), outer);
|
||||||
|
f.render_stateful_widget(TextLine, inner, &mut self.text);
|
||||||
|
self.text.set_cursor(f, inner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue