mirror of
https://github.com/tmux/tmux.git
synced 2026-07-22 08:51:17 +00:00
Add menu tests.
This commit is contained in:
133
regress/screen-redraw-menus.sh
Normal file
133
regress/screen-redraw-menus.sh
Normal file
@@ -0,0 +1,133 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Exercise drawing of window menus in the screen-redraw.c scene. Menus are
|
||||
# window-owned and drawn as REDRAW_MENU spans over panes. Captures use -e so
|
||||
# menu-style, menu-selected-style, and menu-border-style are included.
|
||||
#
|
||||
# Run with GENERATE=1 to (re)create the golden files.
|
||||
|
||||
PATH=/bin:/usr/bin
|
||||
TERM=screen
|
||||
LC_ALL=C.UTF-8
|
||||
export TERM LC_ALL
|
||||
|
||||
[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux)
|
||||
TMUX=
|
||||
TMUX2=
|
||||
SETUP=0
|
||||
RESULTS=screen-redraw-results
|
||||
|
||||
TMP=$(mktemp)
|
||||
TMP2=$(mktemp)
|
||||
|
||||
cleanup() {
|
||||
rm -f "$TMP" "$TMP2"
|
||||
[ -n "$TMUX" ] && $TMUX kill-server 2>/dev/null
|
||||
[ -n "$TMUX2" ] && $TMUX2 kill-server 2>/dev/null
|
||||
}
|
||||
trap cleanup 0 1 15
|
||||
|
||||
fail() {
|
||||
echo "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
trim() {
|
||||
awk '
|
||||
{ lines[NR] = $0 }
|
||||
END {
|
||||
n = NR
|
||||
while (n > 0 && lines[n] == "")
|
||||
n--
|
||||
for (i = 1; i <= n; i++)
|
||||
print lines[i]
|
||||
}
|
||||
' "$TMP" >"$TMP2" || exit 1
|
||||
mv "$TMP2" "$TMP" || exit 1
|
||||
}
|
||||
|
||||
compare() {
|
||||
sleep 1
|
||||
$TMUX capturep -pe >$TMP || exit 1
|
||||
trim
|
||||
if [ -n "$GENERATE" ]; then
|
||||
cp $TMP "$RESULTS/$1.result" || exit 1
|
||||
echo "generated $1"
|
||||
else
|
||||
cmp -s $TMP "$RESULTS/$1.result" || \
|
||||
fail "scene $1 differs from $RESULTS/$1.result"
|
||||
fi
|
||||
}
|
||||
|
||||
C="sh -c 'i=0; while [ \$i -lt 13 ]; do printf \"MENU%02d abcdefghij\n\" \$i; i=\$((i + 1)); done; exec sleep 100'"
|
||||
|
||||
setup() {
|
||||
[ -n "$TMUX" ] && $TMUX kill-server 2>/dev/null
|
||||
[ -n "$TMUX2" ] && $TMUX2 kill-server 2>/dev/null
|
||||
SETUP=$((SETUP + 1))
|
||||
TMUX="$TEST_TMUX -LtestA$$-$SETUP -f/dev/null"
|
||||
TMUX2="$TEST_TMUX -LtestB$$-$SETUP -f/dev/null"
|
||||
$TMUX2 new -d -x"$1" -y"$2" "$C" || exit 1
|
||||
$TMUX2 set -g status off || exit 1
|
||||
$TMUX2 set -g window-size manual || exit 1
|
||||
$TMUX2 resizew -x"$1" -y"$2" || exit 1
|
||||
$TMUX2 setw menu-style "fg=colour250,bg=colour235" || exit 1
|
||||
$TMUX2 setw menu-selected-style "fg=colour16,bg=colour220" || exit 1
|
||||
$TMUX2 setw menu-border-style "fg=colour45,bg=colour235" || exit 1
|
||||
|
||||
$TMUX new -d -x"$1" -y"$2" || exit 1
|
||||
$TMUX set -g status off || exit 1
|
||||
$TMUX set -g window-size manual || exit 1
|
||||
$TMUX set -g default-terminal "tmux-256color" || exit 1
|
||||
$TMUX send -l "$TMUX2 attach" || exit 1
|
||||
$TMUX send Enter || exit 1
|
||||
sleep 1
|
||||
}
|
||||
|
||||
menu() {
|
||||
$TMUX2 display-menu -T "Menu" -C 1 "$@" \
|
||||
"Alpha item" a "" \
|
||||
"Beta item" b "" \
|
||||
"" "" "" \
|
||||
"Gamma item" g "" || exit 1
|
||||
sleep 1
|
||||
}
|
||||
|
||||
# Basic menu over a single pane.
|
||||
setup 40 14
|
||||
menu -x6 -y8
|
||||
compare menu-basic
|
||||
|
||||
# Menu over a split: drawn on top of the pane border.
|
||||
setup 40 14
|
||||
$TMUX2 splitw -h "$C" || exit 1
|
||||
menu -x8 -y9
|
||||
compare menu-over-split
|
||||
|
||||
# Menu with no border lines.
|
||||
setup 40 14
|
||||
menu -b none -x6 -y8
|
||||
compare menu-noborder
|
||||
|
||||
# Menu with double border lines.
|
||||
setup 40 14
|
||||
menu -b double -x6 -y8
|
||||
compare menu-double
|
||||
|
||||
# Window menu styles are re-expanded from window options when redrawn.
|
||||
setup 40 14
|
||||
menu -x6 -y8
|
||||
$TMUX2 setw menu-style "fg=colour196,bg=colour22" || exit 1
|
||||
$TMUX2 setw menu-selected-style "fg=colour231,bg=colour88" || exit 1
|
||||
$TMUX2 setw menu-border-style "fg=colour51,bg=colour22" || exit 1
|
||||
$TMUX2 refresh-client -S || exit 1
|
||||
compare menu-restyled
|
||||
|
||||
# Menu wider than the window: it should be accepted and clipped by the scene.
|
||||
setup 12 6
|
||||
$TMUX2 display-menu -T "Menu" -C 0 -x0 -y5 \
|
||||
"This item is much wider than the window" t "" \
|
||||
"Second item is also too wide" s "" || exit 1
|
||||
compare menu-clipped
|
||||
|
||||
exit 0
|
||||
14
regress/screen-redraw-results/menu-basic.result
Normal file
14
regress/screen-redraw-results/menu-basic.result
Normal file
@@ -0,0 +1,14 @@
|
||||
MENU00 abcdefghij
|
||||
MENU01 abcdefghij
|
||||
MENU02[38;5;45m[48;5;235m┌─Menu───────────┐[39m[49m
|
||||
MENU03[38;5;45m[48;5;235m│[38;5;250m Alpha item (a) [38;5;45m│[39m[49m
|
||||
MENU04[38;5;45m[48;5;235m│[38;5;16m[48;5;220m Beta item (b) [38;5;45m[48;5;235m│[39m[49m
|
||||
MENU05[38;5;45m[48;5;235m├────────────────┤[39m[49m
|
||||
MENU06[38;5;45m[48;5;235m│[38;5;250m Gamma item (g) [38;5;45m│[39m[49m
|
||||
MENU07[38;5;45m[48;5;235m└────────────────┘[39m[49m
|
||||
MENU08 abcdefghij
|
||||
MENU09 abcdefghij
|
||||
MENU10 abcdefghij
|
||||
MENU11 abcdefghij
|
||||
MENU12 abcdefghij
|
||||
|
||||
6
regress/screen-redraw-results/menu-clipped.result
Normal file
6
regress/screen-redraw-results/menu-clipped.result
Normal file
@@ -0,0 +1,6 @@
|
||||
fghij
|
||||
[38;5;45m[48;5;235m┌─Menu─────┐
|
||||
│[38;5;16m[48;5;220m window> [38;5;45m[48;5;235m│
|
||||
│[38;5;250m oo wide> [38;5;45m│
|
||||
└──────────┘
|
||||
|
||||
14
regress/screen-redraw-results/menu-double.result
Normal file
14
regress/screen-redraw-results/menu-double.result
Normal file
@@ -0,0 +1,14 @@
|
||||
MENU00 abcdefghij
|
||||
MENU01 abcdefghij
|
||||
MENU02[38;5;45m[48;5;235m╔═Menu═══════════╗[39m[49m
|
||||
MENU03[38;5;45m[48;5;235m║[38;5;250m Alpha item (a) [38;5;45m║[39m[49m
|
||||
MENU04[38;5;45m[48;5;235m║[38;5;16m[48;5;220m Beta item (b) [38;5;45m[48;5;235m║[39m[49m
|
||||
MENU05[38;5;45m[48;5;235m╠════════════════╣[39m[49m
|
||||
MENU06[38;5;45m[48;5;235m║[38;5;250m Gamma item (g) [38;5;45m║[39m[49m
|
||||
MENU07[38;5;45m[48;5;235m╚════════════════╝[39m[49m
|
||||
MENU08 abcdefghij
|
||||
MENU09 abcdefghij
|
||||
MENU10 abcdefghij
|
||||
MENU11 abcdefghij
|
||||
MENU12 abcdefghij
|
||||
|
||||
14
regress/screen-redraw-results/menu-noborder.result
Normal file
14
regress/screen-redraw-results/menu-noborder.result
Normal file
@@ -0,0 +1,14 @@
|
||||
MENU00 abcdefghij
|
||||
MENU01 abcdefghij
|
||||
MENU02[38;5;45m[48;5;235m Menu [39m[49m
|
||||
MENU03[38;5;45m[48;5;235m [38;5;250m Alpha item (a) [38;5;45m [39m[49m
|
||||
MENU04[38;5;45m[48;5;235m [38;5;16m[48;5;220m Beta item (b) [38;5;45m[48;5;235m [39m[49m
|
||||
MENU05[38;5;45m[48;5;235m [39m[49m
|
||||
MENU06[38;5;45m[48;5;235m [38;5;250m Gamma item (g) [38;5;45m [39m[49m
|
||||
MENU07[38;5;45m[48;5;235m [39m[49m
|
||||
MENU08 abcdefghij
|
||||
MENU09 abcdefghij
|
||||
MENU10 abcdefghij
|
||||
MENU11 abcdefghij
|
||||
MENU12 abcdefghij
|
||||
|
||||
14
regress/screen-redraw-results/menu-over-split.result
Normal file
14
regress/screen-redraw-results/menu-over-split.result
Normal file
@@ -0,0 +1,14 @@
|
||||
MENU00 abcdefghij [38;2;179;179;179m│[39mMENU00 abcdefghij
|
||||
MENU01 abcdefghij [38;2;179;179;179m│[39mMENU01 abcdefghij
|
||||
MENU02 abcdefghij [38;2;179;179;179m│[39mMENU02 abcdefghij
|
||||
MENU03 a[38;5;45m[48;5;235m┌─Menu───────────┐[39m[49m3 abcdefghij
|
||||
MENU04 a[38;5;45m[48;5;235m│[38;5;250m Alpha item (a) [38;5;45m│[39m[49m4 abcdefghij
|
||||
MENU05 a[38;5;45m[48;5;235m│[38;5;16m[48;5;220m Beta item (b) [38;5;45m[48;5;235m│[39m[49m5 abcdefghij
|
||||
MENU06 a[38;5;45m[48;5;235m├────────────────┤[39m[49m6 abcdefghij
|
||||
MENU07 a[38;5;45m[48;5;235m│[38;5;250m Gamma item (g) [38;5;45m│[39m[49m7 abcdefghij
|
||||
MENU08 a[38;5;45m[48;5;235m└────────────────┘[39m[49m8 abcdefghij
|
||||
MENU09 abcdefghij [38;2;154;205;50m│[39mMENU09 abcdefghij
|
||||
MENU10 abcdefghij [38;2;154;205;50m│[39mMENU10 abcdefghij
|
||||
MENU11 abcdefghij [38;2;154;205;50m│[39mMENU11 abcdefghij
|
||||
MENU12 abcdefghij [38;2;154;205;50m│[39mMENU12 abcdefghij
|
||||
[38;2;154;205;50m│[39m
|
||||
14
regress/screen-redraw-results/menu-restyled.result
Normal file
14
regress/screen-redraw-results/menu-restyled.result
Normal file
@@ -0,0 +1,14 @@
|
||||
MENU00 abcdefghij
|
||||
MENU01 abcdefghij
|
||||
MENU02[38;5;51m[48;5;22m┌─Menu───────────┐[39m[49m
|
||||
MENU03[38;5;51m[48;5;22m│[38;5;196m Alpha item (a) [38;5;51m│[39m[49m
|
||||
MENU04[38;5;51m[48;5;22m│[38;5;231m[48;5;88m Beta item (b) [38;5;51m[48;5;22m│[39m[49m
|
||||
MENU05[38;5;51m[48;5;22m├────────────────┤[39m[49m
|
||||
MENU06[38;5;51m[48;5;22m│[38;5;196m Gamma item (g) [38;5;51m│[39m[49m
|
||||
MENU07[38;5;51m[48;5;22m└────────────────┘[39m[49m
|
||||
MENU08 abcdefghij
|
||||
MENU09 abcdefghij
|
||||
MENU10 abcdefghij
|
||||
MENU11 abcdefghij
|
||||
MENU12 abcdefghij
|
||||
|
||||
Reference in New Issue
Block a user