[syslinux:master] rosh: make getscreensize more effective and usable
syslinux-bot for Gene Cumm
gene.cumm at gmail.com
Fri Oct 8 13:57:15 PDT 2010
Commit-ID: b46725feffee6f8492e3cfa009506c614ae2663c
Gitweb: http://syslinux.zytor.com/commit/b46725feffee6f8492e3cfa009506c614ae2663c
Author: Gene Cumm <gene.cumm at gmail.com>
AuthorDate: Fri, 2 Jul 2010 20:08:07 -0400
Committer: Gene Cumm <gene.cumm at gmail.com>
CommitDate: Wed, 7 Jul 2010 09:59:34 -0400
rosh: make getscreensize more effective and usable
---
com32/rosh/rosh.h | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/com32/rosh/rosh.h b/com32/rosh/rosh.h
index a8edda6..bb768fc 100644
--- a/com32/rosh/rosh.h
+++ b/com32/rosh/rosh.h
@@ -32,6 +32,7 @@
#include <stdbool.h> /* macro: true false */
#include <string.h> /* strcpy() strlen() memcpy() strchr() */
#include <sys/types.h>
+#include <limits.h>
#include <sys/stat.h> /* fstat() */
#include <fcntl.h> /* open(); open mode macros */
#include <dirent.h> /* fdopendir() opendir() readdir() closedir() DIR */
@@ -41,7 +42,8 @@
#include <ctype.h> /* isspace() */
#include <getkey.h>
-#include <consoles.h>
+#include <consoles.h> /* console_ansi_raw() console_ansi_std() */
+#include <sys/ioctl.h>
#ifdef DO_DEBUG
# define ROSH_DEBUG printf
@@ -102,15 +104,24 @@ static inline int getscreensize(int fd, int *rows, int *cols)
{
char *str;
int rv;
- *rows = 0;
- *cols = 0;
+ struct winsize ws;
+ if (rows)
+ *rows = 0;
+ if (cols)
+ *cols = 0;
+ str = NULL;
if (fd == 1) {
- if (rows) {
+ ioctl(0, TIOCGWINSZ, &ws);
+/* if (rows)
+ *rows = ws.ws_row;
+ if (cols)
+ *cols = ws.ws_col;*/
+ if (rows && !*rows) {
str = getenv("LINES");
if (str)
*rows = atoi(str);
}
- if (cols) {
+ if (cols && !*cols) {
str = getenv("COLUMNS");
if (str)
*cols = atoi(str);
More information about the Syslinux-commits
mailing list