patches: fix 3 blockers — duplicate functions, idx typo, doc cap
BLOCKER fixes: 1. Remove duplicate ns_ax_face_is_selected, ns_ax_selected_overlay_text, ns_ax_selected_child_frame_text definitions from patch 0002 (now defined only in 0007/0008 where they belong) 2. Fix idx → point_idx in accessibilityInsertionPointLineNumber (0002) 3. Remove stale 100K cap reference from documentation (0006) Architecture fix: - ns_ax_selected_child_frame_text moved from 0007 to 0008 (where it logically belongs) Verified: all 8 patches apply cleanly on fresh emacs HEAD.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
From 8f619411ec75efbd18e663bb3f2ed6f8c9af60d8 Mon Sep 17 00:00:00 2001
|
||||
From 6bb9020421ce0e8459d2095385972b47c64fd184 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Sukany <martin@sukany.cz>
|
||||
Date: Sat, 28 Feb 2026 14:46:25 +0100
|
||||
Subject: [PATCH 7/8] ns: announce overlay completion candidates for VoiceOver
|
||||
@@ -52,8 +52,8 @@ Independent overlay branch, BUF_CHARS_MODIFF gating, candidate
|
||||
announcement with overlay Zoom rect storage.
|
||||
---
|
||||
src/nsterm.h | 3 +
|
||||
src/nsterm.m | 361 ++++++++++++++++++++++++++++++++++++++++++++++-----
|
||||
2 files changed, 329 insertions(+), 35 deletions(-)
|
||||
src/nsterm.m | 359 ++++++++++++++++++++++++++++++++++++++++++++++-----
|
||||
2 files changed, 327 insertions(+), 35 deletions(-)
|
||||
|
||||
diff --git a/src/nsterm.h b/src/nsterm.h
|
||||
index 5298386..a007925 100644
|
||||
@@ -77,10 +77,10 @@ index 5298386..a007925 100644
|
||||
BOOL font_panel_active;
|
||||
NSFont *font_panel_result;
|
||||
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||
index 125e52c..ebd52c6 100644
|
||||
index b3bef4b..7025e6e 100644
|
||||
--- a/src/nsterm.m
|
||||
+++ b/src/nsterm.m
|
||||
@@ -3258,7 +3258,12 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
|
||||
@@ -3258,7 +3258,12 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
|
||||
&& MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
|
||||
if (UAZoomEnabled ())
|
||||
{
|
||||
@@ -94,9 +94,9 @@ index 125e52c..ebd52c6 100644
|
||||
NSRect screenRect = [[view window] convertRectToScreen:windowRect];
|
||||
CGRect cgRect = NSRectToCGRect (screenRect);
|
||||
|
||||
@@ -7159,11 +7164,156 @@ ns_ax_selected_child_frame_text (struct buffer *b, Lisp_Object buf_obj,
|
||||
}
|
||||
@@ -6909,11 +6914,154 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||
|
||||
/* ---- Helper: extract buffer text for accessibility ---- */
|
||||
|
||||
+/* Return true if FACE is or contains a face symbol whose name
|
||||
+ includes "current" or "selected", indicating a highlighted
|
||||
@@ -242,8 +242,6 @@ index 125e52c..ebd52c6 100644
|
||||
+
|
||||
+ return nil;
|
||||
+}
|
||||
+
|
||||
+
|
||||
/* Build accessibility text for window W, skipping invisible text.
|
||||
Populates *OUT_START with the buffer start charpos.
|
||||
Populates *OUT_RUNS with an array of visible runs and *OUT_NRUNS
|
||||
@@ -252,7 +250,7 @@ index 125e52c..ebd52c6 100644
|
||||
static NSString *
|
||||
ns_ax_buffer_text (struct window *w, ptrdiff_t *out_start,
|
||||
ns_ax_visible_run **out_runs, NSUInteger *out_nruns)
|
||||
@@ -7234,7 +7384,7 @@ ns_ax_buffer_text (struct window *w, ptrdiff_t *out_start,
|
||||
@@ -6984,7 +7132,7 @@ Accessibility virtual elements (macOS / Cocoa only)
|
||||
|
||||
/* Extract this visible run's text. Use
|
||||
Fbuffer_substring_no_properties which correctly handles the
|
||||
@@ -261,7 +259,7 @@ index 125e52c..ebd52c6 100644
|
||||
include garbage bytes when the run spans the gap position. */
|
||||
Lisp_Object lstr = Fbuffer_substring_no_properties (
|
||||
make_fixnum (pos), make_fixnum (run_end));
|
||||
@@ -7315,7 +7465,7 @@ ns_ax_frame_for_range (struct window *w, EmacsView *view,
|
||||
@@ -7065,7 +7213,7 @@ Mode lines using icon fonts (e.g. doom-modeline with nerd-font)
|
||||
return NSZeroRect;
|
||||
|
||||
/* charpos_start and charpos_len are already in buffer charpos
|
||||
@@ -270,7 +268,7 @@ index 125e52c..ebd52c6 100644
|
||||
charposForAccessibilityIndex which handles invisible text. */
|
||||
ptrdiff_t cp_start = charpos_start;
|
||||
ptrdiff_t cp_end = cp_start + charpos_len;
|
||||
@@ -7794,6 +7944,7 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
@@ -7544,6 +7692,7 @@ @implementation EmacsAccessibilityBuffer
|
||||
@synthesize cachedOverlayModiff;
|
||||
@synthesize cachedTextStart;
|
||||
@synthesize cachedModiff;
|
||||
@@ -278,7 +276,7 @@ index 125e52c..ebd52c6 100644
|
||||
@synthesize cachedPoint;
|
||||
@synthesize cachedMarkActive;
|
||||
@synthesize cachedCompletionAnnouncement;
|
||||
@@ -7891,7 +8042,7 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
@@ -7641,7 +7790,7 @@ - (void)ensureTextCache
|
||||
NSTRACE ("EmacsAccessibilityBuffer ensureTextCache");
|
||||
/* This method is only called from the main thread (AX getters
|
||||
dispatch_sync to main first). Reads of cachedText/cachedTextModiff
|
||||
@@ -287,7 +285,7 @@ index 125e52c..ebd52c6 100644
|
||||
write section at the end needs synchronization to protect
|
||||
against concurrent reads from AX server thread. */
|
||||
eassert ([NSThread isMainThread]);
|
||||
@@ -7904,16 +8055,15 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
@@ -7654,16 +7803,15 @@ - (void)ensureTextCache
|
||||
return;
|
||||
|
||||
ptrdiff_t modiff = BUF_MODIFF (b);
|
||||
@@ -310,7 +308,7 @@ index 125e52c..ebd52c6 100644
|
||||
&& cachedTextStart == BUF_BEGV (b)
|
||||
&& pt >= cachedTextStart
|
||||
&& (textLen == 0
|
||||
@@ -7930,7 +8080,6 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
@@ -7680,7 +7828,6 @@ - (void)ensureTextCache
|
||||
[cachedText release];
|
||||
cachedText = [text retain];
|
||||
cachedTextModiff = modiff;
|
||||
@@ -318,7 +316,7 @@ index 125e52c..ebd52c6 100644
|
||||
cachedTextStart = start;
|
||||
|
||||
if (visibleRuns)
|
||||
@@ -7995,7 +8144,7 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
@@ -7745,7 +7892,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
/* Binary search: runs are sorted by charpos (ascending). Find the
|
||||
run whose [charpos, charpos+length) range contains the target,
|
||||
or the nearest run after an invisible gap. O(log n) instead of
|
||||
@@ -327,7 +325,7 @@ index 125e52c..ebd52c6 100644
|
||||
NSUInteger lo = 0, hi = visibleRunCount;
|
||||
while (lo < hi)
|
||||
{
|
||||
@@ -8008,7 +8157,7 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
@@ -7758,7 +7905,7 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
else
|
||||
{
|
||||
/* Found: charpos is inside this run. Compute UTF-16 delta
|
||||
@@ -336,7 +334,7 @@ index 125e52c..ebd52c6 100644
|
||||
NSUInteger chars_in = (NSUInteger)(charpos - r->charpos);
|
||||
if (chars_in == 0 || !cachedText)
|
||||
return r->ax_start;
|
||||
@@ -8033,10 +8182,10 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
@@ -7783,10 +7930,10 @@ - (NSUInteger)accessibilityIndexForCharpos:(ptrdiff_t)charpos
|
||||
|
||||
/* Convert accessibility string index to buffer charpos.
|
||||
Safe to call from any thread: uses only cachedText (NSString) and
|
||||
@@ -349,7 +347,7 @@ index 125e52c..ebd52c6 100644
|
||||
@synchronized (self)
|
||||
{
|
||||
if (visibleRunCount == 0)
|
||||
@@ -8070,7 +8219,7 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
@@ -7820,7 +7967,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
||||
return cp;
|
||||
}
|
||||
}
|
||||
@@ -358,7 +356,7 @@ index 125e52c..ebd52c6 100644
|
||||
if (lo > 0)
|
||||
{
|
||||
ns_ax_visible_run *last = &visibleRuns[visibleRunCount - 1];
|
||||
@@ -8092,7 +8241,7 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
@@ -7842,7 +7989,7 @@ - (ptrdiff_t)charposForAccessibilityIndex:(NSUInteger)ax_idx
|
||||
deadlocking the AX server thread. This is prevented by:
|
||||
|
||||
1. validWindow checks WINDOW_LIVE_P and BUFFERP before every
|
||||
@@ -367,13 +365,10 @@ index 125e52c..ebd52c6 100644
|
||||
2. All dispatch_sync blocks run on the main thread where no
|
||||
concurrent Lisp code can modify state between checks.
|
||||
3. block_input prevents timer events and process output from
|
||||
@@ -8443,7 +8592,51 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
if (point_idx > [cachedText length])
|
||||
point_idx = [cachedText length];
|
||||
@@ -8196,6 +8343,50 @@ - (NSInteger)accessibilityInsertionPointLineNumber
|
||||
return [self lineForAXIndex:point_idx];
|
||||
}
|
||||
|
||||
+ return [self lineForAXIndex:point_idx];
|
||||
+}
|
||||
+
|
||||
+- (NSString *)accessibilityStringForRange:(NSRange)range
|
||||
+{
|
||||
+ if (![NSThread isMainThread])
|
||||
@@ -414,12 +409,14 @@ index 125e52c..ebd52c6 100644
|
||||
+ if (idx > [cachedText length])
|
||||
+ idx = [cachedText length];
|
||||
+
|
||||
return [self lineForAXIndex:idx];
|
||||
+ return [self lineForAXIndex:idx];
|
||||
+
|
||||
+}
|
||||
+
|
||||
}
|
||||
|
||||
- (NSRange)accessibilityRangeForLine:(NSInteger)line
|
||||
@@ -8667,7 +8860,7 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
{
|
||||
if (![NSThread isMainThread])
|
||||
@@ -8417,7 +8608,7 @@ - (NSRect)accessibilityFrame
|
||||
|
||||
|
||||
/* ===================================================================
|
||||
@@ -428,7 +425,7 @@ index 125e52c..ebd52c6 100644
|
||||
|
||||
These methods notify VoiceOver of text and selection changes.
|
||||
Called from the redisplay cycle (postAccessibilityUpdates).
|
||||
@@ -8682,7 +8875,7 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
@@ -8432,7 +8623,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
||||
if (point > self.cachedPoint
|
||||
&& point - self.cachedPoint == 1)
|
||||
{
|
||||
@@ -437,7 +434,7 @@ index 125e52c..ebd52c6 100644
|
||||
[self invalidateTextCache];
|
||||
[self ensureTextCache];
|
||||
if (cachedText)
|
||||
@@ -8701,7 +8894,7 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
@@ -8451,7 +8642,7 @@ - (void)postTextChangedNotification:(ptrdiff_t)point
|
||||
/* Update cachedPoint here so the selection-move branch does NOT
|
||||
fire for point changes caused by edits. WebKit and Chromium
|
||||
never send both ValueChanged and SelectedTextChanged for the
|
||||
@@ -446,7 +443,7 @@ index 125e52c..ebd52c6 100644
|
||||
self.cachedPoint = point;
|
||||
|
||||
NSDictionary *change = @{
|
||||
@@ -9034,14 +9227,112 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
@@ -8784,14 +8975,112 @@ - (void)postAccessibilityNotificationsForFrame:(struct frame *)f
|
||||
BOOL markActive = !NILP (BVAR (b, mark_active));
|
||||
|
||||
/* --- Text changed (edit) --- */
|
||||
@@ -561,7 +558,7 @@ index 125e52c..ebd52c6 100644
|
||||
per the WebKit/Chromium pattern. */
|
||||
else if (point != self.cachedPoint || markActive != self.cachedMarkActive)
|
||||
{
|
||||
@@ -9211,7 +9502,7 @@ ns_ax_completion_text_for_span (EmacsAccessibilityBuffer *elem,
|
||||
@@ -8961,7 +9250,7 @@ - (NSRect)accessibilityFrame
|
||||
|
||||
|
||||
/* ===================================================================
|
||||
@@ -570,7 +567,7 @@ index 125e52c..ebd52c6 100644
|
||||
=================================================================== */
|
||||
|
||||
/* Scan visible range of window W for interactive spans.
|
||||
@@ -9402,7 +9693,7 @@ ns_ax_scan_interactive_spans (struct window *w,
|
||||
@@ -9152,7 +9441,7 @@ - (NSRect) accessibilityFrame
|
||||
- (BOOL) isAccessibilityFocused
|
||||
{
|
||||
/* Read the cached point stored by EmacsAccessibilityBuffer on the main
|
||||
@@ -579,7 +576,7 @@ index 125e52c..ebd52c6 100644
|
||||
EmacsAccessibilityBuffer *pb = self.parentBuffer;
|
||||
if (!pb)
|
||||
return NO;
|
||||
@@ -9419,7 +9710,7 @@ ns_ax_scan_interactive_spans (struct window *w,
|
||||
@@ -9169,7 +9458,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
||||
dispatch_async (dispatch_get_main_queue (), ^{
|
||||
/* lwin is a Lisp_Object captured by value. This is GC-safe
|
||||
because Lisp_Objects are tagged integers/pointers that
|
||||
@@ -588,7 +585,7 @@ index 125e52c..ebd52c6 100644
|
||||
Emacs. The WINDOW_LIVE_P check below guards against the
|
||||
window being deleted between capture and execution. */
|
||||
if (!WINDOWP (lwin) || NILP (Fwindow_live_p (lwin)))
|
||||
@@ -9445,7 +9736,7 @@ ns_ax_scan_interactive_spans (struct window *w,
|
||||
@@ -9195,7 +9484,7 @@ - (void) setAccessibilityFocused: (BOOL) focused
|
||||
|
||||
@end
|
||||
|
||||
@@ -597,7 +594,7 @@ index 125e52c..ebd52c6 100644
|
||||
Methods are kept here (same .m file) so they access the ivars
|
||||
declared in the @interface ivar block. */
|
||||
@implementation EmacsAccessibilityBuffer (InteractiveSpans)
|
||||
@@ -10765,13 +11056,13 @@ ns_in_echo_area (void)
|
||||
@@ -10515,13 +10804,13 @@ - (NSSize)windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize
|
||||
if (old_title == 0)
|
||||
{
|
||||
char *t = strdup ([[[self window] title] UTF8String]);
|
||||
@@ -613,7 +610,7 @@ index 125e52c..ebd52c6 100644
|
||||
[window setTitle: [NSString stringWithUTF8String: size_title]];
|
||||
[window display];
|
||||
xfree (size_title);
|
||||
@@ -12167,7 +12458,7 @@ ns_ax_collect_windows (Lisp_Object window, EmacsView *view,
|
||||
@@ -11917,7 +12206,7 @@ - (int) fullscreenState
|
||||
|
||||
if (WINDOW_LEAF_P (w))
|
||||
{
|
||||
@@ -622,7 +619,7 @@ index 125e52c..ebd52c6 100644
|
||||
EmacsAccessibilityBuffer *elem
|
||||
= [existing objectForKey:[NSValue valueWithPointer:w]];
|
||||
if (!elem)
|
||||
@@ -12201,7 +12492,7 @@ ns_ax_collect_windows (Lisp_Object window, EmacsView *view,
|
||||
@@ -11951,7 +12240,7 @@ - (int) fullscreenState
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -631,7 +628,7 @@ index 125e52c..ebd52c6 100644
|
||||
Lisp_Object child = w->contents;
|
||||
while (!NILP (child))
|
||||
{
|
||||
@@ -12313,7 +12604,7 @@ ns_ax_collect_windows (Lisp_Object window, EmacsView *view,
|
||||
@@ -12063,7 +12352,7 @@ - (void)postAccessibilityUpdates
|
||||
accessibilityUpdating = YES;
|
||||
|
||||
/* Detect window tree change (split, delete, new buffer). Compare
|
||||
@@ -640,7 +637,7 @@ index 125e52c..ebd52c6 100644
|
||||
Lisp_Object curRoot = FRAME_ROOT_WINDOW (emacsframe);
|
||||
if (!EQ (curRoot, lastRootWindow))
|
||||
{
|
||||
@@ -12322,12 +12613,12 @@ ns_ax_collect_windows (Lisp_Object window, EmacsView *view,
|
||||
@@ -12072,12 +12361,12 @@ - (void)postAccessibilityUpdates
|
||||
}
|
||||
|
||||
/* If tree is stale, rebuild FIRST so we don't iterate freed
|
||||
|
||||
Reference in New Issue
Block a user