2 * $Id: trace.c,v 1.11 2010/01/17 15:36:26 tom Exp $
4 * trace.c -- implements screen-dump and keystroke-logging
6 * Copyright 2007-2008,2010 Thomas E. Dickey
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License, version 2.1
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to
18 * Free Software Foundation, Inc.
19 * 51 Franklin St., Fifth Floor
20 * Boston, MA 02110, USA.
30 #define myFP dialog_state.trace_output
33 dlg_trace_msg(const char *fmt,...)
38 vfprintf(myFP, fmt, ap);
45 dlg_trace_win(WINDOW *win)
50 int rc = getmaxy(win);
51 int cc = getmaxx(win);
54 fprintf(myFP, "window %dx%d at %d,%d\n",
55 rc, cc, getbegy(win), getbegx(win));
58 for (j = 0; j < rc; ++j) {
59 fprintf(myFP, "%3d:", j);
60 for (k = 0; k < cc; ++k) {
61 ch = mvwinch(win, j, k) & (A_CHARTEXT | A_ALTCHARSET);
62 c2 = dlg_asciibox(ch);
65 } else if (unctrl(ch) == 0 || strlen(unctrl(ch)) > 1) {
68 fputc((int) (ch & 0xff), myFP);
78 dlg_trace_chr(int ch, int fkey)
81 const char *fkey_name = "?";
83 if (fkey > KEY_MAX || (fkey_name = keyname(fkey)) == 0) {
84 #define CASE(name) case name: fkey_name = #name; break
85 switch ((DLG_KEYS_ENUM) fkey) {
92 CASE(DLGK_PAGE_FIRST);
96 CASE(DLGK_ITEM_FIRST);
100 CASE(DLGK_FIELD_FIRST);
101 CASE(DLGK_FIELD_LAST);
102 CASE(DLGK_FIELD_NEXT);
103 CASE(DLGK_FIELD_PREV);
105 CASE(DLGK_GRID_DOWN);
106 CASE(DLGK_GRID_LEFT);
107 CASE(DLGK_GRID_RIGHT);
108 CASE(DLGK_DELETE_LEFT);
109 CASE(DLGK_DELETE_RIGHT);
110 CASE(DLGK_DELETE_ALL);
119 fkey_name = unctrl((chtype) ch);
121 fkey_name = "UNKNOWN";
123 fprintf(myFP, "chr %s (ch=%#x, fkey=%d)\n",
131 dlg_trace(const char *fname)
135 myFP = fopen(fname, "a");
137 time_t now = time((time_t *) 0);
138 fprintf(myFP, "** opened at %s", ctime(&now));
141 } else if (myFP != 0) {
142 time_t now = time((time_t *) 0);
143 fprintf(myFP, "** closed at %s", ctime(&now));
150 extern void dlg_trace(const char *);
152 dlg_trace(const char *fname)