~ubuntu-branches/ubuntu/utopic/xterm/utopic-proposed

« back to all changes in this revision

Viewing changes to misc.c

  • Committer: Daniel Holbach
  • Date: 2010-08-03 06:45:18 UTC
  • mfrom: (1.1.19 upstream)
  • Revision ID: daniel.holbach@canonical.com-20100803064518-obveikvy73ximzvw
Merging shared upstream rev into target branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $XTermId: misc.c,v 1.499 2010/06/04 01:02:08 tom Exp $ */
 
1
/* $XTermId: misc.c,v 1.503 2010/06/20 21:33:49 tom Exp $ */
2
2
 
3
3
/*
4
4
 * Copyright 1999-2009,2010 by Thomas E. Dickey
567
567
            StringInput(term, hexval, (size_t) 1);
568
568
        }
569
569
    } else {
570
 
        StringInput(term, (Char *) * params, strlen(*params));
 
570
        StringInput(term, (const Char *) *params, strlen(*params));
571
571
    }
572
572
}
573
573
 
680
680
                Cardinal *param_count)
681
681
{
682
682
    if (*param_count == 1) {
683
 
        char *value = params[0];
 
683
        const char *value = params[0];
684
684
        int need = (int) strlen(value);
685
685
        int used = (int) (VTbuffer->next - VTbuffer->buffer);
686
686
        int have = (int) (VTbuffer->last - VTbuffer->buffer);
687
687
 
688
688
        if (have - used + need < BUF_SIZE) {
689
689
 
690
 
            fillPtyData(TScreenOf(term), VTbuffer, value, (int) strlen(value));
 
690
            fillPtyData(term, VTbuffer, value, (int) strlen(value));
691
691
 
692
692
            TRACE(("Interpret %s\n", value));
693
693
            VTbuffer->update++;
776
776
                            : FOCUS));
777
777
        }
778
778
        if (screen->grabbedKbd && (event->mode == NotifyUngrab)) {
779
 
            Bell(XkbBI_Info, 100);
 
779
            Bell(xw, XkbBI_Info, 100);
780
780
            ReverseVideo(xw);
781
781
            screen->grabbedKbd = False;
782
782
            update_securekbd();
862
862
}
863
863
 
864
864
void
865
 
Bell(int which, int percent)
 
865
Bell(XtermWidget xw, int which, int percent)
866
866
{
867
 
    XtermWidget xw = term;
868
867
    TScreen *screen = TScreenOf(xw);
869
868
    struct timeval curtime;
870
869
    long now_msecs;
1179
1178
    if ((xw = getXtermWidget(w)) != 0) {
1180
1179
        TScreen *screen = TScreenOf(xw);
1181
1180
        if (!dabbrev_expand(screen))
1182
 
            Bell(XkbBI_TerminalBell, 0);
 
1181
            Bell(xw, XkbBI_TerminalBell, 0);
1183
1182
    }
1184
1183
}
1185
1184
#endif /* OPT_DABBREV */
1606
1605
static SIGNAL_T
1607
1606
logpipe(int sig GCC_UNUSED)
1608
1607
{
1609
 
    TScreen *screen = TScreenOf(term);
 
1608
    XtermWidget xw = term;
 
1609
    TScreen *screen = TScreenOf(xw);
1610
1610
 
1611
1611
#ifdef SYSV
1612
1612
    (void) signal(SIGPIPE, SIG_IGN);
1613
1613
#endif /* SYSV */
1614
1614
    if (screen->logging)
1615
 
        CloseLog(screen);
 
1615
        CloseLog(xw);
1616
1616
}
1617
1617
#endif /* ALLOWLOGFILEEXEC */
1618
1618
 
1619
1619
void
1620
 
StartLog(TScreen * screen)
 
1620
StartLog(XtermWidget xw)
1621
1621
{
1622
1622
    static char *log_default;
1623
1623
#ifdef ALLOWLOGFILEEXEC
1624
1624
    char *cp;
1625
1625
#endif /* ALLOWLOGFILEEXEC */
 
1626
    TScreen *screen = TScreenOf(xw);
1626
1627
 
1627
1628
    if (screen->logging || (screen->inhibit & I_LOG))
1628
1629
        return;
1728
1729
        screen->logfd = p[1];
1729
1730
        signal(SIGPIPE, logpipe);
1730
1731
#else
1731
 
        Bell(XkbBI_Info, 0);
1732
 
        Bell(XkbBI_Info, 0);
 
1732
        Bell(xw, XkbBI_Info, 0);
 
1733
        Bell(xw, XkbBI_Info, 0);
1733
1734
        return;
1734
1735
#endif
1735
1736
    } else {
1746
1747
}
1747
1748
 
1748
1749
void
1749
 
CloseLog(TScreen * screen)
 
1750
CloseLog(XtermWidget xw)
1750
1751
{
 
1752
    TScreen *screen = TScreenOf(xw);
 
1753
 
1751
1754
    if (!screen->logging || (screen->inhibit & I_LOG))
1752
1755
        return;
1753
 
    FlushLog(screen);
 
1756
    FlushLog(xw);
1754
1757
    close(screen->logfd);
1755
1758
    screen->logging = False;
1756
1759
    update_logging();
1757
1760
}
1758
1761
 
1759
1762
void
1760
 
FlushLog(TScreen * screen)
 
1763
FlushLog(XtermWidget xw)
1761
1764
{
 
1765
    TScreen *screen = TScreenOf(xw);
 
1766
 
1762
1767
    if (screen->logging && !(screen->inhibit & I_LOG)) {
1763
1768
        Char *cp;
1764
1769
        int i;
1932
1937
static int
1933
1938
AllocateAnsiColor(XtermWidget xw,
1934
1939
                  ColorRes * res,
1935
 
                  char *spec)
 
1940
                  const char *spec)
1936
1941
{
1937
1942
    int result;
1938
1943
    XColor def;
1999
2004
#endif
2000
2005
 
2001
2006
static int
2002
 
ChangeOneAnsiColor(XtermWidget xw, int color, char *name)
 
2007
ChangeOneAnsiColor(XtermWidget xw, int color, const char *name)
2003
2008
{
2004
2009
    int code;
2005
2010
 
2505
2510
                   int code)
2506
2511
{
2507
2512
    Bool result = False;
2508
 
    char *thisName;
 
2513
    const char *thisName;
2509
2514
    ScrnColors newColors;
2510
2515
    int ndx;
2511
2516
 
2588
2593
        Bool success = True;
2589
2594
        int num;
2590
2595
        char *base = buf + 1;
2591
 
        char *name = 0;
 
2596
        const char *name = 0;
2592
2597
        char temp[10];
2593
2598
 
2594
2599
        num = ParseShiftedFont(xw, buf, &buf);
2595
2600
        if (num < 0
2596
2601
            || num > fontMenu_lastBuiltin) {
2597
 
            Bell(XkbBI_MinorError, 0);
 
2602
            Bell(xw, XkbBI_MinorError, 0);
2598
2603
            success = False;
2599
2604
        } else {
2600
2605
#if OPT_RENDERFONT
2652
2657
 
2653
2658
            if (num < 0
2654
2659
                || num > fontMenu_lastBuiltin) {
2655
 
                Bell(XkbBI_MinorError, 0);
 
2660
                Bell(xw, XkbBI_MinorError, 0);
2656
2661
                success = False;
2657
2662
            } else {
2658
2663
                /*
2699
2704
                SetVTFont(xw, num, True, &fonts);
2700
2705
            }
2701
2706
        } else {
2702
 
            Bell(XkbBI_MinorError, 0);
 
2707
            Bell(xw, XkbBI_MinorError, 0);
2703
2708
        }
2704
2709
        free(name);
2705
2710
    }
2910
2915
            break;
2911
2916
        }
2912
2917
#endif
2913
 
        Bell(XkbBI_Info, 0);
2914
 
        Bell(XkbBI_Info, 0);
 
2918
        Bell(xw, XkbBI_Info, 0);
 
2919
        Bell(xw, XkbBI_Info, 0);
2915
2920
        break;
2916
2921
#endif /* ALLOWLOGGING */
2917
2922
 
4083
4088
void
4084
4089
end_tek_mode(void)
4085
4090
{
4086
 
    if (TEK4014_ACTIVE(term)) {
4087
 
        FlushLog(TScreenOf(term));
 
4091
    XtermWidget xw = term;
 
4092
 
 
4093
    if (TEK4014_ACTIVE(xw)) {
 
4094
        FlushLog(xw);
4088
4095
        longjmp(Tekend, 1);
4089
4096
    }
4090
4097
    return;
4093
4100
void
4094
4101
end_vt_mode(void)
4095
4102
{
4096
 
    if (!TEK4014_ACTIVE(term)) {
4097
 
        FlushLog(TScreenOf(term));
4098
 
        TEK4014_ACTIVE(term) = True;
 
4103
    XtermWidget xw = term;
 
4104
 
 
4105
    if (!TEK4014_ACTIVE(xw)) {
 
4106
        FlushLog(xw);
 
4107
        TEK4014_ACTIVE(xw) = True;
4099
4108
        longjmp(VTend, 1);
4100
4109
    }
4101
4110
    return;
4161
4170
    static XrmOptionDescRec *res_array = 0;
4162
4171
 
4163
4172
#ifdef NO_LEAKS
4164
 
    if (descs == 0 && res_array != 0) {
4165
 
        free(res_array);
4166
 
        res_array = 0;
 
4173
    if (descs == 0) {
 
4174
        if (res_array != 0) {
 
4175
            free(res_array);
 
4176
            res_array = 0;
 
4177
        }
4167
4178
    } else
4168
4179
#endif
4169
4180
    if (res_array == 0) {
4227
4238
#if OPT_TRACE
4228
4239
        for (j = 0; j < opt_count; j++) {
4229
4240
            if (!strncmp(opt_array[j].opt, "-/+", 3)) {
4230
 
                char *name = opt_array[j].opt + 3;
 
4241
                const char *name = opt_array[j].opt + 3;
4231
4242
                for (k = 0; k < numDescs; ++k) {
4232
 
                    char *value = res_array[k].value;
 
4243
                    const char *value = res_array[k].value;
4233
4244
                    if (res_array[k].option[0] == '-') {
4234
4245
                        code = -1;
4235
4246
                    } else if (res_array[k].option[0] == '+') {
4352
4363
char *
4353
4364
xtermVersion(void)
4354
4365
{
 
4366
    static char vendor_version[] = __vendorversion__;
4355
4367
    static char *result;
 
4368
 
4356
4369
    if (result == 0) {
4357
 
        char *vendor = __vendorversion__;
 
4370
        char *vendor = vendor_version;
4358
4371
        char first[BUFSIZ];
4359
4372
        char second[BUFSIZ];
4360
4373