patches: fix granularity — line comparison not delta, fixes org-mode empty lines
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
From b8ca9a5b66f8fd6f60e4f0263c620ae21be9d776 Mon Sep 17 00:00:00 2001
|
||||
From 26208baf6a7d44d471d0c99bd99e288cd23472bc Mon Sep 17 00:00:00 2001
|
||||
From: Martin Sukany <martin@sukany.cz>
|
||||
Date: Fri, 27 Feb 2026 11:14:26 +0100
|
||||
Date: Fri, 27 Feb 2026 11:36:03 +0100
|
||||
Subject: [PATCH] ns: implement VoiceOver accessibility (AXBoundsForRange, line
|
||||
nav, completions, interactive spans)
|
||||
|
||||
---
|
||||
src/nsterm.h | 109 ++
|
||||
src/nsterm.m | 2679 +++++++++++++++++++++++++++++++++++++++++++++++---
|
||||
2 files changed, 2639 insertions(+), 149 deletions(-)
|
||||
src/nsterm.m | 2674 +++++++++++++++++++++++++++++++++++++++++++++++---
|
||||
2 files changed, 2634 insertions(+), 149 deletions(-)
|
||||
|
||||
diff --git a/src/nsterm.h b/src/nsterm.h
|
||||
index 7c1ee4c..6c95673 100644
|
||||
@@ -144,7 +144,7 @@ index 7c1ee4c..6c95673 100644
|
||||
|
||||
|
||||
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||
index 932d209..367ee50 100644
|
||||
index 932d209..e81798a 100644
|
||||
--- a/src/nsterm.m
|
||||
+++ b/src/nsterm.m
|
||||
@@ -46,6 +46,7 @@ Updated by Christian Limpach (chris@nice.ch)
|
||||
@@ -205,7 +205,7 @@ index 932d209..367ee50 100644
|
||||
ns_focus (f, NULL, 0);
|
||||
|
||||
NSGraphicsContext *ctx = [NSGraphicsContext currentContext];
|
||||
@@ -6849,219 +6886,2240 @@ - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg
|
||||
@@ -6849,219 +6886,2235 @@ - (BOOL)fulfillService: (NSString *)name withArg: (NSString *)arg
|
||||
|
||||
/* ==========================================================================
|
||||
|
||||
@@ -1935,34 +1935,29 @@ index 932d209..367ee50 100644
|
||||
+ int ctrlNP = 0;
|
||||
+ bool isCtrlNP = ns_ax_event_is_ctrl_n_or_p (&ctrlNP);
|
||||
+
|
||||
+ /* Compute granularity from movement distance.
|
||||
+ Prefer robust line-range comparison for vertical movement,
|
||||
+ otherwise single char (1) or unknown (0). */
|
||||
+ /* Compute granularity by comparing old and new line positions.
|
||||
+ Never use delta==1 as a proxy for "character move" — a single
|
||||
+ buffer character can cross a line boundary (e.g. empty lines,
|
||||
+ org-mode invisible text gaps) and VoiceOver would say "new line"
|
||||
+ for the \n character instead of reading the next line. */
|
||||
+ NSInteger granularity = ns_ax_text_selection_granularity_unknown;
|
||||
+ [self ensureTextCache];
|
||||
+ if (cachedText && oldPoint > 0)
|
||||
+ {
|
||||
+ ptrdiff_t delta = point - oldPoint;
|
||||
+ if (delta == 1 || delta == -1)
|
||||
+ granularity = ns_ax_text_selection_granularity_character; /* Character. */
|
||||
+ else
|
||||
+ {
|
||||
+ NSUInteger tlen = [cachedText length];
|
||||
+ NSUInteger oldIdx = [self accessibilityIndexForCharpos:oldPoint];
|
||||
+ NSUInteger newIdx = [self accessibilityIndexForCharpos:point];
|
||||
+ if (oldIdx > tlen)
|
||||
+ oldIdx = tlen;
|
||||
+ if (newIdx > tlen)
|
||||
+ newIdx = tlen;
|
||||
+ if (oldIdx > tlen) oldIdx = tlen;
|
||||
+ if (newIdx > tlen) newIdx = tlen;
|
||||
+
|
||||
+ NSRange oldLine = [cachedText lineRangeForRange:
|
||||
+ NSMakeRange (oldIdx, 0)];
|
||||
+ NSRange newLine = [cachedText lineRangeForRange:
|
||||
+ NSMakeRange (newIdx, 0)];
|
||||
+ if (oldLine.location != newLine.location)
|
||||
+ granularity = ns_ax_text_selection_granularity_line; /* Line. */
|
||||
+
|
||||
+ }
|
||||
+ granularity = ns_ax_text_selection_granularity_line;
|
||||
+ else if (oldIdx != newIdx)
|
||||
+ granularity = ns_ax_text_selection_granularity_character;
|
||||
+ }
|
||||
+
|
||||
+ /* Force line semantics for explicit C-n/C-p keystrokes.
|
||||
@@ -2595,7 +2590,7 @@ index 932d209..367ee50 100644
|
||||
unsigned fnKeysym = 0;
|
||||
static NSMutableArray *nsEvArray;
|
||||
unsigned int flags = [theEvent modifierFlags];
|
||||
@@ -8237,6 +10295,28 @@ - (void)windowDidBecomeKey /* for direct calls */
|
||||
@@ -8237,6 +10290,28 @@ - (void)windowDidBecomeKey /* for direct calls */
|
||||
XSETFRAME (event.frame_or_window, emacsframe);
|
||||
kbd_buffer_store_event (&event);
|
||||
ns_send_appdefined (-1); // Kick main loop
|
||||
@@ -2624,7 +2619,7 @@ index 932d209..367ee50 100644
|
||||
}
|
||||
|
||||
|
||||
@@ -9474,6 +11554,307 @@ - (int) fullscreenState
|
||||
@@ -9474,6 +11549,307 @@ - (int) fullscreenState
|
||||
return fs_state;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user