Kernel: Fix termios and enter key handling
Enter key now produces expected \r which gets converted to \n by default by the ICRNL input flag. Also input flags are now handled always, not just when ICANON is set. I don't know why I though ICANON should disable input handling
This commit is contained in:
@@ -165,7 +165,7 @@ namespace Kernel
|
||||
|
||||
PseudoTerminalSlave::PseudoTerminalSlave(BAN::String&& name, uint32_t number, mode_t mode, uid_t uid, gid_t gid)
|
||||
: TTY({
|
||||
.c_iflag = 0,
|
||||
.c_iflag = ICRNL,
|
||||
.c_oflag = 0,
|
||||
.c_cflag = CS8,
|
||||
.c_lflag = ECHO | ECHOE | ECHOK | ICANON | ISIG,
|
||||
|
||||
@@ -243,19 +243,14 @@ namespace Kernel
|
||||
|
||||
LockGuard _(m_mutex);
|
||||
|
||||
if (m_termios.c_lflag & ICANON)
|
||||
{
|
||||
if ((m_termios.c_iflag & ISTRIP))
|
||||
ch &= 0x7F;
|
||||
if ((m_termios.c_iflag & IGNCR) && ch == CR)
|
||||
return;
|
||||
uint8_t conv = ch;
|
||||
if ((m_termios.c_iflag & ICRNL) && ch == CR)
|
||||
conv = NL;
|
||||
if ((m_termios.c_iflag & INLCR) && ch == NL)
|
||||
conv = CR;
|
||||
ch = conv;
|
||||
}
|
||||
if ((m_termios.c_iflag & ISTRIP))
|
||||
ch &= 0x7F;
|
||||
if ((m_termios.c_iflag & IGNCR) && ch == CR)
|
||||
return;
|
||||
if ((m_termios.c_iflag & ICRNL) && ch == CR)
|
||||
ch = NL;
|
||||
else if ((m_termios.c_iflag & INLCR) && ch == NL)
|
||||
ch = CR;
|
||||
|
||||
if (m_termios.c_lflag & ISIG)
|
||||
{
|
||||
@@ -298,11 +293,10 @@ namespace Kernel
|
||||
should_flush = true;
|
||||
}
|
||||
|
||||
if (ch == NL || ch == m_termios.c_cc[VEOL])
|
||||
if (ch == NL || ch == CR || ch == m_termios.c_cc[VEOL])
|
||||
{
|
||||
should_flush = true;
|
||||
force_echo = !!(m_termios.c_lflag & ECHONL);
|
||||
ch = NL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Kernel
|
||||
|
||||
VirtualTTY::VirtualTTY(BAN::RefPtr<TerminalDriver> driver)
|
||||
: TTY({
|
||||
.c_iflag = 0,
|
||||
.c_iflag = ICRNL,
|
||||
.c_oflag = 0,
|
||||
.c_cflag = CS8,
|
||||
.c_lflag = ECHO | ECHOE | ECHOK | ICANON | ISIG,
|
||||
|
||||
Reference in New Issue
Block a user