-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.zsh
executable file
·64 lines (58 loc) · 1.19 KB
/
test.zsh
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
#!/usr/bin/env zsh
source ./motions.zsh
# do nothing when calling zle
zle() :
ret=0
# {{{ select-command
c='simple command '
lefts=(
#'never include' 'include in "a"'
'' ''
'' 'if '
"$c;" ''
"$c;" ' '
"$c;" ' if '
)
rights=(
#'include in "a"' 'never include'
'' ''
'' ''
'&&' ''
'&& ' ''
'&&' "$c"
'&& ' "$c"
)
for ll lm ("${(@)lefts}") {
for rm rr ("${(@)rights}") {
((
iCURSOR = $#ll + $#lm,
aCURSOR = $#ll,
cur = 3 + iCURSOR,
iMARK = $#ll + $#lm + $#c,
aMARK = iMARK + $#rm
))
BUFFER="$ll$lm$c$rm$rr"
CURSOR=$cur
KEYS=ac WIDGET=select-a-command -select-a-command
if (( aCURSOR != CURSOR || aMARK != MARK )); then
print -l 'In "select-command" test:' \
"BUFFER:$BUFFER:" \
"[a] :$aCURSOR:$CURSOR::$aMARK:$MARK" \
"ACTUAL:${BUFFER[CURSOR+1,MARK]}" \
"INTEND:${BUFFER[aCURSOR+1,aMARK]}"
ret=1
fi
CURSOR=$cur
KEYS=ic WIDGET=select-in-command -select-a-command
if (( iCURSOR != CURSOR || iMARK != MARK )); then
print -l 'In "select-command" test:' \
"BUFFER:$BUFFER:" \
"[i] :$iCURSOR:$CURSOR::$iMARK:$MARK" \
"ACTUAL:${BUFFER[CURSOR+1,MARK]}:" \
"INTEND:${BUFFER[iCURSOR+1,iMARK]}:"
ret=1
fi
}
}
# }}}
return $ret