Kernel: Improve error handling when setting TTY font

This commit is contained in:
2025-04-18 02:42:24 +03:00
parent d6667844de
commit cef8779bf7
6 changed files with 13 additions and 14 deletions

View File

@@ -22,7 +22,7 @@ namespace Kernel
virtual bool has_font() const override { return true; }
virtual void set_font(const LibFont::Font& font) override { m_font = font; };
virtual void set_font(LibFont::Font&& font) override { m_font = BAN::move(font); };
virtual const LibFont::Font& font() const override { return m_font; };
private:

View File

@@ -15,7 +15,7 @@ namespace Kernel
class TTY : public CharacterDevice
{
public:
virtual void set_font(const LibFont::Font&) {};
virtual BAN::ErrorOr<void> set_font(LibFont::Font&&) { return BAN::Error::from_errno(EINVAL); }
void set_foreground_pgrp(pid_t pgrp) { m_foreground_pgrp = pgrp; }
pid_t foreground_pgrp() const { return m_foreground_pgrp; }

View File

@@ -37,8 +37,8 @@ namespace Kernel
virtual void set_cursor_position(uint32_t, uint32_t) = 0;
virtual bool has_font() const { return false; }
virtual void set_font(const LibFont::Font&) { ASSERT_NOT_REACHED(); };
virtual const LibFont::Font& font() const { ASSERT_NOT_REACHED(); };
virtual BAN::ErrorOr<void> set_font(LibFont::Font&&) { return BAN::Error::from_errno(EINVAL); }
virtual const LibFont::Font& font() const { ASSERT_NOT_REACHED(); }
};
extern BAN::RefPtr<TerminalDriver> g_terminal_driver;

View File

@@ -14,7 +14,7 @@ namespace Kernel
public:
static BAN::ErrorOr<BAN::RefPtr<VirtualTTY>> create(BAN::RefPtr<TerminalDriver>);
virtual void set_font(const LibFont::Font&) override;
virtual BAN::ErrorOr<void> set_font(LibFont::Font&&) override;
virtual uint32_t height() const override { return m_height; }
virtual uint32_t width() const override { return m_width; }