mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:27:45 +00:00
LibVT: Fix newline handling
Before this commit, we would jump to the first column after receiving the '\n' line feed character. This is not the correct behavior, as it should only move the cursor now. Translating the typed Return key into the correct CR LF ("\r\n") is the TTY's job, which was fixed in #7184. Fixes #6820 Fixes #6960
This commit is contained in:
parent
f25209113f
commit
5d80debc1f
4 changed files with 19 additions and 14 deletions
|
@ -521,7 +521,7 @@ void Terminal::DCH(Parameters params)
|
|||
}
|
||||
#endif
|
||||
|
||||
void Terminal::newline()
|
||||
void Terminal::linefeed()
|
||||
{
|
||||
u16 new_row = m_cursor_row;
|
||||
if (m_cursor_row == m_scroll_region_bottom) {
|
||||
|
@ -529,8 +529,11 @@ void Terminal::newline()
|
|||
} else {
|
||||
++new_row;
|
||||
};
|
||||
set_cursor(new_row, 0);
|
||||
// We shouldn't jump to the first column after receiving a line feed.
|
||||
// The TTY will take care of generating the carriage return.
|
||||
set_cursor(new_row, m_cursor_column);
|
||||
}
|
||||
|
||||
void Terminal::carriage_return()
|
||||
{
|
||||
set_cursor(m_cursor_row, 0);
|
||||
|
@ -591,7 +594,7 @@ void Terminal::set_cursor(unsigned a_row, unsigned a_column)
|
|||
|
||||
void Terminal::NEL()
|
||||
{
|
||||
newline();
|
||||
linefeed();
|
||||
carriage_return();
|
||||
}
|
||||
|
||||
|
@ -658,7 +661,7 @@ void Terminal::emit_code_point(u32 code_point)
|
|||
if (m_stomp) {
|
||||
m_stomp = false;
|
||||
carriage_return();
|
||||
newline();
|
||||
linefeed();
|
||||
put_character_at(m_cursor_row, m_cursor_column, code_point);
|
||||
set_cursor(m_cursor_row, 1);
|
||||
} else {
|
||||
|
@ -690,7 +693,9 @@ void Terminal::execute_control_code(u8 code)
|
|||
return;
|
||||
}
|
||||
case '\n':
|
||||
newline();
|
||||
case '\v':
|
||||
case '\f':
|
||||
linefeed();
|
||||
return;
|
||||
case '\r':
|
||||
carriage_return();
|
||||
|
@ -961,6 +966,11 @@ void Terminal::handle_key_press(KeyCode key, u32 code_point, u8 flags)
|
|||
case KeyCode::Key_PageDown:
|
||||
emit_tilde_with_modifier(6);
|
||||
return;
|
||||
case KeyCode::Key_Return:
|
||||
// The standard says that CR should be generated by the return key.
|
||||
// The TTY will take care of translating it to CR LF for the terminal.
|
||||
emit_string("\r");
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue