diff options
Diffstat (limited to 'src/blocking/input.rs')
-rw-r--r-- | src/blocking/input.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/blocking/input.rs b/src/blocking/input.rs index 1381776..b133e7f 100644 --- a/src/blocking/input.rs +++ b/src/blocking/input.rs @@ -50,6 +50,8 @@ impl Drop for RawGuard { } pub struct Input { + raw: Option<RawGuard>, + buf: Vec<u8>, pos: usize, @@ -112,12 +114,15 @@ impl crate::private::Input for Input { #[allow(clippy::new_without_default)] impl Input { - pub fn new() -> Result<(Self, RawGuard)> { - Ok((Self::new_without_raw(), RawGuard::new()?)) + pub fn new() -> Result<Self> { + let mut self_ = Self::new_without_raw(); + self_.raw = Some(RawGuard::new()?); + Ok(self_) } pub fn new_without_raw() -> Self { Self { + raw: None, buf: Vec::with_capacity(4096), pos: 0, parse_utf8: true, @@ -148,6 +153,10 @@ impl Input { self.parse_single = parse; } + pub fn take_raw_guard(&mut self) -> Option<RawGuard> { + self.raw.take() + } + pub fn read_key(&mut self) -> Result<Option<crate::Key>> { self.fill_buf()?; |