Quellcode durchsuchen

feat: Add basic Emacs-style modeline to GTK4 frontend

Core Features:
- Modeline positioned between editor and minibuffer
- Shows buffer name, cursor position, and modification status
- Integrated with existing StatusLine theme elements
- Real-time updates with cursor movement

Layout Changes:
- Reserved 2 lines at bottom (modeline + minibuffer)
- Adjusted viewport calculations for proper text area
- Maintains proper spacing and padding

Next: Lua customization API and advanced modeline segments

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Bernardo Magri vor 1 Monat
Ursprung
Commit
b88b76af7c
1 geänderte Dateien mit 39 neuen und 2 gelöschten Zeilen
  1. 39 2
      src/gtk_editor.cpp

+ 39 - 2
src/gtk_editor.cpp

@@ -216,8 +216,8 @@ protected:
         int visible_lines = static_cast<int>(content_height_px / line_height_);
         int visible_cols = static_cast<int>(content_width_px / char_width_);
         
-        // Leave 1 line for minibuffer at bottom, adjust content area
-        int editor_lines = std::max(0, visible_lines - 1); // Reserve one line for future minibuffer
+        // Reserve space for modeline and minibuffer at bottom
+        int editor_lines = std::max(0, visible_lines - 2); // Reserve lines for modeline and minibuffer
         core_->set_viewport_size(visible_cols, editor_lines);
 
         // Get default foreground color from theme
@@ -285,6 +285,9 @@ protected:
             }
         }
         
+        // Render Modeline above minibuffer
+        render_modeline(cr, width, height, layout);
+        
         // Render Minibuffer at bottom of screen
         render_minibuffer(cr, width, height, layout);
     }
@@ -311,6 +314,40 @@ protected:
         return true; // Continue timer
     }
 
+    // Render the modeline above minibuffer
+    void render_modeline(const Cairo::RefPtr<Cairo::Context>& cr, int width, int height, 
+                        const Glib::RefPtr<Pango::Layout>& layout) {
+        if (!core_) return;
+        
+        // Calculate modeline position (second line from bottom)
+        double modeline_y = height - (2 * line_height_) - PADDING_BOTTOM;
+        double modeline_x = PADDING_LEFT;
+        
+        // Get theme colors
+        auto theme = core_->active_theme();
+        Color bg = theme ? theme->get_bg_color(ThemeElement::StatusLine) : Color(40, 40, 40);
+        Color fg = theme ? theme->get_fg_color(ThemeElement::StatusLine) : Color(200, 200, 200);
+        
+        // Draw modeline background
+        cr->set_source_rgb(bg.r / 255.0, bg.g / 255.0, bg.b / 255.0);
+        cr->rectangle(0, modeline_y, width, line_height_);
+        cr->fill();
+        
+        // Build modeline content
+        auto cursor = core_->active_window()->cursor();
+        auto& buffer = core_->buffer();
+        std::string modeline_text = " " + buffer.name() + 
+                                   "    Line " + std::to_string(cursor.line + 1) + 
+                                   ":" + std::to_string(cursor.column + 1) + 
+                                   "    (" + (buffer.is_modified() ? "modified" : "saved") + ")";
+        
+        // Render modeline text
+        cr->set_source_rgb(fg.r / 255.0, fg.g / 255.0, fg.b / 255.0);
+        layout->set_text(modeline_text);
+        cr->move_to(modeline_x, modeline_y);
+        layout->show_in_cairo_context(cr);
+    }
+
     // Render the minibuffer at bottom of screen
     void render_minibuffer(const Cairo::RefPtr<Cairo::Context>& cr, int width, int height, 
                           const Glib::RefPtr<Pango::Layout>& layout) {