pager(1) now detects the terminal resolution.

This commit is contained in:
Jonas 'Sortie' Termansen 2012-07-31 16:48:56 +02:00
parent 261c063f4f
commit 47ae712419
1 changed files with 6 additions and 2 deletions

View File

@ -29,6 +29,7 @@
#include <fcntl.h>
#include <errno.h>
#include <error.h>
#include <termios.h>
char* stdinargv[2];
@ -52,8 +53,11 @@ int main(int argc, char* argv[])
close(0);
int ttyfd = open("/dev/tty", O_RDONLY);
if ( ttyfd != 0 ) { perror("/dev/tty"); return 1; }
const int HEIGHT = 25;
const int WIDTH = 80;
struct winsize ws;
if ( tcgetwinsize(0, &ws) )
error(1, errno, "tcgetwinsize");
const int HEIGHT = ws.ws_row;
const int WIDTH = ws.ws_col;
int linesleft = HEIGHT-1;
int result = 0;
size_t charleft = WIDTH;