aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@etherboot.org>2006-12-19 00:51:32 +0000
committerMichael Brown <mcb30@etherboot.org>2006-12-19 00:51:32 +0000
commite85bf5244602591ed30bbb15ce8cc5b6fbc42a0e (patch)
treead79171605b2985e1197dcaf74d8ac76dc100eb3
parent8e460de6be22ef956fdb974b1b3375e01c0b225d (diff)
downloadipxe-e85bf5244602591ed30bbb15ce8cc5b6fbc42a0e.zip
ipxe-e85bf5244602591ed30bbb15ce8cc5b6fbc42a0e.tar.gz
ipxe-e85bf5244602591ed30bbb15ce8cc5b6fbc42a0e.tar.bz2
Avoid cursor move on every single character
-rw-r--r--src/hci/mucurses/ansi_screen.c24
-rw-r--r--src/include/curses.h2
2 files changed, 22 insertions, 4 deletions
diff --git a/src/hci/mucurses/ansi_screen.c b/src/hci/mucurses/ansi_screen.c
index 01fbb8b..25087a5 100644
--- a/src/hci/mucurses/ansi_screen.c
+++ b/src/hci/mucurses/ansi_screen.c
@@ -4,18 +4,25 @@
unsigned short _COLS = 80;
unsigned short _LINES = 25;
-static void ansiscr_init ( struct _curses_screen *scr __unused ) {
+static void ansiscr_init ( struct _curses_screen *scr ) {
/* Reset terminal attributes and clear screen */
+ scr->attrs = 0;
+ scr->curs_x = 0;
+ scr->curs_y = 0;
printf ( "\033[0m\033[2J" );
}
static void ansiscr_exit ( struct _curses_screen *scr __unused ) {
}
-static void ansiscr_movetoyx ( struct _curses_screen *scr __unused,
+static void ansiscr_movetoyx ( struct _curses_screen *scr,
unsigned int y, unsigned int x ) {
- /* ANSI escape sequence to update cursor position */
- printf ( "\033[%d;%dH", ( y + 1 ), ( x + 1 ) );
+ if ( ( x != scr->curs_x ) || ( y != scr->curs_y ) ) {
+ /* ANSI escape sequence to update cursor position */
+ printf ( "\033[%d;%dH", ( y + 1 ), ( x + 1 ) );
+ scr->curs_x = x;
+ scr->curs_y = y;
+ }
}
static void ansiscr_putc ( struct _curses_screen *scr, chtype c ) {
@@ -26,13 +33,22 @@ static void ansiscr_putc ( struct _curses_screen *scr, chtype c ) {
short fcol;
short bcol;
+ /* Update attributes if changed */
if ( attrs != scr->attrs ) {
scr->attrs = attrs;
pair_content ( cpair, &fcol, &bcol );
/* ANSI escape sequence to update character attributes */
printf ( "\033[0;%d;3%d;4%dm", ( bold ? 1 : 22 ), fcol, bcol );
}
+
+ /* Print the actual character */
putchar ( character );
+
+ /* Update expected cursor position */
+ if ( ++(scr->curs_x) == _COLS ) {
+ scr->curs_x = 0;
+ ++scr->curs_y;
+ }
}
static int ansiscr_getc ( struct _curses_screen *scr __unused ) {
diff --git a/src/include/curses.h b/src/include/curses.h
index ed8e880..bdeef2e 100644
--- a/src/include/curses.h
+++ b/src/include/curses.h
@@ -28,6 +28,8 @@ typedef uint32_t attr_t;
/** Curses SCREEN object */
typedef struct _curses_screen {
+ /** Current cursor position */
+ unsigned int curs_x, curs_y;
/** Current attribute */
attr_t attrs;