u16 instead, don't allocate for formatting

This commit is contained in:
Ticki 2016-03-06 17:51:07 +01:00
parent 8a172fdbda
commit 1e30802d32
1 changed files with 7 additions and 2 deletions

View File

@ -141,8 +141,13 @@ pub trait TermControl {
self.csi(b"0m")
}
/// Go to a given position.
fn goto(&mut self, x: usize, y: usize) -> IoResult<usize> {
self.csi(format!("{};{}H", x, y).as_bytes())
fn goto(&mut self, x: u16, y: u16) -> IoResult<usize> {
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,
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,
b'H',
])
}
}