summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libcurses/Makefile10
-rw-r--r--lib/libcurses/hardscroll.c6
-rw-r--r--lib/libcurses/lib_trace.c179
-rw-r--r--lib/libcurses/lib_traceatr.c230
-rw-r--r--lib/libcurses/lib_tracechr.c52
-rw-r--r--lib/libcurses/lib_tracedmp.c115
-rw-r--r--lib/libcurses/lib_tracemse.c82
7 files changed, 671 insertions, 3 deletions
diff --git a/lib/libcurses/Makefile b/lib/libcurses/Makefile
index c213254d71b..fdde4b83143 100644
--- a/lib/libcurses/Makefile
+++ b/lib/libcurses/Makefile
@@ -1,4 +1,7 @@
-# $OpenBSD: Makefile,v 1.15 1997/11/26 04:01:04 millert Exp $
+# $OpenBSD: Makefile,v 1.16 1997/11/28 23:02:29 millert Exp $
+
+# Uncomment this to enable tracing in libcurses
+#TRACE=-DTRACE
LIB= curses
SRCS= hardscroll.c hashmap.c lib_acs.c lib_addch.c lib_addstr.c \
@@ -14,7 +17,10 @@ SRCS= hardscroll.c hashmap.c lib_acs.c lib_addch.c lib_addstr.c \
lib_touch.c lib_tstp.c lib_twait.c lib_vidattr.c lib_window.c \
resizeterm.c unctrl.c wresize.c
SRCS+= expanded.c lib_gen.c lib_keyname.c
-CFLAGS+= -I. -I${.CURDIR} -DTERMIOS -DEXTERN_TERMINFO
+.ifdef ${TRACE}
+SRCS+= lib_trace.c lib_traceatr.c lib_tracechr.c lib_tracedmp.c lib_tracemse.c
+.endif
+CFLAGS+= -I. -I${.CURDIR} -DTERMIOS -DEXTERN_TERMINFO ${TRACE}
LDADD+= -ltermlib
MAN= curs_addch.3 curs_addchstr.3 curs_addstr.3 curs_attr.3 curs_beep.3 \
curs_bkgd.3 curs_border.3 curs_clear.3 curs_color.3 curs_delch.3 \
diff --git a/lib/libcurses/hardscroll.c b/lib/libcurses/hardscroll.c
index 7e6d1cc3bce..230c8f77814 100644
--- a/lib/libcurses/hardscroll.c
+++ b/lib/libcurses/hardscroll.c
@@ -358,8 +358,9 @@ void _nc_linedump(void)
/* dump the state of the real and virtual oldnum fields */
{
int n;
- char buf[BUFSIZ];
+ char *buf;
+ buf = malloc((LINES * 12) + 1); /* Assumes int is at most 32bits */
(void) strcpy(buf, "real");
for (n = 0; n < LINES; n++)
(void) sprintf(buf + strlen(buf), " %02d", REAL(n));
@@ -369,6 +370,7 @@ void _nc_linedump(void)
for (n = 0; n < LINES; n++)
(void) sprintf(buf + strlen(buf), " %02d", OLDNUM(n));
TR(TRACE_UPDATE | TRACE_MOVE, (buf));
+ free(buf);
}
#endif /* defined(TRACE) || defined(SCROLLDEBUG) */
@@ -379,7 +381,9 @@ main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED)
{
char line[BUFSIZ], *st;
+#ifdef TRACE
_nc_tracing = TRACE_MOVE;
+#endif /* TRACE */
for (;;)
{
int n;
diff --git a/lib/libcurses/lib_trace.c b/lib/libcurses/lib_trace.c
new file mode 100644
index 00000000000..0aa2e525a99
--- /dev/null
+++ b/lib/libcurses/lib_trace.c
@@ -0,0 +1,179 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+ * lib_trace.c - Tracing/Debugging routines
+ */
+
+#ifndef TRACE
+#define TRACE /* turn on internal defs for this module */
+#endif
+
+#include <curses.priv.h>
+
+MODULE_ID("Id: lib_trace.c,v 1.23 1997/05/02 00:13:07 tom Exp $")
+
+#include <ctype.h>
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+unsigned _nc_tracing = 0;
+const char *_nc_tputs_trace = "";
+long _nc_outchars;
+int _nc_optimize_enable = OPTIMIZE_ALL;
+
+static FILE * tracefp; /* default to writing to stderr */
+
+void trace(const unsigned int tracelevel)
+{
+static bool been_here = FALSE;
+
+ _nc_tracing = tracelevel;
+ if (! been_here && tracelevel) {
+ been_here = TRUE;
+
+ if ((tracefp = fopen("trace", "w")) == 0) {
+ perror("curses: Can't open 'trace' file: ");
+ exit(EXIT_FAILURE);
+ }
+ /* Try to set line-buffered mode, or (failing that) unbuffered,
+ * so that the trace-output gets flushed automatically at the
+ * end of each line. This is useful in case the program dies.
+ */
+#if HAVE_SETVBUF /* ANSI */
+ (void) setvbuf(tracefp, (char *)0, _IOLBF, 0);
+#elif HAVE_SETBUF /* POSIX */
+ (void) setbuffer(tracefp, (char *)0);
+#endif
+ _tracef("TRACING NCURSES version %s (%d)",
+ NCURSES_VERSION, NCURSES_VERSION_PATCH);
+ }
+}
+
+const char *_nc_visbuf2(int bufnum, const char *buf)
+/* visibilize a given string */
+{
+char *vbuf;
+char *tp;
+int c;
+
+ if (buf == 0)
+ return("(null)");
+
+ tp = vbuf = _nc_trace_buf(bufnum, (strlen(buf) * 4) + 5);
+ *tp++ = '"';
+ while ((c = *buf++) != '\0') {
+ if (c == '"') {
+ *tp++ = '\\'; *tp++ = '"';
+ } else if (is7bits(c) && (isgraph(c) || c == ' ')) {
+ *tp++ = c;
+ } else if (c == '\n') {
+ *tp++ = '\\'; *tp++ = 'n';
+ } else if (c == '\r') {
+ *tp++ = '\\'; *tp++ = 'r';
+ } else if (c == '\b') {
+ *tp++ = '\\'; *tp++ = 'b';
+ } else if (c == '\033') {
+ *tp++ = '\\'; *tp++ = 'e';
+ } else if (is7bits(c) && iscntrl(c)) {
+ *tp++ = '\\'; *tp++ = '^'; *tp++ = '@' + c;
+ } else {
+ sprintf(tp, "\\%03o", c & 0xff);
+ tp += strlen(tp);
+ }
+ }
+ *tp++ = '"';
+ *tp++ = '\0';
+ return(vbuf);
+}
+
+const char *_nc_visbuf(const char *buf)
+{
+ return _nc_visbuf2(0, buf);
+}
+
+void
+_tracef(const char *fmt, ...)
+{
+static const char Called[] = T_CALLED("");
+static const char Return[] = T_RETURN("");
+static int level;
+va_list ap;
+bool before = FALSE;
+bool after = FALSE;
+int doit = _nc_tracing;
+
+ if (strlen(fmt) >= sizeof(Called) - 1) {
+ if (!strncmp(fmt, Called, sizeof(Called)-1)) {
+ before = TRUE;
+ level++;
+ } else if (!strncmp(fmt, Return, sizeof(Return)-1)) {
+ after = TRUE;
+ }
+ if (before || after) {
+ if ((level <= 1)
+ || (doit & TRACE_ICALLS) != 0)
+ doit &= (TRACE_CALLS|TRACE_CCALLS);
+ else
+ doit = 0;
+ }
+ }
+
+ if (doit != 0) {
+ if (tracefp == 0)
+ tracefp = stderr;
+ if (before || after) {
+ int n;
+ for (n = 1; n < level; n++)
+ fputs("+ ", tracefp);
+ }
+ va_start(ap, fmt);
+ vfprintf(tracefp, fmt, ap);
+ fputc('\n', tracefp);
+ va_end(ap);
+ fflush(tracefp);
+ }
+
+ if (after && level)
+ level--;
+}
+
+/* Trace 'int' return-values */
+int _nc_retrace_int(int code)
+{
+ T((T_RETURN("%d"), code));
+ return code;
+}
+
+/* Trace 'char*' return-values */
+char * _nc_retrace_ptr(char * code)
+{
+ T((T_RETURN("%s"), _nc_visbuf(code)));
+ return code;
+}
+
+/* Trace 'WINDOW *' return-values */
+WINDOW *_nc_retrace_win(WINDOW *code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
+}
diff --git a/lib/libcurses/lib_traceatr.c b/lib/libcurses/lib_traceatr.c
new file mode 100644
index 00000000000..df2c1b22473
--- /dev/null
+++ b/lib/libcurses/lib_traceatr.c
@@ -0,0 +1,230 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+ * lib_traceatr.c - Tracing/Debugging routines (attributes)
+ */
+
+#ifndef TRACE
+#define TRACE /* turn on internal defs for this module */
+#endif
+
+#include <curses.priv.h>
+#include <term.h> /* acs_chars */
+
+MODULE_ID("Id: lib_traceatr.c,v 1.20 1997/05/06 11:07:27 tom Exp $")
+
+#define COLOR_OF(c) (c < 0 || c > 7 ? "default" : colors[c].name)
+
+char * _nc_trace_buf(int bufnum, size_t want)
+{
+ static struct {
+ char *text;
+ size_t size;
+ } *list;
+ static size_t have;
+
+ if (bufnum < 0)
+ bufnum = 0;
+
+ if ((size_t)(bufnum+1) > have) {
+ size_t need = (bufnum + 1) * 2;
+ size_t used = sizeof(*list) * need;
+ list = (list == 0) ? malloc(used) : realloc(list, used);
+ while (need > have)
+ list[have++].text = 0;
+ }
+
+ if (list[bufnum].text == 0)
+ {
+ list[bufnum].text = malloc(want);
+ list[bufnum].size = want;
+ }
+ else if (want > list[bufnum].size) {
+ list[bufnum].text = realloc(list[bufnum].text, want);
+ list[bufnum].size = want;
+ }
+ *(list[bufnum].text) = '\0';
+ return list[bufnum].text;
+}
+
+char *_traceattr2(int bufnum, attr_t newmode)
+{
+char *buf = _nc_trace_buf(bufnum, BUFSIZ);
+char *tmp = buf;
+static const struct {unsigned int val; const char *name;}
+names[] =
+ {
+ { A_STANDOUT, "A_STANDOUT" },
+ { A_UNDERLINE, "A_UNDERLINE" },
+ { A_REVERSE, "A_REVERSE" },
+ { A_BLINK, "A_BLINK" },
+ { A_DIM, "A_DIM" },
+ { A_BOLD, "A_BOLD" },
+ { A_ALTCHARSET, "A_ALTCHARSET" },
+ { A_INVIS, "A_INVIS" },
+ { A_PROTECT, "A_PROTECT" },
+ { A_CHARTEXT, "A_CHARTEXT" },
+ { A_NORMAL, "A_NORMAL" },
+ { A_COLOR, "A_COLOR" },
+ },
+colors[] =
+ {
+ { COLOR_BLACK, "COLOR_BLACK" },
+ { COLOR_RED, "COLOR_RED" },
+ { COLOR_GREEN, "COLOR_GREEN" },
+ { COLOR_YELLOW, "COLOR_YELLOW" },
+ { COLOR_BLUE, "COLOR_BLUE" },
+ { COLOR_MAGENTA, "COLOR_MAGENTA" },
+ { COLOR_CYAN, "COLOR_CYAN" },
+ { COLOR_WHITE, "COLOR_WHITE" },
+ };
+size_t n;
+unsigned save_nc_tracing = _nc_tracing;
+ _nc_tracing = 0;
+
+ strcpy(tmp++, "{");
+
+ for (n = 0; n < sizeof(names)/sizeof(names[0]); n++) {
+ if ((newmode & names[n].val) != 0) {
+ if (buf[1] != '\0')
+ strcat(tmp, "|");
+ strcat(tmp, names[n].name);
+ tmp += strlen(tmp);
+
+ if (names[n].val == A_COLOR)
+ {
+ short pairnum = PAIR_NUMBER(newmode);
+ short fg, bg;
+
+ if (pair_content(pairnum, &fg, &bg) == OK)
+ (void) sprintf(tmp,
+ "{%d = {%s, %s}}",
+ pairnum,
+ COLOR_OF(fg),
+ COLOR_OF(bg)
+ );
+ else
+ (void) sprintf(tmp, "{%d}", pairnum);
+ }
+ }
+ }
+ if (AttrOf(newmode) == A_NORMAL) {
+ if (buf[1] != '\0')
+ strcat(tmp, "|");
+ strcat(tmp, "A_NORMAL");
+ }
+
+ _nc_tracing = save_nc_tracing;
+ return (strcat(buf,"}"));
+}
+
+char *_traceattr(attr_t newmode)
+{
+ return _traceattr2(0, newmode);
+}
+
+char *_tracechtype2(int bufnum, chtype ch)
+{
+char *buf = _nc_trace_buf(bufnum, BUFSIZ);
+char *found = 0;
+
+ strcpy(buf, "{");
+ if (ch & A_ALTCHARSET)
+ {
+ char *cp;
+ static const struct {unsigned int val; const char *name;}
+ names[] =
+ {
+ {'l', "ACS_ULCORNER"}, /* upper left corner */
+ {'m', "ACS_LLCORNER"}, /* lower left corner */
+ {'k', "ACS_URCORNER"}, /* upper right corner */
+ {'j', "ACS_LRCORNER"}, /* lower right corner */
+ {'t', "ACS_LTEE"}, /* tee pointing right */
+ {'u', "ACS_RTEE"}, /* tee pointing left */
+ {'v', "ACS_BTEE"}, /* tee pointing up */
+ {'w', "ACS_TTEE"}, /* tee pointing down */
+ {'q', "ACS_HLINE"}, /* horizontal line */
+ {'x', "ACS_VLINE"}, /* vertical line */
+ {'n', "ACS_PLUS"}, /* large plus or crossover */
+ {'o', "ACS_S1"}, /* scan line 1 */
+ {'s', "ACS_S9"}, /* scan line 9 */
+ {'`', "ACS_DIAMOND"}, /* diamond */
+ {'a', "ACS_CKBOARD"}, /* checker board (stipple) */
+ {'f', "ACS_DEGREE"}, /* degree symbol */
+ {'g', "ACS_PLMINUS"}, /* plus/minus */
+ {'~', "ACS_BULLET"}, /* bullet */
+ {',', "ACS_LARROW"}, /* arrow pointing left */
+ {'+', "ACS_RARROW"}, /* arrow pointing right */
+ {'.', "ACS_DARROW"}, /* arrow pointing down */
+ {'-', "ACS_UARROW"}, /* arrow pointing up */
+ {'h', "ACS_BOARD"}, /* board of squares */
+ {'I', "ACS_LANTERN"}, /* lantern symbol */
+ {'0', "ACS_BLOCK"}, /* solid square block */
+ {'p', "ACS_S3"}, /* scan line 3 */
+ {'r', "ACS_S7"}, /* scan line 7 */
+ {'y', "ACS_LEQUAL"}, /* less/equal */
+ {'z', "ACS_GEQUAL"}, /* greater/equal */
+ {'{', "ACS_PI"}, /* Pi */
+ {'|', "ACS_NEQUAL"}, /* not equal */
+ {'}', "ACS_STERLING"}, /* UK pound sign */
+ {'\0',(char *)0}
+ },
+ *sp;
+
+ for (cp = acs_chars; cp[0] && cp[1]; cp += 2)
+ {
+ if (TextOf(cp[1]) == TextOf(ch))
+ {
+ found = cp;
+ /* don't exit from loop - there may be redefinitions */
+ }
+ }
+
+ if (found != 0)
+ {
+ ch = TextOf(*found);
+ for (sp = names; sp->val; sp++)
+ if (sp->val == ch)
+ {
+ (void) strcat(buf, sp->name);
+ ch &= ~A_ALTCHARSET;
+ break;
+ }
+ }
+ }
+
+ if (found == 0)
+ (void) strcat(buf, _tracechar(TextOf(ch)));
+
+ if (AttrOf(ch) != A_NORMAL)
+ (void) sprintf(buf + strlen(buf), " | %s", _traceattr2(bufnum+20,AttrOf(ch)));
+
+ strcat(buf, "}");
+ return(buf);
+}
+
+char *_tracechtype(chtype ch)
+{
+ return _tracechtype2(0, ch);
+}
diff --git a/lib/libcurses/lib_tracechr.c b/lib/libcurses/lib_tracechr.c
new file mode 100644
index 00000000000..2a4eed712d0
--- /dev/null
+++ b/lib/libcurses/lib_tracechr.c
@@ -0,0 +1,52 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+ * lib_tracechr.c - Tracing/Debugging routines
+ */
+
+#ifndef TRACE
+#define TRACE /* turn on internal defs for this module */
+#endif
+
+#include <curses.priv.h>
+
+#include <ctype.h>
+
+char *_tracechar(const unsigned char ch)
+{
+ static char crep[20];
+ /*
+ * We can show the actual character if it's either an ordinary printable
+ * or one of the high-half characters.
+ */
+ if (isprint(ch) || (ch & 0x80))
+ {
+ crep[0] = '\'';
+ crep[1] = ch; /* necessary; printf tries too hard on metachars */
+ (void) sprintf(crep + 2, "' = 0x%02x", (unsigned)ch);
+ }
+ else
+ (void) sprintf(crep, "0x%02x", (unsigned)ch);
+ return(crep);
+}
diff --git a/lib/libcurses/lib_tracedmp.c b/lib/libcurses/lib_tracedmp.c
new file mode 100644
index 00000000000..d14a15c687d
--- /dev/null
+++ b/lib/libcurses/lib_tracedmp.c
@@ -0,0 +1,115 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/*
+ * lib_tracedmp.c - Tracing/Debugging routines
+ */
+
+#ifndef TRACE
+#define TRACE /* turn on internal defs for this module */
+#endif
+
+#include <curses.priv.h>
+
+MODULE_ID("Id: lib_tracedmp.c,v 1.9 1997/01/15 00:39:27 tom Exp $")
+
+void _tracedump(const char *name, WINDOW *win)
+{
+ int i, j, n, width;
+
+ /* compute narrowest possible display width */
+ for (width = i = 0; i <= win->_maxy; i++)
+ {
+ n = 0;
+ for (j = 0; j <= win->_maxx; j++)
+ if (win->_line[i].text[j] != ' ')
+ n = j;
+
+ if (n > width)
+ width = n;
+ }
+ if (width < win->_maxx)
+ ++width;
+
+ for (n = 0; n <= win->_maxy; n++)
+ {
+ char buf[BUFSIZ], *ep;
+ bool haveattrs, havecolors;
+
+ /* dump A_CHARTEXT part */
+ (void) sprintf(buf, "%s[%2d] %3d%3d ='",
+ name, n,
+ win->_line[n].firstchar,
+ win->_line[n].lastchar);
+ ep = buf + strlen(buf);
+ for (j = 0; j <= width; j++) {
+ ep[j] = TextOf(win->_line[n].text[j]);
+ if (ep[j] == 0)
+ ep[j] = '.';
+ }
+ ep[j] = '\'';
+ ep[j+1] = '\0';
+ _tracef(buf);
+
+ /* dump A_COLOR part, will screw up if there are more than 96 */
+ havecolors = FALSE;
+ for (j = 0; j <= width; j++)
+ if (win->_line[n].text[j] & A_COLOR)
+ {
+ havecolors = TRUE;
+ break;
+ }
+ if (havecolors)
+ {
+ (void) sprintf(buf, "%*s[%2d]%*s='", (int)strlen(name), "colors", n, 8, " ");
+ ep = buf + strlen(buf);
+ for (j = 0; j <= width; j++)
+ ep[j] = ((win->_line[n].text[j] >> 8) & 0xff) + ' ';
+ ep[j] = '\'';
+ ep[j+1] = '\0';
+ _tracef(buf);
+ }
+
+ for (i = 0; i < 4; i++)
+ {
+ const char *hex = " 123456789ABCDEF";
+ chtype mask = (0xf << ((i + 4) * 4));
+
+ haveattrs = FALSE;
+ for (j = 0; j <= width; j++)
+ if (win->_line[n].text[j] & mask)
+ {
+ haveattrs = TRUE;
+ break;
+ }
+ if (haveattrs)
+ {
+ (void) sprintf(buf, "%*s%d[%2d]%*s='", (int)strlen(name)-1, "attrs", i, n, 8, " ");
+ ep = buf + strlen(buf);
+ for (j = 0; j <= width; j++)
+ ep[j] = hex[(win->_line[n].text[j] & mask) >> ((i + 4) * 4)];
+ ep[j] = '\'';
+ ep[j+1] = '\0';
+ _tracef(buf);
+ }
+ }
+ }
+}
diff --git a/lib/libcurses/lib_tracemse.c b/lib/libcurses/lib_tracemse.c
new file mode 100644
index 00000000000..3cd220617f3
--- /dev/null
+++ b/lib/libcurses/lib_tracemse.c
@@ -0,0 +1,82 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+
+
+/*
+ * lib_tracemse.c - Tracing/Debugging routines (mouse events)
+ */
+
+#ifndef TRACE
+#define TRACE /* turn on internal defs for this module */
+#endif
+
+#include <curses.priv.h>
+
+MODULE_ID("Id: lib_tracemse.c,v 1.4 1996/12/21 14:24:06 tom Exp $")
+
+char *_tracemouse(MEVENT const *ep)
+{
+ static char buf[80];
+
+ (void) sprintf(buf, "id %2d at (%2d, %2d, %2d) state %4lx = {",
+ ep->id, ep->x, ep->y, ep->z, ep->bstate);
+
+#define SHOW(m, s) if ((ep->bstate & m)==m) {strcat(buf,s); strcat(buf, ", ");}
+ SHOW(BUTTON1_RELEASED, "release-1")
+ SHOW(BUTTON1_PRESSED, "press-1")
+ SHOW(BUTTON1_CLICKED, "click-1")
+ SHOW(BUTTON1_DOUBLE_CLICKED, "doubleclick-1")
+ SHOW(BUTTON1_TRIPLE_CLICKED, "tripleclick-1")
+ SHOW(BUTTON1_RESERVED_EVENT, "reserved-1")
+ SHOW(BUTTON2_RELEASED, "release-2")
+ SHOW(BUTTON2_PRESSED, "press-2")
+ SHOW(BUTTON2_CLICKED, "click-2")
+ SHOW(BUTTON2_DOUBLE_CLICKED, "doubleclick-2")
+ SHOW(BUTTON2_TRIPLE_CLICKED, "tripleclick-2")
+ SHOW(BUTTON2_RESERVED_EVENT, "reserved-2")
+ SHOW(BUTTON3_RELEASED, "release-3")
+ SHOW(BUTTON3_PRESSED, "press-3")
+ SHOW(BUTTON3_CLICKED, "click-3")
+ SHOW(BUTTON3_DOUBLE_CLICKED, "doubleclick-3")
+ SHOW(BUTTON3_TRIPLE_CLICKED, "tripleclick-3")
+ SHOW(BUTTON3_RESERVED_EVENT, "reserved-3")
+ SHOW(BUTTON4_RELEASED, "release-4")
+ SHOW(BUTTON4_PRESSED, "press-4")
+ SHOW(BUTTON4_CLICKED, "click-4")
+ SHOW(BUTTON4_DOUBLE_CLICKED, "doubleclick-4")
+ SHOW(BUTTON4_TRIPLE_CLICKED, "tripleclick-4")
+ SHOW(BUTTON4_RESERVED_EVENT, "reserved-4")
+ SHOW(BUTTON_CTRL, "ctrl")
+ SHOW(BUTTON_SHIFT, "shift")
+ SHOW(BUTTON_ALT, "alt")
+ SHOW(ALL_MOUSE_EVENTS, "all-events")
+ SHOW(REPORT_MOUSE_POSITION, "position")
+#undef SHOW
+
+ if (buf[strlen(buf)-1] == ' ')
+ buf[strlen(buf)-2] = '\0';
+ (void) strcat(buf, "}");
+ return(buf);
+}
+
+
+