diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-01-17 16:20:31 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-01-17 16:20:31 +0000 |
commit | 5af16d68f427511a7d63fc23f6e315c81674d436 (patch) | |
tree | 26966e8ff5f8e84ec9bb80cd3ccc527803017c47 /lib | |
parent | 7d89a72274cbc916a17dbe851d5adaa58fb5583f (diff) |
Add _ti_get_screensize(), like ncurses's _nc_get_screensize()
Crank major number since libcurses will depend on this.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libtermlib/getterm.c | 82 | ||||
-rw-r--r-- | lib/libtermlib/shlib_version | 2 |
2 files changed, 48 insertions, 36 deletions
diff --git a/lib/libtermlib/getterm.c b/lib/libtermlib/getterm.c index 41f57966ca9..ea4b8185a1f 100644 --- a/lib/libtermlib/getterm.c +++ b/lib/libtermlib/getterm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getterm.c,v 1.14 1997/12/16 02:56:08 millert Exp $ */ +/* $OpenBSD: getterm.c,v 1.15 1998/01/17 16:20:29 millert Exp $ */ /* * Copyright (c) 1996 SigmaSoft, Th. Lockert <tholo@sigmasoft.com> @@ -31,7 +31,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: getterm.c,v 1.14 1997/12/16 02:56:08 millert Exp $"; +static char rcsid[] = "$OpenBSD: getterm.c,v 1.15 1998/01/17 16:20:29 millert Exp $"; #endif #include <stdlib.h> @@ -353,13 +353,54 @@ _ti_getterminfo(name) return (i + 1); } -int -_ti_getterm(name) - const char *name; +void +_ti_get_screensize(linep, colp, tabp) + int *linep; + int *colp; + int *tabp; { + char *s; #ifdef TIOCGWINSZ struct winsize winsz; #endif + + *linep = lines; + *colp = columns; + if (tabp != NULL) { + if (init_tabs == 0) + init_tabs = *tabp = 8; + else + *tabp = init_tabs; + } + if (_ti_use_env) { +#ifdef TIOCGWINSZ + /* + * get the current window size, overrides entries in termcap + */ + if (ioctl(cur_term->fd, TIOCGWINSZ, &winsz) >= 0) { + if (winsz.ws_row > 0) + *linep = winsz.ws_row; + if (winsz.ws_col > 0) + *colp = winsz.ws_col; + } +#endif + /* + * LINES and COLS environment variables overrides any other + * method of getting the terminal window size + */ + if ((s = getenv("LINES")) != NULL) + *linep = atoi(s); + if ((s = getenv("COLUMNS")) != NULL) + *colp = atoi(s); + } + lines = *linep; + columns = *colp; +} + +int +_ti_getterm(name) + const char *name; +{ int ret = 1; char *s; @@ -388,36 +429,7 @@ _ti_getterm(name) UP = cursor_up; BC = backspace_if_not_bs; PC = pad_char ? pad_char[0] : '\0'; - - LINES = lines; - COLS = columns; - TABSIZE = init_tabs; - if (TABSIZE == 0) - TABSIZE = 8; - init_tabs = TABSIZE; - if (_ti_use_env) { -#ifdef TIOCGWINSZ - /* - * get the current window size, overrides entries in termcap - */ - if (ioctl(cur_term->fd, TIOCGWINSZ, &winsz) >= 0) { - if (winsz.ws_row > 0) - LINES = winsz.ws_row; - if (winsz.ws_col > 0) - COLS = winsz.ws_col; - } -#endif - /* - * LINES and COLS environment variables overrides any other - * method of getting the terminal window size - */ - if ((s = getenv("LINES")) != NULL) - LINES = atoi(s); - if ((s = getenv("COLUMNS")) != NULL) - COLS = atoi(s); - } - lines = LINES; - columns = COLS; + _ti_get_screensize(&LINES, &COLS, &TABSIZE); } return ret; } diff --git a/lib/libtermlib/shlib_version b/lib/libtermlib/shlib_version index b52599a164f..012c14171d3 100644 --- a/lib/libtermlib/shlib_version +++ b/lib/libtermlib/shlib_version @@ -1,2 +1,2 @@ -major=2 +major=3 minor=0 |