File: conssize.c

package info (click to toggle)
termrec 0.19-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,148 kB
  • sloc: ansic: 8,430; makefile: 181; perl: 16; sh: 15
file content (19 lines) | stat: -rw-r--r-- 416 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "config.h"
#include <windows.h>
#include <io.h>
#include "export.h"
#include "ttysize.h"

int get_tty_size(int fd, int *x, int *y)
{
    CONSOLE_SCREEN_BUFFER_INFO bi;
    HANDLE h;

    if (!(h=(HANDLE)_get_osfhandle(fd)))
        return 0;
    if (!GetConsoleScreenBufferInfo(h, &bi))
        return 0;
    *x=bi.srWindow.Right-bi.srWindow.Left;
    *y=bi.srWindow.Bottom-bi.srWindow.Top;
    return 1;
}