From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7953 invoked by alias); 19 Nov 2015 15:52:21 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20965 Received: (qmail 3064 invoked from network); 19 Nov 2015 15:50:06 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Authority-Analysis: v=2.1 cv=X+5rdgje c=1 sm=1 tr=0 a=T6B4Oe2BqORhJCis3yfoKQ==:117 a=T6B4Oe2BqORhJCis3yfoKQ==:17 a=IkcTkHD0fZMA:10 a=Fa2dEADCgxYfdxDDn0AA:9 a=QVEZr89j-dcRjao0:21 a=RKh-_yIlzUxLGMIJ:21 a=QEXdDO2ut3YA:10 Message-id: <564DEF0F.80104@eastlink.ca> Date: Thu, 19 Nov 2015 07:47:27 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: zcurses scrolling References: <564B653B.9050607@eastlink.ca> In-reply-to: <564B653B.9050607@eastlink.ca> Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 7bit On 11/17/2015 09:34 AM, Ray Andrews wrote: > All: > > I'm experimenting with mouse input and getting strange results with > the scrolling wheel. If I grab input like this: > No advice on my troubles with zcurses gentlemen? I've come up with this hack: n_get_key () # Capture keystroke or mouse action: { # Clear input buffer, doing this here reduces typeahead :-) MSG= # New keystroke will erase old MSG. NKEY= # NB, must do this, or ^C goes strange when searching. MOUSE=() zcurses timeout status 0 # Need this, or first keystrokes disappear. zcurses input status key keypad # w.o. this, typeahead is much worse. zcurses timeout status -1 # This is essential. typeset -g _flag local key= keypad= mouse= zcurses input status key keypad mouse # Get the "keypad" key or regular key: NKEY="$key" [ -z "$NKEY" ] && NKEY="$keypad" [ -z "$NKEY" ] && { n_status_msg "Improper input detected"; zcurses refresh status } MOUSE[X]="${mouse[2]}" MOUSE[Y]="${mouse[3]}" MOUSE[!]="${mouse[5]}" if [ "$NKEY" = 'MOUSE' ]; then if [ "$MOUSE[!]" = 'PRESSED4' ]; then NKEY='UP'; MOUSE[!]= elif [ -z "$MOUSE[!]" ] && [ "$_flag" != '1' ]; then NKEY='DOWN'; MOUSE[!]= # Otherwise a slow click becomes a 'DOWN'!! elif [ -n "$MOUSE[!]" ]; then if [ "$MOUSE[!]" = 'PRESSED1' ]; then _flag=1; else _flag=0; fi fi fi } I've restored the scroll wheel's output to UP and DOWN so that no special handling is needed, and I can capture mouse clicks, but there's a gotcha: If your click timing is not perfect, then you get a click and a DOWN thrown in as a bonus. The above more or less works, but should it be necessary? Should not up-scrolling and down-scrolling be handled the same way? In the SRC there's code for 'PRESSED5' which I guessed might be down-scrolling, but it won't compile if defined and it's commented as being only available in 64 bits. But could it really be the case that we can't handle down-scrolling in 32 bits? Hard to believe. "zcurses mouse 500" gave me a segmentation fault.