__extern int isatty(int);
+__extern int getscreensize(int, int *, int *);
/* Standard file descriptor numbers. */
#define STDIN_FILENO 0
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 \
/* ----------------------------------------------------------------------- *
*
- * 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
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;
}
}
+ fp->o.rows = ti.rows;
+ fp->o.cols = ti.cols;
+
ansicon_counter++;
return 0;
}
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];
return -1;
}
+ /* __DEV_TTY == 1 */
return (fp->iop->flags & __DEV_TTY);
}
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) {
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;
}
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);