Commit claude.md

This commit is contained in:
Greg Shuflin committed 2026-02-09 02:42:31 -08:00
1 parent 35532ff460
commit 8c04b1ee90
1 file changed
+45
+45
View File
@@ -0,0 +1,45 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Build Commands
```bash
cargo build # Build the project
cargo run # Run the TUI editor
cargo run -- --gui # GUI mode (stub, not yet implemented)
cargo clippy # Lint
cargo test # Run tests (no test suite yet)
```
Logs are written to `./pane-editor.log` via tracing-appender.
## Architecture
This is a Rust terminal text editor built with ratatui/crossterm, using an action-based state machine pattern. The editor core is designed to be frontend-agnostic.
### Key Layers
**Input Pipeline:** Keyboard events (crossterm) → `Input` enum → `Configuration` maps Input to `EditorAction` based on current `Mode` → `EditorCore::handle_action()` processes state changes.
**EditorCore** (`src/core.rs`): Central state manager. Owns all buffers (`HashMap<BufferId, Buffer>`), pane layout, mode (Normal/Insert/Command), and command system. All state mutations flow through `handle_action(EditorAction)`.
**EditorAction** (`src/core/actions.rs`): Enum representing every possible state change — character insertion, cursor movement, mode transitions, file I/O, commands, etc.
**TerminalUI** (`src/tui.rs`): Async event loop using tokio. Dual-rate rendering: 30 FPS while typing, 2 FPS when idle (0.5s threshold).
**Rendering** (`src/tui/render/`): Three-area vertical layout — main editing area, info pane (2 lines), command pane (1 line). Supports floating panes for popups (Help, Finder).
### Core Modules
- `src/core/buffer.rs` — TextBuffer (editable text backed by `crop::Rope` via TextLines wrapper) and FinderBuffer (WIP)
- `src/core/cursor.rs` — Cursor position tracking with UTF-8/grapheme-aware movement
- `src/core/commands.rs` + `commands/api.rs` — Command-line parsing and execution (open, quit, write, help, finder)
- `src/core/pane_layout.rs` — Buffer visibility and positioning (Main with tabs, Floating for popups)
- `src/configuration.rs` — Mode-dependent keymap (Vi-inspired: hjkl navigation in Normal, i for Insert, : for Command)
### Design Principles
- The editor core is conceptually separate from frontends — `EditorCore` knows nothing about terminal rendering
- Buffers have unique `BufferId`s and can be visible/invisible, read-only/read-write, text-editing or informational
- `handle_action` runs in a tight loop processing a constant stream of EditorActions from any source (keyboard, filesystem, commands)