more claude changes
This commit is contained in:
26
src/app.rs
26
src/app.rs
@@ -9,19 +9,19 @@ pub const GLOBAL_PATH: usize = 4;
|
||||
pub const GLOBAL_HUT_TYPE: usize = 5;
|
||||
pub const GLOBAL_COUNT: usize = 6;
|
||||
|
||||
pub const LOT_STATUS_OPTIONS: &[&str] = &["Unrestricted", "Blocked", "Quality"];
|
||||
|
||||
// Field indices for per-row inputs
|
||||
pub const ROW_MAT_ID: usize = 0;
|
||||
pub const ROW_QUANTITY: usize = 1;
|
||||
pub const ROW_UOM: usize = 2;
|
||||
pub const ROW_COUNT: usize = 3;
|
||||
|
||||
pub const LOT_STATUS_OPTIONS: &[&str] = &["Unrestricted", "Blocked", "Quality"];
|
||||
|
||||
/// Which section of the UI the cursor is in
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub enum Focus {
|
||||
GlobalField(usize),
|
||||
LotRow(usize), // focused on the row itself (for deletion etc.)
|
||||
LotRow(usize), // focused on the row itself (for deletion etc.)
|
||||
LotField(usize, usize), // (row_index, field_index)
|
||||
}
|
||||
|
||||
@@ -201,7 +201,9 @@ impl App {
|
||||
|
||||
pub fn type_char(&mut self, c: char) {
|
||||
match self.focus.clone() {
|
||||
Focus::GlobalField(i) if i == GLOBAL_CHECKSUM => {} // toggled, not typed
|
||||
// GLOBAL_CHECKSUM is toggled via Space, not typed
|
||||
// GLOBAL_LOT_STATUS is cycled via Space/←/→, not typed
|
||||
Focus::GlobalField(i) if i == GLOBAL_CHECKSUM || i == GLOBAL_LOT_STATUS => {}
|
||||
Focus::GlobalField(i) => {
|
||||
self.global[i].push(c);
|
||||
}
|
||||
@@ -214,7 +216,7 @@ impl App {
|
||||
|
||||
pub fn backspace(&mut self) {
|
||||
match self.focus.clone() {
|
||||
Focus::GlobalField(i) if i == GLOBAL_CHECKSUM => {}
|
||||
Focus::GlobalField(i) if i == GLOBAL_CHECKSUM || i == GLOBAL_LOT_STATUS => {}
|
||||
Focus::GlobalField(i) => {
|
||||
self.global[i].pop();
|
||||
}
|
||||
@@ -234,20 +236,6 @@ impl App {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn cycle_lot_status(&mut self) {
|
||||
if let Focus::GlobalField(i) = self.focus {
|
||||
if i == GLOBAL_LOT_STATUS {
|
||||
let current = self.global[GLOBAL_LOT_STATUS].clone();
|
||||
let idx = LOT_STATUS_OPTIONS
|
||||
.iter()
|
||||
.position(|&s| s == current.as_str())
|
||||
.unwrap_or(0);
|
||||
let next = (idx + 1) % LOT_STATUS_OPTIONS.len();
|
||||
self.global[GLOBAL_LOT_STATUS] = LOT_STATUS_OPTIONS[next].to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── lot management ────────────────────────────────────────────────────────
|
||||
|
||||
pub fn add_lot(&mut self) {
|
||||
|
||||
@@ -2,7 +2,7 @@ mod app;
|
||||
mod row;
|
||||
mod ui;
|
||||
|
||||
use app::{App, Focus, ModalKind, GLOBAL_CHECKSUM, GLOBAL_LOT_STATUS};
|
||||
use app::{App, Focus, ModalKind, GLOBAL_CHECKSUM};
|
||||
use crossterm::{
|
||||
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyModifiers},
|
||||
execute,
|
||||
@@ -131,12 +131,6 @@ fn run<B: ratatui::backend::Backend>(terminal: &mut Terminal<B>) -> anyhow::Resu
|
||||
app.toggle_checksum();
|
||||
}
|
||||
}
|
||||
Focus::GlobalField(i) if i == GLOBAL_LOT_STATUS => match key.code {
|
||||
KeyCode::Left | KeyCode::Right | KeyCode::Char(' ') => {
|
||||
app.cycle_lot_status();
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
_ => match key.code {
|
||||
KeyCode::Backspace => app.backspace(),
|
||||
KeyCode::Char(c) => app.type_char(c),
|
||||
|
||||
@@ -8,7 +8,7 @@ use ratatui::{
|
||||
|
||||
use crate::app::{
|
||||
App, Focus, ModalKind, GLOBAL_CHECKSUM, GLOBAL_COUNT, GLOBAL_HUT_ID, GLOBAL_HUT_TYPE,
|
||||
GLOBAL_LOT_STATUS, GLOBAL_PATH, GLOBAL_TARE, ROW_COUNT, ROW_MAT_ID, ROW_QUANTITY, ROW_UOM,
|
||||
GLOBAL_PATH, GLOBAL_TARE, ROW_COUNT, ROW_MAT_ID, ROW_QUANTITY, ROW_UOM,
|
||||
};
|
||||
|
||||
const GLOBAL_LABELS: &[&str] = &[
|
||||
@@ -129,8 +129,6 @@ fn draw_globals(f: &mut Frame, app: &App, area: Rect) {
|
||||
let value: String = if i == GLOBAL_CHECKSUM {
|
||||
let checked = app.global[i] == "true";
|
||||
format!("[{}] (Space)", if checked { "x" } else { " " })
|
||||
} else if i == GLOBAL_LOT_STATUS {
|
||||
format!("{} (←/→)", app.global[i])
|
||||
} else {
|
||||
app.global[i].clone()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user