X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftrace%2Flib_tracemse.c;h=c62b71a0658bbd9e64155cb0772f007c77828cc8;hp=5edcc13a6ffae5a4b39087ec62f975c2b6ea3ec4;hb=6b99a559185b3b8fad80b56bc2070b08101c33d1;hpb=7a27c7d49c2e8b4a1ecbe85b4423d647cbc75ea5 diff --git a/ncurses/trace/lib_tracemse.c b/ncurses/trace/lib_tracemse.c index 5edcc13a..c62b71a0 100644 --- a/ncurses/trace/lib_tracemse.c +++ b/ncurses/trace/lib_tracemse.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -38,23 +38,22 @@ #include -MODULE_ID("$Id: lib_tracemse.c,v 1.13 2007/04/21 21:23:00 tom Exp $") +MODULE_ID("$Id: lib_tracemse.c,v 1.22 2014/10/10 09:06:26 tom Exp $") #ifdef TRACE -#define my_buffer _nc_globals.tracemse_buf +#define my_buffer sp->tracemse_buf NCURSES_EXPORT(char *) -_tracemouse(MEVENT const *ep) +_nc_trace_mmask_t(SCREEN *sp, mmask_t code) { - (void) sprintf(my_buffer, TRACEMSE_FMT, - ep->id, - ep->x, - ep->y, - ep->z, - (unsigned long) ep->bstate); - -#define SHOW(m, s) if ((ep->bstate & m) == m) strcat(strcat(my_buffer, s), ", ") +#define SHOW(m, s) \ + if ((code & m) == m) { \ + size_t n = strlen(my_buffer); \ + if (n && (my_buffer[n-1] != '{')) \ + _nc_STRCAT(my_buffer, ", ", sizeof(my_buffer)); \ + _nc_STRCAT(my_buffer, s, sizeof(my_buffer)); \ + } SHOW(BUTTON1_RELEASED, "release-1"); SHOW(BUTTON1_PRESSED, "press-1"); @@ -110,10 +109,49 @@ _tracemouse(MEVENT const *ep) if (my_buffer[strlen(my_buffer) - 1] == ' ') my_buffer[strlen(my_buffer) - 2] = '\0'; - (void) strcat(my_buffer, "}"); + return (my_buffer); } +NCURSES_EXPORT(char *) +_nc_tracemouse(SCREEN *sp, MEVENT const *ep) +{ + char *result = 0; + + if (sp != 0) { + _nc_SPRINTF(my_buffer, _nc_SLIMIT(sizeof(my_buffer)) + TRACEMSE_FMT, + ep->id, + ep->x, + ep->y, + ep->z, + (unsigned long) ep->bstate); + + (void) _nc_trace_mmask_t(sp, ep->bstate); + _nc_STRCAT(my_buffer, "}", sizeof(my_buffer)); + result = (my_buffer); + } + return result; +} + +NCURSES_EXPORT(mmask_t) +_nc_retrace_mmask_t(SCREEN *sp, mmask_t code) +{ + if (sp != 0) { + *my_buffer = '\0'; + T((T_RETURN("{%s}"), _nc_trace_mmask_t(sp, code))); + } else { + T((T_RETURN("{?}"))); + } + return code; +} + +NCURSES_EXPORT(char *) +_tracemouse(MEVENT const *ep) +{ + return _nc_tracemouse(CURRENT_SCREEN, ep); +} + #else /* !TRACE */ -empty_module(_nc_lib_tracemouse) +EMPTY_MODULE(_nc_lib_tracemouse) #endif