File: terminfo.c

package info (click to toggle)
ttyload 0.5-7
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 216 kB
  • sloc: ansic: 672; makefile: 62; sh: 5
file content (28 lines) | stat: -rw-r--r-- 573 bytes parent folder | download | duplicates (23)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 * arch/Linux/terminfo.c -- routines for getting terminal
 * information on Linux machines.
 *
 * Copyright 2001, David Lindes.  All rights reserved.
 */

#include <sys/ioctl.h>	/* for ioctl() */

/* globals */
extern	int rows;
extern	int cols;

void gettermsize()
{
    struct winsize info;

    /* try to get data via IOCTL: */
    if (ioctl(1 /* stdout */, TIOCGWINSZ, &info) != -1)
    {
	/* if successful, and the data seems sane, set the
	 * program's globals: */
	if(info.ws_col > 0)
	    cols = info.ws_col;
	if(info.ws_row > 0)
	    rows = info.ws_row;
    }
}