1 /* $OpenBSD: wsmoused.h,v 1.1 2001/04/14 04:44:02 aaron 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 */ 39 40 41 int wsmoused __P((struct wsdisplay_softc *, u_long, caddr_t, int, 42 struct proc *p)); 43 44 void motion_event __P((u_int, int)); 45 void button_event __P((int, int)); 46 int ctrl_event __P((u_int, int, struct wsdisplay_softc *, struct proc *)); 47 48 void mouse_moverel __P((char, char)); 49 50 void inverse_char __P((unsigned short c)); 51 void inverse_region __P((unsigned short start, unsigned short end)); 52 53 unsigned char skip_spc_right __P((char)); 54 unsigned char skip_spc_left __P((void)); 55 unsigned char skip_char_right __P((unsigned short)); 56 unsigned char skip_char_left __P((unsigned short)); 57 unsigned char class_cmp __P((unsigned short, unsigned short)); 58 59 void mouse_copy_start __P((void)); 60 void mouse_copy_word __P((void)); 61 void mouse_copy_line __P((void)); 62 void mouse_copy_end __P((void)); 63 void mouse_copy_extend __P((void)); 64 void mouse_copy_extend_char __P((void)); 65 void mouse_copy_extend_word __P((void)); 66 void mouse_copy_extend_line __P((void)); 67 void mouse_hide __P((struct wsdisplay_softc *)); 68 void mouse_copy_extend_after __P((void)); 69 void remove_selection __P((struct wsdisplay_softc *)); 70 void mouse_copy_selection __P((void)); 71 void mouse_paste __P((void)); 72 73 void mouse_zaxis __P((int)); 74 void allocate_copybuffer __P((struct wsdisplay_softc *)); 75 76 void sysbeep __P((int, int)); 77 78 char *Copybuffer = NULL; /* buffer that contains mouse selections */ 79 unsigned int Copybuffer_size = 0; 80 char Paste_avail = 0; /* flag, to indicate whether a selection is in the 81 Copy buffer */ 82 83 #define NO_BORDER 0 84 #define BORDER 1 85 86 #define WS_NCOLS(ws) ((ws)->scr_dconf->scrdata->ncols) 87 #define WS_NROWS(ws) ((ws)->scr_dconf->scrdata->nrows) 88 89 #define MAXCOL (WS_NCOLS(sc->sc_focus) - 1) 90 #define MAXROW (WS_NROWS(sc->sc_focus) - 1) 91 92 #define N_COLS (WS_NCOLS(sc->sc_focus)) 93 #define N_ROWS (WS_NROWS(sc->sc_focus)) 94 #define MOUSE (sc->sc_focus->mouse) 95 #define CURSOR (sc->sc_focus->cursor) 96 #define CPY_START (sc->sc_focus->cpy_start) 97 #define CPY_END (sc->sc_focus->cpy_end) 98 #define ORIG_START (sc->sc_focus->orig_start) 99 #define ORIG_END (sc->sc_focus->orig_end) 100 #define MOUSE_FLAGS (sc->sc_focus->mouse_flags) 101 102 #define XY_TO_POS(col, row) (((row) * N_COLS) + (col)) 103 #define POS_TO_X(pos) ((pos) % (N_COLS)) 104 #define POS_TO_Y(pos) ((pos) / (N_COLS)) 105 106 #define GET_FULLCHAR(pos)\ 107 ((*sc->sc_accessops->getchar)\ 108 (sc->sc_accesscookie,\ 109 ((pos) / N_COLS), ((pos) % N_COLS))) 110 111 #define GETCHAR(pos)\ 112 (((*sc->sc_accessops->getchar)\ 113 (sc->sc_accesscookie,\ 114 ((pos) / N_COLS), ((pos) % N_COLS)))\ 115 & 0x000000FF) 116 117 #define PUTCHAR(pos, uc, attr)\ 118 ((*sc->sc_focus->scr_dconf->emulops->putchar)\ 119 (sc->sc_focus->scr_dconf->emulcookie, ((pos) / N_COLS),\ 120 ((pos) % N_COLS), (uc), (attr))); 121 122 #define MOUSE_COPY_BUTTON 0 123 #define MOUSE_PASTE_BUTTON 1 124 #define MOUSE_EXTEND_BUTTON 2 125 126 #define IS_ALPHANUM(pos) (GETCHAR((pos)) != ' ') 127 #define IS_SPACE(c) ((c) == ' ') 128