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.
98
99       The  ungetmouse  function  behaves analogously to ungetch.  It pushes a
100       KEY_MOUSE event onto the input queue, and associates  with  that  event
101       the given state data and screen-relative character-cell coordinates.
102
103       The  wenclose  function  tests  whether a given pair of screen-relative
104       character-cell coordinates is enclosed by  a  given  window,  returning
105       TRUE  if  it is and FALSE otherwise.  It is useful for determining what
106       subset of the screen windows enclose the location of a mouse event.
107
108       The wmouse_trafo function transforms a given pair of  coordinates  from
109       stdscr-relative coordinates to coordinates relative to the given window
110       or vice versa.  Please remember, that stdscr-relative  coordinates  are
111       not  always  identical to window-relative coordinates due to the mecha‐
112       nism to reserve lines on top or bottom of the screen for other purposes
113       (see the ripoffline() and slk_init calls, for example).  If the parame‐
114       ter to_screen is TRUE, the pointers pY, pX must reference  the  coordi‐
115       nates  of a location inside the window win.  They are converted to win‐
116       dow-relative coordinates and returned through  the  pointers.   If  the
117       conversion  was  successful,  the function returns TRUE.  If one of the
118       parameters was NULL or the location is not inside the window, FALSE  is
119       returned.   If  to_screen  is FALSE, the pointers pY, pX must reference
120       window-relative coordinates.  They are converted to stdscr-relative co‐
121       ordinates  if  the  window  win  encloses this point.  In this case the
122       function returns TRUE.  If one of the parameters is NULL or  the  point
123       is  not  inside the window, FALSE is returned.  Please notice, that the
124       referenced coordinates are only replaced by the  converted  coordinates
125       if the transformation was successful.
126
127       The mouse_trafo function performs the same translation as wmouse_trafo,
128       using stdscr for win.
129
130       The mouseinterval function sets the maximum time  (in  thousands  of  a
131       second) that can elapse between press and release events for them to be
132       recognized as a click.  Use mouseinterval(0) to disable  click  resolu‐
133       tion.  This function returns the previous interval value.  Use mousein‐
134       terval(-1) to obtain the interval without altering it.  The default  is
135       one sixth of a second.
136
137       The  has_mouse  function returns TRUE if the mouse driver has been suc‐
138       cessfully initialized.
139
140       Note that mouse events will be ignored when input is  in  cooked  mode,
141       and  will  cause an error beep when cooked mode is being simulated in a
142       window by a function such as getstr that expects a linefeed for  input-
143       loop termination.
144

RETURN VALUE

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

PORTABILITY

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

BUGS

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

SEE ALSO

220       curses(3X), curs_kernel(3X), curs_slk(3X).
221
222
223
224                                                                curs_mouse(3X)
Impressum