Kernel: Clear TTY when setting as current

Actually this should replace from old buffer, but this works
for now.
This commit is contained in:
Bananymous 2023-10-13 17:20:26 +03:00
parent c7b6fc950a
commit dafc016293
4 changed files with 10 additions and 4 deletions

View File

@ -43,7 +43,8 @@ namespace Kernel
virtual uint32_t width() const override; virtual uint32_t width() const override;
virtual uint32_t height() const override; virtual uint32_t height() const override;
virtual void putchar_impl(uint8_t) override;
virtual void clear() override { putchar_impl('\e'); putchar_impl('['); putchar_impl('2'); putchar_impl('J'); }
virtual void update() override; virtual void update() override;
@ -51,6 +52,7 @@ namespace Kernel
protected: protected:
virtual BAN::StringView name() const override { return m_name; } virtual BAN::StringView name() const override { return m_name; }
virtual void putchar_impl(uint8_t) override;
private: private:
SerialTTY(Serial); SerialTTY(Serial);

View File

@ -38,7 +38,8 @@ namespace Kernel
virtual uint32_t height() const = 0; virtual uint32_t height() const = 0;
virtual uint32_t width() const = 0; virtual uint32_t width() const = 0;
void putchar(uint8_t ch); void putchar(uint8_t ch);
virtual void putchar_impl(uint8_t ch) = 0;
virtual void clear() = 0;
virtual bool has_data_impl() const override; virtual bool has_data_impl() const override;
@ -47,6 +48,7 @@ namespace Kernel
: CharacterDevice(mode, uid, gid) : CharacterDevice(mode, uid, gid)
{ } { }
virtual void putchar_impl(uint8_t ch) = 0;
virtual BAN::ErrorOr<size_t> read_impl(off_t, void*, size_t) override; virtual BAN::ErrorOr<size_t> read_impl(off_t, void*, size_t) override;
virtual BAN::ErrorOr<size_t> write_impl(off_t, const void*, size_t) override; virtual BAN::ErrorOr<size_t> write_impl(off_t, const void*, size_t) override;

View File

@ -21,15 +21,16 @@ namespace Kernel
virtual uint32_t height() const override { return m_height; } virtual uint32_t height() const override { return m_height; }
virtual uint32_t width() const override { return m_width; } virtual uint32_t width() const override { return m_width; }
virtual void putchar_impl(uint8_t ch) override;
virtual void clear() override;
protected: protected:
virtual BAN::StringView name() const override { return m_name; } virtual BAN::StringView name() const override { return m_name; }
virtual void putchar_impl(uint8_t ch) override;
private: private:
VirtualTTY(TerminalDriver*); VirtualTTY(TerminalDriver*);
void clear();
void reset_ansi(); void reset_ansi();
void handle_ansi_csi(uint8_t ch); void handle_ansi_csi(uint8_t ch);
void handle_ansi_csi_color(); void handle_ansi_csi_color();

View File

@ -27,6 +27,7 @@ namespace Kernel
void TTY::set_as_current() void TTY::set_as_current()
{ {
s_tty = this; s_tty = this;
clear();
auto inode_or_error = DevFileSystem::get().root_inode()->find_inode("tty"sv); auto inode_or_error = DevFileSystem::get().root_inode()->find_inode("tty"sv);
if (inode_or_error.is_error()) if (inode_or_error.is_error())