Merge from vendor branch OPENSSH:
[dragonfly.git] / lib / libncurses / man / curs_mouse.3
1 '\" t
2 .\"***************************************************************************
3 .\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
4 .\"                                                                          *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
6 .\" copy of this software and associated documentation files (the            *
7 .\" "Software"), to deal in the Software without restriction, including      *
8 .\" without limitation the rights to use, copy, modify, merge, publish,      *
9 .\" distribute, distribute with modifications, sublicense, and/or sell       *
10 .\" copies of the Software, and to permit persons to whom the Software is    *
11 .\" furnished to do so, subject to the following conditions:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23 .\"                                                                          *
24 .\" Except as contained in this notice, the name(s) of the above copyright   *
25 .\" holders shall not be used in advertising or otherwise to promote the     *
26 .\" sale, use or other dealings in this Software without prior written       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: curs_mouse.3x,v 1.24 2003/12/27 18:47:54 tom Exp $
31 .\" $DragonFly: src/lib/libncurses/man/curs_mouse.3,v 1.1 2005/03/12 19:13:54 eirikn Exp $
32 .TH curs_mouse 3X ""
33 .SH NAME
34 \fBgetmouse\fR, \fBungetmouse\fR,
35 \fBmousemask\fR, \fBwenclose\fR,
36 \fBmouse_trafo\fR, \fBwmouse_trafo\fR,
37 \fBmouseinterval\fR - mouse interface through curses
38 .SH SYNOPSIS
39 .nf
40 \fB#include <curses.h>
41 .PP
42 \fBtypedef unsigned long mmask_t;
43 .PP
44 typedef struct
45 {
46     short id;         \fI/* ID to distinguish multiple devices */\fB
47     int x, y, z;      \fI/* event coordinates */\fB
48     mmask_t bstate;   \fI/* button state bits */\fB
49 }
50 MEVENT;\fR
51 .fi
52 .br
53 \fBint getmouse(MEVENT *event);\fR
54 .br
55 \fBint ungetmouse(MEVENT *event);\fR
56 .br
57 \fBmmask_t mousemask(mmask_t newmask, mmask_t *oldmask);\fR
58 .br
59 \fBbool wenclose(const WINDOW *win, int y, int x);\fR
60 .br
61 \fBbool mouse_trafo(int* pY, int* pX, bool to_screen);\fR
62 .br
63 \fBbool wmouse_trafo(const WINDOW* win, int* pY, int* pX,\fR
64 .br
65         \fBbool to_screen);\fR
66 .br
67 \fBint mouseinterval(int erval);\fR
68 .br
69 .SH DESCRIPTION
70 These functions provide an interface to mouse events from
71 \fBncurses\fR(3X).
72 Mouse events are represented by \fBKEY_MOUSE\fR
73 pseudo-key values in the \fBwgetch\fR input stream.
74 .PP
75 To make mouse events visible, use the \fBmousemask\fR function.
76 This will set
77 the mouse events to be reported.
78 By default, no mouse events are reported.
79 The function will return a mask to indicate which of the specified mouse events
80 can be reported; on complete failure it returns 0.
81 If oldmask is non-NULL,
82 this function fills the indicated location with the previous value of the given
83 window's mouse event mask.
84 .PP
85 As a side effect, setting a zero mousemask may turn off the mouse pointer;
86 setting a nonzero mask may turn it on.
87 Whether this happens is device-dependent.
88 .PP
89 Here are the mouse event type masks:
90 .PP
91 .TS
92 l l
93 _ _
94 l l.
95 \fIName\fR      \fIDescription\fR
96 BUTTON1_PRESSED mouse button 1 down
97 BUTTON1_RELEASED        mouse button 1 up
98 BUTTON1_CLICKED mouse button 1 clicked
99 BUTTON1_DOUBLE_CLICKED  mouse button 1 double clicked
100 BUTTON1_TRIPLE_CLICKED  mouse button 1 triple clicked
101 BUTTON2_PRESSED mouse button 2 down
102 BUTTON2_RELEASED        mouse button 2 up
103 BUTTON2_CLICKED mouse button 2 clicked
104 BUTTON2_DOUBLE_CLICKED  mouse button 2 double clicked
105 BUTTON2_TRIPLE_CLICKED  mouse button 2 triple clicked
106 BUTTON3_PRESSED mouse button 3 down
107 BUTTON3_RELEASED        mouse button 3 up
108 BUTTON3_CLICKED mouse button 3 clicked
109 BUTTON3_DOUBLE_CLICKED  mouse button 3 double clicked
110 BUTTON3_TRIPLE_CLICKED  mouse button 3 triple clicked
111 BUTTON4_PRESSED mouse button 4 down
112 BUTTON4_RELEASED        mouse button 4 up
113 BUTTON4_CLICKED mouse button 4 clicked
114 BUTTON4_DOUBLE_CLICKED  mouse button 4 double clicked
115 BUTTON4_TRIPLE_CLICKED  mouse button 4 triple clicked
116 BUTTON_SHIFT    shift was down during button state change
117 BUTTON_CTRL     control was down during button state change
118 BUTTON_ALT      alt was down during button state change
119 ALL_MOUSE_EVENTS        report all button state changes
120 REPORT_MOUSE_POSITION   report mouse movement
121 .TE
122 .PP
123 Once a class of mouse events have been made visible in a window,
124 calling the \fBwgetch\fR function on that window may return
125 \fBKEY_MOUSE\fR as an indicator that a mouse event has been queued.
126 To read the event data and pop the event off the queue, call
127 \fBgetmouse\fR.
128 This function will return \fBOK\fR if a mouse event
129 is actually visible in the given window, \fBERR\fR otherwise.
130 When \fBgetmouse\fR returns \fBOK\fR, the data deposited as y and
131 x in the event structure coordinates will be screen-relative character-cell
132 coordinates.
133 The returned state mask will have exactly one bit set to
134 indicate the event type.
135 .PP
136 The \fBungetmouse\fR function behaves analogously to \fBungetch\fR.
137 It pushes
138 a \fBKEY_MOUSE\fR event onto the input queue, and associates with that event
139 the given state data and screen-relative character-cell coordinates.
140 .PP
141 The \fBwenclose\fR function tests whether a given pair of screen-relative
142 character-cell coordinates is enclosed by a given window, returning TRUE
143 if it is and FALSE otherwise.
144 It is useful for determining what subset of
145 the screen windows enclose the location of a mouse event.
146 .PP
147 The \fBwmouse_trafo\fR function transforms a given pair of coordinates from
148 stdscr-relative coordinates to screen-relative coordinates or vice versa.
149 Please remember, that stdscr-relative coordinates are not always identical
150 to screen-relative coordinates due to the mechanism to reserve lines on top
151 or bottom of the screen for other purposes (ripoff() call, see also slk_...
152 functions).
153 If the parameter \fBto_screen\fR is \fBTRUE\fR, the pointers
154 \fBpY, pX\fR must reference the coordinates of a location inside the window
155 \fBwin\fR.
156 They are converted to screen-relative coordinates and returned
157 through the pointers.
158 If the conversion was successful, the function returns \fBTRUE\fR.
159 If one of the parameters was NULL or the location is
160 not inside the window, \fBFALSE\fR is returned.
161 If \fBto_screen\fR is
162 \fBFALSE\fR, the pointers \fBpY, pX\fR must reference screen-relative
163 coordinates.
164 They are converted to stdscr-relative coordinates if the
165 window \fBwin\fR encloses this point.
166 In this case the function returns \fBTRUE\fR.
167 If one of the parameters is NULL or the point is not inside the
168 window, \fBFALSE\fR is returned.
169 Please notice, that the referenced coordinates
170 are only replaced by the converted coordinates if the transformation was
171 successful.
172 .PP
173 The \fBmouseinterval\fR function sets the maximum time (in thousands of a
174 second) that can elapse between press and release events for them to
175 be recognized as a click.
176 Use \fBmouseinterval(-1)\fR to disable click resolution.
177 This function returns the previous interval value.
178 The default is one sixth of a second.
179 .PP
180 Note that mouse events will be ignored when input is in cooked mode, and will
181 cause an error beep when cooked mode is being simulated in a window by a
182 function such as \fBgetstr\fR that expects a linefeed for input-loop
183 termination.
184 .SH RETURN VALUE
185 \fBgetmouse\fR, \fBungetmouse\fR and \fBmouseinterval\fR
186 return the integer \fBERR\fR upon failure or \fBOK\fR
187 upon successful completion.
188 \fBmousemask\fR returns the
189 mask of reportable events.
190 \fBwenclose\fR and \fBwmouse_trafo\fR
191 are boolean functions returning \fBTRUE\fR or \fBFALSE\fR depending
192 on their test result.
193 .SH PORTABILITY
194 These calls were designed for \fBncurses\fR(3X), and are not found in SVr4
195 curses, 4.4BSD curses, or any other previous version of curses.
196 .PP
197 The feature macro \fBNCURSES_MOUSE_VERSION\fR is provided so the preprocessor
198 can be used to test whether these features are present (its value is 1).
199 If the interface is changed, the value of \fBNCURSES_MOUSE_VERSION\fR will be
200 incremented.
201 .PP
202 The order of the \fBMEVENT\fR structure members is not guaranteed.
203 Additional fields may be added to the structure in the future.
204 .PP
205 Under \fBncurses\fR(3X), these calls are implemented using either
206 xterm's built-in mouse-tracking API or
207 platform-specific drivers including
208 .RS
209 Alessandro Rubini's gpm server.
210 .br
211 FreeBSD sysmouse
212 .br
213 OS/2 EMX
214 .RE
215 If you are using an unsupported configuration,
216 mouse events will not be visible to
217 \fBncurses\fR(3X) (and the \fBwmousemask\fR function will always
218 return \fB0\fR).
219 .PP
220 If the terminfo entry contains a \fBXM\fR string,
221 this is used in the xterm mouse driver to control the
222 way the terminal is initialized for mouse operation.
223 The default, if \fBXM\fR is not found,
224 corresponds to private mode 1000 of xterm:
225 .RS
226 \\E[?1000%?%p1%{1}%=%th%el%;
227 .RE
228 The z member in the event structure is not presently used.
229 It is intended
230 for use with touch screens (which may be pressure-sensitive) or with
231 3D-mice/trackballs/power gloves.
232 .SH BUGS
233 Mouse events under xterm will not in fact be ignored during cooked mode,
234 if they have been enabled by \fBwmousemask\fR.
235 Instead, the xterm mouse
236 report sequence will appear in the string read.
237 .PP
238 Mouse events under xterm will not be detected correctly in a window with
239 its keypad bit off, since they are interpreted as a variety of function key.
240 Your terminfo description must have \fBkmous\fR set to "\\E[M" (the beginning
241 of the response from xterm for mouse clicks).
242 .PP
243 Because there are no standard terminal responses that would serve to identify
244 terminals which support the xterm mouse protocol, \fBncurses\fR assumes that
245 if your $TERM environment variable contains "xterm",
246 or \fBkmous\fR is defined in
247 the terminal description, then the terminal may send mouse events.
248 .SH SEE ALSO
249 \fBcurses\fR(3X).
250 .\"#
251 .\"# The following sets edit modes for GNU EMACS
252 .\"# Local Variables:
253 .\"# mode:nroff
254 .\"# fill-column:79
255 .\"# End: