Repository navigation
feat(selection): El::selection_enabled(bool), a subtree or window switch for selectable text - #2206
Merged
Merged
Conversation
…tch for selectable text
opencodejr
Bot
force-pushed
the
bot/issue-358
branch
from
November 25, 2026 08:36
b35dd13 to
6bfa874
Compare
This was referenced Nov 25, 2026
Hona
added a commit
that referenced
this pull request
Nov 25, 2026
#2206 added a bool (selectable_cursor) to TextSpec, which made it 232 bytes; the compile-time assert on its size (224, the budget of #579) then failed, and rune no longer compiled on any 64-bit target. fade_em, the width of a truncate_fade edge that few texts set, moves behind the cold box; the new flag takes its room. The usual width is the cold block's default, so truncate_fade allocates nothing.
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.
Closes #358.
Adds
El::selection_enabled(on: bool), which turnsEl::selectabletext on or off for a whole subtree. It works like SwiftUI's.textSelection(.disabled). Setting it on the view's root gives one app-wide "Enable text selection" setting.How it behaves
falseturns off everyEl::selectabletext in the element and below it: no I-beam, drag, double- or triple-click, Cmd/Ctrl+A,Tx::select_text,Tx::select_all_textor copy. Those texts leave theirEl::selection_group, and a selection holding one of them clears at the next commit (prune_text_selection).trueon a descendant turns selection back on for that subtree, for values meant to be copied.Why a separate builder, not an inherited
El::selectable(false)as the issue suggested: message bodies call.selectable(true), and the app switch has to override that. With a single inheritedselectableflag there would be no way to tell "this text is copyable" apart from "selection is allowed here". It is namedselection_enabledso it doesn't clash with theTx::text_selection()/Runtime::text_selection()getters.How it works
ElColdgainsselection_enabled: Option<bool>andNodegains an inheritedselection_off.flatten_nodeclearsTextSpec::selectableon texts in an off subtree. Hit testing, selection, copy, accessibility and paint already read that field.El::selectablenow records on the text (TextSpec::selectable_cursor) when it was the one that added the I-beam, and only that I-beam is removed. A cursor set withEl::cursorstays.caret_browsinggroup in an off subtree doesn't take focus (flatten.rsandis_caret_browsing_node).InheritedFlatten.selection_offandsame_el_coldkeep a memo flattened under one setting from being reused under the other.window_tree,populate_virtual_children,virtual_selection::Scope,remountandselection_collectcarry the value, so rows that aren't mounted add no texts from an off subtree.page_text_selects).el/selection_scope.rs. Files already over the 800-line cap gain only a few lines each, so this doesn't do the separate split-first PR that AGENTS.md asks for before adding to them.changelog/unreleased/2026-11-25-selection-enabled.md.Tests:
crates/rune/src/runtime/selection_enabled_tests.rs, 12 tests:select_all_textorselect_text, and no I-beam;trueopts back in, and its group skips the turned-off texts;memofollows its ancestor's switch both ways;selectableadded is removed;virtual_rowsunder an off root select nothing, before and after scrolling;Not yet built or run:
cargoisn't available where this was written, so nothing has been compiled, linted or tested. That needs CI or a local run:cargo test -p rune -p rune-mermaid -p rune-kit --features rune-kit/markdown,rune-kit/mermaidcargo check --workspace --all-targetscargo clippyscripts/file-size.shpasses (no errors, no folders out of shape), and the public-repo hygiene grep is clean. The web-page change has no test.Closes #358