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>
|
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
|
Subject: [PATCH] ns: implement VoiceOver accessibility (AXBoundsForRange, line
|
||||||
nav, completions, interactive spans)
|
nav, completions, interactive spans)
|
||||||
|
|
||||||
---
|
---
|
||||||
src/nsterm.h | 109 ++
|
src/nsterm.h | 109 ++
|
||||||
src/nsterm.m | 2679 +++++++++++++++++++++++++++++++++++++++++++++++---
|
src/nsterm.m | 2674 +++++++++++++++++++++++++++++++++++++++++++++++---
|
||||||
2 files changed, 2639 insertions(+), 149 deletions(-)
|
2 files changed, 2634 insertions(+), 149 deletions(-)
|
||||||
|
|
||||||
diff --git a/src/nsterm.h b/src/nsterm.h
|
diff --git a/src/nsterm.h b/src/nsterm.h
|
||||||
index 7c1ee4c..6c95673 100644
|
index 7c1ee4c..6c95673 100644
|
||||||
@@ -144,7 +144,7 @@ index 7c1ee4c..6c95673 100644
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/nsterm.m b/src/nsterm.m
|
diff --git a/src/nsterm.m b/src/nsterm.m
|
||||||
index 932d209..367ee50 100644
|
index 932d209..e81798a 100644
|
||||||
--- a/src/nsterm.m
|
--- a/src/nsterm.m
|
||||||
+++ b/src/nsterm.m
|
+++ b/src/nsterm.m
|
||||||
@@ -46,6 +46,7 @@ Updated by Christian Limpach (chris@nice.ch)
|
@@ -46,6 +46,7 @@ Updated by Christian Limpach (chris@nice.ch)
|
||||||
@@ -205,7 +205,7 @@ index 932d209..367ee50 100644
|
|||||||
ns_focus (f, NULL, 0);
|
ns_focus (f, NULL, 0);
|
||||||
|
|
||||||
NSGraphicsContext *ctx = [NSGraphicsContext currentContext];
|
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;
|
+ int ctrlNP = 0;
|
||||||
+ bool isCtrlNP = ns_ax_event_is_ctrl_n_or_p (&ctrlNP);
|
+ bool isCtrlNP = ns_ax_event_is_ctrl_n_or_p (&ctrlNP);
|
||||||
+
|
+
|
||||||
+ /* Compute granularity from movement distance.
|
+ /* Compute granularity by comparing old and new line positions.
|
||||||
+ Prefer robust line-range comparison for vertical movement,
|
+ Never use delta==1 as a proxy for "character move" — a single
|
||||||
+ otherwise single char (1) or unknown (0). */
|
+ 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;
|
+ NSInteger granularity = ns_ax_text_selection_granularity_unknown;
|
||||||
+ [self ensureTextCache];
|
+ [self ensureTextCache];
|
||||||
+ if (cachedText && oldPoint > 0)
|
+ if (cachedText && oldPoint > 0)
|
||||||
+ {
|
+ {
|
||||||
+ ptrdiff_t delta = point - oldPoint;
|
+ NSUInteger tlen = [cachedText length];
|
||||||
+ if (delta == 1 || delta == -1)
|
+ NSUInteger oldIdx = [self accessibilityIndexForCharpos:oldPoint];
|
||||||
+ granularity = ns_ax_text_selection_granularity_character; /* Character. */
|
+ NSUInteger newIdx = [self accessibilityIndexForCharpos:point];
|
||||||
+ else
|
+ if (oldIdx > tlen) oldIdx = tlen;
|
||||||
+ {
|
+ if (newIdx > tlen) newIdx = tlen;
|
||||||
+ NSUInteger tlen = [cachedText length];
|
|
||||||
+ NSUInteger oldIdx = [self accessibilityIndexForCharpos:oldPoint];
|
|
||||||
+ NSUInteger newIdx = [self accessibilityIndexForCharpos:point];
|
|
||||||
+ if (oldIdx > tlen)
|
|
||||||
+ oldIdx = tlen;
|
|
||||||
+ if (newIdx > tlen)
|
|
||||||
+ newIdx = tlen;
|
|
||||||
+
|
+
|
||||||
+ NSRange oldLine = [cachedText lineRangeForRange:
|
+ NSRange oldLine = [cachedText lineRangeForRange:
|
||||||
+ NSMakeRange (oldIdx, 0)];
|
+ NSMakeRange (oldIdx, 0)];
|
||||||
+ NSRange newLine = [cachedText lineRangeForRange:
|
+ NSRange newLine = [cachedText lineRangeForRange:
|
||||||
+ NSMakeRange (newIdx, 0)];
|
+ NSMakeRange (newIdx, 0)];
|
||||||
+ if (oldLine.location != newLine.location)
|
+ 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.
|
+ /* Force line semantics for explicit C-n/C-p keystrokes.
|
||||||
@@ -2595,7 +2590,7 @@ index 932d209..367ee50 100644
|
|||||||
unsigned fnKeysym = 0;
|
unsigned fnKeysym = 0;
|
||||||
static NSMutableArray *nsEvArray;
|
static NSMutableArray *nsEvArray;
|
||||||
unsigned int flags = [theEvent modifierFlags];
|
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);
|
XSETFRAME (event.frame_or_window, emacsframe);
|
||||||
kbd_buffer_store_event (&event);
|
kbd_buffer_store_event (&event);
|
||||||
ns_send_appdefined (-1); // Kick main loop
|
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;
|
return fs_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user