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)
|
PseudoTerminalSlave::PseudoTerminalSlave(BAN::String&& name, uint32_t number, mode_t mode, uid_t uid, gid_t gid)
|
||||||
: TTY({
|
: TTY({
|
||||||
.c_iflag = 0,
|
.c_iflag = ICRNL,
|
||||||
.c_oflag = 0,
|
.c_oflag = 0,
|
||||||
.c_cflag = CS8,
|
.c_cflag = CS8,
|
||||||
.c_lflag = ECHO | ECHOE | ECHOK | ICANON | ISIG,
|
.c_lflag = ECHO | ECHOE | ECHOK | ICANON | ISIG,
|
||||||
|
|
|
@ -243,19 +243,14 @@ namespace Kernel
|
||||||
|
|
||||||
LockGuard _(m_mutex);
|
LockGuard _(m_mutex);
|
||||||
|
|
||||||
if (m_termios.c_lflag & ICANON)
|
if ((m_termios.c_iflag & ISTRIP))
|
||||||
{
|
ch &= 0x7F;
|
||||||
if ((m_termios.c_iflag & ISTRIP))
|
if ((m_termios.c_iflag & IGNCR) && ch == CR)
|
||||||
ch &= 0x7F;
|
return;
|
||||||
if ((m_termios.c_iflag & IGNCR) && ch == CR)
|
if ((m_termios.c_iflag & ICRNL) && ch == CR)
|
||||||
return;
|
ch = NL;
|
||||||
uint8_t conv = ch;
|
else if ((m_termios.c_iflag & INLCR) && ch == NL)
|
||||||
if ((m_termios.c_iflag & ICRNL) && ch == CR)
|
ch = CR;
|
||||||
conv = NL;
|
|
||||||
if ((m_termios.c_iflag & INLCR) && ch == NL)
|
|
||||||
conv = CR;
|
|
||||||
ch = conv;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_termios.c_lflag & ISIG)
|
if (m_termios.c_lflag & ISIG)
|
||||||
{
|
{
|
||||||
|
@ -298,11 +293,10 @@ namespace Kernel
|
||||||
should_flush = true;
|
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;
|
should_flush = true;
|
||||||
force_echo = !!(m_termios.c_lflag & ECHONL);
|
force_echo = !!(m_termios.c_lflag & ECHONL);
|
||||||
ch = NL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Kernel
|
||||||
|
|
||||||
VirtualTTY::VirtualTTY(BAN::RefPtr<TerminalDriver> driver)
|
VirtualTTY::VirtualTTY(BAN::RefPtr<TerminalDriver> driver)
|
||||||
: TTY({
|
: TTY({
|
||||||
.c_iflag = 0,
|
.c_iflag = ICRNL,
|
||||||
.c_oflag = 0,
|
.c_oflag = 0,
|
||||||
.c_cflag = CS8,
|
.c_cflag = CS8,
|
||||||
.c_lflag = ECHO | ECHOE | ECHOK | ICANON | ISIG,
|
.c_lflag = ECHO | ECHOE | ECHOK | ICANON | ISIG,
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace LibInput
|
||||||
"å", "ä", "ö",
|
"å", "ä", "ö",
|
||||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
||||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
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", "@", "£", "$", "€",
|
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\b", "@", "£", "$", "€",
|
||||||
|
@ -77,7 +77,7 @@ namespace LibInput
|
||||||
"Å", "Ä", "Ö",
|
"Å", "Ä", "Ö",
|
||||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
||||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
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", "@", "£", "$", "€",
|
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\b", "@", "£", "$", "€",
|
||||||
|
@ -96,7 +96,7 @@ namespace LibInput
|
||||||
"Å", "Ä", "Ö",
|
"Å", "Ä", "Ö",
|
||||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
||||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
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", "@", "£", "$", "€",
|
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\b", "@", "£", "$", "€",
|
||||||
|
|
Loading…
Reference in New Issue