diff --git a/client/src/components/handlers/buffer_list.rs b/client/src/components/handlers/buffer_list.rs index 9187eed..09a8590 100644 --- a/client/src/components/handlers/buffer_list.rs +++ b/client/src/components/handlers/buffer_list.rs @@ -1,7 +1,6 @@ // src/components/handlers/buffer_list.rs use crate::config::colors::themes::Theme; -// use crate::state::app::buffer::AppView; use crate::state::app::buffer::BufferState; use ratatui::{ layout::{Alignment, Rect}, @@ -11,6 +10,7 @@ use ratatui::{ Frame, }; use unicode_width::UnicodeWidthStr; +use crate::functions::common::buffer::get_view_layer; pub fn render_buffer_list( f: &mut Frame, @@ -27,12 +27,23 @@ pub fn render_buffer_list( .fg(theme.fg) .bg(theme.bg); + // --- Determine Active Layer --- + let active_layer = match buffer_state.history.get(buffer_state.active_index) { + Some(view) => get_view_layer(view), + None => 1, + }; + // --- Create Spans --- let mut spans = Vec::new(); let mut current_width = 0; - for (i, view) in buffer_state.history.iter().enumerate() { - let is_active = i == buffer_state.active_index; + for (original_index, view) in buffer_state.history.iter().enumerate() { + // Filter: Only process views matching the active layer + if get_view_layer(view) != active_layer { + continue; + } + + let is_active = original_index == buffer_state.active_index; let buffer_name = view.display_name(); let buffer_text = format!(" {} ", buffer_name); let text_width = UnicodeWidthStr::width(buffer_text.as_str()); @@ -51,10 +62,12 @@ pub fn render_buffer_list( // --- Filler Span --- let remaining_width = area.width.saturating_sub(current_width as u16); - spans.push(Span::styled( - " ".repeat(remaining_width as usize), - inactive_style, - )); + if !spans.is_empty() || remaining_width > 0 { + spans.push(Span::styled( + " ".repeat(remaining_width as usize), + inactive_style, + )); + } // --- Render --- let buffer_line = Line::from(spans); diff --git a/client/src/functions/common/buffer.rs b/client/src/functions/common/buffer.rs index 5d45c6e..af487d9 100644 --- a/client/src/functions/common/buffer.rs +++ b/client/src/functions/common/buffer.rs @@ -1,6 +1,15 @@ // src/functions/common/buffer.rs use crate::state::app::buffer::BufferState; +use crate::state::app::buffer::AppView; + +pub fn get_view_layer(view: &AppView) -> u8 { + match view { + AppView::Intro => 1, + AppView::Login | AppView::Register | AppView::Admin => 2, + AppView::Form(_) | AppView::Scratch => 3, + } +} /// Switches the active buffer index. pub fn switch_buffer(buffer_state: &mut BufferState, next: bool) -> bool {