/** * @file EditorWidget.h * @author apio (cloudapio.eu) * @brief Multiline text editing widget. * * @copyright Copyright (c) 2024, the Luna authors. * */ #include #include #include #include #include class EditorWidget : public ui::TextInput { public: EditorWidget(SharedPtr font); Result load_file(const os::Path& path); Result save_file(); Result save_file_as(); Result handle_key_event(const ui::KeyEventRequest& request) override; Result draw(ui::Canvas& canvas) override; os::Path path() { return m_path.view(); } private: SharedPtr m_font; struct Line { usize begin; usize end; }; Vector m_lines; String m_path; Result recalculate_lines(); void recalculate_cursor_position(); void recalculate_cursor_index(); };