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:
parent
95b353dae5
commit
34bdcb12e5
|
@ -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,
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace LibInput
|
|||
"å", "ä", "ö",
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\x7F", nullptr, nullptr, nullptr, nullptr, "\n", " ",
|
||||
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\x7F", nullptr, nullptr, nullptr, nullptr, "\r", " ",
|
||||
"!", "\"", "#", "¤", "%", "&", "/", "§", "½",
|
||||
"(", ")", "[", "]", "{", "}",
|
||||
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\b", "@", "£", "$", "€",
|
||||
|
@ -77,7 +77,7 @@ namespace LibInput
|
|||
"Å", "Ä", "Ö",
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\x7F", nullptr, nullptr, nullptr, nullptr, "\n", " ",
|
||||
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\x7F", nullptr, nullptr, nullptr, nullptr, "\r", " ",
|
||||
"!", "\"", "#", "¤", "%", "&", "/", "§", "½",
|
||||
"(", ")", "[", "]", "{", "}",
|
||||
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\b", "@", "£", "$", "€",
|
||||
|
@ -96,7 +96,7 @@ namespace LibInput
|
|||
"Å", "Ä", "Ö",
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\x7F", nullptr, nullptr, nullptr, nullptr, "\n", " ",
|
||||
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\x7F", nullptr, nullptr, nullptr, nullptr, "\r", " ",
|
||||
"!", "\"", "#", "¤", "%", "&", "/", "§", "½",
|
||||
"(", ")", "[", "]", "{", "}",
|
||||
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\b", "@", "£", "$", "€",
|
||||
|
|
Loading…
Reference in New Issue