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

feat: Add vertical separator between windows in split view

Bernardo Magri 1 месяц назад
Родитель
Сommit
b34320e5b9
1 измененных файлов с 24 добавлено и 3 удалено
  1. 24 3
      src/main_ncurses.cpp

+ 24 - 3
src/main_ncurses.cpp

@@ -907,11 +907,32 @@ private:
             render_layout_node(node->child2, x, y + top_height, width, bottom_height);
         } else if (node->type == LayoutNode::Type::VerticalSplit) {
             // Split vertically: left and right windows  
-            int left_width = width / 2;
-            int right_width = width - left_width;
+            int separator_width = (width > 2) ? 1 : 0;
+            int available_width = width - separator_width;
+
+            int left_width = available_width / 2;
+            int right_width = available_width - left_width;
             
             render_layout_node(node->child1, x, y, left_width, height);
-            render_layout_node(node->child2, x + left_width, y, right_width, height);
+
+            // Draw separator if enabled
+            if (separator_width > 0) {
+                auto theme = core_->active_theme();
+                if (theme) {
+                    attron(theme->get_color_pair(ThemeElement::WindowBorder));
+                }
+                
+                int sep_x = x + left_width;
+                for (int i = 0; i < height; ++i) {
+                    mvaddch(y + i, sep_x, ACS_VLINE);
+                }
+                
+                if (theme) {
+                    attroff(theme->get_color_pair(ThemeElement::WindowBorder));
+                }
+            }
+
+            render_layout_node(node->child2, x + left_width + separator_width, y, right_width, height);
         }
     }