summaryrefslogtreecommitdiff
path: root/com32/cmenu
diff options
context:
space:
mode:
authorPierre-Alexandre Meyer <pierre@mouraf.org>2009-08-30 17:06:30 -0700
committerPierre-Alexandre Meyer <pierre@mouraf.org>2009-09-01 11:43:39 -0700
commit9eacdefabc99e6c98cc9373ee04dce23dc6d49bc (patch)
tree319ea49256dde1e4b33c8b96c864e59bdbe1d73b /com32/cmenu
parent0ca265e1a55ddfda946efdd49277803b2c0beacb (diff)
downloadsyslinux-9eacdefabc99e6c98cc9373ee04dce23dc6d49bc.tar.gz
cmenu: remove multi pages support
The cmenu used to display the help on a separate page. Since we can't have multi pages on the serial line, get rid of them completely. This has a fairly big impact as the external cmenu API has changed. adv_menu.tpl and HDT have been patched accordingly. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
Diffstat (limited to 'com32/cmenu')
-rw-r--r--com32/cmenu/adv_menu.tpl20
-rw-r--r--com32/cmenu/complex.c46
-rw-r--r--com32/cmenu/libmenu/com32io.c49
-rw-r--r--com32/cmenu/libmenu/com32io.h40
-rw-r--r--com32/cmenu/libmenu/help.c37
-rw-r--r--com32/cmenu/libmenu/menu.c117
-rw-r--r--com32/cmenu/libmenu/tui.c68
-rw-r--r--com32/cmenu/libmenu/tui.h26
8 files changed, 191 insertions, 212 deletions
diff --git a/com32/cmenu/adv_menu.tpl b/com32/cmenu/adv_menu.tpl
index 6ce4acf8..7e738cc5 100644
--- a/com32/cmenu/adv_menu.tpl
+++ b/com32/cmenu/adv_menu.tpl
@@ -192,7 +192,7 @@ TIMEOUTCODE ontotaltimeout()
return timeout(totaltimeoutcmd);
}
-void keys_handler(t_menusystem *ms, t_menuitem *mi,unsigned int scancode)
+void keys_handler(t_menuitem *mi,unsigned int scancode)
{
char nc;
@@ -207,15 +207,15 @@ void keys_handler(t_menusystem *ms, t_menuitem *mi,unsigned int scancode)
(isallowed(username,"editcmd") || isallowed(username,"root"))) {
nc = getnumcols();
// User typed TAB and has permissions to edit command line
- gotoxy(EDIT_ROW,1,ms->menupage);
+ gotoxy(EDIT_ROW,1);
csprint("Command line:",0x07);
editstring(mi->data,ACTIONLEN);
- gotoxy(EDIT_ROW,1,ms->menupage);
- cprint(' ',0x07,nc-1,ms->menupage);
+ gotoxy(EDIT_ROW,1);
+ cprint(' ',0x07,nc-1);
}
}
-t_handler_return login_handler(t_menusystem *ms, t_menuitem *mi)
+t_handler_return login_handler(t_menuitem *mi)
{
(void)mi; // Unused
char pwd[40];
@@ -228,15 +228,15 @@ t_handler_return login_handler(t_menusystem *ms, t_menuitem *mi)
if (mi->item == loginstr) { /* User wants to login */
nc = getnumcols();
- gotoxy(PWD_ROW,1,ms->menupage);
+ gotoxy(PWD_ROW,1);
csprint("Enter Username: ",0x07);
getstring(login, sizeof username);
- gotoxy(PWD_ROW,1,ms->menupage);
- cprint(' ',0x07,nc,ms->menupage);
+ gotoxy(PWD_ROW,1);
+ cprint(' ',0x07,nc);
csprint("Enter Password: ",0x07);
getpwd(pwd, sizeof pwd);
- gotoxy(PWD_ROW,1,ms->menupage);
- cprint(' ',0x07,nc,ms->menupage);
+ gotoxy(PWD_ROW,1);
+ cprint(' ',0x07,nc);
if (authenticate_user(login,pwd))
{
diff --git a/com32/cmenu/complex.c b/com32/cmenu/complex.c
index 063125d6..fb68a319 100644
--- a/com32/cmenu/complex.c
+++ b/com32/cmenu/complex.c
@@ -65,7 +65,7 @@ TIMEOUTCODE ontimeout()
#define PWDATTR 0x74
#define EDITPROMPT 21
-void keys_handler(t_menusystem * ms, t_menuitem * mi, unsigned int scancode)
+void keys_handler(t_menuitem * mi, unsigned int scancode)
{
char nc;
@@ -78,15 +78,15 @@ void keys_handler(t_menusystem * ms, t_menuitem * mi, unsigned int scancode)
(isallowed(username, "editcmd") || isallowed(username, "root"))) {
nc = getnumcols();
// User typed TAB and has permissions to edit command line
- gotoxy(EDITPROMPT, 1, ms->menupage);
+ gotoxy(EDITPROMPT, 1);
csprint("Command line:", 0x07);
editstring(mi->data, ACTIONLEN);
- gotoxy(EDITPROMPT, 1, ms->menupage);
- cprint(' ', 0x07, nc - 1, ms->menupage);
+ gotoxy(EDITPROMPT, 1);
+ cprint(' ', 0x07, nc - 1);
}
}
-t_handler_return login_handler(t_menusystem * ms, t_menuitem * mi)
+t_handler_return login_handler(t_menuitem * mi)
{
(void)mi; // Unused
char pwd[40];
@@ -96,15 +96,15 @@ t_handler_return login_handler(t_menusystem * ms, t_menuitem * mi)
if (mi->item == loginstr) { /* User wants to login */
nc = getnumcols();
- gotoxy(PWDPROMPT, 1, ms->menupage);
+ gotoxy(PWDPROMPT, 1);
csprint("Enter Username: ", 0x07);
getstring(login, sizeof username);
- gotoxy(PWDPROMPT, 1, ms->menupage);
- cprint(' ', 0x07, nc, ms->menupage);
+ gotoxy(PWDPROMPT, 1);
+ cprint(' ', 0x07, nc);
csprint("Enter Password: ", 0x07);
getpwd(pwd, sizeof pwd);
- gotoxy(PWDPROMPT, 1, ms->menupage);
- cprint(' ', 0x07, nc, ms->menupage);
+ gotoxy(PWDPROMPT, 1);
+ cprint(' ', 0x07, nc);
if (authenticate_user(login, pwd)) {
strcpy(username, login);
@@ -137,18 +137,18 @@ void msys_handler(t_menusystem * ms, t_menuitem * mi)
void *v;
nc = getnumcols(); // Get number of columns
- gotoxy(PWDLINE, PWDCOLUMN, ms->menupage);
+ gotoxy(PWDLINE, PWDCOLUMN);
csprint("User: ", PWDATTR);
- cprint(ms->fillchar, ms->fillattr, sizeof username, ms->menupage);
- gotoxy(PWDLINE, PWDCOLUMN + 6, ms->menupage);
+ cprint(ms->fillchar, ms->fillattr, sizeof username);
+ gotoxy(PWDLINE, PWDCOLUMN + 6);
csprint(username, PWDATTR);
if (mi->parindex != PREPMENU) // If we are not in the PREP MENU
{
- gotoxy(INFLINE, 0, ms->menupage);
- cprint(' ', 0x07, nc, ms->menupage);
- gotoxy(INFLINE + 1, 0, ms->menupage);
- cprint(' ', 0x07, nc, ms->menupage);
+ gotoxy(INFLINE, 0);
+ cprint(' ', 0x07, nc);
+ gotoxy(INFLINE + 1, 0);
+ cprint(' ', 0x07, nc);
return;
}
strcpy(infoline, " ");
@@ -167,13 +167,13 @@ void msys_handler(t_menusystem * ms, t_menuitem * mi)
if (flags.linrep)
strcat(infoline, "repair=lin ");
- gotoxy(INFLINE, 0, ms->menupage);
- cprint(' ', 0x07, nc, ms->menupage);
- gotoxy(INFLINE + 1, 0, ms->menupage);
- cprint(' ', 0x07, nc, ms->menupage);
- gotoxy(INFLINE, 0, ms->menupage);
+ gotoxy(INFLINE, 0);
+ cprint(' ', 0x07, nc);
+ gotoxy(INFLINE + 1, 0);
+ cprint(' ', 0x07, nc);
+ gotoxy(INFLINE, 0);
csprint("Kernel Arguments:", 0x07);
- gotoxy(INFLINE, 17, ms->menupage);
+ gotoxy(INFLINE, 17);
csprint(infoline, 0x07);
}
diff --git a/com32/cmenu/libmenu/com32io.c b/com32/cmenu/libmenu/com32io.c
index 60789f82..f1ed17da 100644
--- a/com32/cmenu/libmenu/com32io.c
+++ b/com32/cmenu/libmenu/com32io.c
@@ -62,36 +62,47 @@ static void cprint_vga2ansi(char chr, char attr)
putchar(chr);
}
-/* Print character and attribute at cursor */
-// Note: attr is a vga attribute
-void cprint(char chr, char attr, unsigned int times, char disppage)
+/**
+ * cprint - given a VGA attribute, print a single character at cursor
+ * @chr: character to print
+ * @attr: VGA attribute
+ * @times: number of times to print @chr
+ *
+ * Note: @attr is a VGA attribute.
+ **/
+void cprint(const char chr, const char attr, unsigned int times)
{
- // XXX disppage
-
while (times--)
cprint_vga2ansi(chr, attr);
}
-void csprint(const char *str, char attr)
+/**
+ * csprint - given a VGA attribute, print a NULL-terminated string
+ * @str: string to print
+ * @attr: VGA attribute
+ **/
+void csprint(const char *str, const char attr)
{
while (*str) {
- cprint(*str, attr, 1, 0);
+ cprint(*str, attr, 1);
str++;
}
}
-void setdisppage(char num) // Set the display page to specified number
-{
- REG_AH(inreg) = 0x05;
- REG_AL(inreg) = num;
- __intcall(0x10, &inreg, &outreg);
-}
-
-char getdisppage() // Get current display page
+/**
+ * clearwindow - fill a given a region on the screen
+ * @top, @left, @bot, @right: coordinates to fill
+ * @fillchar: character to use to fill the region
+ * @fillattr: character attribute (VGA)
+ **/
+void clearwindow(const char top, const char left, const char bot,
+ const char right, const char fillchar, const char fillattr)
{
- REG_AH(inreg) = 0x0f;
- __intcall(0x10, &inreg, &outreg);
- return REG_BH(outreg);
+ char x;
+ for (x = top; x < bot + 1; x++) {
+ gotoxy(x, left);
+ cprint(fillchar, fillattr, right - left + 1);
+ }
}
void getpos(char *row, char *col, char page)
@@ -137,7 +148,7 @@ char inputc(char *scancode)
void getcursorshape(char *start, char *end)
{
- char page = getdisppage();
+ char page = 0; // XXX TODO
REG_AH(inreg) = 0x03;
REG_BH(inreg) = page;
__intcall(0x10, &inreg, &outreg);
diff --git a/com32/cmenu/libmenu/com32io.h b/com32/cmenu/libmenu/com32io.h
index 938eceeb..54593328 100644
--- a/com32/cmenu/libmenu/com32io.h
+++ b/com32/cmenu/libmenu/com32io.h
@@ -34,23 +34,38 @@ static inline beep()
// i.e. \n in str will move cursor to column left
// Print a C str (NUL-terminated)
-void csprint(const char *str, char attr);
+void csprint(const char *, const char);
-static inline void cswprint(const char *str, char attr, char left)
-{
- csprint(str, attr);
-}
+//static inline void cswprint(const char *str, const char attr)
+//{
+// csprint(str, attr);
+//}
+void cprint(const char, const char, unsigned int);
-void cprint(char chr, char attr, unsigned int times, char disppage); // Print a char
+static inline void putch(const char x, char attr)
+{
+ cprint(x, attr, 1);
+}
-void setdisppage(char num); // Set the display page to specified number
+void clearwindow(const char, const char, const char, const char,
+ const char, const char);
-char getdisppage(); // Get current display page
+/*
+ * cls - clear and initialize the entire screen
+ *
+ * Note: when initializing xterm, one has to specify that
+ * G1 points to the alternate character set (this is not true
+ * by default). Without the initial printf "\033)0", line drawing
+ * characters won't be displayed.
+ */
+static inline void cls(void)
+{
+ fputs("\033e\033%@\033)0\033(B\1#0\033[?25l\033[2J", stdout);
+}
-static inline void gotoxy(char row, char col, char page)
+static inline void gotoxy(const char row, const char col)
{
- // XXX page
printf(CSI "%d;%dH", row + 1, col + 1);
}
@@ -58,11 +73,6 @@ void getpos(char *row, char *col, char page);
char inputc(char *scancode); // Return ASCII char by val, and scancode by reference
-static inline void putch(char x, char attr, char page)
-{
- cprint(x, attr, 1, page);
-}
-
void setcursorshape(char start, char end); // Set cursor shape
void getcursorshape(char *start, char *end); // Get shape for current page
diff --git a/com32/cmenu/libmenu/help.c b/com32/cmenu/libmenu/help.c
index a635bd21..b0011c0d 100644
--- a/com32/cmenu/libmenu/help.c
+++ b/com32/cmenu/libmenu/help.c
@@ -69,8 +69,8 @@ void printtext(char *buf, int from)
p = findline(f, nlines);
if (p && (*p == '\n'))
*p = '\0'; // change to NUL
- gotoxy(HELP_BODY_ROW, HELP_LEFT_MARGIN, HELPPAGE);
- cswprint(f, 0x07, HELP_LEFT_MARGIN);
+ gotoxy(HELP_BODY_ROW, HELP_LEFT_MARGIN);
+ csprint(f, 0x07);
if (p)
*p = '\n'; // set it back
}
@@ -93,12 +93,12 @@ void showhelp(const char *filename)
nr = getnumrows();
ph = nr - HELP_BOTTOM_MARGIN - HELP_BODY_ROW - 1;
cls();
- drawbox(0, 0, nr, nc - 1, HELPPAGE, 0x07, HELPBOX);
+ drawbox(0, 0, nr, nc - 1, 0x07);
- drawhorizline(2, 0, nc - 1, HELPPAGE, 0x07, HELPBOX, 0); // dumb==0
+ drawhorizline(2, 0, nc - 1, 0x07, 0); // dumb==0
if (filename == NULL) { // print file contents
- gotoxy(HELP_BODY_ROW, HELP_LEFT_MARGIN, HELPPAGE);
- cswprint("Filename not given", 0x07, HELP_LEFT_MARGIN);
+ gotoxy(HELP_BODY_ROW, HELP_LEFT_MARGIN);
+ csprint("Filename not given", 0x07);
while (1) {
inputc(&scan);
if (scan == ESCAPE)
@@ -112,8 +112,8 @@ void showhelp(const char *filename)
if (rv < 0) { // Error reading file or no such file
sprintf(line, "Error reading file or file not found\n file=%s",
filename);
- gotoxy(HELP_BODY_ROW, HELP_LEFT_MARGIN, HELPPAGE);
- cswprint(line, 0x07, HELP_LEFT_MARGIN);
+ gotoxy(HELP_BODY_ROW, HELP_LEFT_MARGIN);
+ csprint(line, 0x07);
while (1) {
inputc(&scan);
if (scan == ESCAPE)
@@ -128,7 +128,7 @@ void showhelp(const char *filename)
*text++ = '\0'; // end the title string and increment text
// Now we have a file just print it.
- gotoxy(1, (nc - strlen(title)) / 2, HELPPAGE);
+ gotoxy(1, (nc - strlen(title)) / 2);
csprint(title, 0x07);
numlines = countlines(text);
curr_line = 0;
@@ -136,16 +136,16 @@ void showhelp(const char *filename)
while (scan != ESCAPE) {
printtext(text, curr_line);
- gotoxy(HELP_BODY_ROW - 1, nc - HELP_RIGHT_MARGIN, HELPPAGE);
+ gotoxy(HELP_BODY_ROW - 1, nc - HELP_RIGHT_MARGIN);
if (curr_line > 0)
- putch(HELP_MORE_ABOVE, 0x07, HELPPAGE);
+ putch(HELP_MORE_ABOVE, 0x07);
else
- putch(' ', 0x07, HELPPAGE);
- gotoxy(nr - HELP_BOTTOM_MARGIN + 1, nc - HELP_RIGHT_MARGIN, HELPPAGE);
+ putch(' ', 0x07);
+ gotoxy(nr - HELP_BOTTOM_MARGIN + 1, nc - HELP_RIGHT_MARGIN);
if (curr_line < numlines - ph)
- putch(HELP_MORE_BELOW, 0x07, HELPPAGE);
+ putch(HELP_MORE_BELOW, 0x07);
else
- putch(' ', 0x07, HELPPAGE);
+ putch(' ', 0x07);
inputc(&scan); // wait for user keypress
@@ -182,12 +182,9 @@ void showhelp(const char *filename)
void runhelp(const char *filename)
{
- char dp;
char fullname[HELPDIRLEN + 16];
- dp = getdisppage();
- if (dp != HELPPAGE)
- setdisppage(HELPPAGE);
+ cls();
cursoroff();
if (helpbasedir[0] != 0) {
strcpy(fullname, helpbasedir);
@@ -196,8 +193,6 @@ void runhelp(const char *filename)
showhelp(fullname);
} else
showhelp(filename); // Assume filename is absolute
- if (dp != HELPPAGE)
- setdisppage(dp);
}
void runhelpsystem(unsigned int helpid)
diff --git a/com32/cmenu/libmenu/menu.c b/com32/cmenu/libmenu/menu.c
index 03e83672..b60e7b7a 100644
--- a/com32/cmenu/libmenu/menu.c
+++ b/com32/cmenu/libmenu/menu.c
@@ -90,7 +90,6 @@ char getch(char *scan)
*/
void printmenuitem(const char *str, uchar * attr)
{
- uchar page = getdisppage();
int hlite = NOHLITE; // Initially no highlighting
while (*str) {
@@ -104,7 +103,7 @@ void printmenuitem(const char *str, uchar * attr)
hlite = NOHLITE;
break;
default:
- putch(*str, attr[hlite], page);
+ putch(*str, attr[hlite]);
}
str++;
}
@@ -160,12 +159,12 @@ void printmenu(pt_menu menu, int curr, uchar top, uchar left, uchar first)
menuwidth = menu->menuwidth + 3;
clearwindow(top, left - 2, top + numitems + 1, left + menuwidth + 1,
- ms->menupage, ms->fillchar, ms->shadowattr);
+ ms->fillchar, ms->shadowattr);
drawbox(top - 1, left - 3, top + numitems, left + menuwidth,
- ms->menupage, ms->normalattr[NOHLITE], ms->menubt);
+ ms->normalattr[NOHLITE]);
// Menu title
x = (menuwidth - strlen(menu->title) - 1) >> 1;
- gotoxy(top - 1, left + x, ms->menupage);
+ gotoxy(top - 1, left + x);
printmenuitem(menu->title, ms->normalattr);
row = -1; // 1 less than inital value of x
for (x = first; x < menu->numitems; x++) {
@@ -219,14 +218,14 @@ void printmenu(pt_menu menu, int curr, uchar top, uchar left, uchar first)
default: // Just to keep the compiler happy
break;
}
- gotoxy(top + row, left - 2, ms->menupage);
- cprint(ms->spacechar, attr[NOHLITE], menuwidth + 2, ms->menupage); // Wipe area with spaces
- gotoxy(top + row, left - 2, ms->menupage);
+ gotoxy(top + row, left - 2);
+ cprint(ms->spacechar, attr[NOHLITE], menuwidth + 2); // Wipe area with spaces
+ gotoxy(top + row, left - 2);
csprint(fchar, attr[NOHLITE]); // Print first part
- gotoxy(top + row, left, ms->menupage);
+ gotoxy(top + row, left);
printmenuitem(str, attr); // Print main part
- gotoxy(top + row, left + menuwidth - 1, ms->menupage); // Last char if any
- csprint(lchar, attr[NOHLITE]); // Print first part
+ gotoxy(top + row, left + menuwidth - 1); // Last char if any
+ csprint(lchar, attr[NOHLITE]); // Print last part
}
// Check if we need to MOREABOVE and MOREBELOW to be added
// reuse x
@@ -235,21 +234,21 @@ void printmenu(pt_menu menu, int curr, uchar top, uchar left, uchar first)
if (!isvisible(menu, first, x)) // There is more above
{
row = 1;
- gotoxy(top, left + menuwidth, ms->menupage);
- cprint(MOREABOVE, ms->normalattr[NOHLITE], 1, ms->menupage);
+ gotoxy(top, left + menuwidth);
+ cprint(MOREABOVE, ms->normalattr[NOHLITE], 1);
}
x = prev_visible_sep(menu, menu->numitems); // last item
if (!isvisible(menu, first, x)) // There is more above
{
row = 1;
- gotoxy(top + numitems - 1, left + menuwidth, ms->menupage);
- cprint(MOREBELOW, ms->normalattr[NOHLITE], 1, ms->menupage);
+ gotoxy(top + numitems - 1, left + menuwidth);
+ cprint(MOREBELOW, ms->normalattr[NOHLITE], 1);
}
// Add a scroll box
x = ((numitems - 1) * curr) / (menu->numitems);
if ((x > 0) && (row == 1)) {
- gotoxy(top + x, left + menuwidth, ms->menupage);
- cprint(SCROLLBOX, ms->normalattr[NOHLITE], 1, ms->menupage);
+ gotoxy(top + x, left + menuwidth);
+ cprint(SCROLLBOX, ms->normalattr[NOHLITE], 1);
}
if (ms->handler)
ms->handler(ms, menu->items[curr]);
@@ -273,14 +272,14 @@ void printradiomenu(pt_menu menu, int curr, uchar top, uchar left, int first)
menuwidth = menu->menuwidth + 3;
clearwindow(top, left - 2, top + numitems + 1, left + menuwidth + 1,
- ms->menupage, ms->fillchar, ms->shadowattr);
+ ms->fillchar, ms->shadowattr);
drawbox(top - 1, left - 3, top + numitems, left + menuwidth,
- ms->menupage, ms->normalattr[NOHLITE], ms->menubt);
+ ms->normalattr[NOHLITE]);
memset(sep, ms->box_horiz, menuwidth); // String containing the seperator string
sep[menuwidth - 1] = 0;
// Menu title
x = (menuwidth - strlen(menu->title) - 1) >> 1;
- gotoxy(top - 1, left + x, ms->menupage);
+ gotoxy(top - 1, left + x);
printmenuitem(menu->title, ms->normalattr);
row = -1; // 1 less than inital value of x
for (x = first; x < menu->numitems; x++) {
@@ -316,13 +315,13 @@ void printradiomenu(pt_menu menu, int curr, uchar top, uchar left, int first)
default: // To keep the compiler happy
break;
}
- gotoxy(top + row, left - 2, ms->menupage);
- cprint(ms->spacechar, attr[NOHLITE], menuwidth + 2, ms->menupage); // Wipe area with spaces
- gotoxy(top + row, left - 2, ms->menupage);
+ gotoxy(top + row, left - 2);
+ cprint(ms->spacechar, attr[NOHLITE], menuwidth + 2); // Wipe area with spaces
+ gotoxy(top + row, left - 2);
csprint(fchar, attr[NOHLITE]); // Print first part
- gotoxy(top + row, left, ms->menupage);
+ gotoxy(top + row, left);
printmenuitem(str, attr); // Print main part
- gotoxy(top + row, left + menuwidth - 1, ms->menupage); // Last char if any
+ gotoxy(top + row, left + menuwidth - 1); // Last char if any
csprint(lchar, attr[NOHLITE]); // Print last part
}
// Check if we need to MOREABOVE and MOREBELOW to be added
@@ -332,21 +331,21 @@ void printradiomenu(pt_menu menu, int curr, uchar top, uchar left, int first)
if (!isvisible(menu, first, x)) // There is more above
{
row = 1;
- gotoxy(top, left + menuwidth, ms->menupage);
- cprint(MOREABOVE, ms->normalattr[NOHLITE], 1, ms->menupage);
+ gotoxy(top, left + menuwidth);
+ cprint(MOREABOVE, ms->normalattr[NOHLITE], 1);
}
x = prev_visible_sep(menu, menu->numitems); // last item
if (!isvisible(menu, first, x)) // There is more above
{
row = 1;
- gotoxy(top + numitems - 1, left + menuwidth, ms->menupage);
- cprint(MOREBELOW, ms->normalattr[NOHLITE], 1, ms->menupage);
+ gotoxy(top + numitems - 1, left + menuwidth);
+ cprint(MOREBELOW, ms->normalattr[NOHLITE], 1);
}
// Add a scroll box
x = ((numitems - 1) * curr) / (menu->numitems);
if ((x > 0) && (row == 1)) {
- gotoxy(top + x, left + menuwidth, ms->menupage);
- cprint(SCROLLBOX, ms->normalattr[NOHLITE], 1, ms->menupage);
+ gotoxy(top + x, left + menuwidth);
+ cprint(SCROLLBOX, ms->normalattr[NOHLITE], 1);
}
if (ms->handler)
ms->handler(ms, menu->items[curr]);
@@ -356,8 +355,8 @@ void cleanupmenu(pt_menu menu, uchar top, uchar left, int numitems)
{
if (numitems > menu->menuheight)
numitems = menu->menuheight;
- clearwindow(top, left - 2, top + numitems + 1, left + menu->menuwidth + 4, ms->menupage, ms->fillchar, ms->fillattr); // Clear the shadow
- clearwindow(top - 1, left - 3, top + numitems, left + menu->menuwidth + 3, ms->menupage, ms->fillchar, ms->fillattr); // main window
+ clearwindow(top, left - 2, top + numitems + 1, left + menu->menuwidth + 4, ms->fillchar, ms->fillattr); // Clear the shadow
+ clearwindow(top - 1, left - 3, top + numitems, left + menu->menuwidth + 3, ms->fillchar, ms->fillattr); // main window
}
/* Handle a radio menu */
@@ -371,15 +370,15 @@ pt_menuitem getradiooption(pt_menu menu, uchar top, uchar left, uchar startopt)
numitems = calc_visible(menu, 0);
// Setup status line
- gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage);
- cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols, ms->menupage);
+ gotoxy(ms->minrow + ms->statline, ms->mincol);
+ cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols);
// Initialise current menu item
curr = next_visible(menu, startopt);
- gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage);
- cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols, 1);
- gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage);
+ gotoxy(ms->minrow + ms->statline, ms->mincol);
+ cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols);
+ gotoxy(ms->minrow + ms->statline, ms->mincol);
printmenuitem(menu->items[curr]->status, ms->statusattr);
first = calc_first_early(menu, curr);
while (1) // Forever
@@ -448,9 +447,8 @@ pt_menuitem getradiooption(pt_menu menu, uchar top, uchar left, uchar startopt)
break;
}
// Update status line
- gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage);
- cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols,
- ms->menupage);
+ gotoxy(ms->minrow + ms->statline, ms->mincol);
+ cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols);
printmenuitem(menu->items[curr]->status, ms->statusattr);
}
return NULL; // Should never come here
@@ -468,15 +466,15 @@ pt_menuitem getmenuoption(pt_menu menu, uchar top, uchar left, uchar startopt)
numitems = calc_visible(menu, 0);
// Setup status line
- gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage);
- cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols, ms->menupage);
+ gotoxy(ms->minrow + ms->statline, ms->mincol);
+ cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols);
// Initialise current menu item
curr = next_visible(menu, startopt);
- gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage);
- cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols, 1);
- gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage);
+ gotoxy(ms->minrow + ms->statline, ms->mincol);
+ cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols);
+ gotoxy(ms->minrow + ms->statline, ms->mincol);
printmenuitem(menu->items[curr]->status, ms->statusattr);
first = calc_first_early(menu, curr);
while (1) // Forever
@@ -584,9 +582,11 @@ pt_menuitem getmenuoption(pt_menu menu, uchar top, uchar left, uchar startopt)
break;
}
// Update status line
- gotoxy(ms->minrow + ms->statline, ms->mincol, ms->menupage);
- cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols,
- ms->menupage);
+ /* Erase the previous status */
+ gotoxy(ms->minrow + ms->statline, ms->mincol);
+ cprint(ms->spacechar, ms->statusattr[NOHLITE], ms->numcols);
+ /* Print the new status */
+ gotoxy(ms->minrow + ms->statline, ms->mincol);
printmenuitem(menu->items[curr]->status, ms->statusattr);
}
return NULL; // Should never come here
@@ -640,7 +640,7 @@ startover:
// itemdata.submenunum = itemdata.radiomenunum (since enum data type)
if (opt->itemdata.submenunum >= ms->nummenus) // This is Bad....
{
- gotoxy(12, 12, ms->menupage); // Middle of screen
+ gotoxy(12, 12); // Middle of screen
csprint("ERROR: Invalid submenu requested.", 0x07);
cleanupmenu(cmenu, top, left, calc_visible(cmenu, 0));
return NULL; // Pretend user hit esc
@@ -725,20 +725,18 @@ void fix_submenus()
pt_menuitem showmenus(uchar startmenu)
{
pt_menuitem rv;
- uchar oldpage, tpos;
+ uchar tpos;
fix_submenus(); // Fix submenu numbers incase nick names were used
// Setup screen for menusystem
- oldpage = getdisppage();
- setdisppage(ms->menupage);
cls();
clearwindow(ms->minrow, ms->mincol, ms->maxrow, ms->maxcol,
- ms->menupage, ms->fillchar, ms->fillattr);
+ ms->fillchar, ms->fillattr);
tpos = (ms->numcols - strlen(ms->title) - 1) >> 1; // center it on line
- gotoxy(ms->minrow, ms->mincol, ms->menupage);
- cprint(ms->tfillchar, ms->titleattr, ms->numcols, ms->menupage);
- gotoxy(ms->minrow, ms->mincol + tpos, ms->menupage);
+ gotoxy(ms->minrow, ms->mincol);
+ cprint(ms->tfillchar, ms->titleattr, ms->numcols);
+ gotoxy(ms->minrow, ms->mincol + tpos);
csprint(ms->title, ms->titleattr);
cursoroff(); // Doesn't seem to work?
@@ -749,10 +747,7 @@ pt_menuitem showmenus(uchar startmenu)
// Hide the garbage we left on the screen
cursoron();
- if (oldpage == ms->menupage)
cls();
- else
- setdisppage(oldpage);
// Return user choice
return rv;
@@ -1332,9 +1327,7 @@ void append_line_helper(int menunum, char *line)
pt_menuitem mi, ri;
char *app;
int ctr;
- char dp;
- dp = getdisppage();
menu = ms->menus[menunum];
for (ctr = 0; ctr < (int)menu->numitems; ctr++) {
mi = menu->items[ctr];
diff --git a/com32/cmenu/libmenu/tui.c b/com32/cmenu/libmenu/tui.c
index a8ca1cd5..e256502a 100644
--- a/com32/cmenu/libmenu/tui.c
+++ b/com32/cmenu/libmenu/tui.c
@@ -20,7 +20,6 @@ com32sys_t inreg, outreg; // Global register sets for use
char bkspstr[] = " \b$";
char eolstr[] = "\n$";
-#define GETSTRATTR 0x07
// Reads a line of input from stdin. Replace CR with NUL byte
// password <> 0 implies not echoed on screen
@@ -34,14 +33,12 @@ void getuserinput(char *stra, unsigned int size, unsigned int password,
char *p, *q; // p = current char of string, q = tmp
char *last; // The current last char of string
char *str; // pointer to string which is going to be allocated
- char page;
char row, col;
char start, end; // Cursor shape
char fudge; // How many chars should be removed from output
char insmode; // Are we in insert or overwrite
- page = getdisppage();
- getpos(&row, &col, page); // Get current position
+ getpos(&row, &col, 0); // Get current position
getcursorshape(&start, &end);
insmode = 1;
@@ -68,7 +65,7 @@ void getuserinput(char *stra, unsigned int size, unsigned int password,
// col is the corresponding column on the screen
if (password == 0) // Not a password, print initial value
{
- gotoxy(row, col, page);
+ gotoxy(row, col);
csprint(str, GETSTRATTR);
}
while (1) { // Do forever
@@ -195,11 +192,11 @@ void getuserinput(char *stra, unsigned int size, unsigned int password,
}
// Now the string has been modified, print it
if (password == 0) {
- gotoxy(row, col, page);
+ gotoxy(row, col);
csprint(str, GETSTRATTR);
if (fudge > 0)
- cprint(' ', GETSTRATTR, fudge, page);
- gotoxy(row, col + (p - str), page);
+ cprint(' ', GETSTRATTR, fudge);
+ gotoxy(row, col + (p - str));
}
}
*p = '\0';
@@ -212,16 +209,6 @@ void getuserinput(char *stra, unsigned int size, unsigned int password,
free(str);
}
-void clearwindow(char top, char left, char bot, char right, char page,
- char fillchar, char fillattr)
-{
- char x;
- for (x = top; x < bot + 1; x++) {
- gotoxy(x, left, page);
- cprint(fillchar, fillattr, right - left + 1, page);
- }
-}
-
//////////////////////////////Box Stuff
// This order of numbers must match
@@ -270,36 +257,35 @@ unsigned char *getboxchars(boxtype bt)
}
// Draw box and lines
-void drawbox(char top, char left, char bot, char right,
- char page, char attr, boxtype bt)
+void drawbox(const char top, const char left, const char bot,
+ const char right, const char attr)
{
unsigned char x;
putchar(SO);
// Top border
- gotoxy(top, left, page);
- cprint(TOP_LEFT_CORNER_BORDER, attr, 1, page);
- cprint(TOP_BORDER, attr, right - left - 1, page);
- cprint(TOP_RIGHT_CORNER_BORDER, attr, 1, page);
+ gotoxy(top, left);
+ putch(TOP_LEFT_CORNER_BORDER, attr);
+ cprint(TOP_BORDER, attr, right - left - 1);
+ putch(TOP_RIGHT_CORNER_BORDER, attr);
// Bottom border
- gotoxy(bot, left, page);
- cprint(BOTTOM_LEFT_CORNER_BORDER, attr, 1, page);
- cprint(BOTTOM_BORDER, attr, right - left - 1, page);
- cprint(BOTTOM_RIGHT_CORNER_BORDER, attr, 1, page);
+ gotoxy(bot, left);
+ putch(BOTTOM_LEFT_CORNER_BORDER, attr);
+ cprint(BOTTOM_BORDER, attr, right - left - 1);
+ putch(BOTTOM_RIGHT_CORNER_BORDER, attr);
// Left & right borders
for (x = top + 1; x < bot; x++) {
- gotoxy(x, left, page);
- cprint(LEFT_BORDER, attr, 1, page);
- gotoxy(x, right, page);
- cprint(RIGHT_BORDER, attr, 1, page);
+ gotoxy(x, left);
+ putch(LEFT_BORDER, attr);
+ gotoxy(x, right);
+ putch(RIGHT_BORDER, attr);
}
putchar(SI);
}
-void drawhorizline(char top, char left, char right, char page, char attr,
- boxtype bt, char dumb)
+void drawhorizline(const char top, const char left, const char right,
+ const char attr, char dumb)
{
unsigned char start, end;
- unsigned char *box_chars = getboxchars(bt);
if (dumb == 0) {
start = left + 1;
end = right - 1;
@@ -307,14 +293,14 @@ void drawhorizline(char top, char left, char right, char page, char attr,
start = left;
end = right;
}
- gotoxy(top, start, page);
+ gotoxy(top, start);
putchar(SO);
- cprint(MIDDLE_BORDER, attr, end - start + 1, page);
+ cprint(MIDDLE_BORDER, attr, end - start + 1);
if (dumb == 0) {
- gotoxy(top, left, page);
- cprint(MIDDLE_BORDER, attr, 1, page);
- gotoxy(top, right, page);
- cprint(MIDDLE_BORDER, attr, 1, page);
+ gotoxy(top, left);
+ putch(MIDDLE_BORDER, attr);
+ gotoxy(top, right);
+ putch(MIDDLE_BORDER, attr);
}
putchar(SI);
}
diff --git a/com32/cmenu/libmenu/tui.h b/com32/cmenu/libmenu/tui.h
index 54bce86e..c72a41d2 100644
--- a/com32/cmenu/libmenu/tui.h
+++ b/com32/cmenu/libmenu/tui.h
@@ -41,23 +41,7 @@
// CHRELATTR = ^N, CHABSATTR = ^O
#define CHABSATTR 15
#define CHRELATTR 14
-
-void clearwindow(char top, char left, char bot, char right,
- char page, char fillchar, char fillattr);
-
-/*
- * Clears the entire screen
- *
- * Note: when initializing xterm, one has to specify that
- * G1 points to the alternate character set (this is not true
- * by default). Without the initial printf "\033)0", line drawing
- * characters won't be displayed.
- */
-static inline void cls(void)
-{
- return fputs("\033e\033%@\033)0\033(B\1#0\033[?25l\033[2J", stdout);
-}
-
+#define GETSTRATTR 0x07
// Generic user input,
// password = 0 iff chars echoed on screen
@@ -101,14 +85,14 @@ typedef enum { BOX_SINSIN, BOX_DBLDBL, BOX_SINDBL, BOX_DBLSIN } boxtype;
unsigned char *getboxchars(boxtype bt);
-void drawbox(char top, char left, char bot, char right,
- char page, char attr, boxtype bt);
+void drawbox(const char, const char, const char, const char,
+ const char);
// Draw a horizontal line
// dumb == 1, means just draw the line
// dumb == 0 means check the first and last positions and depending on what is
// currently on the screen make it a LTRT and/or RTLT appropriately.
-void drawhorizline(char top, char left, char right, char page, char attr,
- boxtype bt, char dumb);
+void drawhorizline(const char, const char, const char, const char,
+ const char dumb);
#endif