#pragma once #include "DI/auto_wirable.hpp" #include "interfaces/command.hpp" #include "interfaces/input.hpp" #include "interfaces/observable.hpp" #include #include #include #include #include class InputHandler : public IInputHandler, public AutoWirable { public: InputHandler() noexcept = default; void listen() const noexcept override; void attach(const char &key, const std::shared_ptr &command) noexcept override; void notify(const char &key) const noexcept override; void enter_raw_mode() noexcept override; void leave_raw_mode() noexcept override; private: std::array>, CHAR_MAX> _key_commands; std::shared_ptr _original_termios = nullptr; using _KeyCommandsSizeType = decltype(_key_commands)::size_type; static _KeyCommandsSizeType _key_as_index(const char &key) noexcept; };