NAME
ggeettmmoouussee, uunnggeettmmoouussee, mmoouusseemmaasskk, wweenncclloossee, mmoouusseettrraaffoo, wwmmoouusseettrraaffoo,mmoouusseeiinntteerrvvaall - mouse interface through curses
SYNOPSIS
##iinncclluuddee <
ttyyppeeddeeff uunnssiiggnneedd lloonngg mmmmaasskktt;; typedef struct { short id; /* ID to distinguish multiple devices */ iinntt xx,, yy,, zz;; /* event coordinates */ mmmmaasskktt bbssttaattee;; /* button state bits */ }} MMEEVVEENNTT;; iinntt ggeettmmoouussee((MMEEVVEENNTT **eevveenntt));; iinntt uunnggeettmmoouussee((MMEEVVEENNTT **eevveenntt));; mmmmaasskktt mmoouusseemmaasskk((mmmmaasskktt nneewwmmaasskk,, mmmmaasskktt **oollddmmaasskk));; bbooooll wweenncclloossee((ccoonnsstt WWIINNDDOOWW **wwiinn,, iinntt yy,, iinntt xx));; bbooooll mmoouusseettrraaffoo((iinntt** ppYY,, iinntt** ppXX,, bbooooll ttoossccrreeeenn));; bbooooll wwmmoouusseettrraaffoo((ccoonnsstt WWIINNDDOOWW** wwiinn,, iinntt** ppYY,, iinntt** ppXX,, bbooooll ttoossccrreeeenn));; iinntt mmoouusseeiinntteerrvvaall((iinntt eerrvvaall));;> DESCRIPTION
These functions provide an interface to mouse events from nnccuurrsseess(3X).Mouse events are represented by KKEEYYMMOOUUSSEE pseudo-key values in the
wwggeettcchh input stream. To make mouse events visible, use the mmoouusseemmaasskk function. This will set the mouse events to be reported. By default, no mouse events are reported. The function will return a mask to indicate which of the specified mouse events can be reported; on complete failure it returns0. If oldmask is non-NULL, this function fills the indicated location
with the previous value of the given window's mouse event mask. As a side effect, setting a zero mousemask may turn off the mouse pointer; setting a nonzero mask may turn it on. Whether this happensis device-dependent.
Here are the mouse event type masks which may be defined: Name Description-----------------------------------
BUTTON1PRESSED mouse button 1 down BUTTON1RELEASED mouse button 1 up BUTTON1CLICKED mouse button 1 clicked BUTTON1DOUBLECLICKED mouse button 1 double clicked BUTTON1TRIPLECLICKED mouse button 1 triple clicked-----------------------------------
BUTTON2PRESSED mouse button 2 down BUTTON2RELEASED mouse button 2 up BUTTON2CLICKED mouse button 2 clicked BUTTON2DOUBLECLICKED mouse button 2 double clicked BUTTON2TRIPLECLICKED mouse button 2 triple clicked-----------------------------------
BUTTON3PRESSED mouse button 3 down BUTTON3RELEASED mouse button 3 up BUTTON3CLICKED mouse button 3 clicked BUTTON3DOUBLECLICKED mouse button 3 double clicked BUTTON3TRIPLECLICKED mouse button 3 triple clicked-----------------------------------
BUTTON4PRESSED mouse button 4 down BUTTON4RELEASED mouse button 4 up BUTTON4CLICKED mouse button 4 clicked BUTTON4DOUBLECLICKED mouse button 4 double clicked BUTTON4TRIPLECLICKED mouse button 4 triple clicked-----------------------------------
BUTTON5PRESSED mouse button 5 down BUTTON5RELEASED mouse button 5 up BUTTON5CLICKED mouse button 5 clicked BUTTON5DOUBLECLICKED mouse button 5 double clicked BUTTON5TRIPLECLICKED mouse button 5 triple clicked-----------------------------------
BUTTONSHIFT shift was down during button state change BUTTONCTRL control was down during button state change BUTTONALT alt was down during button state change ALLMOUSEEVENTS report all button state changes REPORTMOUSEPOSITION report mouse movement-----------------------------------
Once a class of mouse events have been made visible in a window, call-
ing the wwggeettcchh function on that window may return KKEEYYMMOOUUSSEE as an indi-
cator that a mouse event has been queued. To read the event data and pop the event off the queue, call ggeettmmoouussee. This function will returnOOKK if a mouse event is actually visible in the given window, EERRRR other-
wise. When ggeettmmoouussee returns OOKK, the data deposited as y and x in theevent structure coordinates will be screen-relative character-cell co-
ordinates. The returned state mask will have exactly one bit set to indicate the event type. The uunnggeettmmoouussee function behaves analogously to uunnggeettcchh. It pushes a KKEEYYMMOOUUSSEE event onto the input queue, and associates with that eventthe given state data and screen-relative character-cell coordinates.
The wweenncclloossee function tests whether a given pair of screen-relative
character-cell coordinates is enclosed by a given window, returning
TRUE if it is and FALSE otherwise. It is useful for determining what subset of the screen windows enclose the location of a mouse event. The wwmmoouusseettrraaffoo function transforms a given pair of coordinates fromstdscr-relative coordinates to screen-relative coordinates or vice ver-
sa. Please remember, that stdscr-relative coordinates are not always
identical to screen-relative coordinates due to the mechanism to re-
serve lines on top or bottom of the screen for other purposes (ripoff() call, see also slk... functions). If the parameter ttoossccrreeeenn is TTRRUUEE, the pointers ppYY,, ppXX must reference the coordinates of a locationinside the window wwiinn. They are converted to screen-relative coordi-
nates and returned through the pointers. If the conversion was suc-
cessful, the function returns TTRRUUEE. If one of the parameters was NULL or the location is not inside the window, FFAALLSSEE is returned. Ifttoossccrreeeenn is FFAALLSSEE, the pointers ppYY,, ppXX must reference screen-relative
coordinates. They are converted to stdscr-relative coordinates if the
window wwiinn encloses this point. In this case the function returns TTRRUUEE. If one of the parameters is NULL or the point is not inside thewindow, FFAALLSSEE is returned. Please notice, that the referenced coordi-
nates are only replaced by the converted coordinates if the transforma-
tion was successful. The mmoouusseeiinntteerrvvaall function sets the maximum time (in thousands of a second) that can elapse between press and release events for them to berecognized as a click. Use mmoouusseeiinntteerrvvaall((00)) to disable click resolu-
tion. This function returns the previous interval value. Use mmoouusseeiinn-
tteerrvvaall((-11)) to obtain the interval without altering it. The default is
one sixth of a second. Note that mouse events will be ignored when input is in cooked mode, and will cause an error beep when cooked mode is being simulated in awindow by a function such as ggeettssttrr that expects a linefeed for input-
loop termination. RREETTUURRNN VVAALLUUEE ggeettmmoouussee and uunnggeettmmoouussee return the integer EERRRR upon failure or OOKK upon successful completion. ggeettmmoouussee returns an error. If no mouse driver was initialized, or if the mask parameter is zero, uunnggeettmmoouussee returns an error if the FIFO is full. mmoouusseemmaasskk returns the mask of reportable events. mmoouusseeiinntteerrvvaall returns the previous interval value, unless the terminal was not initialized. In that case, it returns the maximum interval value (166). wweenncclloossee and wwmmoouusseettrraaffoo are boolean functions returning TTRRUUEE or FFAALLSSEE depending on their test result. PPOORRTTAABBIILLIITTYY These calls were designed for nnccuurrsseess(3X), and are not found in SVr4 curses, 4.4BSD curses, or any other previous version of curses. The feature macro NNCCUURRSSEESSMMOOUUSSEEVVEERRSSIIOONN is provided so the preprocessorcan be used to test whether these features are present. If the inter-
face is changed, the value of NNCCUURRSSEESSMMOOUUSSEEVVEERRSSIIOONN will be increment-
ed. These values for NNCCUURRSSEESSMMOOUUSSEEVVEERRSSIIOONN may be specified when con-
figuring ncurses: 1 has definitions for reserved events. The mask uses 28 bits. 2 adds definitions for button 5, removes the definitions for reserved events. The mask uses 29 bits.The order of the MMEEVVEENNTT structure members is not guaranteed. Addition-
al fields may be added to the structure in the future. Under nnccuurrsseess(3X), these calls are implemented using either xterm'sbuilt-in mouse-tracking API or platform-specific drivers including
Alessandro Rubini's gpm server. FreeBSD sysmouse OS/2 EMX If you are using an unsupported configuration, mouse events will not be visible to nnccuurrsseess(3X) (and the wwmmoouusseemmaasskk function will always return 00). If the terminfo entry contains a XXMM string, this is used in the xterm mouse driver to control the way the terminal is initialized for mouse operation. The default, if XXMM is not found, corresponds to private mode 1000 of xterm:\E[?1000%?%p1%{1}%=%th%el%;
The z member in the event structure is not presently used. It is in-
tended for use with touch screens (which may be pressure-sensitive) or
with 3D-mice/trackballs/power gloves.
BUGS
Mouse events under xterm will not in fact be ignored during cooked mode, if they have been enabled by wwmmoouusseemmaasskk. Instead, the xterm mouse report sequence will appear in the string read. Mouse events under xterm will not be detected correctly in a window with its keypad bit off, since they are interpreted as a variety of function key. Your terminfo description must have kkmmoouuss set to "\E[M" (the beginning of the response from xterm for mouse clicks). Because there are no standard terminal responses that would serve toidentify terminals which support the xterm mouse protocol, nnccuurrsseess as-
sumes that if your $TERM environment variable contains "xterm", or
kkmmoouuss is defined in the terminal description, then the terminal may send mouse events.SEE ALSO
ccuurrsseess(3X). cursmouse(3X)