Skip to content

Commit ccd9784

Browse files
committed
Fix inconsistant zoom in/out all the way. Fixes #413.
1 parent e6ab510 commit ccd9784

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

Rules/Languages/en/navigate.yaml

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,16 @@
4848
- if: "$MatchCounter = 0 and $SayCommand = 'true'"
4949
then_test:
5050
- if: "self::m:math and starts-with($NavCommand, 'ZoomOut')"
51-
then: [t: "zoomed out all the way", pause: "medium"]
51+
then: [t: "zoomed out all of the way", pause: "medium"]
5252
- else_if: "IsNode(., 'leaf') and starts-with($NavCommand, 'ZoomIn')"
53-
then: [t: "zoomed in all the way", pause: "medium"]
53+
then:
54+
- test:
55+
- if: "string-length(.) = 1"
56+
then: [t: "zoomed in all of the way"] # phrase('zoomed in all of the way')
57+
- else_if: "$NavNodeOffset = 0"
58+
then: [t: "zoomed in to first character"] # phrase('zoomed in to first character')
59+
else: [t: "zoomed to character"] # phrase('zoomed in to character')
60+
- pause: "medium"
5461
else:
5562
- test:
5663
- if: "starts-with($NavCommand, 'Zoom')"
@@ -70,12 +77,12 @@
7077
then: [t: "in"] # phrase(zoom 'in' to see more details)
7178
- else_if: "substring($NavCommand, string-length($Prefix)+1) = 'InAll'"
7279
# HACK: '\uF8FE' is used internally for the concatenation char by 'ct' -- this gets "ed" concatenated to "zoom"
73-
then: [t: "\uF8FEed in all the way"] # phrase(zoom 'out all the way' to see more details)
80+
then: [t: "\uF8FEed in all of the way"] # phrase(zoom 'out all of the way' to see more details)
7481
- else_if: "substring($NavCommand, string-length($Prefix)+1) = 'Out'"
7582
then: [t: "out"] # phrase(zoom 'out' to see more details)
7683
- else_if: "substring($NavCommand, string-length($Prefix)+1) = 'OutAll'"
7784
# HACK: '\uF8FE' is used internally for the concatenation char by 'ct' -- this gets "ed" concatenated to "zoom"
78-
then: [t: "\uF8FEed out all the way"] # phrase(zoom 'out all the way' to see more details)
85+
then: [t: "\uF8FEed out all of the way"] # phrase(zoom 'out all of the way' to see more details)
7986
- else_if: "substring($NavCommand, string-length($Prefix)+1) = 'Next'"
8087
then: [t: "right"] # phrase(move to the 'right')
8188
- else_if: "substring($NavCommand, string-length($Prefix)+1) = 'Previous'"
@@ -180,9 +187,9 @@
180187
- else_if: "$PreviousNavCommand = 'ZoomOut'"
181188
then: [t: "undo zoom out"] # phrase('undo zoom out')
182189
- else_if: "$PreviousNavCommand = 'ZoomInAll'"
183-
then: [t: "undo zooming in all the way"] # phrase('undo zooming in all the way')
190+
then: [t: "undo zooming in all of the way"] # phrase('undo zooming in all of the way')
184191
- else_if: "$PreviousNavCommand = 'ZoomOutAll'"
185-
then: [t: "undo zooming out all the way"] # phrase('undo zooming out all the way')
192+
then: [t: "undo zooming out all of the way"] # phrase('undo zooming out all of the way')
186193
- else_if: "$PreviousNavCommand = 'MovePrevious' or $PreviousNavCommand = 'MovePreviousZoom'"
187194
then: [t: "undo move left"] # phrase('undo move left')
188195
- else_if: "$PreviousNavCommand = 'MoveNext' or $PreviousNavCommand = 'MoveNextZoom'"
@@ -209,25 +216,15 @@
209216
tag: "*"
210217
match: "($NavCommand = 'ZoomIn' or $NavCommand = 'ZoomInAll') and IsNode(., 'leaf')"
211218
replace:
212-
- test:
213-
if: "$MatchCounter = 0 and $NavVerbosity != 'Terse'"
214-
then:
215-
- test:
216-
- if: "string-length(.) = 1"
217-
then:
218-
- t: "zoomed in all of the way"
219-
- else_if: "$NavNodeOffset = 0"
220-
then:
221-
- t: "zoomed in to first character" # phrase('zoomed in to first character')
222-
else:
223-
- t: "zoomed to character" # phrase('zoomed in to character')
224-
- pause: "long"
219+
- with:
220+
variables: [SayCommand: "string($NavVerbosity != 'Terse')"]
221+
replace: [x: "."]
225222
- test:
226223
if: "$ReadZoomLevel !=-1"
227224
then:
228225
- set_variables: [ReadZoomLevel: "0"]
229226
- test:
230-
if: "string-length(.) > 1 and $MatchCounter = 0 and $NavNodeOffset = 0"
227+
if: "string-length(.) > 1 and $MatchCounter = 1 and $NavNodeOffset = 0"
231228
then: [set_variables: [NavNodeOffset: "1"]]
232229
- set_variables: [NavNode: "@id"]
233230

@@ -372,7 +369,7 @@
372369
match: "$NavCommand = 'ZoomOut' or $NavCommand = 'ZoomOutAll'"
373370
replace:
374371
- with:
375-
variables: [SayCommand: "string($NavVerbosity = 'Verbose')"]
372+
variables: [SayCommand: "string($NavVerbosity != 'Terse')"]
376373
replace: [x: "."]
377374
- set_variables: [NavNode: "*[1]/@id"] # no-op for $NavCommand = 'ZoomOut'
378375

@@ -389,7 +386,7 @@
389386
tag: "*"
390387
match:
391388
- "($NavCommand = 'ZoomOut' or $NavCommand = 'ZoomOutAll') and"
392-
- "parent::m:math "
389+
- "parent::m:math"
393390
replace:
394391
- x: ".." # let math rule deal with it
395392

src/navigate.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ mod tests {
14101410
return MATHML_INSTANCE.with(|package_instance| {
14111411
let package_instance = package_instance.borrow();
14121412
let mathml = get_element(&*package_instance);
1413-
assert_eq!("zoomed in all the way; 1", test_command("ZoomInAll", mathml, "id-2"));
1413+
assert_eq!("zoomed in all of the way; 1", test_command("ZoomInAll", mathml, "id-2"));
14141414
assert_eq!("move right; plus", test_command("MoveNext", mathml, "id-3"));
14151415
assert_eq!("move right; in base; x", test_command("MoveNext", mathml, "id-5"));
14161416
assert_eq!("move right; in subscript; 2", test_command("MoveNext", mathml, "id-6"));
@@ -1449,7 +1449,7 @@ mod tests {
14491449
return MATHML_INSTANCE.with(|package_instance| {
14501450
let package_instance = package_instance.borrow();
14511451
let mathml = get_element(&*package_instance);
1452-
assert_eq!("zoomed in all the way; in base; open bracket", test_command("ZoomInAll", mathml, "id-3"));
1452+
assert_eq!("zoomed in all of the way; in base; open bracket", test_command("ZoomInAll", mathml, "id-3"));
14531453
assert_eq!("move right; in base; cap c o", test_command("MoveNext", mathml, "id-5"));
14541454
assert_eq!("move right; in subscript; 6", test_command("MoveNext", mathml, "id-6"));
14551455
assert_eq!("move right; out of subscript; close bracket", test_command("MoveNext", mathml, "id-8"));
@@ -1634,6 +1634,7 @@ mod tests {
16341634

16351635
#[test]
16361636
fn move_inside_leaves() -> Result<()> {
1637+
init_logger();
16371638
let mathml_str = "<math display='block' id='id-0'>
16381639
<mrow id='id-1'>
16391640
<mfrac id='id-2'>
@@ -2174,7 +2175,7 @@ mod tests {
21742175
let speech = test_command("MoveNext", mathml, "row2-negative");
21752176
assert_eq!(speech, "move right; column 2, negative 6");
21762177
let speech = test_command("ZoomOutAll", mathml, "table");
2177-
assert_eq!(speech, "zoomed out all the way; the 2 by 2 determinant; row 1; 9, negative 13; row 2; 5, negative 6");
2178+
assert_eq!(speech, "zoomed out all of the way; the 2 by 2 determinant; row 1; 9, negative 13; row 2; 5, negative 6");
21782179
return Ok( () );
21792180
});
21802181
}
@@ -2386,7 +2387,7 @@ mod tests {
23862387
let package_instance = package_instance.borrow();
23872388
let mathml = get_element(&*package_instance);
23882389
let speech = test_command("ZoomOutAll", mathml, "mrow");
2389-
assert_eq!(speech, "zoomed out all the way; 1 plus 2 plus 3 plus 4 plus 5 plus 6 plus 7");
2390+
assert_eq!(speech, "zoomed out all of the way; 1 plus 2 plus 3 plus 4 plus 5 plus 6 plus 7");
23902391
let speech = test_command("ReadCurrent", mathml, "mrow");
23912392
assert_eq!(speech, "read current; 1 plus 2 plus 3 plus 4 plus 5 plus 6 plus 7");
23922393
let speech = test_command("DescribeCurrent", mathml, "mrow");

0 commit comments

Comments
 (0)