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.
Face system is implemented, allowing for UI-agnostic styling definitions.Face system in include/lumacs/face.hppTheme system refactored to manage Face definitionsBuffer stores face_name for styling rangesNcursesEditor renders Faces to best of its ability (colors, bold, italic)EditorCore and any UI frontend.IEditorView Interface: Create an abstract base class (e.g., IEditorView or EditorFrontend) in include/lumacs/ui_interface.hpp that EditorCore will interact with. This interface will declare methods for:
NcursesEditor:
NcursesEditor to TuiEditor.TuiEditor implement IEditorView.EditorCore to hold a pointer/reference to IEditorView instead of tightly coupled NcursesEditor logic.main.cpp (or main_ncurses.cpp) to instantiate TuiEditor and pass it to EditorCore.EditorEvent Usage: Ensure EditorCore communicates solely via IEditorView or its existing event system (EditorEvent).EditorCore that can interact with any IEditorView implementation.CMakeLists.txt: Add find_package(PkgConfig REQUIRED) and pkg_check_modules(GTKMM REQUIRED gtkmm-4.0). Add GTKMM include directories and link libraries.main_gtk.cpp: A new entry point for the GTK frontend.GtkEditor Stub: Create a placeholder class GtkEditor that inherits from IEditorView.main_gtk.cpp, initialize GTK, create a simple Gtk::Application and Gtk::Window, and show it.lumacs (TUI) or lumacs-gtk (GUI) executables based on a flag (e.g., -DBUILD_GUI=ON).lumacs-gtk executable that opens an empty GTK window.gtkmm-4.0 development libraries.Gtk::DrawingArea: Use a Gtk::DrawingArea to draw text.DrawingArea.EditorCore and render it.Pango, Cairo.Face system within GtkEditor to render styled text.FaceAttributes to Pango attributes (foreground, background, weight, slant, underline, font family, font size).StyledRange objects from the Buffer and apply the corresponding Pango attributes before drawing text segments.EditorCore's key processing.DrawingArea.Gtk::Entry for the minibuffer (command input, find file, etc.).TuiEditor (window splits, status lines, messages, marks, regions) in GtkEditor.Gtk::Paned or Gtk::Grid).Gtk::FileChooserDialog for find-file and save-as.