diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-03-12 00:33:26 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-03-12 01:31:04 -0500 |
commit | 9885f5ca8db5060f95066b16f68f69c1a858cf0f (patch) | |
tree | fc8de46ffcbbfaf58a40b111ef85e056c0ccf72b /src/lib.rs | |
parent | 2071214d70206e0dad43222c350ce3cd1ca31192 (diff) | |
download | textmode-9885f5ca8db5060f95066b16f68f69c1a858cf0f.tar.gz textmode-9885f5ca8db5060f95066b16f68f69c1a858cf0f.zip |
refactor input implementations to share some code
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 20 |
1 files changed, 1 insertions, 19 deletions
@@ -7,6 +7,7 @@ mod error; pub use error::{Error, Result}; mod key; pub use key::Key; +mod private; #[cfg(feature = "async")] mod output; @@ -20,25 +21,6 @@ pub use input::{Input, RawGuard}; const INIT: &[u8] = b"\x1b7\x1b[?47h\x1b[2J\x1b[H\x1b[?25h"; const DEINIT: &[u8] = b"\x1b[?47l\x1b8\x1b[?25h"; -mod private { - pub trait TextmodeImpl { - fn cur(&self) -> &vt100::Parser; - fn cur_mut(&mut self) -> &mut vt100::Parser; - fn next(&self) -> &vt100::Parser; - fn next_mut(&mut self) -> &mut vt100::Parser; - - fn write_u16(&mut self, i: u16) { - // unwrap is fine because vt100::Parser::write can never fail - itoa::write(self.next_mut(), i).unwrap(); - } - - fn write_u8(&mut self, i: u8) { - // unwrap is fine because vt100::Parser::write can never fail - itoa::write(self.next_mut(), i).unwrap(); - } - } -} - pub trait Textmode: private::TextmodeImpl { fn screen(&self) -> &vt100::Screen { self.next().screen() |