Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@

---

### Phase 12 — Command input + history
### Phase 12 — Command input + history

**Goal:** Full-featured input line with readline-like editing and session history.

**Deliverables:**
- `InputWidget` with cursor tracking, character insert/delete, Home/End.
- Arrow-key history navigation (in-memory `VecDeque<String>`).
- Ctrl-A (beginning of line), Ctrl-E (end), Ctrl-K (kill to end).
- History persistence to `~/.local/share/logicshell/history` (one command per line, 1 000 entry cap).
- `HistoryStore` abstraction (sync, pure) — testable without the TUI.
- `InputWidget` with cursor tracking, character insert/delete, Home/End.
- Arrow-key history navigation (in-memory `VecDeque<String>`).
- Ctrl-A (beginning of line), Ctrl-E (end), Ctrl-K (kill to end).
- History persistence to `~/.local/share/logicshell/history` (one command per line, 1 000 entry cap).
- `HistoryStore` abstraction (sync, pure) — testable without the TUI.

**Tests:** InputWidget cursor math, history ring-buffer, persistence round-trip.
**Tests:** InputWidget cursor math, history ring-buffer, persistence round-trip. ✅ (173 tests, 94.26% coverage)

---

Expand Down
36 changes: 36 additions & 0 deletions logicshell-tui/examples/phase12.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/// Phase 12 interactive demo — readline-like input + session history
///
/// Run with: cargo run --example phase12 -p logicshell-tui
///
/// Key bindings:
/// Left / Right — move cursor
/// Home / End — beginning / end of line
/// Ctrl-A / Ctrl-E — beginning / end of line (readline style)
/// Ctrl-K — kill from cursor to end of line
/// Up / Down — history navigation
/// Backspace — delete character before cursor
/// Delete — delete character at cursor
/// Enter — submit command
/// Ctrl-C / q — quit (q only when input is empty)
use logicshell_tui::{terminal, App, Event, EventHandler};
use ratatui::crossterm::event::KeyEventKind;
use std::time::Duration;

#[tokio::main]
async fn main() -> logicshell_tui::Result<()> {
let mut term = terminal::init()?;
let mut app = App::default();
let mut events = EventHandler::new(Duration::from_millis(100));

while app.is_running() {
term.draw(|f| logicshell_tui::ui::draw(f, &app))?;
if let Some(Event::Key(key)) = events.next().await {
if key.kind == KeyEventKind::Press {
app.handle_key(key);
}
}
}

terminal::restore(&mut term)?;
Ok(())
}
Loading
Loading