Просмотр исходного кода

fix(tui): ensure visible block cursor

Restored software cursor drawing in TUI with forced A_REVERSE attribute. This ensures a highly visible block cursor is rendered on top of the character, complementing the hardware cursor and resolving visibility issues.
Bernardo Magri 1 месяц назад
Родитель
Сommit
535d3d7bb0
2 измененных файлов с 19 добавлено и 1 удалено
  1. 1 1
      documentation/PLAN.md
  2. 18 0
      src/tui_editor.cpp

+ 1 - 1
documentation/PLAN.md

@@ -143,7 +143,7 @@ Lumacs/
     - [x] **Persistent Messages**: Implemented `*Messages*` buffer to log all minibuffer outputs, ensuring history is accessible via buffer switching.
     - [x] **File Path Completion**: Implemented robust file path autocompletion with tilde expansion and directory browsing.
     - [x] **GTK Minibuffer Cursor**: Fixed cursor rendering to be a proper block cursor positioned correctly at the editing point, not a line at the end of the text.
-    - [x] **TUI Cursor**: Replaced software block cursor with standard hardware cursor (`curs_set(2)`) for better visibility and standard behavior.
+    - [x] **TUI Cursor**: Replaced software block cursor with standard hardware cursor (`curs_set(2)`). Added fallback software cursor with forced `A_REVERSE` to ensure visibility on all terminals.
 - ✅ **Theme System Refactoring**:
     - [x] Implemented `editor:create_and_register_theme` Lua API to allow theme definition from Lua.
     - [x] Factored all hardcoded C++ themes (`default`, `everforest-dark`, `dracula`, `solarized-dark`, `nord`, `gruvbox-light`) into individual Lua files (`lua/themes/*.lua`).

+ 18 - 0
src/tui_editor.cpp

@@ -249,6 +249,24 @@ void TuiEditor::render_window(std::shared_ptr<Window> window, int x, int y, int
             }
         }
         
+        // Show cursor if this is the cursor line and this is the active window
+        if (buffer_line_idx == cursor.line && is_active && cursor_visible_) {
+            int cursor_screen_x = x + line_number_width + cursor.column;
+            if (cursor_screen_x < x + width) {
+                char cursor_char = ' ';
+                if (cursor.column < line_text.size()) {
+                    cursor_char = line_text[cursor.column];
+                }
+                
+                // Force A_REVERSE to ensure visible block cursor
+                int attrs = A_REVERSE;
+                
+                attron(attrs);
+                mvaddch(y + screen_y, cursor_screen_x, cursor_char);
+                attroff(attrs);
+            }
+        }
+
         // Track hardware cursor position for active window
         if (buffer_line_idx == cursor.line && is_active) {
             int cursor_screen_x = x + line_number_width + (int)cursor.column;