150276Speter/**************************************************************************** 2184989Srafan * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * 350276Speter * * 450276Speter * Permission is hereby granted, free of charge, to any person obtaining a * 550276Speter * copy of this software and associated documentation files (the * 650276Speter * "Software"), to deal in the Software without restriction, including * 750276Speter * without limitation the rights to use, copy, modify, merge, publish, * 850276Speter * distribute, distribute with modifications, sublicense, and/or sell * 950276Speter * copies of the Software, and to permit persons to whom the Software is * 1050276Speter * furnished to do so, subject to the following conditions: * 1150276Speter * * 1250276Speter * The above copyright notice and this permission notice shall be included * 1350276Speter * in all copies or substantial portions of the Software. * 1450276Speter * * 1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2250276Speter * * 2350276Speter * Except as contained in this notice, the name(s) of the above copyright * 2450276Speter * holders shall not be used in advertising or otherwise to promote the * 2550276Speter * sale, use or other dealings in this Software without prior written * 2650276Speter * authorization. * 2750276Speter ****************************************************************************/ 2850276Speter 2950276Speter/**************************************************************************** 3050276Speter * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * 3150276Speter * and: Eric S. Raymond <esr@snark.thyrsus.com> * 32166124Srafan * and: Thomas E. Dickey 1996-on * 3350276Speter ****************************************************************************/ 3450276Speter 3550276Speter/* 3650276Speter * lib_tracemse.c - Tracing/Debugging routines (mouse events) 3750276Speter */ 3850276Speter 3950276Speter#include <curses.priv.h> 4050276Speter 41184989SrafanMODULE_ID("$Id: lib_tracemse.c,v 1.15 2008/08/03 15:39:29 tom Exp $") 4250276Speter 4350276Speter#ifdef TRACE 4450276Speter 45184989Srafan#define my_buffer sp->tracemse_buf 46174993Srafan 4776726SpeterNCURSES_EXPORT(char *) 48184989Srafan_nc_tracemouse(SCREEN *sp, MEVENT const *ep) 4950276Speter{ 50174993Srafan (void) sprintf(my_buffer, TRACEMSE_FMT, 51166124Srafan ep->id, 52166124Srafan ep->x, 53166124Srafan ep->y, 54166124Srafan ep->z, 55166124Srafan (unsigned long) ep->bstate); 5650276Speter 57174993Srafan#define SHOW(m, s) if ((ep->bstate & m) == m) strcat(strcat(my_buffer, s), ", ") 58166124Srafan 5997049Speter SHOW(BUTTON1_RELEASED, "release-1"); 6097049Speter SHOW(BUTTON1_PRESSED, "press-1"); 6197049Speter SHOW(BUTTON1_CLICKED, "click-1"); 6297049Speter SHOW(BUTTON1_DOUBLE_CLICKED, "doubleclick-1"); 6397049Speter SHOW(BUTTON1_TRIPLE_CLICKED, "tripleclick-1"); 64166124Srafan#if NCURSES_MOUSE_VERSION == 1 6597049Speter SHOW(BUTTON1_RESERVED_EVENT, "reserved-1"); 66166124Srafan#endif 67166124Srafan 6897049Speter SHOW(BUTTON2_RELEASED, "release-2"); 6997049Speter SHOW(BUTTON2_PRESSED, "press-2"); 7097049Speter SHOW(BUTTON2_CLICKED, "click-2"); 7197049Speter SHOW(BUTTON2_DOUBLE_CLICKED, "doubleclick-2"); 7297049Speter SHOW(BUTTON2_TRIPLE_CLICKED, "tripleclick-2"); 73166124Srafan#if NCURSES_MOUSE_VERSION == 1 7497049Speter SHOW(BUTTON2_RESERVED_EVENT, "reserved-2"); 75166124Srafan#endif 76166124Srafan 7797049Speter SHOW(BUTTON3_RELEASED, "release-3"); 7897049Speter SHOW(BUTTON3_PRESSED, "press-3"); 7997049Speter SHOW(BUTTON3_CLICKED, "click-3"); 8097049Speter SHOW(BUTTON3_DOUBLE_CLICKED, "doubleclick-3"); 8197049Speter SHOW(BUTTON3_TRIPLE_CLICKED, "tripleclick-3"); 82166124Srafan#if NCURSES_MOUSE_VERSION == 1 8397049Speter SHOW(BUTTON3_RESERVED_EVENT, "reserved-3"); 84166124Srafan#endif 85166124Srafan 8697049Speter SHOW(BUTTON4_RELEASED, "release-4"); 8797049Speter SHOW(BUTTON4_PRESSED, "press-4"); 8897049Speter SHOW(BUTTON4_CLICKED, "click-4"); 8997049Speter SHOW(BUTTON4_DOUBLE_CLICKED, "doubleclick-4"); 9097049Speter SHOW(BUTTON4_TRIPLE_CLICKED, "tripleclick-4"); 91166124Srafan#if NCURSES_MOUSE_VERSION == 1 9297049Speter SHOW(BUTTON4_RESERVED_EVENT, "reserved-4"); 93166124Srafan#endif 94166124Srafan 95166124Srafan#if NCURSES_MOUSE_VERSION == 2 96166124Srafan SHOW(BUTTON5_RELEASED, "release-5"); 97166124Srafan SHOW(BUTTON5_PRESSED, "press-5"); 98166124Srafan SHOW(BUTTON5_CLICKED, "click-5"); 99166124Srafan SHOW(BUTTON5_DOUBLE_CLICKED, "doubleclick-5"); 100166124Srafan SHOW(BUTTON5_TRIPLE_CLICKED, "tripleclick-5"); 101166124Srafan#endif 102166124Srafan 10397049Speter SHOW(BUTTON_CTRL, "ctrl"); 10497049Speter SHOW(BUTTON_SHIFT, "shift"); 10597049Speter SHOW(BUTTON_ALT, "alt"); 10697049Speter SHOW(ALL_MOUSE_EVENTS, "all-events"); 10797049Speter SHOW(REPORT_MOUSE_POSITION, "position"); 108166124Srafan 10950276Speter#undef SHOW 11050276Speter 111174993Srafan if (my_buffer[strlen(my_buffer) - 1] == ' ') 112174993Srafan my_buffer[strlen(my_buffer) - 2] = '\0'; 113174993Srafan (void) strcat(my_buffer, "}"); 114174993Srafan return (my_buffer); 11550276Speter} 11650276Speter 117184989SrafanNCURSES_EXPORT(char *) 118184989Srafan_tracemouse(MEVENT const *ep) 119184989Srafan{ 120184989Srafan return _nc_tracemouse(SP, ep); 121184989Srafan} 122184989Srafan 12350276Speter#else /* !TRACE */ 124184989SrafanEMPTY_MODULE(_nc_lib_tracemouse) 12550276Speter#endif 126