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

NAME

6       has_mouse, getmouse, ungetmouse, mousemask, wenclose, mouse_trafo,
7       wmouse_trafo, 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       bool has_mouse(void);
22       int getmouse(MEVENT *event);
23       int ungetmouse(MEVENT *event);
24       mmask_t mousemask(mmask_t newmask, mmask_t *oldmask);
25       bool wenclose(const WINDOW *win, int y, int x);
26       bool mouse_trafo(int* pY, int* pX, bool to_screen);
27       bool wmouse_trafo(const WINDOW* win, int* pY, int* pX,
28            bool to_screen);
29       int mouseinterval(int erval);
30

DESCRIPTION

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

RETURN VALUE

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

PORTABILITY

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

BUGS

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

SEE ALSO

223       curses(3X), curs_kernel(3X), curs_slk(3X), curs_variables(3X).
224
225
226
227                                                                curs_mouse(3X)
Impressum