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

« back to all changes in this revision

Viewing changes to os2main.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2011-06-17 10:40:36 UTC
  • mfrom: (1.4.12 upstream) (11.1.26 sid)
  • Revision ID: james.westby@ubuntu.com-20110617104036-id4ml81yetasewp9
Tags: 270-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - debian/patches/950_ubuntu_charclass_highlight.diff: Enabled 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

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $XTermId: os2main.c,v 1.265 2010/06/20 21:27:07 tom Exp $ */
 
1
/* $XTermId: os2main.c,v 1.269 2011/04/23 00:02:03 tom Exp $ */
2
2
 
3
3
/* removed all foreign stuff to get the code more clear (hv)
4
4
 * and did some rewrite for the obscure OS/2 environment
262
262
 
263
263
static XtResource application_resources[] =
264
264
{
265
 
    Sres("name", "Name", xterm_name, DFT_TERMTYPE),
266
265
    Sres("iconGeometry", "IconGeometry", icon_geometry, NULL),
267
266
    Sres(XtNtitle, XtCTitle, title, NULL),
268
267
    Sres(XtNiconName, XtCIconName, icon_name, NULL),
274
273
    Bres("messages", "Messages", messages, True),
275
274
    Ires("minBufSize", "MinBufSize", minBufSize, 4096),
276
275
    Ires("maxBufSize", "MaxBufSize", maxBufSize, 32768),
277
 
    Sres("menuLocale", "MenuLocale", menuLocale, ""),
 
276
    Sres("menuLocale", "MenuLocale", menuLocale, DEF_MENU_LOCALE),
 
277
    Sres("omitTranslation", "OmitTranslation", omitTranslation, NULL),
278
278
    Sres("keyboardType", "KeyboardType", keyboardType, "unknown"),
 
279
#if OPT_PRINT_ON_EXIT
 
280
    Ires("printModeOnXError", "PrintModeOnXError", printModeOnXError, 0),
 
281
    Sres("printFileOnXError", "PrintFileOnXError", printFileOnXError, NULL),
 
282
#endif
279
283
#if OPT_SUNPC_KBD
280
284
    Bres("sunKeyboard", "SunKeyboard", sunKeyboard, False),
281
285
#endif
315
319
#endif
316
320
#if OPT_MAXIMIZE
317
321
    Bres(XtNmaximized, XtCMaximized, maximized, False),
 
322
    Sres(XtNfullscreen, XtCFullscreen, fullscreen_s, "off"),
318
323
#endif
319
324
};
320
325
 
321
326
static String fallback_resources[] =
322
327
{
 
328
#if OPT_TOOLBAR
 
329
    "*toolBar: false",
 
330
#endif
323
331
    "*SimpleMenu*menuLabel.vertSpace: 100",
324
332
    "*SimpleMenu*HorizontalMargins: 16",
325
333
    "*SimpleMenu*Sme.height: 16",
511
519
#if OPT_MAXIMIZE
512
520
{"-maximized",  "*maximized",   XrmoptionNoArg,         (XPointer) "on"},
513
521
{"+maximized",  "*maximized",   XrmoptionNoArg,         (XPointer) "off"},
 
522
{"-fullscreen", "*fullscreen",  XrmoptionNoArg,         (XPointer) "on"},
 
523
{"+fullscreen", "*fullscreen",  XrmoptionNoArg,         (XPointer) "off"},
514
524
#endif
515
525
/* options that we process ourselves */
516
526
{"-help",       NULL,           XrmoptionSkipNArgs,     (XPointer) NULL},
728
738
    char *string = *ptr;
729
739
    int value = -1;
730
740
 
731
 
    TRACE(("...decode '%s'\n", string));
 
741
    TRACE(("decode_keyvalue '%s'\n", string));
732
742
    if (*string == '^') {
733
743
        switch (*++string) {
734
744
        case '?':
742
752
#endif
743
753
#if defined(_PC_VDISABLE)
744
754
                if (value == -1) {
745
 
                    value = fpathconf(0, _PC_VDISABLE);
 
755
                    value = (int) fpathconf(0, _PC_VDISABLE);
746
756
                    if (value == -1) {
747
757
                        if (errno != 0)
748
758
                            break;      /* skip this (error) */
763
773
        ++string;
764
774
    } else if (termcap && (*string == '\\')) {
765
775
        char *d;
766
 
        int temp = strtol(string + 1, &d, 8);
 
776
        int temp = (int) strtol(string + 1, &d, 8);
767
777
        if (temp > 0 && d != string) {
768
778
            value = temp;
769
779
            string = d;
773
783
        ++string;
774
784
    }
775
785
    *ptr = string;
 
786
    TRACE(("...decode_keyvalue %#x\n", value));
776
787
    return value;
777
788
}
778
789
 
956
967
    TRACE_ARGV("Before XtOpenApplication", argv);
957
968
    if (argc > 1) {
958
969
        int n;
959
 
        unsigned unique = 2;
 
970
        size_t unique = 2;
960
971
        Bool quit = True;
961
972
 
962
973
        for (n = 1; n < argc; n++) {
965
976
                Version();
966
977
            } else if (abbrev(argv[n], "-help", unique)) {
967
978
                Help();
968
 
            } else if (abbrev(argv[n], "-class", 3)) {
 
979
            } else if (abbrev(argv[n], "-class", (size_t) 3)) {
969
980
                if ((my_class = argv[++n]) == 0) {
970
981
                    Help();
971
982
                } else {
973
984
                }
974
985
                unique = 3;
975
986
            } else {
976
 
#if OPT_COLOR_RES
977
 
                if (abbrev(argv[n], "-reverse", 2)
978
 
                    || !strcmp("-rv", argv[n])) {
979
 
                    reversed = True;
980
 
                } else if (!strcmp("+rv", argv[n])) {
981
 
                    reversed = False;
982
 
                }
983
 
#endif
984
987
                quit = False;
985
988
                unique = 3;
986
989
            }
1050
1053
                              application_resources,
1051
1054
                              XtNumber(application_resources), NULL, 0);
1052
1055
    TRACE_XRES();
 
1056
#if OPT_MAXIMIZE
 
1057
    resource.fullscreen = extendedBoolean(resource.fullscreen_s,
 
1058
                                          tblFullscreen,
 
1059
                                          XtNumber(tblFullscreen));
 
1060
#endif
1053
1061
 
1054
1062
    /*
1055
1063
     * ICCCM delete_window.
1076
1084
    }
1077
1085
#endif /* OPT_ZICONBEEP */
1078
1086
    hold_screen = resource.hold_screen ? 1 : 0;
1079
 
    xterm_name = resource.xterm_name;
1080
 
    if (strcmp(xterm_name, "-") == 0)
1081
 
        xterm_name = DFT_TERMTYPE;
1082
1087
    if (resource.icon_geometry != NULL) {
1083
1088
        int scr, junk;
1084
1089
        int ix, iy;
1259
1264
            int n;
1260
1265
            char **c;
1261
1266
            for (n = 0, c = command_to_exec; *c; n++, c++) ;
1262
 
            c = TypeMallocN(char *, n + 3 + u);
 
1267
            c = TypeMallocN(char *, (unsigned) (n + 3 + u));
1263
1268
            if (c == NULL)
1264
1269
                SysError(ERROR_LUMALLOC);
1265
 
            memcpy(c + 2 + u, command_to_exec, (n + 1) * sizeof(char *));
 
1270
            memcpy(c + 2 + u, command_to_exec, (unsigned) (n + 1) * sizeof(char *));
1266
1271
            c[0] = term->misc.localefilter;
1267
1272
            if (u) {
1268
1273
                c[1] = "-encoding";
1365
1370
                        winToEmbedInto, 0, 0);
1366
1371
    }
1367
1372
#if OPT_COLOR_RES
1368
 
    TRACE(("checking resource values rv %s fg %s, bg %s\n",
1369
 
           BtoS(term->misc.re_verse0),
 
1373
    TRACE(("checking reverseVideo before rv %s fg %s, bg %s\n",
 
1374
           term->misc.re_verse0 ? "reverse" : "normal",
1370
1375
           NonNull(TScreenOf(term)->Tcolors[TEXT_FG].resource),
1371
1376
           NonNull(TScreenOf(term)->Tcolors[TEXT_BG].resource)));
1372
1377
 
1373
 
    if ((reversed && term->misc.re_verse0)
1374
 
        && ((TScreenOf(term)->Tcolors[TEXT_FG].resource
1375
 
             && !isDefaultForeground(TScreenOf(term)->Tcolors[TEXT_FG].resource))
1376
 
            || (TScreenOf(term)->Tcolors[TEXT_BG].resource
1377
 
                && !isDefaultBackground(TScreenOf(term)->Tcolors[TEXT_BG].resource))
1378
 
        ))
1379
 
        ReverseVideo(term);
 
1378
    if (term->misc.re_verse0) {
 
1379
        if (isDefaultForeground(TScreenOf(term)->Tcolors[TEXT_FG].resource)
 
1380
            && isDefaultBackground(TScreenOf(term)->Tcolors[TEXT_BG].resource)) {
 
1381
            TScreenOf(term)->Tcolors[TEXT_FG].resource = x_strdup(XtDefaultBackground);
 
1382
            TScreenOf(term)->Tcolors[TEXT_BG].resource = x_strdup(XtDefaultForeground);
 
1383
        } else {
 
1384
            ReverseVideo(term);
 
1385
        }
 
1386
        term->misc.re_verse = True;
 
1387
        update_reversevideo();
 
1388
        TRACE(("updated  reverseVideo after  rv %s fg %s, bg %s\n",
 
1389
               term->misc.re_verse ? "reverse" : "normal",
 
1390
               NonNull(TScreenOf(term)->Tcolors[TEXT_FG].resource),
 
1391
               NonNull(TScreenOf(term)->Tcolors[TEXT_BG].resource)));
 
1392
    }
1380
1393
#endif /* OPT_COLOR_RES */
1381
1394
 
1382
1395
#if OPT_MAXIMIZE
1471
1484
 * The VT420 has up to 48 lines on the screen.
1472
1485
 */
1473
1486
 
1474
 
static char *vtterm[] =
 
1487
static const char *vtterm[] =
1475
1488
{
1476
1489
#ifdef USE_X11TERM
1477
1490
    "x11term",                  /* for people who want special term name */
1688
1701
     * entry is not found.
1689
1702
     */
1690
1703
    ok_termcap = True;
1691
 
    if (!get_termcap(TermName = resource.term_name)) {
1692
 
        char *last = NULL;
1693
 
        TermName = *envnew;
 
1704
    if (!get_termcap(xw, TermName = resource.term_name)) {
 
1705
        const char *last = NULL;
 
1706
        char *next;
 
1707
 
 
1708
        TermName = x_strdup(*envnew);
1694
1709
        ok_termcap = False;
1695
1710
        while (*envnew != NULL) {
1696
 
            if ((last == NULL || strcmp(last, *envnew))
1697
 
                && get_termcap(*envnew)) {
1698
 
                TermName = *envnew;
1699
 
                ok_termcap = True;
1700
 
                break;
 
1711
            if (last == NULL || strcmp(last, *envnew)) {
 
1712
                next = x_strdup(*envnew);
 
1713
                if (get_termcap(xw, next)) {
 
1714
                    free(TermName);
 
1715
                    TermName = next;
 
1716
                    ok_termcap = True;
 
1717
                    break;
 
1718
                } else {
 
1719
                    free(next);
 
1720
                }
1701
1721
            }
1702
1722
            last = *envnew;
1703
1723
            envnew++;
1704
1724
        }
1705
1725
    }
1706
1726
    if (ok_termcap) {
 
1727
        resource.term_name = TermName;
1707
1728
        resize_termcap(xw);
1708
1729
    }
1709
1730
 
1810
1831
 
1811
1832
            xtermCopyEnv(gblenvp);
1812
1833
 
1813
 
            xtermSetenv("TERM", TermName);
1814
 
            if (!TermName)
 
1834
            xtermSetenv("TERM", resource.term_name);
 
1835
            if (!resource.term_name)
1815
1836
                *get_tcap_buffer(xw) = 0;
1816
1837
 
1817
1838
            sprintf(buf, "%lu",
1831
1852
            /* dup the tty */
1832
1853
            for (i = 0; i <= 2; i++)
1833
1854
                if (i != ttyfd) {
1834
 
                    (void) close(i);
 
1855
                    IGNORE_RC(close(i));
1835
1856
                    IGNORE_RC(dup(ttyfd));
1836
1857
                }
1837
1858
 
1847
1868
                       handshake.rows, handshake.cols));
1848
1869
                set_max_row(screen, handshake.rows);
1849
1870
                set_max_col(screen, handshake.cols);
1850
 
                TTYSIZE_ROWS(ts) = MaxRows(screen);
1851
 
                TTYSIZE_COLS(ts) = MaxCols(screen);
1852
 
                ts.ws_xpixel = FullWidth(screen);
1853
 
                ts.ws_ypixel = FullHeight(screen);
 
1871
                TTYSIZE_ROWS(ts) = (ttySize_t) MaxRows(screen);
 
1872
                TTYSIZE_COLS(ts) = (ttySize_t) MaxCols(screen);
 
1873
                ts.ws_xpixel = (ttySize_t) FullWidth(screen);
 
1874
                ts.ws_ypixel = (ttySize_t) FullHeight(screen);
1854
1875
            }
1855
1876
 
1856
1877
            sprintf(numbuf, "%d", MaxCols(screen));
2018
2039
#endif
2019
2040
            TRACE(("closed display\n"));
2020
2041
        }
2021
 
        TRACE((0));
 
2042
        TRACE_CLOSE();
2022
2043
    }
2023
2044
#endif
2024
2045
 
2091
2112
    int count = 0;
2092
2113
 
2093
2114
    TRACE(("parse_tty_modes\n"));
2094
 
    while (1) {
 
2115
    for (;;) {
2095
2116
        size_t len;
2096
2117
 
2097
2118
        while (*s && isascii(CharOf(*s)) && isspace(CharOf(*s)))