core: send selection_changed notification

The core had no signal to the apprt when the active selection changed,
so a consumer (e.g. a screen reader) kept reading a stale selection
until some unrelated query refreshed it.

This change adds a payload-less selection_changed action that's fired on
a selection state transition. The apprt reads the current selection
through the normal read path.

This consolidates selection state changes so the notification fires
consistently: all sites route through setSelection rather than calling
screen.select directly, including the mouse paths that previously
bypassed it for clipboard timing.

The new setSelectionAndCopy extends setSelection with the additional
'copy_on_select' behavior.

On macOS, this posts .ghosttySelectionDidChange, which is debounced
before posting a NSAccessibility .selectedTextChanged notification.

GTK has no consumer yet and no-ops the action.
This commit is contained in:
Jon Parise
2026-06-01 11:05:17 -04:00
parent 6246c288ae
commit c4e1ab8883
7 changed files with 93 additions and 17 deletions

View File

@@ -295,6 +295,10 @@ pub const Action = union(Key) {
/// it needs to ring the bell. This is usually a sound or visual effect.
ring_bell,
/// Called when the active selection changes. The apprt should read the
/// current selection itself; this carries no payload.
selection_changed,
/// Undo the last action. See the "undo" keybinding for more
/// details on what can and cannot be undone.
undo,
@@ -396,6 +400,7 @@ pub const Action = union(Key) {
config_change,
close_window,
ring_bell,
selection_changed,
undo,
redo,
check_for_updates,

View File

@@ -743,6 +743,9 @@ pub const Application = extern struct {
.ring_bell => Action.ringBell(target),
// GTK has no accessibility consumer for this yet.
.selection_changed => {},
.scrollbar => Action.scrollbar(target, value),
.set_title => Action.setTitle(target, value),