| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #pragma once
- #include <functional> // Required for EventCallback
- namespace lumacs {
- // Forward declarations
- class EditorCore;
- /// @brief Editor state change events triggered by core actions.
- /// Used by the UI layer to react to model updates.
- enum class EditorEvent {
- BufferModified, ///< The content of the active buffer has changed.
- CursorMoved, ///< The cursor position has changed.
- ViewportChanged, ///< The visible area (scroll/size) has changed.
- WindowLayoutChanged, ///< The window tree structure (splits) has changed.
- WindowFocused, ///< A different window has gained focus.
- Message, ///< A transient message should be displayed (e.g., in minibuffer).
-
- // Modal Interaction Events
- CommandMode, ///< Enter command input mode (M-x).
- BufferSwitchMode, ///< Enter buffer switching mode (C-x b).
- KillBufferMode, ///< Enter kill buffer mode (C-x k).
- FindFileMode, ///< Enter file finding mode (C-x C-f).
- ThemeSelectionMode, ///< Enter theme selection mode.
- ISearchMode, ///< Enter incremental search mode (C-s).
- ISearchBackwardMode, ///< Enter backward incremental search mode (C-r).
-
- TransientMessageCleared, ///< A transient message has been cleared.
- Quit, ///< The application should exit.
- ThemeChanged, ///< The active theme has changed.
- FontChanged ///< The font size has changed.
- };
- /// @brief Abstract interface for a Lumacs editor UI frontend.
- ///
- /// All editor UIs (ncurses, GTK, etc.) must implement this interface.
- /// This decouples the core logic from the specific display technology.
- class IEditorView {
- public:
- virtual ~IEditorView() = default;
- /// @brief Initialize the UI system (e.g., ncurses init, GTK window setup).
- /// This should be called before run().
- virtual void init() = 0;
- /// @brief Run the main UI loop.
- /// This method should block until the UI exits (e.g., gtk_main()).
- virtual void run() = 0;
- /// @brief Handle events emitted by the EditorCore.
- /// The EditorCore will notify the view of model changes (buffer modified, cursor moved).
- /// @param event The event type.
- virtual void handle_editor_event(EditorEvent event) = 0;
- /// @brief Set the EditorCore instance for the view to interact with.
- /// This is typically called once during setup.
- /// @param core Pointer to the core logic instance.
- virtual void set_core(EditorCore* core) = 0;
- };
- } // namespace lumacs
|