1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-25 17:20:25 +02:00

15511: zcalc tweaks

This commit is contained in:
Peter Stephenson 2001-07-27 22:23:15 +00:00
parent 4da5c1b2e0
commit 1619df1c5d
3 changed files with 17 additions and 2 deletions

View file

@ -84,11 +84,13 @@
emulate -L zsh
setopt extendedglob
local line latest base defbase match mbegin mend
local line latest base defbase match mbegin mend psvar
integer num
zmodload -i zsh/mathfunc 2>/dev/null
: ${ZCALCPROMPT="%1v> "}
# Supply some constants.
float PI E
(( PI = 4 * atan(1), E = exp(1) ))
@ -101,7 +103,8 @@ for (( num = 1; num <= $#; num++ )); do
print "$num> $argv[$num]"
done
while vared -chp "$num> " line; do
psvar[1]=$num
while vared -cehp "${(%)ZCALCPROMPT}" line; do
[[ -z $line ]] && break
# special cases
# Set default base if `[#16]' or `[##16]' etc. on its own.
@ -134,6 +137,7 @@ while vared -chp "$num> " line; do
# arrays always store scalars anyway.
eval "latest=\$(( $base $line ))"
argv[num++]=$latest
psvar[1]=$num
print -- $latest
fi
line=