buffer working
This commit is contained in:
@@ -1,14 +1,12 @@
|
|||||||
// src/components/common.rs
|
// src/components/common.rs
|
||||||
pub mod command_line;
|
pub mod command_line;
|
||||||
pub mod status_line;
|
pub mod status_line;
|
||||||
pub mod buffer_list;
|
|
||||||
pub mod background;
|
pub mod background;
|
||||||
pub mod dialog;
|
pub mod dialog;
|
||||||
pub mod autocomplete;
|
pub mod autocomplete;
|
||||||
|
|
||||||
pub use command_line::*;
|
pub use command_line::*;
|
||||||
pub use status_line::*;
|
pub use status_line::*;
|
||||||
pub use buffer_list::*;
|
|
||||||
pub use background::*;
|
pub use background::*;
|
||||||
pub use dialog::*;
|
pub use dialog::*;
|
||||||
pub use autocomplete::*;
|
pub use autocomplete::*;
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
// src/components/common/buffer_list.rs
|
|
||||||
|
|
||||||
use crate::config::colors::themes::Theme;
|
|
||||||
use crate::state::app::state::AppState;
|
|
||||||
use ratatui::{
|
|
||||||
layout::Rect,
|
|
||||||
style::{Style, Stylize},
|
|
||||||
text::Line,
|
|
||||||
widgets::{Block, Borders, List, ListItem, ListState},
|
|
||||||
Frame,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn render_buffer_list(
|
|
||||||
f: &mut Frame,
|
|
||||||
area: Rect,
|
|
||||||
theme: &Theme,
|
|
||||||
app_state: &AppState,
|
|
||||||
) {
|
|
||||||
let mut items = Vec::new();
|
|
||||||
let mut current_buffer_name = "*scratch*"; // Default if nothing else is shown
|
|
||||||
|
|
||||||
// Determine the active buffer name based on UI state
|
|
||||||
if app_state.ui.show_intro {
|
|
||||||
current_buffer_name = "Intro";
|
|
||||||
} else if app_state.ui.show_register {
|
|
||||||
current_buffer_name = "Register";
|
|
||||||
} else if app_state.ui.show_login {
|
|
||||||
current_buffer_name = "Login";
|
|
||||||
} else if app_state.ui.show_admin {
|
|
||||||
current_buffer_name = "Admin Panel";
|
|
||||||
} else if app_state.ui.show_form {
|
|
||||||
current_buffer_name = "Data Form"; // Or derive from selected profile/table if needed
|
|
||||||
}
|
|
||||||
|
|
||||||
items.push(ListItem::new(Line::from(vec![
|
|
||||||
" ".into(), // Padding
|
|
||||||
current_buffer_name.fg(theme.highlight),
|
|
||||||
" ".into(), // Padding
|
|
||||||
])));
|
|
||||||
|
|
||||||
let list = List::new(items)
|
|
||||||
.block(
|
|
||||||
Block::default()
|
|
||||||
.borders(Borders::TOP) // Simple top border
|
|
||||||
.border_style(Style::default().fg(theme.secondary)),
|
|
||||||
)
|
|
||||||
.style(Style::default().bg(theme.bg).fg(theme.fg));
|
|
||||||
|
|
||||||
let mut state = ListState::default();
|
|
||||||
|
|
||||||
f.render_stateful_widget(list, area, &mut state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
// src/components/handlers.rs
|
// src/components/handlers.rs
|
||||||
pub mod canvas;
|
pub mod canvas;
|
||||||
pub mod sidebar;
|
pub mod sidebar;
|
||||||
|
pub mod buffer_list;
|
||||||
|
|
||||||
pub use canvas::*;
|
pub use canvas::*;
|
||||||
pub use sidebar::*;
|
pub use sidebar::*;
|
||||||
|
pub use buffer_list::*;
|
||||||
|
|||||||
61
client/src/components/handlers/buffer_list.rs
Normal file
61
client/src/components/handlers/buffer_list.rs
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
// src/components/handlers/buffer_list.rs
|
||||||
|
|
||||||
|
use crate::config::colors::themes::Theme;
|
||||||
|
use crate::state::app::state::AppState;
|
||||||
|
use ratatui::{
|
||||||
|
layout::{Alignment, Rect}, // Added Alignment
|
||||||
|
style::{Style, Stylize},
|
||||||
|
text::{Line, Span}, // Added Span
|
||||||
|
widgets::{Block, Borders, Paragraph}, // Changed widgets
|
||||||
|
Frame,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn render_buffer_list(
|
||||||
|
f: &mut Frame,
|
||||||
|
area: Rect,
|
||||||
|
theme: &Theme,
|
||||||
|
app_state: &AppState,
|
||||||
|
) {
|
||||||
|
let mut current_buffer_name = "*scratch*"; // Default
|
||||||
|
|
||||||
|
// Determine the active buffer name based on UI state
|
||||||
|
if app_state.ui.show_intro {
|
||||||
|
current_buffer_name = "Intro";
|
||||||
|
} else if app_state.ui.show_register {
|
||||||
|
current_buffer_name = "Register";
|
||||||
|
} else if app_state.ui.show_login {
|
||||||
|
current_buffer_name = "Login";
|
||||||
|
} else if app_state.ui.show_admin {
|
||||||
|
current_buffer_name = "Admin Panel";
|
||||||
|
} else if app_state.ui.show_form {
|
||||||
|
// Potentially make this more specific later (e.g., show table name)
|
||||||
|
current_buffer_name = "Data Form";
|
||||||
|
}
|
||||||
|
// Add more conditions if other views exist
|
||||||
|
|
||||||
|
// Create the text line for the buffer name with padding
|
||||||
|
let buffer_text = Line::from(vec![
|
||||||
|
Span::raw(" "), // Left padding
|
||||||
|
Span::styled(
|
||||||
|
current_buffer_name,
|
||||||
|
Style::default().fg(theme.bg).bg(theme.highlight), // Style active tab
|
||||||
|
),
|
||||||
|
Span::raw(" "), // Right padding
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Create the paragraph centered within the block
|
||||||
|
let paragraph = Paragraph::new(buffer_text)
|
||||||
|
.alignment(Alignment::Left) // Align text left, padding handles spacing
|
||||||
|
.block(
|
||||||
|
Block::default()
|
||||||
|
// Keep only the bottom border to act as a separator
|
||||||
|
.borders(Borders::BOTTOM)
|
||||||
|
.border_style(Style::default().fg(theme.secondary)),
|
||||||
|
)
|
||||||
|
// Set the background for the entire area (behind the text/block)
|
||||||
|
.style(Style::default().bg(theme.bg));
|
||||||
|
|
||||||
|
// Render the paragraph widget
|
||||||
|
f.render_widget(paragraph, area);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ pub fn render_ui(
|
|||||||
// Adjust layout based on whether buffer list is shown
|
// Adjust layout based on whether buffer list is shown
|
||||||
let constraints = if app_state.ui.show_buffer_list {
|
let constraints = if app_state.ui.show_buffer_list {
|
||||||
vec![
|
vec![
|
||||||
Constraint::Length(1), // Buffer list
|
Constraint::Length(2), // Buffer list
|
||||||
Constraint::Min(1), // Main content
|
Constraint::Min(1), // Main content
|
||||||
Constraint::Length(1), // Status line
|
Constraint::Length(1), // Status line
|
||||||
Constraint::Length(1), // Command line
|
Constraint::Length(1), // Command line
|
||||||
|
|||||||
Reference in New Issue
Block a user