| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #pragma once
- #include "lumacs/ui_interface.hpp"
- #include "lumacs/gtk_renderer.hpp"
- #include "lumacs/window.hpp"
- #include "lumacs/editor_core.hpp"
- #include "lumacs/face.hpp"
- #include "lumacs/completion_common.hpp" // For CompletionCandidate
- #include "lumacs/cursor_blink.hpp"
- #include <chrono> // For std::chrono
- #include <gtkmm.h>
- #include <pangomm.h>
- #include <memory>
- #include <vector>
- #include <map>
- namespace lumacs {
- // Forward declarations
- class EditorCore;
- class Window;
- class GtkCompletionPopup; // Forward declaration
- class ModeActivator; // Forward declaration
- // Custom Gtk::ApplicationWindow to make constructor public
- class LumacsWindow : public Gtk::ApplicationWindow {
- public:
- explicit LumacsWindow(const Glib::RefPtr<Gtk::Application>& application);
- };
- class GtkEditor : public IEditorView {
- public:
- GtkEditor();
- ~GtkEditor() override;
- void init() override;
- void run() override;
- void handle_editor_event(EditorEvent event) override;
- void set_core(EditorCore* core) override;
- void queue_redraw_all_windows(Gtk::Widget* widget);
- private:
- EditorCore* core_;
- std::shared_ptr<Window> cached_active_window_;
- Glib::RefPtr<Gtk::Application> app_;
- Gtk::Window* window_ = nullptr;
- Gtk::DrawingArea* drawing_area_ = nullptr; // Raw pointer to the main drawing area if single window
- Gtk::DrawingArea* minibuffer_drawing_area_ = nullptr; // Dedicated drawing area for minibuffer
- Gtk::Widget* content_widget_ = nullptr; // The root widget of the editor content (Paned or DrawingArea)
-
- // Cursor blinking using shared controller
- CursorBlinkController cursor_blink_;
- sigc::connection cursor_timer_connection_;
- std::unique_ptr<GtkRenderer> gtk_renderer_;
- std::unique_ptr<GtkCompletionPopup> completion_popup_; // Completion popup
- std::unique_ptr<ModeActivator> mode_activator_;
- protected:
- void on_activate();
- void on_draw(const Cairo::RefPtr<Cairo::Context>& cr, int width, int height);
- bool on_cursor_blink();
- void rebuild_layout();
- Gtk::Widget* create_widget_for_layout_node(std::shared_ptr<LayoutNode> node);
- // Completion popup helpers
- void show_completion_popup();
- void hide_completion_popup();
- void on_completion_selected(CompletionCandidate candidate);
- void on_completion_cancelled();
- // Global key event handler
- std::string get_lumacs_key_name(guint keyval, Gdk::ModifierType state);
- bool on_global_key_pressed(guint keyval, guint keycode, Gdk::ModifierType state);
- };
- std::unique_ptr<IEditorView> create_gtk_editor();
- } // namespace lumacs
|