2022-12-13 21:34:50 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <BAN/String.h>
|
2023-01-13 15:07:24 +02:00
|
|
|
#include <BAN/Vector.h>
|
2023-03-29 03:05:16 +03:00
|
|
|
#include <kernel/Input/KeyEvent.h>
|
2022-12-13 21:34:50 +02:00
|
|
|
|
|
|
|
namespace Kernel
|
|
|
|
{
|
|
|
|
|
|
|
|
class Shell
|
|
|
|
{
|
|
|
|
public:
|
2023-04-05 00:56:09 +03:00
|
|
|
Shell();
|
2022-12-13 21:34:50 +02:00
|
|
|
Shell(const Shell&) = delete;
|
2023-03-17 21:16:22 +02:00
|
|
|
BAN::ErrorOr<void> set_prompt(BAN::StringView);
|
2023-02-01 21:05:44 +02:00
|
|
|
void run();
|
2022-12-13 21:34:50 +02:00
|
|
|
|
|
|
|
private:
|
2023-02-01 21:05:44 +02:00
|
|
|
void rerender_buffer() const;
|
|
|
|
BAN::Vector<BAN::String> parse_arguments(BAN::StringView) const;
|
2023-03-08 17:05:37 +02:00
|
|
|
BAN::ErrorOr<void> process_command(const BAN::Vector<BAN::String>&);
|
2023-03-17 21:16:22 +02:00
|
|
|
BAN::ErrorOr<void> update_prompt();
|
2022-12-13 21:34:50 +02:00
|
|
|
|
2023-04-05 01:30:58 +03:00
|
|
|
private:
|
2023-01-13 15:07:24 +02:00
|
|
|
BAN::Vector<BAN::String> m_old_buffer;
|
|
|
|
BAN::Vector<BAN::String> m_buffer;
|
2023-03-17 21:16:22 +02:00
|
|
|
BAN::String m_prompt_string;
|
2023-01-13 15:07:24 +02:00
|
|
|
BAN::String m_prompt;
|
|
|
|
uint32_t m_prompt_length = 0;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32_t line = 0;
|
|
|
|
uint32_t col = 0;
|
|
|
|
uint32_t index = 0;
|
|
|
|
} m_cursor_pos;
|
2022-12-13 21:34:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|