Improvements for cooked mode
This commit is contained in:
parent
25519c4f1c
commit
c36c62385b
|
@ -27,6 +27,7 @@ struct DisplayScheme {
|
||||||
console: RefCell<Console>,
|
console: RefCell<Console>,
|
||||||
display: RefCell<Display>,
|
display: RefCell<Display>,
|
||||||
input: RefCell<VecDeque<u8>>,
|
input: RefCell<VecDeque<u8>>,
|
||||||
|
cooked: RefCell<VecDeque<u8>>,
|
||||||
requested: RefCell<usize>
|
requested: RefCell<usize>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,16 +66,32 @@ impl Scheme for DisplayScheme {
|
||||||
|
|
||||||
fn write(&self, id: usize, buf: &[u8]) -> Result<usize> {
|
fn write(&self, id: usize, buf: &[u8]) -> Result<usize> {
|
||||||
if id == 1 {
|
if id == 1 {
|
||||||
|
if self.console.borrow().raw_mode {
|
||||||
for &b in buf.iter() {
|
for &b in buf.iter() {
|
||||||
self.input.borrow_mut().push_back(b);
|
self.input.borrow_mut().push_back(b);
|
||||||
if ! self.console.borrow().raw_mode {
|
}
|
||||||
if b == 0x7F {
|
|
||||||
self.write(0, b"\x08")?;
|
|
||||||
} else {
|
} else {
|
||||||
|
for &b in buf.iter() {
|
||||||
|
match b {
|
||||||
|
b'\x08' | b'\x7F' => {
|
||||||
|
if let Some(c) = self.cooked.borrow_mut().pop_back() {
|
||||||
|
self.write(0, b"\x08")?;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
b'\n' | b'\r' => {
|
||||||
|
self.cooked.borrow_mut().push_back(b);
|
||||||
|
while let Some(c) = self.cooked.borrow_mut().pop_front() {
|
||||||
|
self.input.borrow_mut().push_back(c);
|
||||||
|
}
|
||||||
|
self.write(0, b"\n")?;
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
self.cooked.borrow_mut().push_back(b);
|
||||||
self.write(0, &[b])?;
|
self.write(0, &[b])?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Ok(buf.len())
|
Ok(buf.len())
|
||||||
} else {
|
} else {
|
||||||
let mut display = self.display.borrow_mut();
|
let mut display = self.display.borrow_mut();
|
||||||
|
@ -135,6 +152,7 @@ fn main() {
|
||||||
unsafe { slice::from_raw_parts_mut(offscreen as *mut u32, size) }
|
unsafe { slice::from_raw_parts_mut(offscreen as *mut u32, size) }
|
||||||
)),
|
)),
|
||||||
input: RefCell::new(VecDeque::new()),
|
input: RefCell::new(VecDeque::new()),
|
||||||
|
cooked: RefCell::new(VecDeque::new()),
|
||||||
requested: RefCell::new(0)
|
requested: RefCell::new(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ pub fn main() {
|
||||||
|
|
||||||
println!("");
|
println!("");
|
||||||
|
|
||||||
print!("hash: '{}' ", password);
|
print!("hash: {}: '{}' ", user, password);
|
||||||
for b in output.iter() {
|
for b in output.iter() {
|
||||||
print!("{:X} ", b);
|
print!("{:X} ", b);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue