GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libcurses/trace/lib_tracemse.c Lines: 0 1 0.0 %
Date: 2017-11-07 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/* $OpenBSD: lib_tracemse.c,v 1.5 2010/01/12 23:22:07 nicm Exp $ */
2
3
/****************************************************************************
4
 * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
5
 *                                                                          *
6
 * Permission is hereby granted, free of charge, to any person obtaining a  *
7
 * copy of this software and associated documentation files (the            *
8
 * "Software"), to deal in the Software without restriction, including      *
9
 * without limitation the rights to use, copy, modify, merge, publish,      *
10
 * distribute, distribute with modifications, sublicense, and/or sell       *
11
 * copies of the Software, and to permit persons to whom the Software is    *
12
 * furnished to do so, subject to the following conditions:                 *
13
 *                                                                          *
14
 * The above copyright notice and this permission notice shall be included  *
15
 * in all copies or substantial portions of the Software.                   *
16
 *                                                                          *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20
 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23
 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24
 *                                                                          *
25
 * Except as contained in this notice, the name(s) of the above copyright   *
26
 * holders shall not be used in advertising or otherwise to promote the     *
27
 * sale, use or other dealings in this Software without prior written       *
28
 * authorization.                                                           *
29
 ****************************************************************************/
30
31
/****************************************************************************
32
 *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
33
 *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
34
 *     and: Thomas E. Dickey                        1996-on                 *
35
 ****************************************************************************/
36
37
/*
38
 *	lib_tracemse.c - Tracing/Debugging routines (mouse events)
39
 */
40
41
#include <curses.priv.h>
42
43
MODULE_ID("$Id: lib_tracemse.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
44
45
#ifdef TRACE
46
47
#define my_buffer sp->tracemse_buf
48
49
NCURSES_EXPORT(char *)
50
_nc_tracemouse(SCREEN *sp, MEVENT const *ep)
51
{
52
	(void) snprintf(my_buffer, TRACEMSE_MAX, TRACEMSE_FMT,
53
		   ep->id,
54
		   ep->x,
55
		   ep->y,
56
		   ep->z,
57
		   (unsigned long) ep->bstate);
58
59
#define SHOW(m, s) \
60
    if ((ep->bstate & m) == m) {		\
61
	strlcat(my_buffer, s, TRACEMSE_MAX);	\
62
	strlcat(my_buffer, ", ", TRACEMSE_MAX);	\
63
}
64
65
    SHOW(BUTTON1_RELEASED, "release-1");
66
    SHOW(BUTTON1_PRESSED, "press-1");
67
    SHOW(BUTTON1_CLICKED, "click-1");
68
    SHOW(BUTTON1_DOUBLE_CLICKED, "doubleclick-1");
69
    SHOW(BUTTON1_TRIPLE_CLICKED, "tripleclick-1");
70
#if NCURSES_MOUSE_VERSION == 1
71
    SHOW(BUTTON1_RESERVED_EVENT, "reserved-1");
72
#endif
73
74
    SHOW(BUTTON2_RELEASED, "release-2");
75
    SHOW(BUTTON2_PRESSED, "press-2");
76
    SHOW(BUTTON2_CLICKED, "click-2");
77
    SHOW(BUTTON2_DOUBLE_CLICKED, "doubleclick-2");
78
    SHOW(BUTTON2_TRIPLE_CLICKED, "tripleclick-2");
79
#if NCURSES_MOUSE_VERSION == 1
80
    SHOW(BUTTON2_RESERVED_EVENT, "reserved-2");
81
#endif
82
83
    SHOW(BUTTON3_RELEASED, "release-3");
84
    SHOW(BUTTON3_PRESSED, "press-3");
85
    SHOW(BUTTON3_CLICKED, "click-3");
86
    SHOW(BUTTON3_DOUBLE_CLICKED, "doubleclick-3");
87
    SHOW(BUTTON3_TRIPLE_CLICKED, "tripleclick-3");
88
#if NCURSES_MOUSE_VERSION == 1
89
    SHOW(BUTTON3_RESERVED_EVENT, "reserved-3");
90
#endif
91
92
    SHOW(BUTTON4_RELEASED, "release-4");
93
    SHOW(BUTTON4_PRESSED, "press-4");
94
    SHOW(BUTTON4_CLICKED, "click-4");
95
    SHOW(BUTTON4_DOUBLE_CLICKED, "doubleclick-4");
96
    SHOW(BUTTON4_TRIPLE_CLICKED, "tripleclick-4");
97
#if NCURSES_MOUSE_VERSION == 1
98
    SHOW(BUTTON4_RESERVED_EVENT, "reserved-4");
99
#endif
100
101
#if NCURSES_MOUSE_VERSION == 2
102
    SHOW(BUTTON5_RELEASED, "release-5");
103
    SHOW(BUTTON5_PRESSED, "press-5");
104
    SHOW(BUTTON5_CLICKED, "click-5");
105
    SHOW(BUTTON5_DOUBLE_CLICKED, "doubleclick-5");
106
    SHOW(BUTTON5_TRIPLE_CLICKED, "tripleclick-5");
107
#endif
108
109
    SHOW(BUTTON_CTRL, "ctrl");
110
    SHOW(BUTTON_SHIFT, "shift");
111
    SHOW(BUTTON_ALT, "alt");
112
    SHOW(ALL_MOUSE_EVENTS, "all-events");
113
    SHOW(REPORT_MOUSE_POSITION, "position");
114
115
#undef SHOW
116
117
    if (my_buffer[strlen(my_buffer) - 1] == ' ')
118
	my_buffer[strlen(my_buffer) - 2] = '\0';
119
    (void) strlcat(my_buffer, "}", TRACEMSE_MAX);
120
    return (my_buffer);
121
}
122
123
NCURSES_EXPORT(char *)
124
_tracemouse(MEVENT const *ep)
125
{
126
    return _nc_tracemouse(SP, ep);
127
}
128
129
#else /* !TRACE */
130
EMPTY_MODULE(_nc_lib_tracemouse)
131
#endif