Remove warnings from example
This commit is contained in:
parent
c89a8f7027
commit
2f0c72e1e4
|
@ -4,14 +4,15 @@ use libterm::{TermControl, raw_mode};
|
||||||
use std::io::{Read, Write, stdout, stdin};
|
use std::io::{Read, Write, stdout, stdin};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let raw = raw_mode();
|
let _raw = raw_mode();
|
||||||
let mut stdout = stdout();
|
let mut stdout = stdout();
|
||||||
let mut stdin = stdin();
|
let stdin = stdin();
|
||||||
|
|
||||||
stdout.goto(5, 5);
|
stdout.goto(5, 5).unwrap();
|
||||||
stdout.clear();
|
stdout.clear().unwrap();
|
||||||
stdout.write(b"yo, 'q' will exit.");
|
stdout.write(b"yo, 'q' will exit.").unwrap();
|
||||||
stdout.flush();
|
stdout.flush().unwrap();
|
||||||
|
stdout.goto(20, 10).unwrap();
|
||||||
|
|
||||||
let mut bytes = stdin.bytes();
|
let mut bytes = stdin.bytes();
|
||||||
loop {
|
loop {
|
||||||
|
@ -20,9 +21,10 @@ fn main() {
|
||||||
match b {
|
match b {
|
||||||
b'q' => return,
|
b'q' => return,
|
||||||
b'c' => stdout.clear(),
|
b'c' => stdout.clear(),
|
||||||
|
b'r' => stdout.rendition(91),
|
||||||
a => stdout.write(&[a]),
|
a => stdout.write(&[a]),
|
||||||
};
|
}.unwrap();
|
||||||
|
|
||||||
stdout.flush();
|
stdout.flush().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,12 +27,19 @@ pub trait TermControl {
|
||||||
/// Go to a given position.
|
/// Go to a given position.
|
||||||
fn goto(&mut self, x: u16, y: u16) -> IoResult<usize> {
|
fn goto(&mut self, x: u16, y: u16) -> IoResult<usize> {
|
||||||
self.csi(&[
|
self.csi(&[
|
||||||
(x / 10000 % 10) as u8, (x / 1000 % 10) as u8, (x / 100 % 10) as u8, (x / 10 % 10) as u8, (x % 10) as u8,
|
(x / 10000) as u8 + b'0', ((x / 1000) % 10) as u8 + b'0', ((x / 100) % 10) as u8 + b'0', ((x / 10) % 10) as u8 + b'0', (x % 10) as u8 + b'0',
|
||||||
b';',
|
b';',
|
||||||
(y / 10000 % 10) as u8, (y / 1000 % 10) as u8, (y / 100 % 10) as u8, (y / 10 % 10) as u8, (y % 10) as u8,
|
(y / 10000) as u8 + b'0', ((y / 1000) % 10) as u8 + b'0', ((y / 100) % 10) as u8 + b'0', ((y / 10) % 10) as u8 + b'0', (y % 10) as u8 + b'0',
|
||||||
b'H',
|
b'H',
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
/// Set graphic rendition.
|
||||||
|
fn rendition(&mut self, r: u8) -> IoResult<usize> {
|
||||||
|
self.csi(&[
|
||||||
|
r / 100 + b'0', r / 10 % 10 + b'0', r % 10 + b'0',
|
||||||
|
b'm',
|
||||||
|
])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: Write> TermControl for W {
|
impl<W: Write> TermControl for W {
|
||||||
|
|
Loading…
Reference in New Issue