1/**************************************************************************** 2 * Copyright (c) 1998-2002,2005 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 * and: Thomas E. Dickey 1996-on * 33 ****************************************************************************/ 34 35/* 36 * lib_tracemse.c - Tracing/Debugging routines (mouse events) 37 */ 38 39#include <curses.priv.h> 40 41MODULE_ID("$Id: lib_tracemse.c,v 1.12 2005/06/11 19:53:50 tom Exp $") 42 43#ifdef TRACE 44 45NCURSES_EXPORT(char *) 46_tracemouse(MEVENT const *ep) 47{ 48 /* 49 * hmm - format is no longer than 80 columns, there are 5 numbers that 50 * could at most have 10 digits, and the mask contains no more than 32 bits 51 * with each bit representing less than 15 characters. Usually the whole 52 * string is less than 80 columns, but this buffer size is an absolute 53 * limit. 54 */ 55 static char buf[80 + (5 * 10) + (32 * 15)]; 56 57 (void) sprintf(buf, "id %2d at (%2d, %2d, %2d) state %4lx = {", 58 ep->id, 59 ep->x, 60 ep->y, 61 ep->z, 62 (unsigned long) ep->bstate); 63 64#define SHOW(m, s) if ((ep->bstate & m) == m) strcat(strcat(buf, s), ", ") 65 66 SHOW(BUTTON1_RELEASED, "release-1"); 67 SHOW(BUTTON1_PRESSED, "press-1"); 68 SHOW(BUTTON1_CLICKED, "click-1"); 69 SHOW(BUTTON1_DOUBLE_CLICKED, "doubleclick-1"); 70 SHOW(BUTTON1_TRIPLE_CLICKED, "tripleclick-1"); 71#if NCURSES_MOUSE_VERSION == 1 72 SHOW(BUTTON1_RESERVED_EVENT, "reserved-1"); 73#endif 74 75 SHOW(BUTTON2_RELEASED, "release-2"); 76 SHOW(BUTTON2_PRESSED, "press-2"); 77 SHOW(BUTTON2_CLICKED, "click-2"); 78 SHOW(BUTTON2_DOUBLE_CLICKED, "doubleclick-2"); 79 SHOW(BUTTON2_TRIPLE_CLICKED, "tripleclick-2"); 80#if NCURSES_MOUSE_VERSION == 1 81 SHOW(BUTTON2_RESERVED_EVENT, "reserved-2"); 82#endif 83 84 SHOW(BUTTON3_RELEASED, "release-3"); 85 SHOW(BUTTON3_PRESSED, "press-3"); 86 SHOW(BUTTON3_CLICKED, "click-3"); 87 SHOW(BUTTON3_DOUBLE_CLICKED, "doubleclick-3"); 88 SHOW(BUTTON3_TRIPLE_CLICKED, "tripleclick-3"); 89#if NCURSES_MOUSE_VERSION == 1 90 SHOW(BUTTON3_RESERVED_EVENT, "reserved-3"); 91#endif 92 93 SHOW(BUTTON4_RELEASED, "release-4"); 94 SHOW(BUTTON4_PRESSED, "press-4"); 95 SHOW(BUTTON4_CLICKED, "click-4"); 96 SHOW(BUTTON4_DOUBLE_CLICKED, "doubleclick-4"); 97 SHOW(BUTTON4_TRIPLE_CLICKED, "tripleclick-4"); 98#if NCURSES_MOUSE_VERSION == 1 99 SHOW(BUTTON4_RESERVED_EVENT, "reserved-4"); 100#endif 101 102#if NCURSES_MOUSE_VERSION == 2 103 SHOW(BUTTON5_RELEASED, "release-5"); 104 SHOW(BUTTON5_PRESSED, "press-5"); 105 SHOW(BUTTON5_CLICKED, "click-5"); 106 SHOW(BUTTON5_DOUBLE_CLICKED, "doubleclick-5"); 107 SHOW(BUTTON5_TRIPLE_CLICKED, "tripleclick-5"); 108#endif 109 110 SHOW(BUTTON_CTRL, "ctrl"); 111 SHOW(BUTTON_SHIFT, "shift"); 112 SHOW(BUTTON_ALT, "alt"); 113 SHOW(ALL_MOUSE_EVENTS, "all-events"); 114 SHOW(REPORT_MOUSE_POSITION, "position"); 115 116#undef SHOW 117 118 if (buf[strlen(buf) - 1] == ' ') 119 buf[strlen(buf) - 2] = '\0'; 120 (void) strcat(buf, "}"); 121 return (buf); 122} 123 124#else /* !TRACE */ 125empty_module(_nc_lib_tracemouse) 126#endif 127