mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 13:21:38 +03:00
pty: remove dead code
This commit is contained in:
parent
c5f270f48b
commit
954a05919d
@ -13,7 +13,6 @@ use winapi::um::winbase::INFINITE;
|
||||
pub mod conpty;
|
||||
mod procthreadattr;
|
||||
mod psuedocon;
|
||||
mod readbuf;
|
||||
|
||||
use filedescriptor::OwnedHandle;
|
||||
|
||||
|
@ -1,44 +0,0 @@
|
||||
/// A simple read buffer
|
||||
pub struct ReadBuffer {
|
||||
data: Vec<u8>,
|
||||
/// The position to read data from
|
||||
pos: usize,
|
||||
}
|
||||
|
||||
impl ReadBuffer {
|
||||
pub fn new() -> Self {
|
||||
let data = Vec::with_capacity(8192);
|
||||
Self { data, pos: 0 }
|
||||
}
|
||||
|
||||
pub fn append(&mut self, buf: &[u8]) {
|
||||
if self.data.len() + buf.len() > self.data.capacity() {
|
||||
if self.pos == self.data.len() {
|
||||
self.pos = 0;
|
||||
} else if self.pos > 0 {
|
||||
let (front, back) = self.data.split_at_mut(self.pos);
|
||||
let len = back.len();
|
||||
front[0..len].copy_from_slice(back);
|
||||
|
||||
self.pos = len;
|
||||
self.data.resize(len, 0);
|
||||
}
|
||||
}
|
||||
self.data.extend_from_slice(buf);
|
||||
}
|
||||
|
||||
pub fn avail(&self) -> usize {
|
||||
self.data.len() - self.pos
|
||||
}
|
||||
|
||||
pub fn consume(&mut self, buf: &mut [u8]) -> usize {
|
||||
let len = buf.len().min(self.avail());
|
||||
if len == 0 {
|
||||
0
|
||||
} else {
|
||||
buf[0..len].copy_from_slice(&self.data[self.pos..self.pos + len]);
|
||||
self.pos += len;
|
||||
len
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user