Implement OPOST and ONLCR

This commit is contained in:
Jeremy Soller
2020-01-26 19:54:18 -07:00
parent 743fac4727
commit b6042e673c
2 changed files with 10 additions and 1 deletions
+1
View File
@@ -58,6 +58,7 @@ fn main(){
}
}
}
fn post_fevent(socket: &mut File, id: usize, flags: usize, count: usize) {
socket.write(&Packet {
id: 0,
+9 -1
View File
@@ -213,12 +213,20 @@ impl Pty {
}
pub fn output(&mut self, buf: &[u8]) {
//TODO: Output flags
//TODO: more output flags
let ofl = &self.termios.c_oflag;
let opost = ofl & OPOST == OPOST;
let onlcr = ofl & ONLCR == ONLCR;
let mut vec = Vec::with_capacity(buf.len() + 1);
vec.push(0);
for &b in buf.iter() {
if opost && onlcr && b == b'\n' {
vec.push(b'\r');
}
vec.push(b);
}