2018-07-18 05:04:23 +03:00
|
|
|
extern crate failure;
|
2018-07-19 22:31:31 +03:00
|
|
|
extern crate termwiz;
|
2018-07-18 05:04:23 +03:00
|
|
|
|
|
|
|
use failure::Error;
|
2018-07-19 16:58:48 +03:00
|
|
|
use termwiz::caps::Capabilities;
|
|
|
|
use termwiz::cell::{AttributeChange, CellAttributes};
|
|
|
|
use termwiz::color::AnsiColor;
|
|
|
|
use termwiz::render::terminfo::TerminfoRenderer;
|
|
|
|
use termwiz::render::Renderer;
|
|
|
|
use termwiz::screen::{Change, Screen};
|
2018-07-19 20:52:29 +03:00
|
|
|
use termwiz::terminal::{Terminal, UnixTerminal};
|
2018-07-18 05:04:23 +03:00
|
|
|
|
|
|
|
fn main() -> Result<(), Error> {
|
2018-07-19 16:58:48 +03:00
|
|
|
let caps = Capabilities::new_from_env()?;
|
2018-07-19 21:26:24 +03:00
|
|
|
let renderer = TerminfoRenderer::new(caps);
|
2018-07-19 20:52:29 +03:00
|
|
|
|
|
|
|
let mut terminal = UnixTerminal::new()?;
|
|
|
|
terminal.set_raw_mode()?;
|
|
|
|
|
2018-07-19 21:26:24 +03:00
|
|
|
let size = terminal.get_screen_size()?;
|
|
|
|
let mut screen = Screen::new(size.cols as usize, size.rows as usize);
|
2018-07-19 16:58:48 +03:00
|
|
|
|
|
|
|
screen.add_change(Change::Attribute(AttributeChange::Foreground(
|
|
|
|
AnsiColor::Maroon.into(),
|
|
|
|
)));
|
|
|
|
screen.add_change("Hello world\r\n");
|
|
|
|
|
2018-07-19 22:31:31 +03:00
|
|
|
let (_seq, changes) = screen.get_changes(0);
|
|
|
|
let _end_attr = renderer.render_to(&CellAttributes::default(), &changes, &mut terminal);
|
2018-07-19 16:58:48 +03:00
|
|
|
//println!("changes: {:?}", changes);
|
2018-07-19 21:26:24 +03:00
|
|
|
println!("size: {:?}", size);
|
|
|
|
|
2018-07-19 16:58:48 +03:00
|
|
|
Ok(())
|
2018-07-18 05:04:23 +03:00
|
|
|
}
|