xref: /openbsd/sys/dev/wscons/wsmoused.h (revision 4bdff4be)
1 /* $OpenBSD: wsmoused.h,v 1.10 2014/10/27 13:55:05 mpi Exp $ */
2 
3 /*
4  * Copyright (c) 2001 Jean-Baptiste Marchand, Julien Montagne and Jerome Verdon
5  *
6  * All rights reserved.
7  *
8  * This code is for mouse console support under the wscons console driver.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by
21  *	Hellmuth Michaelis, Brian Dunford-Shore, Joerg Wunsch, Scott Turner
22  *	and Charles Hannum.
23  * 4. The name authors may not be used to endorse or promote products
24  *    derived from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
27  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 int	wsmoused(struct wsdisplay_softc *, caddr_t, int, struct proc *);
39 
40 void	motion_event(struct wsscreen *, u_int, int);
41 void	button_event(struct wsscreen *, int, int);
42 int	ctrl_event(struct wsdisplay_softc *, u_int, int, struct proc *);
43 
44 void	mouse_moverel(struct wsscreen *, int, int);
45 
46 void	inverse_char(struct wsscreen *, u_int);
47 void	inverse_region(struct wsscreen *, u_int, u_int);
48 
49 u_int	skip_spc_right(struct wsscreen *, int);
50 u_int	skip_spc_left(struct wsscreen *);
51 u_int	skip_char_right(struct wsscreen *, u_int);
52 u_int	skip_char_left(struct wsscreen *, u_int);
53 u_int	class_cmp(struct wsscreen *, u_int, u_int);
54 
55 void	mouse_copy_start(struct wsscreen *);
56 void	mouse_copy_word(struct wsscreen *);
57 void	mouse_copy_line(struct wsscreen *);
58 void	mouse_copy_end(struct wsscreen *);
59 void	mouse_copy_extend(struct wsscreen *);
60 void	mouse_copy_extend_char(struct wsscreen *);
61 void	mouse_copy_extend_word(struct wsscreen *);
62 void	mouse_copy_extend_line(struct wsscreen *);
63 void	mouse_copy_extend_after(struct wsscreen *);
64 void	mouse_hide(struct wsscreen *);
65 void	remove_selection(struct wsscreen *);
66 void	mouse_copy_selection(struct wsscreen *);
67 void	mouse_paste(struct wsscreen *);
68 
69 void	mouse_zaxis(struct wsscreen *, int);
70 void	allocate_copybuffer(struct wsdisplay_softc *);
71 void	mouse_remove(struct wsscreen *);
72 
73 #define NO_BORDER 0
74 #define BORDER 1
75 
76 #define N_COLS(dconf) 	((dconf)->scrdata->ncols)
77 #define N_ROWS(dconf) 	((dconf)->scrdata->nrows)
78 
79 #define WS_NCOLS(scr)	N_COLS((scr)->scr_dconf)
80 #define WS_NROWS(scr)	N_ROWS((scr)->scr_dconf)
81 
82 #define MAXCOL(dconf)	(N_COLS(dconf) - 1)
83 #define MAXROW(dconf)	(N_ROWS(dconf) - 1)
84 
85 /* Shortcuts to the various display operations */
86 #define	GETCHAR(scr, pos, cellp) \
87 	((*(scr)->sc->sc_accessops->getchar) \
88 	    ((scr)->sc->sc_accesscookie, (pos) / N_COLS((scr)->scr_dconf), \
89 	     (pos) % N_COLS((scr)->scr_dconf), cellp))
90 #define PUTCHAR(dconf, pos, uc, attr) \
91 	((*(dconf)->emulops->putchar) \
92 	    ((dconf)->emulcookie, ((pos) / N_COLS(dconf)), \
93 	    ((pos) % N_COLS(dconf)), (uc), (attr)))
94 
95 #define MOUSE_COPY_BUTTON 	0
96 #define MOUSE_PASTE_BUTTON 	1
97 #define MOUSE_EXTEND_BUTTON	2
98 
99 #define IS_ALPHANUM(c) ((c) != ' ')
100 #define IS_SPACE(c) ((c) == ' ')
101