1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-22 22:42:48 +03:00

pty: remove dead code

This commit is contained in:
Wez Furlong 2020-06-05 07:33:23 -07:00
parent c5f270f48b
commit 954a05919d
2 changed files with 0 additions and 45 deletions

View File

@ -13,7 +13,6 @@ use winapi::um::winbase::INFINITE;
pub mod conpty;
mod procthreadattr;
mod psuedocon;
mod readbuf;
use filedescriptor::OwnedHandle;

View File

@ -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
}
}
}