mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +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
Notes:
sideshowbarker
2024-07-18 17:56:52 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/5d80debc1f8 Pull-request: https://github.com/SerenityOS/serenity/pull/7213 Issue: https://github.com/SerenityOS/serenity/issues/6820 Issue: https://github.com/SerenityOS/serenity/issues/6960
4 changed files with 19 additions and 14 deletions
|
@ -68,7 +68,7 @@ void ConsoleImpl::scroll_up()
|
|||
void ConsoleImpl::scroll_down()
|
||||
{
|
||||
}
|
||||
void ConsoleImpl::newline()
|
||||
void ConsoleImpl::linefeed()
|
||||
{
|
||||
u16 new_row = m_cursor_row;
|
||||
u16 max_row = rows() - 1;
|
||||
|
@ -383,10 +383,6 @@ void VirtualConsole::scroll_up()
|
|||
m_console_impl.m_need_full_flush = true;
|
||||
}
|
||||
|
||||
void VirtualConsole::newline()
|
||||
{
|
||||
}
|
||||
|
||||
void VirtualConsole::clear_line(size_t y_index)
|
||||
{
|
||||
m_lines[y_index].dirty = true;
|
||||
|
|
|
@ -38,7 +38,7 @@ private:
|
|||
|
||||
virtual void scroll_up() override;
|
||||
virtual void scroll_down() override;
|
||||
virtual void newline() override;
|
||||
virtual void linefeed() override;
|
||||
virtual void put_character_at(unsigned row, unsigned column, u32 ch) override;
|
||||
virtual void set_window_title(const String&) override;
|
||||
|
||||
|
@ -137,7 +137,6 @@ private:
|
|||
|
||||
void scroll_down();
|
||||
void scroll_up();
|
||||
void newline();
|
||||
void clear_line(size_t index);
|
||||
void put_character_at(unsigned row, unsigned column, u32 ch, const VT::Attribute&);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -161,13 +161,13 @@ protected:
|
|||
#ifndef KERNEL
|
||||
void scroll_up();
|
||||
void scroll_down();
|
||||
void newline();
|
||||
void linefeed();
|
||||
void put_character_at(unsigned row, unsigned column, u32 ch);
|
||||
void set_window_title(const String&);
|
||||
#else
|
||||
virtual void scroll_up() = 0;
|
||||
virtual void scroll_down() = 0;
|
||||
virtual void newline() = 0;
|
||||
virtual void linefeed() = 0;
|
||||
virtual void put_character_at(unsigned row, unsigned column, u32 ch) = 0;
|
||||
virtual void set_window_title(const String&) = 0;
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue