buffers are in the layers now
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
// src/components/handlers/buffer_list.rs
|
// src/components/handlers/buffer_list.rs
|
||||||
|
|
||||||
use crate::config::colors::themes::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
// use crate::state::app::buffer::AppView;
|
|
||||||
use crate::state::app::buffer::BufferState;
|
use crate::state::app::buffer::BufferState;
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
layout::{Alignment, Rect},
|
layout::{Alignment, Rect},
|
||||||
@@ -11,6 +10,7 @@ use ratatui::{
|
|||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
use crate::functions::common::buffer::get_view_layer;
|
||||||
|
|
||||||
pub fn render_buffer_list(
|
pub fn render_buffer_list(
|
||||||
f: &mut Frame,
|
f: &mut Frame,
|
||||||
@@ -27,12 +27,23 @@ pub fn render_buffer_list(
|
|||||||
.fg(theme.fg)
|
.fg(theme.fg)
|
||||||
.bg(theme.bg);
|
.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 ---
|
// --- Create Spans ---
|
||||||
let mut spans = Vec::new();
|
let mut spans = Vec::new();
|
||||||
let mut current_width = 0;
|
let mut current_width = 0;
|
||||||
|
|
||||||
for (i, view) in buffer_state.history.iter().enumerate() {
|
for (original_index, view) in buffer_state.history.iter().enumerate() {
|
||||||
let is_active = i == buffer_state.active_index;
|
// 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_name = view.display_name();
|
||||||
let buffer_text = format!(" {} ", buffer_name);
|
let buffer_text = format!(" {} ", buffer_name);
|
||||||
let text_width = UnicodeWidthStr::width(buffer_text.as_str());
|
let text_width = UnicodeWidthStr::width(buffer_text.as_str());
|
||||||
@@ -51,10 +62,12 @@ pub fn render_buffer_list(
|
|||||||
|
|
||||||
// --- Filler Span ---
|
// --- Filler Span ---
|
||||||
let remaining_width = area.width.saturating_sub(current_width as u16);
|
let remaining_width = area.width.saturating_sub(current_width as u16);
|
||||||
|
if !spans.is_empty() || remaining_width > 0 {
|
||||||
spans.push(Span::styled(
|
spans.push(Span::styled(
|
||||||
" ".repeat(remaining_width as usize),
|
" ".repeat(remaining_width as usize),
|
||||||
inactive_style,
|
inactive_style,
|
||||||
));
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// --- Render ---
|
// --- Render ---
|
||||||
let buffer_line = Line::from(spans);
|
let buffer_line = Line::from(spans);
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
// src/functions/common/buffer.rs
|
// src/functions/common/buffer.rs
|
||||||
|
|
||||||
use crate::state::app::buffer::BufferState;
|
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.
|
/// Switches the active buffer index.
|
||||||
pub fn switch_buffer(buffer_state: &mut BufferState, next: bool) -> bool {
|
pub fn switch_buffer(buffer_state: &mut BufferState, next: bool) -> bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user