Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zcurses scrolling

On 11/17/2015 09:34 AM, Ray Andrews wrote:

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.
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:
    [ -z "$NKEY" ] && NKEY="$keypad"
    [ -z "$NKEY" ] &&
        { n_status_msg "Improper input detected"; zcurses refresh status }


    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

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.

Messages sorted by: Reverse Date, Date, Thread, Author