From 77311ae63f42066ab90f0344f9a6e5271f263b32 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 8 Mar 2016 19:07:39 +0100 Subject: [PATCH] Make the position 0-based --- src/control.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/control.rs b/src/control.rs index e427af3..9b35fc0 100644 --- a/src/control.rs +++ b/src/control.rs @@ -33,19 +33,24 @@ pub trait TermControl { self.csi(b"m") } /// Go to a given position. - fn goto(&mut self, x: u16, y: u16) -> IoResult { + /// + /// The position is 0-based. + fn goto(&mut self, mut x: u16, mut y: u16) -> IoResult { + x += 1; + y += 1; + self.csi(&[ - b'0' + (x / 10000) as u8, - b'0' + (x / 1000) as u8 % 10, - b'0' + (x / 100) as u8 % 10, - b'0' + (x / 10) as u8 % 10, - b'0' + x as u8 % 10, - b';', b'0' + (y / 10000) as u8, b'0' + (y / 1000) as u8 % 10, b'0' + (y / 100) as u8 % 10, b'0' + (y / 10) as u8 % 10, b'0' + y as u8 % 10, + b';', + b'0' + (x / 10000) as u8, + b'0' + (x / 1000) as u8 % 10, + b'0' + (x / 100) as u8 % 10, + b'0' + (x / 10) as u8 % 10, + b'0' + x as u8 % 10, b'H', ]) }