1curs_mouse(3X)                                                  curs_mouse(3X)
2
3
4

NAME

6       getmouse, ungetmouse, mousemask, wenclose, mouse_trafo, wmouse_trafo,
7       mouseinterval - mouse interface through curses
8

SYNOPSIS

10       #include <curses.h>
11
12       typedef unsigned long mmask_t;
13
14       typedef struct
15       {
16           short id;         /* ID to distinguish multiple devices */
17           int x, y, z;      /* event coordinates */
18           mmask_t bstate;   /* button state bits */
19       }
20       MEVENT;
21       int getmouse(MEVENT *event);
22       int ungetmouse(MEVENT *event);
23       mmask_t mousemask(mmask_t newmask, mmask_t *oldmask);
24       bool wenclose(const WINDOW *win, int y, int x);
25       bool mouse_trafo(int* pY, int* pX, bool to_screen);
26       bool wmouse_trafo(const WINDOW* win, int* pY, int* pX,
27            bool to_screen);
28       int mouseinterval(int erval);
29

DESCRIPTION

31       These functions provide an interface to mouse events from  ncurses(3X).
32       Mouse  events  are  represented  by  KEY_MOUSE pseudo-key values in the
33       wgetch input stream.
34
35       To make mouse events visible, use the mousemask  function.   This  will
36       set  the  mouse events to be reported.  By default, no mouse events are
37       reported.  The function will return a mask to  indicate  which  of  the
38       specified  mouse events can be reported; on complete failure it returns
39       0.  If oldmask is non-NULL, this function fills the indicated  location
40       with the previous value of the given window's mouse event mask.
41
42       As  a  side  effect,  setting  a  zero mousemask may turn off the mouse
43       pointer; setting a nonzero mask may turn it on.  Whether  this  happens
44       is device-dependent.
45
46       Here are the mouse event type masks which may be defined:
47
48       Name                     Description
49       ─────────────────────────────────────────────────────────────────────
50       BUTTON1_PRESSED          mouse button 1 down
51       BUTTON1_RELEASED         mouse button 1 up
52       BUTTON1_CLICKED          mouse button 1 clicked
53       BUTTON1_DOUBLE_CLICKED   mouse button 1 double clicked
54       BUTTON1_TRIPLE_CLICKED   mouse button 1 triple clicked
55       ─────────────────────────────────────────────────────────────────────
56       BUTTON2_PRESSED          mouse button 2 down
57       BUTTON2_RELEASED         mouse button 2 up
58       BUTTON2_CLICKED          mouse button 2 clicked
59       BUTTON2_DOUBLE_CLICKED   mouse button 2 double clicked
60       BUTTON2_TRIPLE_CLICKED   mouse button 2 triple clicked
61       ─────────────────────────────────────────────────────────────────────
62       BUTTON3_PRESSED          mouse button 3 down
63       BUTTON3_RELEASED         mouse button 3 up
64       BUTTON3_CLICKED          mouse button 3 clicked
65       BUTTON3_DOUBLE_CLICKED   mouse button 3 double clicked
66
67       BUTTON3_TRIPLE_CLICKED   mouse button 3 triple clicked
68       ─────────────────────────────────────────────────────────────────────
69       BUTTON4_PRESSED          mouse button 4 down
70       BUTTON4_RELEASED         mouse button 4 up
71       BUTTON4_CLICKED          mouse button 4 clicked
72       BUTTON4_DOUBLE_CLICKED   mouse button 4 double clicked
73       BUTTON4_TRIPLE_CLICKED   mouse button 4 triple clicked
74       ─────────────────────────────────────────────────────────────────────
75       BUTTON5_PRESSED          mouse button 5 down
76       BUTTON5_RELEASED         mouse button 5 up
77       BUTTON5_CLICKED          mouse button 5 clicked
78       BUTTON5_DOUBLE_CLICKED   mouse button 5 double clicked
79       BUTTON5_TRIPLE_CLICKED   mouse button 5 triple clicked
80       ─────────────────────────────────────────────────────────────────────
81       BUTTON_SHIFT             shift was down during button state change
82       BUTTON_CTRL              control was down during button state change
83       BUTTON_ALT               alt was down during button state change
84       ALL_MOUSE_EVENTS         report all button state changes
85       REPORT_MOUSE_POSITION    report mouse movement
86       ─────────────────────────────────────────────────────────────────────
87
88       Once  a class of mouse events have been made visible in a window, call‐
89       ing the wgetch function on that window may return KEY_MOUSE as an indi‐
90       cator  that  a mouse event has been queued.  To read the event data and
91       pop the event off the queue, call getmouse.  This function will  return
92       OK if a mouse event is actually visible in the given window, ERR other‐
93       wise.  When getmouse returns OK, the data deposited as y and x  in  the
94       event  structure coordinates will be screen-relative character-cell co‐
95       ordinates.  The returned state mask will have exactly one  bit  set  to
96       indicate the event type.
97
98       The  ungetmouse  function  behaves analogously to ungetch.  It pushes a
99       KEY_MOUSE event onto the input queue, and associates  with  that  event
100       the given state data and screen-relative character-cell coordinates.
101
102       The  wenclose  function  tests  whether a given pair of screen-relative
103       character-cell coordinates is enclosed by  a  given  window,  returning
104       TRUE  if  it is and FALSE otherwise.  It is useful for determining what
105       subset of the screen windows enclose the location of a mouse event.
106
107       The wmouse_trafo function transforms a given pair of  coordinates  from
108       stdscr-relative coordinates to coordinates relative to the given window
109       or vice versa.  Please remember, that stdscr-relative  coordinates  are
110       not  always  identical to window-relative coordinates due to the mecha‐
111       nism to reserve lines on top or bottom of the screen for other purposes
112       (see the ripoffline() and slk_init calls, for example).  If the parame‐
113       ter to_screen is TRUE, the pointers pY, pX must reference  the  coordi‐
114       nates  of a location inside the window win.  They are converted to win‐
115       dow-relative coordinates and returned through  the  pointers.   If  the
116       conversion  was  successful,  the function returns TRUE.  If one of the
117       parameters was NULL or the location is not inside the window, FALSE  is
118       returned.   If  to_screen  is FALSE, the pointers pY, pX must reference
119       window-relative coordinates.  They are converted to stdscr-relative co‐
120       ordinates  if  the  window  win  encloses this point.  In this case the
121       function returns TRUE.  If one of the parameters is NULL or  the  point
122       is  not  inside the window, FALSE is returned.  Please notice, that the
123       referenced coordinates are only replaced by the  converted  coordinates
124       if the transformation was successful.
125
126       The mouse_trafo function performs the same translation as wmouse_trafo,
127       using stdscr for win.
128
129       The mouseinterval function sets the maximum time  (in  thousands  of  a
130       second) that can elapse between press and release events for them to be
131       recognized as a click.  Use mouseinterval(0) to disable  click  resolu‐
132       tion.  This function returns the previous interval value.  Use mousein‐
133       terval(-1) to obtain the interval without altering it.  The default  is
134       one sixth of a second.
135
136       Note  that  mouse  events will be ignored when input is in cooked mode,
137       and will cause an error beep when cooked mode is being simulated  in  a
138       window  by a function such as getstr that expects a linefeed for input-
139       loop termination.
140

RETURN VALUE

142       getmouse and ungetmouse return the integer ERR upon failure or OK  upon
143       successful completion.
144
145              getmouse
146                   returns  an  error.  If no mouse driver was initialized, or
147                   if the mask parameter is zero,
148
149              ungetmouse
150                   returns an error if the FIFO is full.
151
152       mousemask returns the mask of reportable events.
153
154       mouseinterval returns the previous interval value, unless the  terminal
155       was  not  initialized.   In  that case, it returns the maximum interval
156       value (166).
157
158       wenclose and wmouse_trafo are boolean functions returning TRUE or FALSE
159       depending on their test result.
160

PORTABILITY

162       These  calls  were  designed for ncurses(3X), and are not found in SVr4
163       curses, 4.4BSD curses, or any other previous version of curses.
164
165       The feature macro NCURSES_MOUSE_VERSION is provided so the preprocessor
166       can  be used to test whether these features are present.  If the inter‐
167       face is changed, the value of NCURSES_MOUSE_VERSION will be  increment‐
168       ed.   These values for NCURSES_MOUSE_VERSION may be specified when con‐
169       figuring ncurses:
170
171              1  has definitions for reserved events.  The mask uses 28 bits.
172
173              2  adds definitions for button 5, removes  the  definitions  for
174                 reserved events.  The mask uses 29 bits.
175
176       The order of the MEVENT structure members is not guaranteed.  Addition‐
177       al fields may be added to the structure in the future.
178
179       Under ncurses(3X), these calls are  implemented  using  either  xterm's
180       built-in mouse-tracking API or platform-specific drivers including
181              Alessandro Rubini's gpm server.
182              FreeBSD sysmouse
183              OS/2 EMX
184       If you are using an unsupported configuration, mouse events will not be
185       visible to ncurses(3X) (and the mousemask function will  always  return
186       0).
187
188       If  the  terminfo entry contains a XM string, this is used in the xterm
189       mouse driver to control the way the terminal is initialized  for  mouse
190       operation.   The  default,  if  XM is not found, corresponds to private
191       mode 1000 of xterm:
192              \E[?1000%?%p1%{1}%=%th%el%;
193       The z member in the event structure is not presently used.  It  is  in‐
194       tended  for use with touch screens (which may be pressure-sensitive) or
195       with 3D-mice/trackballs/power gloves.
196

BUGS

198       Mouse events under xterm will not in  fact  be  ignored  during  cooked
199       mode, if they have been enabled by mousemask.  Instead, the xterm mouse
200       report sequence will appear in the string read.
201
202       Mouse events under xterm will not be detected  correctly  in  a  window
203       with  its  keypad  bit  off, since they are interpreted as a variety of
204       function key.  Your terminfo  description  should  have  kmous  set  to
205       "\E[M"  (the  beginning  of  the response from xterm for mouse clicks).
206       Other values for kmous are permitted, but under  the  same  assumption,
207       i.e., it is the beginning of the response.
208
209       Because  there  are  no standard terminal responses that would serve to
210       identify terminals which support the xterm mouse protocol, ncurses  as‐
211       sumes  that  if  your  $TERM  environment variable contains "xterm", or
212       kmous is defined in the terminal description,  then  the  terminal  may
213       send mouse events.
214

SEE ALSO

216       curses(3X), curs_kernel(3X), curs_slk(3X).
217
218
219
220                                                                curs_mouse(3X)
Impressum