terminal: implement nl to crnl
This commit is contained in:
@@ -111,12 +111,22 @@ impl<O: TerminalOutput> Terminal<O> {
|
||||
}
|
||||
|
||||
pub fn putc_to_output(&self, byte: u8) -> Result<(), Error> {
|
||||
let config = self.config.read().output;
|
||||
if byte == b'\n' && config.contains(TerminalOutputOptions::NL_TO_CRNL) {
|
||||
self.output.write(b'\r').ok();
|
||||
}
|
||||
self.output.write(byte)
|
||||
}
|
||||
|
||||
pub fn write_to_output(&self, buffer: &[u8]) -> Result<usize, Error> {
|
||||
// TODO handle options
|
||||
self.output.write_multiple(buffer)
|
||||
let config = self.config.read().output;
|
||||
for &byte in buffer {
|
||||
if byte == b'\n' && config.contains(TerminalOutputOptions::NL_TO_CRNL) {
|
||||
self.output.write(b'\r').ok();
|
||||
}
|
||||
self.output.write(byte)?;
|
||||
}
|
||||
Ok(buffer.len())
|
||||
}
|
||||
|
||||
pub fn write_to_input(&self, mut byte: u8) {
|
||||
|
||||
Reference in New Issue
Block a user