summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/console.c9
-rw-r--r--src/hci/mucurses/ansi_screen.c5
-rw-r--r--src/include/curses.h7
-rw-r--r--src/include/ipxe/console.h20
4 files changed, 33 insertions, 8 deletions
diff --git a/src/core/console.c b/src/core/console.c
index 5f3c28d8..141d8f0f 100644
--- a/src/core/console.c
+++ b/src/core/console.c
@@ -10,6 +10,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
/** Current console usage */
int console_usage = CONSOLE_USAGE_STDOUT;
+/** Console width */
+unsigned int console_width = CONSOLE_DEFAULT_WIDTH;
+
+/** Console height */
+unsigned int console_height = CONSOLE_DEFAULT_HEIGHT;
+
/**
* Write a single character to each console device
*
@@ -138,6 +144,9 @@ int console_configure ( struct console_configuration *config ) {
struct console_driver *console;
int rc;
+ /* Reset console width and height */
+ console_set_size ( CONSOLE_DEFAULT_WIDTH, CONSOLE_DEFAULT_HEIGHT );
+
/* Try to configure each console */
for_each_table_entry ( console, CONSOLES ) {
if ( ( console->configure ) &&
diff --git a/src/hci/mucurses/ansi_screen.c b/src/hci/mucurses/ansi_screen.c
index d3c685ed..a37daff3 100644
--- a/src/hci/mucurses/ansi_screen.c
+++ b/src/hci/mucurses/ansi_screen.c
@@ -9,9 +9,6 @@ static void ansiscr_movetoyx(struct _curses_screen *scr,
unsigned int y, unsigned int x) __nonnull;
static void ansiscr_putc(struct _curses_screen *scr, chtype c) __nonnull;
-unsigned short _COLS = 80;
-unsigned short _LINES = 24;
-
static unsigned int saved_usage;
static void ansiscr_attrs ( struct _curses_screen *scr, attr_t attrs ) {
@@ -72,7 +69,7 @@ static void ansiscr_putc ( struct _curses_screen *scr, chtype c ) {
putchar ( character );
/* Update expected cursor position */
- if ( ++(scr->curs_x) == _COLS ) {
+ if ( ++(scr->curs_x) == COLS ) {
scr->curs_x = 0;
++scr->curs_y;
}
diff --git a/src/include/curses.h b/src/include/curses.h
index c472d695..f16f9d7d 100644
--- a/src/include/curses.h
+++ b/src/include/curses.h
@@ -3,6 +3,7 @@
#include <stdint.h>
#include <stdarg.h>
+#include <ipxe/console.h>
/** @file
*
@@ -105,12 +106,10 @@ typedef struct _curses_window {
} WINDOW;
extern WINDOW _stdscr;
-extern unsigned short _COLS;
-extern unsigned short _LINES;
#define stdscr ( &_stdscr )
-#define COLS _COLS
-#define LINES _LINES
+#define COLS console_width
+#define LINES console_height
#define MUCURSES_BITS( mask, shift ) (( mask ) << (shift))
#define CPAIR_SHIFT 8
diff --git a/src/include/ipxe/console.h b/src/include/ipxe/console.h
index 9c2620bc..ab39cbfc 100644
--- a/src/include/ipxe/console.h
+++ b/src/include/ipxe/console.h
@@ -159,7 +159,15 @@ struct console_driver {
*/
#define CONSOLE_EXPLICIT( console ) ( ( 2 * console + 1 ) != 2 )
+/** Default console width */
+#define CONSOLE_DEFAULT_WIDTH 80
+
+/** Default console height */
+#define CONSOLE_DEFAULT_HEIGHT 25
+
extern int console_usage;
+extern unsigned int console_width;
+extern unsigned int console_height;
/**
* Set console usage
@@ -175,6 +183,18 @@ console_set_usage ( int usage ) {
return old_usage;
}
+/**
+ * Set console size
+ *
+ * @v width Width, in characters
+ * @v height Height, in characters
+ */
+static inline __attribute__ (( always_inline )) void
+console_set_size ( unsigned int width, unsigned int height ) {
+ console_width = width;
+ console_height = height;
+}
+
extern int iskey ( void );
extern int getkey ( unsigned long timeout );
extern int console_configure ( struct console_configuration *config );