summaryrefslogtreecommitdiffhomepage
path: root/tests/linux/i-emacs.sh
blob: 465b5831a921d9a85093e93df93bac2dd55519c1 (plain)
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
# Interactive: the built-in editor in emacs mode.
command -v python3 >/dev/null 2>&1 || exit 77
PS1='$ ' ENV='' HISTFILE='' python3 "$TESTS/tools/ptydrive.py" "$TSH" <<'END'
# insert in the middle: ^A, ^F
send echo one  two\x01\x06\x06\x06\x06\x06X\r
expect Xone
# ^E, backspace, ^B, ^D, ^K
send echo abcdef\x05\x7f\x02\x02\x04\x02\x0b\r
expect ab
# ^U and ^Y, ^W
send echo kill\x15echo yank \x19 word gone\x17\r
expect yank echo kill word
# arrows, Home, End, Delete
send bcd\x1b[Hecho a\x1b[F e\x1b[D\x1b[D\x1b[3~\r
expect abcde
# meta-b, meta-f, meta-d, ^T
send echo aa bb cc\x1bb\x1bbXX\x1bf\x1bd\r
expect aa XXbb
send echo ab\x14\r
expect ba
# bash's word keys: meta-u, meta-l, meta-c, meta-t
send echo hello\x01\x06\x06\x06\x06\x06\x1bu\r
expect HELLO
send echo HELLO\x01\x06\x06\x06\x06\x06\x1bl\r
expect hello
send echo HELLO\x01\x06\x06\x06\x06\x06\x1bc\r
expect Hello
send echo aa bb\x01\x06\x06\x06\x06\x06\x06\x06\x1bt\r
expect bb aa
# meta-. takes the last word of the previous line; meta-\\ closes blanks
send echo alpha beta\r
expect alpha beta
send echo \x1b.\r
expect echo beta
send echo x   y\x1b[4D\x1b\\\r
expect xy
# ^V inserts the next key literally
send echo 'a\x16\tb' | tr '\\t' T\r
expect aTb
# a long line scrolls sideways and still runs
send echo 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 | wc -c\r
expect 101
# ^C abandons the line; ^L redraws
send echo abandoned\x03
wait 0.2
send echo st=$?\x0c\r
expect st=130
# ^D on an empty line leaves
send \x04
END