mirror of
https://github.com/wez/wezterm.git
synced 2024-12-24 13:52:55 +03:00
c91219d65b
Make the WindowsTerminal constructors more closely match those of UnixTerminal in behavior.
36 lines
1012 B
Rust
36 lines
1012 B
Rust
extern crate failure;
|
|
extern crate termwiz;
|
|
|
|
use failure::Error;
|
|
use termwiz::caps::Capabilities;
|
|
use termwiz::cell::AttributeChange;
|
|
use termwiz::color::AnsiColor;
|
|
use termwiz::surface::{Change, Surface};
|
|
use termwiz::terminal::{new_terminal, Terminal};
|
|
|
|
fn main() -> Result<(), Error> {
|
|
let caps = Capabilities::new_from_env()?;
|
|
|
|
let mut terminal = new_terminal(caps)?;
|
|
terminal.set_raw_mode()?;
|
|
|
|
let size = terminal.get_screen_size()?;
|
|
let mut screen = Surface::new(size.cols as usize, size.rows as usize);
|
|
|
|
screen.add_change(Change::Attribute(AttributeChange::Foreground(
|
|
AnsiColor::Maroon.into(),
|
|
)));
|
|
screen.add_change("Hello world\r\n");
|
|
screen.add_change(Change::Attribute(AttributeChange::Foreground(
|
|
AnsiColor::Red.into(),
|
|
)));
|
|
screen.add_change("and in red here\r\n");
|
|
|
|
let (_seq, changes) = screen.get_changes(0);
|
|
terminal.render(&changes)?;
|
|
//println!("changes: {:?}", changes);
|
|
println!("size: {:?}", size);
|
|
|
|
Ok(())
|
|
}
|