ui_interface.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #include "lumacs/editor_core.hpp" // For EditorEvent and other core types
  3. namespace lumacs {
  4. // Forward declaration to avoid circular dependency
  5. class EditorCore;
  6. /// @brief Abstract interface for a Lumacs editor UI frontend.
  7. ///
  8. /// All editor UIs (ncurses, GTK, etc.) must implement this interface.
  9. /// This decouples the core logic from the specific display technology.
  10. class IEditorView {
  11. public:
  12. virtual ~IEditorView() = default;
  13. /// @brief Initialize the UI system (e.g., ncurses init, GTK window setup).
  14. /// This should be called before run().
  15. virtual void init() = 0;
  16. /// @brief Run the main UI loop.
  17. /// This method should block until the UI exits (e.g., gtk_main()).
  18. virtual void run() = 0;
  19. /// @brief Handle events emitted by the EditorCore.
  20. /// The EditorCore will notify the view of model changes (buffer modified, cursor moved).
  21. /// @param event The event type.
  22. virtual void handle_editor_event(EditorEvent event) = 0;
  23. /// @brief Set the EditorCore instance for the view to interact with.
  24. /// This is typically called once during setup.
  25. /// @param core Pointer to the core logic instance.
  26. virtual void set_core(EditorCore* core) = 0;
  27. };
  28. } // namespace lumacs