~ubuntu-branches/ubuntu/wily/xterm/wily

« back to all changes in this revision

Viewing changes to resize.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker
  • Date: 2010-06-10 22:13:44 UTC
  • mfrom: (1.1.18 upstream) (11.1.19 sid)
  • Revision ID: james.westby@ubuntu.com-20100610221344-s4wbmxbevlklu7fv
Tags: 259-1ubuntu1
* Merge from debian unstable. Remaining Ubuntu changes:
  - Revert the libutempter change because it's in universe. (LP: #539473)
  - Enabled URL highlighting
  - Add 100_uxterm_utf8_title.patch: 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. (LP: #320388, #408496)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $XTermId: resize.c,v 1.109 2009/10/12 00:41:33 tom Exp $ */
 
1
/* $XTermId: resize.c,v 1.114 2010/05/23 16:04:32 tom Exp $ */
2
2
 
3
3
/*
4
 
 * Copyright 2003-2008,2009 by Thomas E. Dickey
 
4
 * Copyright 2003-2009,2010 by Thomas E. Dickey
5
5
 *
6
6
 *                         All Rights Reserved
7
7
 *
341
341
#ifdef USE_ANY_SYSV_TERMIO
342
342
    ioctl(tty, TCGETA, &tioorig);
343
343
    tio = tioorig;
344
 
    tio.c_iflag &= ~(ICRNL | IUCLC);
345
 
    tio.c_lflag &= ~(ICANON | ECHO);
 
344
    UIntClr(tio.c_iflag, (ICRNL | IUCLC));
 
345
    UIntClr(tio.c_lflag, (ICANON | ECHO));
346
346
    tio.c_cflag |= CS8;
347
347
    tio.c_cc[VMIN] = 6;
348
348
    tio.c_cc[VTIME] = 1;
349
349
#elif defined(USE_TERMIOS)
350
350
    tcgetattr(tty, &tioorig);
351
351
    tio = tioorig;
352
 
    tio.c_iflag &= ~ICRNL;
353
 
    tio.c_lflag &= ~(ICANON | ECHO);
 
352
    UIntClr(tio.c_iflag, ICRNL);
 
353
    UIntClr(tio.c_lflag, (ICANON | ECHO));
354
354
    tio.c_cflag |= CS8;
355
355
    tio.c_cc[VMIN] = 6;
356
356
    tio.c_cc[VTIME] = 1;
358
358
    ioctl(tty, TIOCGETP, &sgorig);
359
359
    sg = sgorig;
360
360
    sg.sg_flags |= RAW;
361
 
    sg.sg_flags &= ~ECHO;
 
361
    UIntClr(sg.sg_flags, ECHO);
362
362
#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */
363
363
    signal(SIGINT, onintr);
364
364
    signal(SIGQUIT, onintr);
380
380
        if (tmpbuf == 0) {
381
381
            fprintf(stderr, "%s: Cannot query size\n", myname);
382
382
            onintr(0);
 
383
        } else {
 
384
            sprintf(tmpbuf, setsize[emu], argv[0], argv[1]);
 
385
            IGNORE_RC(write(tty, tmpbuf, strlen(tmpbuf)));
 
386
            free(tmpbuf);
383
387
        }
384
 
        sprintf(tmpbuf, setsize[emu], argv[0], argv[1]);
385
 
        IGNORE_RC(write(tty, tmpbuf, strlen(tmpbuf)));
386
 
        free(tmpbuf);
387
388
    }
388
389
    IGNORE_RC(write(tty, getsize[emu], strlen(getsize[emu])));
389
390
    readstring(ttyfp, buf, size[emu]);
410
411
            fprintf(stderr, "%s: Can't get window size\r\n", myname);
411
412
            onintr(0);
412
413
        }
413
 
        TTYSIZE_ROWS(ts) = rows;
414
 
        TTYSIZE_COLS(ts) = cols;
 
414
        TTYSIZE_ROWS(ts) = (ttySize_t) rows;
 
415
        TTYSIZE_COLS(ts) = (ttySize_t) cols;
415
416
        SET_TTYSIZE(tty, ts);
416
417
    } else if (ioctl(tty, TIOCGWINSZ, &ts) != -1) {
417
418
        /* we don't have any way of directly finding out
419
420
           our best by computing the font height and width from the "old"
420
421
           window-size values, and multiplying by these ratios... */
421
422
        if (TTYSIZE_COLS(ts) != 0)
422
 
            ts.ws_xpixel = cols * (ts.ws_xpixel / TTYSIZE_COLS(ts));
 
423
            ts.ws_xpixel = (ttySize_t) (cols * (ts.ws_xpixel / TTYSIZE_COLS(ts)));
423
424
        if (TTYSIZE_ROWS(ts) != 0)
424
 
            ts.ws_ypixel = rows * (ts.ws_ypixel / TTYSIZE_ROWS(ts));
425
 
        TTYSIZE_ROWS(ts) = rows;
426
 
        TTYSIZE_COLS(ts) = cols;
 
425
            ts.ws_ypixel = (ttySize_t) (rows * (ts.ws_ypixel / TTYSIZE_ROWS(ts)));
 
426
        TTYSIZE_ROWS(ts) = (ttySize_t) rows;
 
427
        TTYSIZE_COLS(ts) = (ttySize_t) cols;
427
428
        SET_TTYSIZE(tty, ts);
428
429
    }
429
430
#endif /* USE_STRUCT_{TTYSIZE|WINSIZE} */
449
450
        }
450
451
 
451
452
        i = ptr - termcap + 3;
452
 
        strncpy(newtc, termcap, (unsigned) i);
 
453
        strncpy(newtc, termcap, (size_t) i);
453
454
        sprintf(newtc + i, "%d", cols);
454
455
        ptr = strchr(ptr, ':');
455
456
        strcat(newtc, ptr);
461
462
        }
462
463
 
463
464
        i = ptr - newtc + 3;
464
 
        strncpy(termcap, newtc, (unsigned) i);
 
465
        strncpy(termcap, newtc, (size_t) i);
465
466
        sprintf(termcap + i, "%d", rows);
466
467
        ptr = strchr(ptr, ':');
467
468
        strcat(termcap, ptr);