aboutsummaryrefslogtreecommitdiffstats
path: root/com32/cmenu/libmenu/help.c
diff options
context:
space:
mode:
authorPierre-Alexandre Meyer <pierre@mouraf.org>2009-09-03 14:16:17 -0700
committerPierre-Alexandre Meyer <pierre@mouraf.org>2009-09-03 14:16:17 -0700
commit6e64433a5db40467759ca858d8f998d52d921b5f (patch)
tree7fbf0d45f647465fb34894c2c4c9d0367cdcf091 /com32/cmenu/libmenu/help.c
parentbe67a5d4fa9705b36fe36bebed708a0a2e95946b (diff)
downloadsyslinux-6e64433a5db40467759ca858d8f998d52d921b5f.tar.gz
syslinux-6e64433a5db40467759ca858d8f998d52d921b5f.tar.xz
syslinux-6e64433a5db40467759ca858d8f998d52d921b5f.zip
cmenu: use getscreensize to access number of rows/columns
The simple menu system already uses getscreensize. Another step towards unification. Impact: exported getnumcols and getnumrows are now deprecated. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
Diffstat (limited to 'com32/cmenu/libmenu/help.c')
-rw-r--r--com32/cmenu/libmenu/help.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/com32/cmenu/libmenu/help.c b/com32/cmenu/libmenu/help.c
index b0011c0d..22f6f3dc 100644
--- a/com32/cmenu/libmenu/help.c
+++ b/com32/cmenu/libmenu/help.c
@@ -16,10 +16,11 @@
#include "com32io.h"
#include <syslinux/loadfile.h> // to read entire file into memory
+int nc, nr; // Number of columns/rows of the screen
char helpbasedir[HELPDIRLEN]; // name of help directory limited to HELPDIRLEN
// Find the occurence of the count'th \n in buffer (or NULL) if not found
-char *findline(char *buffer, int count)
+static char *findline(char *buffer, int count)
{
int ctr;
char *p = buffer - 1;
@@ -35,7 +36,7 @@ char *findline(char *buffer, int count)
}
// return the number of lines in buffer
-int countlines(char *buffer)
+static int countlines(char *buffer)
{
int ans;
const char *p;
@@ -50,14 +51,14 @@ int countlines(char *buffer)
}
// Print numlines of text starting from buf
-void printtext(char *buf, int from)
+static void printtext(char *buf, int from)
{
char *p, *f;
- char right, bot, nlines;
+ int right, bot, nlines;
// clear window to print
- right = getnumcols() - HELP_RIGHT_MARGIN;
- bot = getnumrows() - HELP_BOTTOM_MARGIN;
+ right = nc - HELP_RIGHT_MARGIN;
+ bot = nr - HELP_BOTTOM_MARGIN;
nlines = bot - HELP_BODY_ROW + 1;
scrollupwindow(HELP_BODY_ROW, HELP_LEFT_MARGIN, bot, right, 0x07, nlines);
@@ -77,7 +78,7 @@ void printtext(char *buf, int from)
void showhelp(const char *filename)
{
- char nc, nr, ph;
+ char ph;
char *title, *text;
union {
char *buffer;
@@ -89,38 +90,25 @@ void showhelp(const char *filename)
char scan;
int rv, numlines, curr_line;
- nc = getnumcols();
- nr = getnumrows();
+ if (getscreensize(1, &nr, &nc)) {
+ /* Unknown screen size? */
+ nc = 80;
+ nr = 24;
+ }
ph = nr - HELP_BOTTOM_MARGIN - HELP_BODY_ROW - 1;
cls();
drawbox(0, 0, nr, nc - 1, 0x07);
drawhorizline(2, 0, nc - 1, 0x07, 0); // dumb==0
if (filename == NULL) { // print file contents
- gotoxy(HELP_BODY_ROW, HELP_LEFT_MARGIN);
- csprint("Filename not given", 0x07);
- while (1) {
- inputc(&scan);
- if (scan == ESCAPE)
- break;
- }
- cls();
- return;
+ strcpy(line, "Filename not given");
+ goto puke;
}
rv = loadfile(filename, (void **)&buf.vbuf, &size); // load entire file into memory
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);
- csprint(line, 0x07);
- while (1) {
- inputc(&scan);
- if (scan == ESCAPE)
- break;
- }
- cls();
- return;
+ sprintf(line, "Error reading file or file not found\n file=%s", filename);
+ goto puke;
}
title = buf.buffer;
@@ -176,8 +164,19 @@ void showhelp(const char *filename)
if (curr_line < 0)
curr_line = 0;
}
+out:
cls();
return;
+
+puke:
+ gotoxy(HELP_BODY_ROW, HELP_LEFT_MARGIN);
+ csprint(line, 0x07);
+ while (1) {
+ inputc(&scan);
+ if (scan == ESCAPE)
+ break;
+ }
+ goto out;
}
void runhelp(const char *filename)