mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-26 04:30:27 +01:00
31154: make zcalc understand continuation lines with a backslash
This commit is contained in:
parent
a69f05b4ce
commit
136cc1e1b7
3 changed files with 23 additions and 3 deletions
|
|
@ -1,3 +1,8 @@
|
||||||
|
2013-03-15 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||||
|
|
||||||
|
* 31154: Doc/Zsh/contrib.yo, Functions/Misc/zcalc: make zcalc
|
||||||
|
understand continuation lines using backslash.
|
||||||
|
|
||||||
2013-03-14 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
2013-03-14 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||||
|
|
||||||
* 31151: Pavol Juhas: complete (C etc) tags better
|
* 31151: Pavol Juhas: complete (C etc) tags better
|
||||||
|
|
@ -603,5 +608,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.5821 $
|
* $Revision: 1.5822 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
|
||||||
|
|
@ -3144,7 +3144,12 @@ line preceded by `tt(4> )' is available as tt($4). The last value
|
||||||
calculated is available as tt(ans). Full command line editing, including
|
calculated is available as tt(ans). Full command line editing, including
|
||||||
the history of previous calculations, is available; the history is saved in
|
the history of previous calculations, is available; the history is saved in
|
||||||
the file tt(~/.zcalc_history). To exit, enter a blank line or type `tt(:q)'
|
the file tt(~/.zcalc_history). To exit, enter a blank line or type `tt(:q)'
|
||||||
on its own (`tt(q)' is allowed for historical compatibility).
|
on its own (`tt(q)' is allowed for historical compatibility). A
|
||||||
|
line ending with a single backslash is treated in the same fashion
|
||||||
|
as it is in command line editing: the backslash is removed, the
|
||||||
|
function prompts for more input (the prompt is preceded by `tt(...)'
|
||||||
|
to indicate this), and the lines are combined into one to get the final
|
||||||
|
result.
|
||||||
|
|
||||||
If arguments are given to tt(zcalc) on start up, they are used to prime the
|
If arguments are given to tt(zcalc) on start up, they are used to prime the
|
||||||
first few positional parameters. A visual indication of this is given when
|
first few positional parameters. A visual indication of this is given when
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,17 @@ for (( num = 1; num <= $#; num++ )); do
|
||||||
done
|
done
|
||||||
|
|
||||||
psvar[1]=$num
|
psvar[1]=$num
|
||||||
while vared -cehp "${ZCALCPROMPT}" line; do
|
local prev_line cont_prompt
|
||||||
|
while vared -cehp "${cont_prompt}${ZCALCPROMPT}" line; do
|
||||||
|
if [[ $line = (|*[^\\])('\\')#'\' ]]; then
|
||||||
|
prev_line+=$line[1,-2]
|
||||||
|
cont_prompt="..."
|
||||||
|
line=
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
line="$prev_line$line"
|
||||||
|
prev_line=
|
||||||
|
cont_prompt=
|
||||||
[[ -z $line ]] && break
|
[[ -z $line ]] && break
|
||||||
# special cases
|
# special cases
|
||||||
# Set default base if `[#16]' or `[##16]' etc. on its own.
|
# Set default base if `[#16]' or `[##16]' etc. on its own.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue