diff --git a/kernel/include/kernel/Shell.h b/kernel/include/kernel/Shell.h index 42827dd5..c2aa38f7 100644 --- a/kernel/include/kernel/Shell.h +++ b/kernel/include/kernel/Shell.h @@ -11,17 +11,12 @@ namespace Kernel class Shell { public: + Shell(TTY*); Shell(const Shell&) = delete; - - static Shell& Get(); - - void SetTTY(TTY* tty); void SetPrompt(BAN::StringView); - void Run(); private: - Shell(); void ReRenderBuffer() const; void ProcessCommand(const BAN::Vector&); void KeyEventCallback(Input::KeyEvent); diff --git a/kernel/kernel/Shell.cpp b/kernel/kernel/Shell.cpp index 7511d132..81a83112 100644 --- a/kernel/kernel/Shell.cpp +++ b/kernel/kernel/Shell.cpp @@ -18,7 +18,7 @@ namespace Kernel { using namespace BAN; - static Shell* s_instance = nullptr; + static auto s_default_prompt = "\\[\e[32m\\]user\\[\e[m\\]# "_sv; static uint8_t s_pointer[] { ________, @@ -39,18 +39,12 @@ namespace Kernel X_______, }; - Shell& Shell::Get() + Shell::Shell(TTY* tty) + : m_tty(tty) { - if (!s_instance) - s_instance = new Shell(); - return *s_instance; - } - - Shell::Shell() - { - SetPrompt("\\[\e[32m\\]user\\[\e[m\\]# "_sv); Input::register_key_event_callback({ &Shell::KeyEventCallback, this }); Input::register_mouse_move_event_callback({ &Shell::MouseMoveEventCallback, this }); + SetPrompt(s_default_prompt); MUST(m_buffer.PushBack(""_sv)); } @@ -78,14 +72,8 @@ namespace Kernel } } - void Shell::SetTTY(TTY* tty) - { - m_tty = tty; - } - void Shell::Run() { - ASSERT(m_tty); TTY_PRINT("{}", m_prompt); for (;;) { diff --git a/kernel/kernel/kernel.cpp b/kernel/kernel/kernel.cpp index b55363b4..550efc55 100644 --- a/kernel/kernel/kernel.cpp +++ b/kernel/kernel/kernel.cpp @@ -95,8 +95,7 @@ extern "C" void kernel_main() kprintln("Hello from the kernel!"); - auto& shell = Kernel::Shell::Get(); - shell.SetTTY(tty1); + Kernel::Shell shell(tty1); shell.Run(); for (;;)