diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Doc/Zsh/contrib.yo | 6 | ||||
-rw-r--r-- | Functions/Misc/zcalc | 8 |
3 files changed, 17 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index f97228948..6f7418026 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-07-28 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> + + * 15511: Functions/Misc/zcalc, Doc/Zsh/contrib.yo: make + zcalc prompt configurable and allow ^D to exit. + 2001-07-27 Sven Wischnowsky <wischnow@zsh.org> * 15509: Completion/Base/Utility/_describe, Src/Zle/compresult.c, diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index c104c594d..d168dc9d3 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -820,6 +820,12 @@ indication of the base, or `tt([##16])' just to display the raw number in the given base. Bases themselves are always specified in decimal. `tt([#])' restores the normal output format. +The prompt is configurable via the parameter tt(ZCALCPROMPT), which +undergoes standard prompt expansion. The index of the current entry is +stored locally in the first element of the array tt(psvar), which can be +referred to in tt(ZCALCPROMPT) as `tt(%1v)'. The default prompt is +`tt(%1v> )'. + See the comments in the function for a few extra tips. ) findex(zed) diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc index 80a031a8b..503bcb94b 100644 --- a/Functions/Misc/zcalc +++ b/Functions/Misc/zcalc @@ -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= |