feat: right-click context menu in the editor#8
Merged
Conversation
Add a context menu to the editor surface, which egui's TextEdit does not provide on its own. The menu offers Cut, Copy, Paste, and Select all (Cut/Copy disabled with no selection), plus Find, Find and replace, and Save. Clipboard text edits are imperative rather than event-driven: egui can write the clipboard but exposes no read, so a new clipboard module uses arboard for both directions, and a new edit_ops module holds the pure, char-indexed buffer splices (cut/paste/select) that back them. After an edit the resulting caret is stored back into the live TextEdit state so the cursor follows the change. A clipboard edit that mutates the buffer is folded into the existing changed-this-frame handling so it persists and refreshes search matches like a typed edit. Menu choices are collected into a deferred EditorAction and applied after the editor borrow ends, matching the existing MenuAction/TreeAction pattern. Find/replace and Save reuse the existing actions.
fredclausen
enabled auto-merge
June 30, 2026 14:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a right-click context menu to the editor surface (the second of two context-menu PRs; the sidebar menus landed in #7).
egui's
TextEditships no context menu of its own, so this adds one rather than replacing anything. Entries:How
egui can write the clipboard but exposes no imperative read, which a menu-driven Paste needs. So the clipboard ops are imperative:
clipboardmodule \u2014 wrapsarboard(already in the tree via eframe; now a pinned direct dep, default features off) for read and write, non-panicking and logging on failure.edit_opsmodule \u2014 pure, char-indexed buffer splices (selected_text,delete_range,replace_range) that back cut/paste/select. Fully unit-tested, no egui or clipboard coupling.TextEditstate so the cursor follows the change; the editor is refocused.Menu choices flow through a deferred
EditorActionapplied after the editor borrow ends, matching the establishedMenuAction/TreeActionpattern.Verification
cargo fmt --check,cargo clippy --all-targets --all-features -D warnings,cargo test --all(113 pass, +12 new acrossedit_opsandapp), andcargo macheteall green in the Nix dev shell. Release build compiles.The only Cargo.lock change is adding
arboardto frext's dependency list \u2014 no new packages were resolved, since it was already present transitively.