GUI Frontend Roadmap: Lumacs with GTK4 (gtkmm)
This document outlines the phased approach to integrate a graphical frontend into Lumacs, utilizing GTK4 with its C++ bindings (gtkmm). The goal is to provide a rich, native user experience while leveraging the existing C++ core and Lua extensibility.
Phase 0: Preparation (Current State)
- Status: Complete
- Description: Core editor logic (EditorCore, Buffer) is decoupled from the UI. An abstract
Face system is implemented, allowing for UI-agnostic styling definitions.
- Key Achievements:
- Abstract
Face system in include/lumacs/face.hpp
Theme system refactored to manage Face definitions
Buffer stores face_name for styling ranges
NcursesEditor renders Faces to best of its ability (colors, bold, italic)
Phase 1: Abstract UI Interface Extraction
- Status: Complete
- Goal: Define a clean separation between
EditorCore and any UI frontend.
- Achievements:
IEditorView interface defined in include/lumacs/ui_interface.hpp.
NcursesEditor refactored to TuiEditor implementing IEditorView.
EditorCore decoupled from specific UI implementation.
Phase 2: GTK4 Environment Setup & Basic Window
- Status: Complete
- Goal: Integrate GTK4 into the build system and display a minimal window.
- Achievements:
- Updated
CMakeLists.txt with gtkmm-4.0 dependency.
- Created
src/gtk_editor.cpp implementing IEditorView.
- Single binary architecture with
-nw fallback.
Phase 3: Displaying Buffer Content
- Status: Complete
- Goal: Render the active buffer's text content within the GTK window.
- Achievements:
- Implemented
GtkEditor::on_draw using Cairo and Pango.
- Text rendering works with font metrics.
Phase 4: Styling with Faces
- Status: Complete
- Goal: Implement the
Face system within GtkEditor to render styled text.
- Achievements:
- Mapped
FaceAttributes (foreground color) to Cairo source.
- Cursor rendering implemented.
Phase 5: Input Handling & Minibuffer
- Status: Complete (Prototype)
- Goal: Capture keyboard input and integrate with the minibuffer and other interactive UI elements.
- Achievements:
- Implemented
GtkEditor::on_key_pressed.
- Mapped GDK key events to Lumacs key strings (with modifiers).
- Minibuffer command input works.
Phase 6: Full UI Feature Parity
- Status: In Progress
- Goal: Implement all existing features of
TuiEditor (window splits, status lines, messages, marks, regions) in GtkEditor.
- Completed Tasks:
Stability: Fix crash on exit. ✅ (2025-11-27)
- Fixed double-free by clearing event callbacks before view destruction
- Added null safety checks in draw and event handlers
- Proper GTK Application/Window lifetime management
Character Input: Self-insert for printable characters. ✅ (2025-11-27)
- Added fallback handler for unbound printable keys
- Characters now render correctly when typed
Cursor Rendering: Visible inverted block cursor. ✅ (2025-11-27)
- Cursor draws with theme color and inverted character
- Remaining Tasks:
- Status Line/Modelines: Render status bars for each window. (Basic implementation done)
- Window Splits: Implement window splitting logic using GTK containers (e.g.,
Gtk::Paned or Gtk::Grid).
- Scrolling: Implement visual scrolling (viewport offset).
Future Considerations
- High-DPI Support: Ensure crisp rendering on high-resolution displays.
- Accessibility: Integrate with GTK's accessibility features.
- Native File Dialogs: Use
Gtk::FileChooserDialog for find-file and save-as.