bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: read mouse position beyond column 256 ?


From: Egmont Koblinger
Subject: Re: read mouse position beyond column 256 ?
Date: Thu, 20 Feb 2014 15:37:31 +0100

Hi Patrick,

I guess with most terminals the limit is the 223rd row-column.  (It
might be 255 with certain terminals, I'm not sure.)  This is due to
the limitations of the legacy mouse protocol used by the terminals
(row and column encoded in single bytes).

The recent SGR 1006 mouse extension allows arbitrary coordinates to be
reported.  Most terminal emulators already support it, and so do quite
a few applications (vim, emacs, tmux, mc, links, ...).  They handle
mouse their own way, rather than via getmouse().  Unfortunately, the
ncurses library doesn't support this extension yet.

I've already asked Thomas to implement it, it must be somewhere on his
TODO list.  When enabling mouse with ncurses, it should also
automatically transparently enable the extension.  Terminals that
don't support it will silently ignore this request and keep reporting
the coordinates using the old method.  Terminals that do support it
will report coordinates using the new method.  The old and new methods
are perfectly distinguishable, so it'll work no matter if the terminal
supports the extension or not.  (Of course, if it doesn't support it,
you'll get coordinates up to 223 only.)  This change would be totally
transparent towards ncurses applications (no API/ABI change), and
would automatically fix mouse handling in all applications that use
getmouse() (like htop, lynx, and probably many more).


egmont

On Thu, Feb 20, 2014 at 3:22 PM, Patrick <address@hidden> wrote:
>
> Hi Everyone
>
> I am trying to read the co-ordinates of a graphics tablet. I could read the
> X Y position with a GUi toolkit but I would strongly prefer ncurses.
>
> I can't seem to read past 250 something or so. I am guessing that the
> locations may be stored as short types
>
> At the end of the email is a sample program from Gookin's Programmers Guide
> To Ncurses.
>
> I changed the #include to link to ncursesw in the hopes that it would
> support columns beyond 256 but it does not seem to.
>
> I compiled it with this:
>
> gcc mevent.c -o debug `ncursesw5-config --cflags --libs`
>
> If anyone could lend a hand I would really appreciate it-Patrick
>
>
>
> #include <ncursesw/ncurses.h>
>
> int main(void)
> {
>     MEVENT mwhat;
>     int ch;
>
>     initscr();
>     noecho();
>     keypad(stdscr,TRUE);
>
>     mousemask(ALL_MOUSE_EVENTS,NULL);
>
>     while(1)
>     {
>         ch = getch();
>         if( ch == KEY_MOUSE )
>         {
>             getmouse(&mwhat);
>             move(0,0);
>             clrtoeol();
>             printw("%2d %2d",mwhat.y,mwhat.x);
>             refresh();
>             continue;
>         }
>         if( ch == '\n' )
>             break;
>     }
>
>     endwin();
>
>
>     return 0;
> }
>
> _______________________________________________
> Bug-ncurses mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/bug-ncurses



reply via email to

[Prev in Thread] Current Thread [Next in Thread]