/** * @file TextInput.h * @author apio (cloudapio.eu) * @brief Base class for text inputs. * * @copyright Copyright (c) 2024, the Luna authors. * */ #pragma once #include #include #include namespace ui { class TextInput : public Widget { public: TextInput(); virtual Result handle_key_event(const ui::KeyEventRequest& request) = 0; virtual Result draw(ui::Canvas& canvas) = 0; protected: Buffer m_data; usize m_cursor { 0 }; ui::Point m_cursor_position { 0, 0 }; OwnedPtr m_cursor_timer; bool m_cursor_activated = true; void tick_cursor(); void update_cursor(); Result delete_current_character(); Result insert_character(char c); }; }