Add README
This commit is contained in:
parent
bf7ca5c143
commit
8a172fdbda
|
@ -0,0 +1,2 @@
|
|||
target
|
||||
Cargo.lock
|
|
@ -0,0 +1,6 @@
|
|||
[package]
|
||||
name = "libterm"
|
||||
version = "0.1.0"
|
||||
authors = ["Ticki <Ticki@users.noreply.github.com>"]
|
||||
|
||||
[dependencies]
|
|
@ -0,0 +1,14 @@
|
|||
libterm
|
||||
=======
|
||||
|
||||
A Rust Termios wrapper, providing various useful abstractions for dealing with terminals.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
See `examples/`.
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
MIT.
|
|
@ -0,0 +1,28 @@
|
|||
extern crate libterm;
|
||||
|
||||
use libterm::{TermControl, raw_mode};
|
||||
use std::io::{Read, Write, stdout, stdin};
|
||||
|
||||
fn main() {
|
||||
let raw = raw_mode();
|
||||
let mut stdout = stdout();
|
||||
let mut stdin = stdin();
|
||||
|
||||
stdout.goto(5, 5);
|
||||
stdout.clear();
|
||||
stdout.write(b"yo, 'q' will exit.");
|
||||
stdout.flush();
|
||||
|
||||
let mut bytes = stdin.bytes();
|
||||
loop {
|
||||
let b = bytes.next().unwrap().unwrap();
|
||||
|
||||
match b {
|
||||
b'q' => return,
|
||||
b'c' => stdout.clear(),
|
||||
a => stdout.write(&[a]),
|
||||
};
|
||||
|
||||
stdout.flush();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue