diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..bbcf851 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,33 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project + +Redactor is a two-pane text redaction GUI built in Rust with eframe/egui. Users paste text in the left panel, select regions and press Ctrl+R to toggle redaction, and the right panel shows a live preview with redacted regions replaced by block characters (U+2588). The entire application lives in `src/main.rs`. + +## Build & Run + +```bash +cargo build # debug build +cargo build --release # release build +cargo run # run the app +``` + +Nix flake provides the dev environment (Rust toolchain + native deps for egui). Direnv auto-loads it via `.envrc`. + +## Architecture + +All logic is in `src/main.rs` (~490 lines) in the `RedactorApp` struct: + +- **State**: source text (`String`) + sorted non-overlapping byte ranges (`Vec>`) of redactions +- **Left panel**: editable `TextEdit` with redacted regions highlighted via `LayoutJob` text formatting +- **Right panel**: read-only preview where redacted bytes become full-block characters, preserving whitespace +- **Reconciliation**: when source text is edited, `reconcile_redactions` adjusts byte ranges by detecting unchanged prefix/suffix regions +- **Range operations**: `add_redaction` merges overlapping ranges; `remove_redaction` splits ranges; all operations snap to UTF-8 character boundaries + +## UI + +- Nord color palette (dark theme) with BrassMonoCode monospace font (bundled .ttf files, embedded at compile time) +- Keyboard: Ctrl+R toggles redaction on selection, Cmd+Q quits +- Toolbar has keyboard help and "Copy Redacted" button diff --git a/fonts/BrassMono-Regular.ttf b/fonts/BrassMono-Regular.ttf new file mode 100644 index 0000000..2b2b959 Binary files /dev/null and b/fonts/BrassMono-Regular.ttf differ diff --git a/fonts/BrassMonoCode-Regular.ttf b/fonts/BrassMonoCode-Regular.ttf new file mode 100644 index 0000000..c4f6b44 Binary files /dev/null and b/fonts/BrassMonoCode-Regular.ttf differ diff --git a/src/main.rs b/src/main.rs index b45d841..81c6d56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,10 +13,7 @@ const NORD9: egui::Color32 = egui::Color32::from_rgb(0x81, 0xA1, 0xC1); const NORD11: egui::Color32 = egui::Color32::from_rgb(0xBF, 0x61, 0x6A); const NORD13: egui::Color32 = egui::Color32::from_rgb(0xEB, 0xCB, 0x8B); -const BRASS_MONO: &[u8] = include_bytes!(concat!( - env!("HOME"), - "/.local/share/fonts/BrassMonoCode-Regular.ttf" -)); +const BRASS_MONO: &[u8] = include_bytes!("../fonts/BrassMonoCode-Regular.ttf"); fn main() -> eframe::Result { let options = eframe::NativeOptions {