From 19e4b032cd28c30c1e1d58782e63faeaf1edd6ee Mon Sep 17 00:00:00 2001 From: lindes Date: Tue, 28 Aug 2001 01:01:10 +0000 Subject: [PATCH] now have code for screen-size auto-detect for solaris, cool. :-) --- arch/SunOS/terminfo.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 arch/SunOS/terminfo.c diff --git a/arch/SunOS/terminfo.c b/arch/SunOS/terminfo.c new file mode 100644 index 0000000..020d6f2 --- /dev/null +++ b/arch/SunOS/terminfo.c @@ -0,0 +1,36 @@ +/* + * arch/SunOS/terminfo.c -- routines for getting terminal + * information on Solaris (SunOS) machines. + * + * Copyright 2001, David Lindes. All rights reserved. + */ + + +#include /* for ioctl() */ +#include /* for TIOCGWINSZ */ +#define _KMEMUSER /* something needs this in order + * for strsubr.h to be happy */ +#include /* sys/strsubr.h needs this */ +#include /* sys/strsubr.h needs this */ +#include /* sys/ptem.h needs this */ +#include /* for struct winsize */ + +/* 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; + } +}