Embed fonts from repo instead of ~/.local/share/fonts

Move BrassMono font files into fonts/ and use a repo-relative
include_bytes! path so the build is self-contained. Add CLAUDE.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-31 17:15:48 -07:00
parent 1ad67aea20
commit 963fcc6458
4 changed files with 34 additions and 4 deletions

33
CLAUDE.md Normal file
View File

@@ -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<Range<usize>>`) 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

BIN
fonts/BrassMono-Regular.ttf Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -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 NORD11: egui::Color32 = egui::Color32::from_rgb(0xBF, 0x61, 0x6A);
const NORD13: egui::Color32 = egui::Color32::from_rgb(0xEB, 0xCB, 0x8B); const NORD13: egui::Color32 = egui::Color32::from_rgb(0xEB, 0xCB, 0x8B);
const BRASS_MONO: &[u8] = include_bytes!(concat!( const BRASS_MONO: &[u8] = include_bytes!("../fonts/BrassMonoCode-Regular.ttf");
env!("HOME"),
"/.local/share/fonts/BrassMonoCode-Regular.ttf"
));
fn main() -> eframe::Result { fn main() -> eframe::Result {
let options = eframe::NativeOptions { let options = eframe::NativeOptions {