aboutsummaryrefslogtreecommitdiffstats
path: root/com32/cmenu
diff options
context:
space:
mode:
authorPierre-Alexandre Meyer <pierre@mouraf.org>2009-08-29 20:53:38 -0700
committerPierre-Alexandre Meyer <pierre@mouraf.org>2009-09-01 11:43:38 -0700
commitf7c2dd07b141050f6401622382be26fe9442d949 (patch)
tree4cd28d3eb45fd8fe102586073fd1ec33359c5bba /com32/cmenu
parente9a9e808f2705766ef7f80b0970401dbeb690433 (diff)
downloadsyslinux-f7c2dd07b141050f6401622382be26fe9442d949.tar.gz
syslinux-f7c2dd07b141050f6401622382be26fe9442d949.tar.xz
syslinux-f7c2dd07b141050f6401622382be26fe9442d949.zip
cmenu: fix menu separators
Use the alternate character set to draw horizontal lines (menu separator). Refactor the c*print functions in the same time as they were severely broken. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
Diffstat (limited to 'com32/cmenu')
-rw-r--r--com32/cmenu/libmenu/com32io.c9
-rw-r--r--com32/cmenu/libmenu/com32io.h8
-rw-r--r--com32/cmenu/libmenu/menu.c34
-rw-r--r--com32/cmenu/libmenu/tui.c45
-rw-r--r--com32/cmenu/libmenu/tui.h3
5 files changed, 40 insertions, 59 deletions
diff --git a/com32/cmenu/libmenu/com32io.c b/com32/cmenu/libmenu/com32io.c
index f59baebb..60789f82 100644
--- a/com32/cmenu/libmenu/com32io.c
+++ b/com32/cmenu/libmenu/com32io.c
@@ -13,6 +13,7 @@
#include <string.h>
#include <com32.h>
#include "com32io.h"
+#include "tui.h"
#include "syslnx.h"
com32sys_t inreg, outreg; // Global register sets for use
@@ -71,6 +72,14 @@ void cprint(char chr, char attr, unsigned int times, char disppage)
cprint_vga2ansi(chr, attr);
}
+void csprint(const char *str, char attr)
+{
+ while (*str) {
+ cprint(*str, attr, 1, 0);
+ str++;
+ }
+}
+
void setdisppage(char num) // Set the display page to specified number
{
REG_AH(inreg) = 0x05;
diff --git a/com32/cmenu/libmenu/com32io.h b/com32/cmenu/libmenu/com32io.h
index a73b9f3d..938eceeb 100644
--- a/com32/cmenu/libmenu/com32io.h
+++ b/com32/cmenu/libmenu/com32io.h
@@ -30,16 +30,18 @@ static inline beep()
/* BIOS Assisted output routines */
-void cswprint(const char *str, char attr, char left);
// Print a C str (NUL-terminated) respecting the left edge of window
// i.e. \n in str will move cursor to column left
// Print a C str (NUL-terminated)
-static inline void csprint(const char *str, char attr)
+void csprint(const char *str, char attr);
+
+static inline void cswprint(const char *str, char attr, char left)
{
- cswprint(str, attr, 0);
+ csprint(str, attr);
}
+
void cprint(char chr, char attr, unsigned int times, char disppage); // Print a char
void setdisppage(char num); // Set the display page to specified number
diff --git a/com32/cmenu/libmenu/menu.c b/com32/cmenu/libmenu/menu.c
index a00c0ce7..03e83672 100644
--- a/com32/cmenu/libmenu/menu.c
+++ b/com32/cmenu/libmenu/menu.c
@@ -148,10 +148,10 @@ void printmenu(pt_menu menu, int curr, uchar top, uchar left, uchar first)
{
int x, row; // x = index, row = position from top
int numitems, menuwidth;
- char fchar[5], lchar[5]; // The first and last char in for each entry
+ char fchar[6], lchar[6]; // The first and last char in for each entry
const char *str; // and inbetween the item or a seperator is printed
+ char sep[MENULEN]; // Separator (OPT_SEP)
uchar *attr; // attribute attr
- char sep[MENULEN]; // and inbetween the item or a seperator is printed
pt_menuitem ci;
numitems = calc_visible(menu, first);
@@ -163,8 +163,6 @@ void printmenu(pt_menu menu, int curr, uchar top, uchar left, uchar first)
ms->menupage, ms->fillchar, ms->shadowattr);
drawbox(top - 1, left - 3, top + numitems, left + menuwidth,
ms->menupage, ms->normalattr[NOHLITE], ms->menubt);
- 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);
@@ -200,18 +198,22 @@ void printmenu(pt_menu menu, int curr, uchar top, uchar left, uchar first)
lchar[1] = 0;
break;
case OPT_SEP:
- fchar[0] = '\b';
- fchar[1] = ms->box_ltrt;
- fchar[2] = ms->box_horiz;
- fchar[3] = ms->box_horiz;
- fchar[4] = 0;
- lchar[0] = ms->box_horiz;
- lchar[1] = ms->box_rtlt;
- lchar[2] = 0;
- str = sep;
- break;
+ fchar[0] = '\b';
+ fchar[1] = SO;
+ fchar[2] = LEFT_MIDDLE_BORDER;
+ fchar[3] = MIDDLE_BORDER;
+ fchar[4] = MIDDLE_BORDER;
+ fchar[5] = 0;
+ memset(sep, MIDDLE_BORDER, menuwidth);
+ sep[menuwidth - 1] = 0;
+ str = sep;
+ lchar[0] = MIDDLE_BORDER;
+ lchar[1] = RIGHT_MIDDLE_BORDER;
+ lchar[2] = SI;
+ lchar[3] = 0;
+ break;
case OPT_EXITMENU:
- fchar[0] = EXITMENUCHAR;
+ fchar[0] = '<';
fchar[1] = 0;
break;
default: // Just to keep the compiler happy
@@ -224,7 +226,7 @@ void printmenu(pt_menu menu, int curr, uchar top, uchar left, uchar first)
gotoxy(top + row, left, ms->menupage);
printmenuitem(str, attr); // Print main part
gotoxy(top + row, left + menuwidth - 1, ms->menupage); // Last char if any
- fputs(lchar, stdout); // Print last part
+ csprint(lchar, attr[NOHLITE]); // Print first part
}
// Check if we need to MOREABOVE and MOREBELOW to be added
// reuse x
diff --git a/com32/cmenu/libmenu/tui.c b/com32/cmenu/libmenu/tui.c
index d4e08286..a8ca1cd5 100644
--- a/com32/cmenu/libmenu/tui.c
+++ b/com32/cmenu/libmenu/tui.c
@@ -212,43 +212,6 @@ void getuserinput(char *stra, unsigned int size, unsigned int password,
free(str);
}
-/* Print a C string (NUL-terminated) */
-void cswprint(const char *str, char attr, char left)
-{
- char page = getdisppage();
- char newattr = 0, cha, chb;
-
- while (*str) {
- switch (*str) {
- case BELL: // Bell Char
- beep();
- break;
- case CHRELATTR: // change attribute (relatively)
- case CHABSATTR: // change attribute (absolute)
- cha = *(str + 1);
- chb = *(str + 2);
- if ((((cha >= '0') && (cha <= '9')) || ((cha >= 'A') && (cha <= 'F'))) && (((chb >= '0') && (chb <= '9')) || ((chb >= 'A') && (chb <= 'F')))) // Next two chars are legal
- {
- if ((cha >= 'A') && (cha <= 'F'))
- cha = cha - 'A' + 10;
- else
- cha = cha - '0';
- if ((chb >= 'A') && (chb <= 'F'))
- chb = chb - 'A' + 10;
- else
- chb = chb - '0';
- newattr = (cha << 4) + chb;
- attr = (*str == CHABSATTR ? newattr : attr ^ newattr);
- str += 2; // Will be incremented again later
- }
- break;
- default:
- cprint(*str, attr, 1, page);
- }
- str++;
- }
-}
-
void clearwindow(char top, char left, char bot, char right, char page,
char fillchar, char fillattr)
{
@@ -345,11 +308,13 @@ void drawhorizline(char top, char left, char right, char page, char attr,
end = right;
}
gotoxy(top, start, page);
- cprint(box_chars[BOX_HORIZ], attr, end - start + 1, page);
+ putchar(SO);
+ cprint(MIDDLE_BORDER, attr, end - start + 1, page);
if (dumb == 0) {
gotoxy(top, left, page);
- cprint(box_chars[BOX_LTRT], attr, 1, page);
+ cprint(MIDDLE_BORDER, attr, 1, page);
gotoxy(top, right, page);
- cprint(box_chars[BOX_RTLT], attr, 1, page);
+ cprint(MIDDLE_BORDER, attr, 1, page);
}
+ putchar(SI);
}
diff --git a/com32/cmenu/libmenu/tui.h b/com32/cmenu/libmenu/tui.h
index 5cf5dd7a..54bce86e 100644
--- a/com32/cmenu/libmenu/tui.h
+++ b/com32/cmenu/libmenu/tui.h
@@ -33,6 +33,9 @@
#define BOTTOM_RIGHT_CORNER_BORDER '\152'
#define LEFT_BORDER '\170'
#define RIGHT_BORDER '\170'
+#define LEFT_MIDDLE_BORDER '\164'
+#define MIDDLE_BORDER '\161'
+#define RIGHT_MIDDLE_BORDER '\165'
#define BELL 0x07
// CHRELATTR = ^N, CHABSATTR = ^O