diff options
author | H. Peter Anvin <hpa@zytor.com> | 2006-09-16 14:35:58 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2006-09-16 14:35:58 -0700 |
commit | 299884750e87e05c9d804e7f0fbcb08e02b37a8d (patch) | |
tree | a2949ba3298e3be3463e40a0c1e38e41b6bc74b2 /com32 | |
parent | 239f89d68bd15ff3c4048fa23acfeba57a80dd61 (diff) | |
download | syslinux-299884750e87e05c9d804e7f0fbcb08e02b37a8d.tar.gz |
Proper handling of different screen sizes (we're 78x29 in graphics mode...)
Diffstat (limited to 'com32')
-rw-r--r-- | com32/include/unistd.h | 1 | ||||
-rw-r--r-- | com32/lib/Makefile | 2 | ||||
-rw-r--r-- | com32/lib/sys/ansicon_write.c | 7 | ||||
-rw-r--r-- | com32/lib/sys/file.h | 5 | ||||
-rw-r--r-- | com32/lib/sys/isatty.c | 1 | ||||
-rw-r--r-- | com32/lib/sys/opendev.c | 3 | ||||
-rw-r--r-- | com32/lib/sys/vesacon_write.c | 9 | ||||
-rw-r--r-- | com32/modules/menumain.c | 15 |
8 files changed, 36 insertions, 7 deletions
diff --git a/com32/include/unistd.h b/com32/include/unistd.h index 84120d38..d0b8309c 100644 --- a/com32/include/unistd.h +++ b/com32/include/unistd.h @@ -20,6 +20,7 @@ __extern ssize_t write(int, const void *, size_t); __extern int isatty(int); +__extern int getscreensize(int, int *, int *); /* Standard file descriptor numbers. */ #define STDIN_FILENO 0 diff --git a/com32/lib/Makefile b/com32/lib/Makefile index e3cef233..a6355c9f 100644 --- a/com32/lib/Makefile +++ b/com32/lib/Makefile @@ -28,7 +28,7 @@ LIBOBJS = \ sys/fileinfo.o sys/opendev.o sys/read.o sys/write.o sys/ftell.o \ sys/close.o sys/open.o sys/fileread.o sys/fileclose.o \ sys/isatty.o sys/fstat.o sys/openconsole.o sys/line_input.o \ - sys/colortable.o \ + sys/colortable.o sys/screensize.o \ \ sys/stdcon_read.o sys/stdcon_write.o sys/rawcon_read.o \ sys/rawcon_write.o sys/err_read.o sys/err_write.o \ diff --git a/com32/lib/sys/ansicon_write.c b/com32/lib/sys/ansicon_write.c index 1fab2ac1..c500adbc 100644 --- a/com32/lib/sys/ansicon_write.c +++ b/com32/lib/sys/ansicon_write.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 2004 H. Peter Anvin - All Rights Reserved + * Copyright 2004-2006 H. Peter Anvin - All Rights Reserved * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -80,8 +80,6 @@ int __ansicon_open(struct file_info *fp) static com32sys_t ireg; /* Auto-initalized to all zero */ com32sys_t oreg; - (void)fp; - if (!ansicon_counter) { /* Are we disabled? */ ireg.eax.w[0] = 0x000b; @@ -109,6 +107,9 @@ int __ansicon_open(struct file_info *fp) } } + fp->o.rows = ti.rows; + fp->o.cols = ti.cols; + ansicon_counter++; return 0; } diff --git a/com32/lib/sys/file.h b/com32/lib/sys/file.h index 3b73848d..61386086 100644 --- a/com32/lib/sys/file.h +++ b/com32/lib/sys/file.h @@ -91,6 +91,11 @@ struct file_info { char *datap; /* Current data pointer */ char buf[MAXBLOCK]; } i; + + /* Output file data */ + struct { + int rows, cols; /* Rows and columns */ + } o; }; extern struct file_info __file_info[NFILES]; diff --git a/com32/lib/sys/isatty.c b/com32/lib/sys/isatty.c index c0a14db3..837a90a6 100644 --- a/com32/lib/sys/isatty.c +++ b/com32/lib/sys/isatty.c @@ -48,5 +48,6 @@ int isatty(int fd) return -1; } + /* __DEV_TTY == 1 */ return (fp->iop->flags & __DEV_TTY); } diff --git a/com32/lib/sys/opendev.c b/com32/lib/sys/opendev.c index 1bcc1010..a61da0ca 100644 --- a/com32/lib/sys/opendev.c +++ b/com32/lib/sys/opendev.c @@ -61,10 +61,9 @@ int opendev(const struct input_dev *idev, return -1; } + /* The file structure is already zeroed */ fp->iop = &dev_error_r; fp->oop = &dev_error_w; - fp->i.offset = 0; - fp->i.nbytes = 0; fp->i.datap = fp->i.buf; if (idev) { diff --git a/com32/lib/sys/vesacon_write.c b/com32/lib/sys/vesacon_write.c index da940062..7f1570be 100644 --- a/com32/lib/sys/vesacon_write.c +++ b/com32/lib/sys/vesacon_write.c @@ -85,15 +85,22 @@ int __vesacon_open(struct file_info *fp) ti.disabled = 1; } else { /* Switch mode */ - if (__vesacon_init()) + if (__vesacon_init()) { + vesacon_counter = -1; return EAGAIN; + } /* Initial state */ __ansi_init(&ti); ti.rows = __vesacon_text_rows; } + } else if (vesacon_counter == -1) { + return EAGAIN; } + fp->o.rows = ti.rows; + fp->o.cols = ti.cols; + vesacon_counter++; return 0; } diff --git a/com32/modules/menumain.c b/com32/modules/menumain.c index 282618c8..433f1694 100644 --- a/com32/modules/menumain.c +++ b/com32/modules/menumain.c @@ -845,12 +845,27 @@ execute(const char *cmdline) int menu_main(int argc, char *argv[]) { const char *cmdline; + int rows, cols; + int i; (void)argc; install_default_color_table(); + if (getscreensize(1, &rows, &cols)) { + /* Unknown screen size? */ + rows = 24; + cols = 80; + } + + WIDTH = cols; parse_config(argv[1]); + /* If anyone has specified negative parameters, consider them + relative to the bottom row of the screen. */ + for (i = 0; mparm[i].name; i++) + if (mparm[i].value < 0) + mparm[i].value = max(mparm[i].value+rows, 0); + if (draw_background) draw_background(menu_background); |