Kernel/Terminal: Add support for ANSI DSR

This commit is contained in:
Bananymous 2025-04-23 06:10:38 +03:00
parent 8a00b53050
commit 28bf2d6374
2 changed files with 26 additions and 3 deletions

View File

@ -360,11 +360,24 @@ namespace Kernel
return reset_ansi();
}
reset_ansi();
dprintln_if(DEBUG_VTTY, "invalid ANSI CSI ?{}{}", m_ansi_state.nums[0], (char)ch);
dprintln_if(DEBUG_VTTY, "invalid ANSI CSI character {}", static_cast<char>(ch));
return;
case 'n':
if (m_ansi_state.nums[0] == 6)
{
char buffer[2 + 10 + 1 + 10 + 1];
size_t len = 0;
BAN::Formatter::print([&](char ch) { buffer[len++] = ch; }, "\e[{};{}R", m_row + 1, m_column + 1);
for (size_t i = 0; i < len; i++)
handle_input_byte(buffer[i]);
return reset_ansi();
};
reset_ansi();
dprintln_if(DEBUG_VTTY, "Unsupported ANSI CSI character n");
return;
default:
reset_ansi();
dprintln_if(DEBUG_VTTY, "Unsupported ANSI CSI character {}", ch);
dprintln_if(DEBUG_VTTY, "Unsupported ANSI CSI character {}", static_cast<char>(ch));
return;
}
}

View File

@ -517,11 +517,21 @@ Rectangle Terminal::handle_csi(char ch)
case 'l':
if (!m_csi_info.question || m_csi_info.fields[0] != 25)
{
dprintln("invalid ANSI CSI ?{}{}", m_csi_info.fields[0], (char)ch);
dprintln("unsupported ANSI CSI {}", ch);
break;
}
m_cursor_shown = (ch == 'h');
break;
case 'n':
if (m_csi_info.fields[0] != 6)
{
dprintln("unsupported ANSI CSI n");
break;
}
char buffer[2 + 10 + 1 + 10 + 2];
sprintf(buffer, "\e[%u;%uR", m_cursor.y + 1, m_cursor.x + 1);
write(m_shell_info.pts_master, buffer, strlen(buffer));
break;
default:
dprintln("TODO: CSI {}", ch);
break;