Merge branch 'obsd-master'
[tmux.git] / regress / copy-mode-test-vi.sh
blob8146e4563c9b255cd3b993664d5464227534fd57
1 #!/bin/sh
3 PATH=/bin:/usr/bin
4 TERM=screen
6 [ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux)
7 TMUX="$TEST_TMUX -f/dev/null -Ltest"
8 $TMUX kill-server 2>/dev/null
10 $TMUX new -d -x40 -y10 \
11 "cat copy-mode-test.txt; printf '\e[9;15H'; cat" || exit 1
12 $TMUX set -g window-size manual || exit 1
14 # Enter copy mode and go to the first column of the first row.
15 $TMUX set-window-option -g mode-keys vi
16 $TMUX copy-mode
17 $TMUX send-keys -X history-top
18 $TMUX send-keys -X start-of-line
20 # Test that `previous-word` and `previous-space`
21 # do not go past the start of text.
22 $TMUX send-keys -X begin-selection
23 $TMUX send-keys -X previous-word
24 $TMUX send-keys -X previous-space
25 $TMUX send-keys -X previous-word
26 $TMUX send-keys -X copy-selection
27 [ "$($TMUX show-buffer)" = "A" ] || exit 1
29 # Test that `next-word-end` skips single-letter words
30 # and `previous-word` does not skip multi-letter words.
31 $TMUX send-keys -X next-word-end
32 $TMUX send-keys -X begin-selection
33 $TMUX send-keys -X previous-word
34 $TMUX send-keys -X copy-selection
35 [ "$($TMUX show-buffer)" = "line" ] || exit 1
37 # Test that `next-word-end` wraps around indented line breaks.
38 $TMUX send-keys -X next-word
39 $TMUX send-keys -X next-word
40 $TMUX send-keys -X begin-selection
41 $TMUX send-keys -X next-word-end
42 $TMUX send-keys -X next-word-end
43 $TMUX send-keys -X copy-selection
44 [ "$($TMUX show-buffer)" = "$(printf "words\n Indented")" ] || exit 1
46 # Test that `next-word` wraps around un-indented line breaks.
47 $TMUX send-keys -X next-word
48 $TMUX send-keys -X begin-selection
49 $TMUX send-keys -X next-word
50 $TMUX send-keys -X copy-selection
51 [ "$($TMUX show-buffer)" = "$(printf "line\nA")" ] || exit 1
53 # Test that `next-word-end` does not treat periods as letters.
54 $TMUX send-keys -X next-word
55 $TMUX send-keys -X begin-selection
56 $TMUX send-keys -X next-word-end
57 $TMUX send-keys -X copy-selection
58 [ "$($TMUX show-buffer)" = "line" ] || exit 1
60 # Test that `next-space-end` treats periods as letters.
61 $TMUX send-keys -X previous-word
62 $TMUX send-keys -X begin-selection
63 $TMUX send-keys -X next-space-end
64 $TMUX send-keys -X copy-selection
65 [ "$($TMUX show-buffer)" = "line..." ] || exit 1
67 # Test that `previous-space` and `next-space` treat periods as letters.
68 $TMUX send-keys -X previous-space
69 $TMUX send-keys -X begin-selection
70 $TMUX send-keys -X next-space
71 $TMUX send-keys -X copy-selection
72 [ "$($TMUX show-buffer)" = "$(printf "line...\n.")" ] || exit 1
74 # Test that `next-word` and `next-word-end` do not treat other symbols as letters.
75 $TMUX send-keys -X begin-selection
76 $TMUX send-keys -X next-word
77 $TMUX send-keys -X next-word
78 $TMUX send-keys -X next-word-end
79 $TMUX send-keys -X next-word-end
80 $TMUX send-keys -X copy-selection
81 [ "$($TMUX show-buffer)" = "... @nd then" ] || exit 1
83 # Test that `next-space` wraps around for indented symbols
84 $TMUX send-keys -X next-space
85 $TMUX send-keys -X begin-selection
86 $TMUX send-keys -X next-space
87 $TMUX send-keys -X copy-selection
88 [ "$($TMUX show-buffer)" = "$(printf "\$ym_bols[]{}\n ?")" ] || exit 1
90 # Test that `next-word-end` treats digits as letters
91 $TMUX send-keys -X next-word-end
92 $TMUX send-keys -X begin-selection
93 $TMUX send-keys -X next-word-end
94 $TMUX send-keys -X copy-selection
95 [ "$($TMUX show-buffer)" = "? 500xyz" ] || exit 1
97 # Test that `previous-word` treats digits as letters
98 $TMUX send-keys -X begin-selection
99 $TMUX send-keys -X previous-word
100 $TMUX send-keys -X copy-selection
101 [ "$($TMUX show-buffer)" = "500xyz" ] || exit 1
103 # Test that `next-word`, `next-word-end`,
104 # `next-space`, and `next-space-end` stop at the end of text.
105 $TMUX send-keys -X begin-selection
106 $TMUX send-keys -X next-word
107 $TMUX send-keys -X next-word-end
108 $TMUX send-keys -X next-word
109 $TMUX send-keys -X next-space
110 $TMUX send-keys -X next-space-end
111 $TMUX send-keys -X copy-selection
112 [ "$($TMUX show-buffer)" = "500xyz" ] || exit 1
114 $TMUX kill-server 2>/dev/null
115 exit 0