* zcurses scrolling
@ 2015-11-17 17:34 Ray Andrews
2015-11-19 15:47 ` Ray Andrews
0 siblings, 1 reply; 2+ messages in thread
From: Ray Andrews @ 2015-11-17 17:34 UTC (permalink / raw)
To: Zsh Users
All:
I'm experimenting with mouse input and getting strange results with the
scrolling wheel. If I grab input like this:
zcurses input status key keypad
... then the scroll wheel returns either 'UP' or 'DOWN' in '$keypad'. So
it simulates the arrow keys, which is logical and it works fine.
However, when I attempt to handle mouse events explicitly:
zcurses input status key keypad mouse
... things change. Now, if I scroll up:
$keypad is 'MOUSE' and
$mouse is '0 40 18 0 PRESSED4'
... but if I scroll down:
$keypad is 'MOUSE' and
$mouse is [unset]
So if I want to capture mouse clicks (which is working fine) then I'm
not able to capture scrolling down, tho I can capture scrolling up.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: zcurses scrolling
2015-11-17 17:34 zcurses scrolling Ray Andrews
@ 2015-11-19 15:47 ` Ray Andrews
0 siblings, 0 replies; 2+ messages in thread
From: Ray Andrews @ 2015-11-19 15:47 UTC (permalink / raw)
To: zsh-users
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-19 15:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-17 17:34 zcurses scrolling Ray Andrews
2015-11-19 15:47 ` Ray Andrews
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).