xterm.c
author viric@llimona
Mon, 24 Sep 2007 13:59:40 +0200
changeset 38 f1e581c862d5
parent 35 69dbea6c3882
child 41 954941c6e40a
permissions -rw-r--r--
Improved help. Moving to 0.2.

#include <sys/ioctl.h>
#include <termios.h>
#include <sys/types.h>
#include <stdio.h>
#include "main.h"

static char xterm_resize_string[100];

char * get_xterm_resize_string()
{
    struct winsize win;
    int rows, cols;

    /* Get rows and cols from our connection to the terminal: fd 1 */
    ioctl(1, TIOCGWINSZ, (char *)&win);
    rows = win.ws_row;
    cols = win.ws_col;

    /* Prepare the xterm resize string */
    snprintf(xterm_resize_string, sizeof xterm_resize_string,
            "\033[8;%i;%it", rows, cols);

    return xterm_resize_string;
}