From 1e30802d32f839d125e8b2eaa58b52cfa43530c5 Mon Sep 17 00:00:00 2001 From: Ticki Date: Sun, 6 Mar 2016 17:51:07 +0100 Subject: [PATCH] u16 instead, don't allocate for formatting --- src/lib.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 892fe69..5368cdc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 { - self.csi(format!("{};{}H", x, y).as_bytes()) + fn goto(&mut self, x: u16, y: u16) -> IoResult { + 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', + ]) } }