From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3265 invoked by alias); 15 Mar 2013 14:18:52 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 31153 Received: (qmail 14616 invoked from network); 15 Mar 2013 14:18:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: softfail (ns1.primenet.com.au: transitioning SPF record at amazonses.com does not designate 210.118.77.14 as permitted sender) X-AuditID: cbfec7f5-b7fd76d000007247-53-51432dc69467 Date: Fri, 15 Mar 2013 14:18:40 +0000 From: Peter Stephenson To: Zsh Hackers' List Subject: PATCH: Make zcalc understand continuation lines Message-id: <20130315141840.2d8236d8@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIJMWRmVeSWpSXmKPExsVy+t/xy7rHdJ0DDc7cYbc42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGafPzWYu6OevePjpHVsD4ySeLkYODgkBE4me7/VdjJxAppjE hXvr2boYuTiEBJYySsxZdYUVJCEksJxJYt5iHZB6FgFVidf7QkHCbAKGElM3zWYECYsIaEu0 fxQDCQsLWEi0H/nIBmLzCthLHGx+DzaFX0Bf4urfT0wQq+wlZl45wwhRIyjxY/I9FhCbWUBL YvO2JlYIW15i85q3zBMY+WYhKZuFpGwWkrIFjMyrGEVTS5MLipPSc430ihNzi0vz0vWS83M3 MUKC6esOxqXHrA4xCnAwKvHwOj50DBRiTSwrrsw9xCjBwawkwmuj7RwoxJuSWFmVWpQfX1Sa k1p8iJGJg1OqgfH67mn24YsLVOeUhlgxvD7a8WmG5R9fJd62kofXYxyn7qyvuNtUJfk3QmH9 2hbOdq4+ng2/Cw1ixXfaJ8oes1LcOv8z8xoNQbd2b3vzT6deH1hgeuRJ/f82zUsN+84vmnNa 2/L6pOS7mX1P5kUUTLpvZXIpK832wdOLl4I2df13FDy/y71HOl2JpTgj0VCLuag4EQADZ0SQ BAIAAA== diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 14886d6..22202b0 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -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 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)' -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 first few positional parameters. A visual indication of this is given when diff --git a/Functions/Misc/zcalc b/Functions/Misc/zcalc index 3d44f20..2eeb498 100644 --- a/Functions/Misc/zcalc +++ b/Functions/Misc/zcalc @@ -155,7 +155,16 @@ for (( num = 1; num <= $#; num++ )); do done 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" + cont_prompt= [[ -z $line ]] && break # special cases # Set default base if `[#16]' or `[##16]' etc. on its own. -- Peter Stephenson Consultant, Software Tel: +44 (0)1223 434724 Samsung Cambridge Solution Centre St John's House, St John's Innovation Park, Cowley Road, Cambridge, CB4 0DS, UK