zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: zcurses scrolling
Date: Thu, 19 Nov 2015 07:47:27 -0800	[thread overview]
Message-ID: <564DEF0F.80104@eastlink.ca> (raw)
In-Reply-To: <564B653B.9050607@eastlink.ca>

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.



      reply	other threads:[~2015-11-19 15:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-17 17:34 Ray Andrews
2015-11-19 15:47 ` Ray Andrews [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=564DEF0F.80104@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).