fbdd2c006de0078d4c4759198a1d81212da459cf
[ncurses.git] / ncurses / trace / lib_tracemse.c
1 /****************************************************************************
2  * Copyright (c) 1998 Free Software Foundation, Inc.                        *
3  *                                                                          *
4  * Permission is hereby granted, free of charge, to any person obtaining a  *
5  * copy of this software and associated documentation files (the            *
6  * "Software"), to deal in the Software without restriction, including      *
7  * without limitation the rights to use, copy, modify, merge, publish,      *
8  * distribute, distribute with modifications, sublicense, and/or sell       *
9  * copies of the Software, and to permit persons to whom the Software is    *
10  * furnished to do so, subject to the following conditions:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22  *                                                                          *
23  * Except as contained in this notice, the name(s) of the above copyright   *
24  * holders shall not be used in advertising or otherwise to promote the     *
25  * sale, use or other dealings in this Software without prior written       *
26  * authorization.                                                           *
27  ****************************************************************************/
28
29 /****************************************************************************
30  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
31  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
32  ****************************************************************************/
33
34
35
36 /*
37  *      lib_tracemse.c - Tracing/Debugging routines (mouse events)
38  */
39
40 #include <curses.priv.h>
41
42 MODULE_ID("$Id: lib_tracemse.c,v 1.6 1998/11/16 14:28:17 Alexander.V.Lukyanov Exp $")
43
44 #ifdef TRACE
45
46 char *_tracemouse(MEVENT const *ep)
47 {
48         static char buf[80];
49
50         (void) sprintf(buf, "id %2d  at (%2d, %2d, %2d) state %4lx = {",
51                        ep->id, ep->x, ep->y, ep->z, ep->bstate);
52
53 #define SHOW(m, s) if ((ep->bstate & m)==m) {strcat(buf,s); strcat(buf, ", ");}
54         SHOW(BUTTON1_RELEASED,          "release-1")
55         SHOW(BUTTON1_PRESSED,           "press-1")
56         SHOW(BUTTON1_CLICKED,           "click-1")
57         SHOW(BUTTON1_DOUBLE_CLICKED,    "doubleclick-1")
58         SHOW(BUTTON1_TRIPLE_CLICKED,    "tripleclick-1")
59         SHOW(BUTTON1_RESERVED_EVENT,    "reserved-1")
60         SHOW(BUTTON2_RELEASED,          "release-2")
61         SHOW(BUTTON2_PRESSED,           "press-2")
62         SHOW(BUTTON2_CLICKED,           "click-2")
63         SHOW(BUTTON2_DOUBLE_CLICKED,    "doubleclick-2")
64         SHOW(BUTTON2_TRIPLE_CLICKED,    "tripleclick-2")
65         SHOW(BUTTON2_RESERVED_EVENT,    "reserved-2")
66         SHOW(BUTTON3_RELEASED,          "release-3")
67         SHOW(BUTTON3_PRESSED,           "press-3")
68         SHOW(BUTTON3_CLICKED,           "click-3")
69         SHOW(BUTTON3_DOUBLE_CLICKED,    "doubleclick-3")
70         SHOW(BUTTON3_TRIPLE_CLICKED,    "tripleclick-3")
71         SHOW(BUTTON3_RESERVED_EVENT,    "reserved-3")
72         SHOW(BUTTON4_RELEASED,          "release-4")
73         SHOW(BUTTON4_PRESSED,           "press-4")
74         SHOW(BUTTON4_CLICKED,           "click-4")
75         SHOW(BUTTON4_DOUBLE_CLICKED,    "doubleclick-4")
76         SHOW(BUTTON4_TRIPLE_CLICKED,    "tripleclick-4")
77         SHOW(BUTTON4_RESERVED_EVENT,    "reserved-4")
78         SHOW(BUTTON_CTRL,               "ctrl")
79         SHOW(BUTTON_SHIFT,              "shift")
80         SHOW(BUTTON_ALT,                "alt")
81         SHOW(ALL_MOUSE_EVENTS,          "all-events")
82         SHOW(REPORT_MOUSE_POSITION,     "position")
83 #undef SHOW
84
85         if (buf[strlen(buf)-1] == ' ')
86                 buf[strlen(buf)-2] = '\0';
87         (void) strcat(buf, "}");
88         return(buf);
89 }
90
91 #else /* !TRACE */
92 /* don't make empty module */
93 void _nc_lib_tracemouse(void);
94 void _nc_lib_tracemouse(void) {}
95 #endif