~ubuntu-branches/ubuntu/trusty/xterm/trusty

« back to all changes in this revision

Viewing changes to trace.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2013-10-28 22:15:39 UTC
  • mfrom: (1.4.15) (11.1.37 sid)
  • Revision ID: package-import@ubuntu.com-20131028221539-hkfkjoqjk7i2djqz
Tags: 297-1ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - debian/patches/950_ubuntu_charclass_highlight.diff: Enable URL
    highlighting.
  - debian/patches/Add 951_uxterm_utf8_title.diff: Set utf8Titles to true
    by default when using uxterm, so that it displays utf8 directories in
    titles properly.  May cause issues with apps that use control
    sequences for updating the xterm titlebar - users should use xterm or
    set utf8Title to false in this case.
  - debian/gbp.conf: Use "Ubuntu" in "debian-branch" directly.
  - Use autotools-dev's debhelper integration to update
    config.guess/config.sub for each build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $XTermId: trace.c,v 1.133 2011/12/27 10:10:53 tom Exp $ */
 
1
/* $XTermId: trace.c,v 1.149 2013/09/09 00:15:00 tom Exp $ */
2
2
 
3
3
/*
4
 
 * Copyright 1997-2010,2011 by Thomas E. Dickey
 
4
 * Copyright 1997-2012,2013 by Thomas E. Dickey
5
5
 *
6
6
 *                         All Rights Reserved
7
7
 *
35
35
 */
36
36
 
37
37
#include <xterm.h>              /* for definition of GCC_UNUSED */
 
38
#include <version.h>
38
39
 
39
40
#if OPT_TRACE
40
41
 
85
86
    trace_out = trace_who;
86
87
 
87
88
    if (!trace_fp) {
 
89
        unsigned oldmask = umask(077);
88
90
        char name[BUFSIZ];
89
91
#if 0                           /* usually I do not want unique names */
90
92
        int unique;
110
112
            xtermWarning("Cannot open \"%s\"\n", name);
111
113
            exit(EXIT_FAILURE);
112
114
        }
 
115
        (void) umask(oldmask);
113
116
    }
114
117
 
115
118
    va_start(ap, fmt);
127
130
        (void) fflush(stderr);
128
131
        (void) visibleChars(NULL, 0);
129
132
        (void) visibleIChars(NULL, 0);
130
 
        (void) visibleIChar(NULL, 0);
131
133
        trace_fp = 0;
132
134
    }
133
135
}
181
183
        break;
182
184
    default:
183
185
        if (E2A(value) < 32 || (E2A(value) >= 127 && E2A(value) < 160))
184
 
            sprintf(dst, "\\%03o", value);
 
186
            sprintf(dst, "\\%03o", value & 0xff);
185
187
        else
186
188
            sprintf(dst, "%c", CharOf(value));
187
189
        break;
191
193
#if OPT_DEC_CHRSET
192
194
 
193
195
const char *
194
 
visibleChrsetName(unsigned chrset)
 
196
visibleDblChrset(unsigned chrset)
195
197
{
196
198
    const char *result = "?";
197
199
    switch (chrset) {
212
214
}
213
215
#endif
214
216
 
 
217
const char *
 
218
visibleScsCode(unsigned chrset)
 
219
{
 
220
#define MAP(to,from) case from: result = to; break
 
221
    const char *result = "<ERR>";
 
222
    switch ((DECNRCM_codes) chrset) {
 
223
        MAP("B", nrc_ASCII);
 
224
        MAP("A", nrc_British);
 
225
        MAP("A", nrc_British_Latin_1);
 
226
        MAP("&4", nrc_Cyrillic);
 
227
        MAP("0", nrc_DEC_Spec_Graphic);
 
228
        MAP("1", nrc_DEC_Alt_Chars);
 
229
        MAP("2", nrc_DEC_Alt_Graphics);
 
230
        MAP("<", nrc_DEC_Supp);
 
231
        MAP("%5", nrc_DEC_Supp_Graphic);
 
232
        MAP(">", nrc_DEC_Technical);
 
233
        MAP("4", nrc_Dutch);
 
234
        MAP("5", nrc_Finnish);
 
235
        MAP("C", nrc_Finnish2);
 
236
        MAP("R", nrc_French);
 
237
        MAP("f", nrc_French2);
 
238
        MAP("Q", nrc_French_Canadian);
 
239
        MAP("9", nrc_French_Canadian2);
 
240
        MAP("K", nrc_German);
 
241
        MAP("\"?", nrc_Greek);
 
242
        MAP("F", nrc_Greek_Supp);
 
243
        MAP("\"4", nrc_Hebrew);
 
244
        MAP("%=", nrc_Hebrew2);
 
245
        MAP("H", nrc_Hebrew_Supp);
 
246
        MAP("Y", nrc_Italian);
 
247
        MAP("M", nrc_Latin_5_Supp);
 
248
        MAP("L", nrc_Latin_Cyrillic);
 
249
        MAP("`", nrc_Norwegian_Danish);
 
250
        MAP("E", nrc_Norwegian_Danish2);
 
251
        MAP("6", nrc_Norwegian_Danish3);
 
252
        MAP("%6", nrc_Portugese);
 
253
        MAP("&5", nrc_Russian);
 
254
        MAP("%3", nrc_SCS_NRCS);
 
255
        MAP("Z", nrc_Spanish);
 
256
        MAP("7", nrc_Swedish);
 
257
        MAP("H", nrc_Swedish2);
 
258
        MAP("=", nrc_Swiss);
 
259
        MAP("%0", nrc_Turkish);
 
260
        MAP("%2", nrc_Turkish2);
 
261
        MAP("<UNK>", nrc_Unknown);
 
262
    }
 
263
#undef MAP
 
264
    return result;
 
265
}
 
266
 
215
267
char *
216
 
visibleChars(const Char * buf, unsigned len)
 
268
visibleChars(const Char *buf, unsigned len)
217
269
{
218
270
    static char *result;
219
271
    static unsigned used;
244
296
}
245
297
 
246
298
char *
247
 
visibleIChars(IChar * buf, unsigned len)
 
299
visibleIChars(IChar *buf, unsigned len)
248
300
{
249
301
    static char *result;
250
302
    static unsigned used;
280
332
}
281
333
 
282
334
char *
283
 
visibleIChar(IChar * buf, unsigned len)
 
335
visibleUChar(unsigned chr)
284
336
{
285
 
    static char *result;
286
 
    static unsigned used;
287
 
 
288
 
    if (buf != 0) {
289
 
        unsigned limit = ((len + 1) * 8) + 1;
290
 
        char *dst;
291
 
 
292
 
        if (limit > used) {
293
 
            used = limit;
294
 
            result = XtRealloc(result, used);
295
 
        }
296
 
        if (result != 0) {
297
 
            dst = result;
298
 
            while (len--) {
299
 
                unsigned value = *buf++;
300
 
#if OPT_WIDE_CHARS
301
 
                if (value > 255)
302
 
                    sprintf(dst, "\\u+%04X", value);
303
 
                else
304
 
#endif
305
 
                    formatAscii(dst, value);
306
 
                dst += strlen(dst);
307
 
            }
308
 
        }
309
 
    } else if (result != 0) {
310
 
        free(result);
311
 
        result = 0;
312
 
        used = 0;
313
 
    }
314
 
    return result;
 
337
    IChar buf[1];
 
338
    buf[0] = chr;
 
339
    return visibleIChars(buf, 1);
315
340
}
316
341
 
317
342
#define CASETYPE(name) case name: result = #name; break
375
400
}
376
401
 
377
402
const char *
 
403
visibleNotifyMode(int code)
 
404
{
 
405
    const char *result = "?";
 
406
    switch (code) {
 
407
        CASETYPE(NotifyNormal);
 
408
        CASETYPE(NotifyGrab);
 
409
        CASETYPE(NotifyUngrab);
 
410
        CASETYPE(NotifyWhileGrabbed);
 
411
    }
 
412
    return result;
 
413
}
 
414
 
 
415
const char *
378
416
visibleNotifyDetail(int code)
379
417
{
380
418
    const char *result = "?";
392
430
}
393
431
 
394
432
const char *
395
 
visibleSelectionTarget(Display * d, Atom a)
 
433
visibleSelectionTarget(Display *d, Atom a)
396
434
{
397
435
    const char *result = "?";
398
436
 
447
485
#define isScrnFlag(flag) ((flag) == LINEWRAPPED)
448
486
 
449
487
static char *
450
 
ScrnText(LineData * ld)
 
488
ScrnText(LineData *ld)
451
489
{
452
490
    return visibleIChars(ld->charData, ld->lineSize);
453
491
}
461
499
              ScrnText(ld))
462
500
 
463
501
void
464
 
LineClrFlag(LineData * ld, int flag)
 
502
LineClrFlag(LineData *ld, int flag)
465
503
{
466
504
    if (ld == 0) {
467
505
        SHOW_BAD_LINE(LineClrFlag, ld);
474
512
}
475
513
 
476
514
void
477
 
LineSetFlag(LineData * ld, int flag)
 
515
LineSetFlag(LineData *ld, int flag)
478
516
{
479
517
    if (ld == 0) {
480
518
        SHOW_BAD_LINE(LineSetFlag, ld);
503
541
}
504
542
#endif /* OPT_TRACE_FLAGS */
505
543
 
 
544
/*
 
545
 * Trace the normal or alternate screen, showing color values up to 16, e.g.,
 
546
 * for debugging with vttest.
 
547
 */
 
548
void
 
549
TraceScreen(XtermWidget xw, int whichBuf)
 
550
{
 
551
    TScreen *screen = TScreenOf(xw);
 
552
    int row, col;
 
553
 
 
554
    if (screen->editBuf_index[whichBuf]) {
 
555
        TRACE(("TraceScreen %d:\n", whichBuf));
 
556
        for (row = 0; row <= screen->max_row; ++row) {
 
557
            LineData *ld = getLineData(screen, row);
 
558
            TRACE((" %3d:", row));
 
559
            if (ld != 0) {
 
560
                for (col = 0; col < ld->lineSize; ++col) {
 
561
                    int ch = (int) ld->charData[col];
 
562
                    if (ch < ' ')
 
563
                        ch = ' ';
 
564
                    if (ch >= 127)
 
565
                        ch = '#';
 
566
                    TRACE(("%c", ch));
 
567
                }
 
568
                TRACE((":\n"));
 
569
 
 
570
                TRACE(("  xx:"));
 
571
                for (col = 0; col < ld->lineSize; ++col) {
 
572
                    unsigned attrs = ld->attribs[col];
 
573
                    char ch;
 
574
                    if (attrs & PROTECTED) {
 
575
                        ch = '*';
 
576
                    } else if (attrs & BLINK) {
 
577
                        ch = 'B';
 
578
                    } else if (attrs & CHARDRAWN) {
 
579
                        ch = '+';
 
580
                    } else {
 
581
                        ch = ' ';
 
582
                    }
 
583
                    TRACE(("%c", ch));
 
584
                }
 
585
                TRACE((":\n"));
 
586
 
 
587
#if 0
 
588
                TRACE(("  fg:"));
 
589
                for (col = 0; col < ld->lineSize; ++col) {
 
590
                    unsigned fg = extract_fg(xw, ld->color[col], ld->attribs[col]);
 
591
                    if (fg > 15)
 
592
                        fg = 15;
 
593
                    TRACE(("%1x", fg));
 
594
                }
 
595
                TRACE((":\n"));
 
596
 
 
597
                TRACE(("  bg:"));
 
598
                for (col = 0; col < ld->lineSize; ++col) {
 
599
                    unsigned bg = extract_bg(xw, ld->color[col], ld->attribs[col]);
 
600
                    if (bg > 15)
 
601
                        bg = 15;
 
602
                    TRACE(("%1x", bg));
 
603
                }
 
604
                TRACE((":\n"));
 
605
#endif
 
606
            } else {
 
607
                TRACE(("null lineData\n"));
 
608
            }
 
609
        }
 
610
    } else {
 
611
        TRACE(("TraceScreen %d is nil\n", whichBuf));
 
612
    }
 
613
}
 
614
 
506
615
void
507
616
TraceFocus(Widget w, XEvent * ev)
508
617
{
514
623
        {
515
624
            XFocusChangeEvent *event = (XFocusChangeEvent *) ev;
516
625
            TRACE(("\tdetail: %s\n", visibleNotifyDetail(event->detail)));
517
 
            TRACE(("\tmode:   %d\n", event->mode));
 
626
            TRACE(("\tmode:   %s\n", visibleNotifyMode(event->mode)));
518
627
            TRACE(("\twindow: %#lx\n", event->window));
519
628
        }
520
629
        break;
523
632
        {
524
633
            XCrossingEvent *event = (XCrossingEvent *) ev;
525
634
            TRACE(("\tdetail:    %s\n", visibleNotifyDetail(event->detail)));
526
 
            TRACE(("\tmode:      %d\n", event->mode));
 
635
            TRACE(("\tmode:      %s\n", visibleNotifyMode(event->mode)));
527
636
            TRACE(("\twindow:    %#lx\n", event->window));
528
637
            TRACE(("\tfocus:     %d\n", event->focus));
529
638
            TRACE(("\troot:      %#lx\n", event->root));
660
769
 */
661
770
/* ARGSUSED */
662
771
static int
663
 
no_error(Display * dpy GCC_UNUSED, XErrorEvent * event GCC_UNUSED)
 
772
no_error(Display *dpy GCC_UNUSED, XErrorEvent * event GCC_UNUSED)
664
773
{
665
774
    return 1;
666
775
}
667
776
 
 
777
const char *
 
778
ModifierName(unsigned modifier)
 
779
{
 
780
    const char *s = "";
 
781
    if (modifier & ShiftMask)
 
782
        s = " Shift";
 
783
    else if (modifier & LockMask)
 
784
        s = " Lock";
 
785
    else if (modifier & ControlMask)
 
786
        s = " Control";
 
787
    else if (modifier & Mod1Mask)
 
788
        s = " Mod1";
 
789
    else if (modifier & Mod2Mask)
 
790
        s = " Mod2";
 
791
    else if (modifier & Mod3Mask)
 
792
        s = " Mod3";
 
793
    else if (modifier & Mod4Mask)
 
794
        s = " Mod4";
 
795
    else if (modifier & Mod5Mask)
 
796
        s = " Mod5";
 
797
    return s;
 
798
}
 
799
 
668
800
void
669
801
TraceTranslations(const char *name, Widget w)
670
802
{
696
828
TraceResizeRequest(const char *fn, int ln, Widget w,
697
829
                   unsigned reqwide,
698
830
                   unsigned reqhigh,
699
 
                   Dimension * gotwide,
700
 
                   Dimension * gothigh)
 
831
                   Dimension *gotwide,
 
832
                   Dimension *gothigh)
701
833
{
702
834
    XtGeometryResult rc;
703
835
 
725
857
    Trace("XTERM_RESOURCE settings:\n");
726
858
    XRES_S(icon_geometry);
727
859
    XRES_S(title);
 
860
    XRES_S(icon_hint);
728
861
    XRES_S(icon_name);
729
862
    XRES_S(term_name);
730
863
    XRES_S(tty_modes);
764
897
    XRES_B(useInsertMode);
765
898
#if OPT_ZICONBEEP
766
899
    XRES_I(zIconBeep);
 
900
    XRES_S(zIconFormat);
767
901
#endif
768
902
#if OPT_PTY_HANDSHAKE
769
903
    XRES_B(wait_for_map);