Shell: rewrite the whole shell to use tokens instead of raw strings

tab completion is still running with raw strings and that has to be
fixed in the future.
This commit is contained in:
2024-10-13 21:56:59 +03:00
parent dab6e5a60f
commit 8adc97980a
18 changed files with 2721 additions and 1732 deletions

View File

@@ -0,0 +1,36 @@
#pragma once
#include <BAN/NoCopyMove.h>
#include <BAN/String.h>
#include <BAN/Optional.h>
#include <BAN/Vector.h>
#include <sys/types.h>
#include <termios.h>
class Input
{
BAN_NON_COPYABLE(Input);
BAN_NON_MOVABLE(Input);
public:
Input();
BAN::Optional<BAN::String> get_input(BAN::Optional<BAN::StringView> custom_prompt);
private:
BAN::String parse_ps1_prompt();
private:
BAN::String m_hostname;
BAN::Vector<BAN::String> m_buffers { 1, ""_sv };
BAN::Vector<BAN::String> m_history;
size_t m_buffer_index { 0 };
size_t m_buffer_col { 0 };
BAN::Optional<ssize_t> m_tab_index;
BAN::Optional<BAN::Vector<BAN::String>> m_tab_completions;
size_t m_tab_completion_keep { 0 };
int m_waiting_utf8 { 0 };
};