There was an error while loading. Please reload this page.
1 parent a970490 commit 0feed15Copy full SHA for 0feed15
2 files changed
kernel/src/device/input/mod.rs
@@ -501,7 +501,7 @@ fn key_byte(code: u16, state: &KeyboardState) -> Option<u8> {
501
input::KEY_KPASTERISK => Some(b'*'),
502
input::KEY_KPMINUS => Some(b'-'),
503
input::KEY_KPPLUS => Some(b'+'),
504
- input::KEY_KPENTER | input::KEY_ENTER => Some(b'\n'),
+ input::KEY_KPENTER | input::KEY_ENTER => Some(b'\r'),
505
input::KEY_BACKSPACE => Some(0x7f),
506
input::KEY_TAB => Some(b'\t'),
507
input::KEY_ESC => Some(0x1b),
@@ -534,7 +534,7 @@ fn ctrl_key_byte(code: u16) -> Option<u8> {
534
input::KEY_MINUS => Some(0x1f),
535
input::KEY_2 => Some(0x00),
536
input::KEY_8 => Some(0x7f),
537
538
539
540
kernel/src/device/tty/mod.rs
@@ -77,6 +77,14 @@ impl LineDiscipline {
77
self.termios.c_iflag & ICRNL != 0
78
}
79
80
+ fn is_igncr(&self) -> bool {
81
+ self.termios.c_iflag & IGNCR != 0
82
+ }
83
+
84
+ fn is_inlcr(&self) -> bool {
85
+ self.termios.c_iflag & INLCR != 0
86
87
88
fn cc(&self, idx: u32) -> u8 {
89
self.termios.c_cc[idx as usize]
90
@@ -98,8 +106,17 @@ impl LineDiscipline {
98
106
99
107
pub fn input_char(&mut self, mut byte: u8, tty: &Tty) -> Vec<u8> {
100
108
let mut output = Vec::new();
101
- if self.is_icrnl() && byte == b'\r' {
102
- byte = b'\n';
109
110
+ // CR/NL input translation.
111
+ if byte == b'\r' {
112
+ if self.is_igncr() {
113
+ return output;
114
115
+ if self.is_icrnl() {
116
+ byte = b'\n';
117
118
+ } else if byte == b'\n' && self.is_inlcr() {
119
+ byte = b'\r';
103
120
104
121
105
122
// Signal generation.
0 commit comments