cmenu: implement gotoxy using escape sequences
authorPierre-Alexandre Meyer <pierre@mouraf.org>
Wed, 19 Aug 2009 04:09:09 +0000 (21:09 -0700)
committerPierre-Alexandre Meyer <pierre@mouraf.org>
Tue, 1 Sep 2009 18:43:37 +0000 (11:43 -0700)
Use ansicon and the ANSI CUP - CUrsor Position escape sequence
to implement the gotoxy function.

Note: page switching is not supported (yet).

Testing Done: ran com32/cmenu/test.c32 in qemu.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
com32/cmenu/libmenu/com32io.c
com32/cmenu/libmenu/com32io.h
com32/cmenu/libmenu/menu.c

index d99eb87..a53b614 100644 (file)
@@ -51,14 +51,6 @@ void getpos(char *row, char *col, char page)
     *col = REG_DL(outreg);
 }
 
-void gotoxy(char row, char col, char page)
-{
-    REG_AH(inreg) = 0x02;
-    REG_BH(inreg) = page;
-    REG_DX(inreg) = (row << 8) + col;
-    __intcall(0x10, &inreg, &outreg);
-}
-
 unsigned char sleep(unsigned int msec)
 {
     unsigned long micro = 1000 * msec;
index cdaf0a8..55d0189 100644 (file)
 #define __COM32IO_H__
 
 #include <com32.h>
+#include <stdio.h>
 
 #ifndef NULL
 #define NULL ((void *)0)
 #endif
 
+#define CSI "\e["
+
 /* BIOS Assisted output routines */
 
 void cswprint(const char *str, char attr, char left);
@@ -37,7 +40,11 @@ void setdisppage(char num);  // Set the display page to specified number
 
 char getdisppage();            // Get current display page
 
-void gotoxy(char row, char col, char page);
+static inline void gotoxy(char row, char col, char page)
+{
+       // XXX page
+       printf(CSI "%d;%dH", row + 1, col + 1);
+}
 
 void getpos(char *row, char *col, char page);
 
index cfe8f39..4abc7b5 100644 (file)
@@ -13,6 +13,7 @@
 #include "menu.h"
 #include "com32io.h"
 #include <stdlib.h>
+#include <console.h>
 
 // Local Variables
 static pt_menusystem ms;       // Pointer to the menusystem
@@ -851,6 +852,9 @@ pt_menusystem init_menusystem(const char *title)
 
     // Set up the look of the box
     set_box_type(MENUBOXTYPE);
+
+       openconsole(&dev_stdcon_r, &dev_ansiserial_w);
+
     return ms;
 }