mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
pager(1) now detects the terminal resolution.
This commit is contained in:
parent
261c063f4f
commit
47ae712419
1 changed files with 6 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue