diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-11-13 15:23:43 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-11-13 15:23:43 -0500 |
commit | 4490ced4e32f47863539d1d346e1619ba581322b (patch) | |
tree | 7439fc99bf7136eb814a66c6e6ec77a45ec98c04 /src | |
parent | 45af291f81f33f18080532d4aacaa27074503d20 (diff) | |
download | textmode-4490ced4e32f47863539d1d346e1619ba581322b.tar.gz textmode-4490ced4e32f47863539d1d346e1619ba581322b.zip |
add move_relative
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -122,6 +122,31 @@ pub trait Textmode: private::Output { self.write(b"H"); } + fn move_relative(&mut self, row_offset: i16, col_offset: i16) { + let abs_row_offset = row_offset.unsigned_abs(); + let abs_col_offset = col_offset.unsigned_abs(); + if row_offset > 0 { + self.write(b"\x1b["); + self.write_u16(abs_row_offset); + self.write(b"B") + } + if row_offset < 0 { + self.write(b"\x1b["); + self.write_u16(abs_row_offset); + self.write(b"A") + } + if col_offset > 0 { + self.write(b"\x1b["); + self.write_u16(abs_col_offset); + self.write(b"C") + } + if col_offset < 0 { + self.write(b"\x1b["); + self.write_u16(abs_col_offset); + self.write(b"D") + } + } + /// Clears the in-memory screen. fn clear(&mut self) { self.write(b"\x1b[2J"); |