mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 06:02:07 +03:00
Make /bin/clear work again.
After I made stdio buffered, we were dropping anything unflushed on exit. Since /bin/clear just prints out some escape sequences without a newline, the entire buffer was being discarded. Also add VirtualConsole::clear() that handles clearing of background VC's.
This commit is contained in:
parent
3e3de67f02
commit
8605711f4b
Notes:
sideshowbarker
2024-07-19 16:11:41 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/8605711f4bb
@ -39,6 +39,16 @@ VirtualConsole::~VirtualConsole()
|
||||
{
|
||||
}
|
||||
|
||||
void VirtualConsole::clear()
|
||||
{
|
||||
word* linemem = m_active ? (word*)s_vga_buffer : (word*)m_buffer;
|
||||
for (word i = 0; i < 80 * 25; ++i)
|
||||
linemem[i] = 0x0720;
|
||||
if (m_active)
|
||||
set_vga_start_row(0);
|
||||
set_cursor(0, 0);
|
||||
}
|
||||
|
||||
void VirtualConsole::switch_to(unsigned index)
|
||||
{
|
||||
if ((int)index == s_active_console)
|
||||
@ -248,11 +258,11 @@ void VirtualConsole::escape$J(const Vector<unsigned>& params)
|
||||
notImplemented();
|
||||
break;
|
||||
case 2:
|
||||
vga_clear();
|
||||
clear();
|
||||
break;
|
||||
case 3:
|
||||
// FIXME: <esc>[3J should also clear the scrollback buffer.
|
||||
vga_clear();
|
||||
clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ private:
|
||||
void escape$s(const Vector<unsigned>&);
|
||||
void escape$u(const Vector<unsigned>&);
|
||||
|
||||
void clear();
|
||||
|
||||
const byte m_rows { 25 };
|
||||
const byte m_columns { 80 };
|
||||
byte m_cursor_row { 0 };
|
||||
|
@ -41,6 +41,9 @@ extern "C" int _start()
|
||||
goto epilogue;
|
||||
status = main(argc, argv);
|
||||
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
epilogue:
|
||||
Syscall::invoke(Syscall::SC_exit, status);
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
#include <LibC/stdio.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
printf("\033[3J\033[H\033[2J");
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user