4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
40 #pragma ident "%Z%%M% %I% %E% SMI"
44 #include <sys/types.h>
45 #include "curses_inc.h"
48 mouse_set(long int mbe
)
52 (void) tputs(tparm_p1(get_mouse
, mbe
), 1, _outch
);
53 (void) fflush(SP
->term_file
);
60 mouse_on(long int mbe
)
64 (void) tputs(tparm_p1(get_mouse
, (long) SP
->_trap_mbe
),
66 (void) fflush(SP
->term_file
);
73 mouse_off(long int mbe
)
76 SP
->_trap_mbe
&= ~mbe
;
77 (void) tputs(tparm_p1(get_mouse
, (long) SP
->_trap_mbe
),
79 (void) fflush(SP
->term_file
);
87 request_mouse_pos(void)
92 (void) tputs(req_mouse_pos
, 1, _outch
);
93 (void) fflush(SP
->term_file
);
95 /* we now must wait for report of mouse position. How do */
96 /* we know that this is mouse position report an not any- */
97 /* thing else? thetch() returns KEY_MOUSE and the status */
98 /* off all the buttons remains unchanged. */
99 /* just to avoid going into infinite loop, we have a */
100 /* counter. if 1000 responses won't have what we need, */
101 /* we'll return error */
103 for (i
= 0; i
< 1000; i
++) {
104 if ((tgetch(1) == KEY_MOUSE
) && MOUSE_POS_REPORT
)
115 wmouse_position(WINDOW
*win
, int *x
, int *y
)
117 /* mouse pointer outside the window, store -1's into x and y */
119 if (win
->_begy
> MOUSE_Y_POS
|| win
->_begx
> MOUSE_X_POS
||
120 win
->_begy
+win
->_maxy
< MOUSE_Y_POS
||
121 win
->_begx
+win
->_maxx
< MOUSE_X_POS
) {
124 *x
= MOUSE_X_POS
- win
->_begx
;
125 *y
= MOUSE_Y_POS
- win
->_begy
;
131 map_button(unsigned long a
)
133 SP
->_map_mbe_to_key
= a
;
141 return (SP
->_trap_mbe
);
148 return (SP
->_map_mbe_to_key
);