1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# RANGED LOOK PATHS. `path:LINE:COL` says where to PARK; a range says what to
# SELECT, and it belongs to the PATH (config.range_sep) rather than to the
# search that is merely the first thing writing one. So this script right-
# clicks the three spellings as ordinary words sitting in a file:
# r.txt:3-5 whole lines 3 through 5
# r.txt:7:4-9 line 7, columns 4 through 9
# r.txt:3:2-5:3 line 3 column 2 through line 5 column 3
# ...and only then presses `/`, whose result rows are exactly this syntax —
# which is how n/N step to a hit with the matched text selected.
#
# `snapstyle` is the assertion that matters: the grid TEXT after a ranged look
# is the same text a plain `:LINE:COL` look leaves, so the selection only shows
# in the styles.
file r.txt aaaa\nbbbb\ncccc dccc\ndddd\neeee\nffff\ngg NEEDLE gg\nhhhh NEEDLE\niiii
file look.txt r.txt:3-5\nr.txt:7:4-9\nr.txt:3:2-5:3\nr.txt:8:6-99:9
start 30 150 look.txt
wait 8000 r.txt:3-5
stable 700 20000
snap opened
# --- form 1: whole lines. r.txt opens BELOW look.txt (an ordinary look) with
# lines 3, 4 and 5 selected whole, terminators included — helix's own `x`.
press right 10 3
release right 10 3
wait 10000 cccc dccc
stable 700 15000
snap wholelines
snapstyle wholelines
# --- form 2: one line, a column span. r.txt is open now, so this re-uses that
# pane (focusPaneByPath) — the same route a `/` result row takes.
press right 12 4
release right 12 4
stable 700 15000
snap onelinespan
snapstyle onelinespan
# --- form 3: the general one, across both lines and columns
press right 12 5
release right 12 5
stable 700 15000
snap fullspan
snapstyle fullspan
# --- a STALE range: line 99 of a nine-line file, which is what a result row
# looks like once the file has changed underneath it. It must CLAMP — no crash,
# no garbage highlight — landing on the last cell that really exists.
press right 12 6
release right 12 6
stable 700 15000
snap stale
snapstyle stale
# --- and now the first consumer. The look above left r.txt focused, so `/`
# arms on it: the rows it writes carry the match's span, and n/N therefore step
# to each hit with the word itself selected.
key /
text NEEDLE
key enter
wait 10000 r.txt:7:4-9 gg NEEDLE
stable 700 15000
snap results
key n
stable 700 15000
snap hit1
snapstyle hit1
key n
stable 700 15000
snap hit2
snapstyle hit2
# N walks back onto the first hit, still selected
key N
stable 700 15000
snap back
snapstyle back
|