refactor: update TogglePanelAndFocus to use open/focused flags
Update TogglePanelAndFocus and related components to use open/focused flags. Changed TogglePanelAndFocus from currently_open to open+focused flags. Parser accepts optional [open] [focused] arguments. Interactive mode toggles between open+focus and closed/unfocused. Keymap updates: F/C/V in panel modes close panels when focused. Model initialization: Virtual categories _Index/_Dim default to None axis, regular categories auto-assign Row/Column/Page. App test context updated with visible_rows/visible_cols. Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M)
This commit is contained in:
89
src/draw.rs
89
src/draw.rs
@ -65,8 +65,15 @@ pub fn run_tui(
|
||||
tui_context.terminal.draw(|f| draw(f, &app))?;
|
||||
|
||||
if event::poll(Duration::from_millis(100))? {
|
||||
if let Event::Key(key) = event::read()? {
|
||||
app.handle_key(key)?;
|
||||
match event::read()? {
|
||||
Event::Key(key) => {
|
||||
app.handle_key(key)?;
|
||||
}
|
||||
Event::Resize(w, h) => {
|
||||
app.term_width = w;
|
||||
app.term_height = h;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,9 +168,7 @@ fn draw(f: &mut Frame, app: &App) {
|
||||
f.render_widget(ImportWizardWidget::new(wizard), size);
|
||||
}
|
||||
}
|
||||
if matches!(app.mode, AppMode::ExportPrompt { .. }) {
|
||||
draw_export_prompt(f, size, app);
|
||||
}
|
||||
// ExportPrompt now uses the minibuffer at the bottom bar.
|
||||
if app.is_empty_model() && matches!(app.mode, AppMode::Normal | AppMode::CommandMode { .. }) {
|
||||
draw_welcome(f, main_chunks[1]);
|
||||
}
|
||||
@ -266,12 +271,59 @@ fn draw_tile_bar(f: &mut Frame, area: Rect, app: &App) {
|
||||
}
|
||||
|
||||
fn draw_bottom_bar(f: &mut Frame, area: Rect, app: &App) {
|
||||
match app.mode {
|
||||
// All text-entry modes use the bottom bar as a minibuffer.
|
||||
let minibuf = match &app.mode {
|
||||
AppMode::CommandMode { .. } => {
|
||||
let buf = app.buffers.get("command").map(|s| s.as_str()).unwrap_or("");
|
||||
draw_command_bar(f, area, buf);
|
||||
Some((format!(":{buf}▌"), Color::Yellow))
|
||||
}
|
||||
_ => draw_status(f, area, app),
|
||||
AppMode::Editing { .. } => {
|
||||
let buf = app.buffers.get("edit").map(|s| s.as_str()).unwrap_or("");
|
||||
Some((format!("edit: {buf}▌"), Color::Green))
|
||||
}
|
||||
AppMode::FormulaEdit { .. } => {
|
||||
let buf = app
|
||||
.buffers
|
||||
.get("formula")
|
||||
.map(|s| s.as_str())
|
||||
.unwrap_or("");
|
||||
Some((format!("formula: {buf}▌"), Color::Cyan))
|
||||
}
|
||||
AppMode::CategoryAdd { .. } => {
|
||||
let buf = app
|
||||
.buffers
|
||||
.get("category")
|
||||
.map(|s| s.as_str())
|
||||
.unwrap_or("");
|
||||
Some((format!("new category: {buf}▌"), Color::Yellow))
|
||||
}
|
||||
AppMode::ItemAdd { category, .. } => {
|
||||
let buf = app.buffers.get("item").map(|s| s.as_str()).unwrap_or("");
|
||||
Some((format!("add item to {category}: {buf}▌"), Color::Green))
|
||||
}
|
||||
AppMode::ExportPrompt { .. } => {
|
||||
let buf = app
|
||||
.buffers
|
||||
.get("export")
|
||||
.map(|s| s.as_str())
|
||||
.unwrap_or("");
|
||||
Some((format!("export path: {buf}▌"), Color::Yellow))
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
if let Some((text, color)) = minibuf {
|
||||
f.render_widget(
|
||||
Paragraph::new(text).style(
|
||||
Style::default()
|
||||
.fg(color)
|
||||
.bg(Color::Indexed(235))
|
||||
.add_modifier(Modifier::BOLD),
|
||||
),
|
||||
area,
|
||||
);
|
||||
} else {
|
||||
draw_status(f, area, app);
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,27 +349,6 @@ fn draw_status(f: &mut Frame, area: Rect, app: &App) {
|
||||
f.render_widget(Paragraph::new(line).style(mode_style(&app.mode)), area);
|
||||
}
|
||||
|
||||
fn draw_command_bar(f: &mut Frame, area: Rect, buffer: &str) {
|
||||
f.render_widget(
|
||||
Paragraph::new(format!(":{buffer}▌"))
|
||||
.style(Style::default().fg(Color::White).bg(Color::Black)),
|
||||
area,
|
||||
);
|
||||
}
|
||||
|
||||
fn draw_export_prompt(f: &mut Frame, area: Rect, app: &App) {
|
||||
let buf = if let AppMode::ExportPrompt { buffer } = &app.mode {
|
||||
buffer.as_str()
|
||||
} else {
|
||||
""
|
||||
};
|
||||
let popup = centered_popup(area, 64, 3);
|
||||
let inner = draw_popup_frame(f, popup, " Export CSV — path (Esc cancel) ", Color::Yellow);
|
||||
f.render_widget(
|
||||
Paragraph::new(format!("{buf}▌")).style(Style::default().fg(Color::Green)),
|
||||
inner,
|
||||
);
|
||||
}
|
||||
|
||||
fn draw_welcome(f: &mut Frame, area: Rect) {
|
||||
let popup = centered_popup(area, 58, 20);
|
||||
|
||||
Reference in New Issue
Block a user