1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-27 04:40:59 +01:00

26121: add -B <lines> option to calendar

This commit is contained in:
Peter Stephenson 2008-12-10 13:30:27 +00:00
parent 63e60d3d21
commit 37a4dce4bc
3 changed files with 25 additions and 9 deletions

View file

@ -60,7 +60,7 @@ while [[ ${argv[opti+1]} = -* ]]; do
########################
# Options with arguments
########################
([CnS])
([BCnS])
if [[ -n $optrest ]]; then
optarg=$optrest
optrest=
@ -72,6 +72,15 @@ while [[ ${argv[opti+1]} = -* ]]; do
return 1
fi
case $opt in
(B)
# Brief, with number of lines to show.
brief=$optarg
if (( brief <= 0 )); then
print -r "$0: option -$opt requires a positive integer." >&2
return 1
fi
;;
(C)
# Pick the calendar file, overriding style and default.
calendar=$optarg
@ -289,17 +298,17 @@ fi
fi
(( shown = 0 ))
if (( brief )); then
showline=${line%%$'\n'*}
showline=${(F)${${(f)line}[1,brief]}}
else
showline=$line
match=()
# Strip continuation lines starting " #".
while [[ $showline = (#b)(*$'\n')[[:space:]]##\#[^$'\n']##(|$'\n'(*)) ]]; do
showline="$match[1]$match[3]"
done
# Strip trailing empty lines
showline=${showline%%[[:space:]]#}
fi
match=()
# Strip continuation lines starting " #".
while [[ $showline = (#b)(*$'\n')[[:space:]]##\#[^$'\n']##(|$'\n'(*)) ]]; do
showline="$match[1]$match[3]"
done
# Strip trailing empty lines
showline=${showline%%[[:space:]]#}
if (( showall || (t >= start && (remaining || t <= stop || icount < showcount)) ))
then
$showprog $start $stop "$showline"