aboutsummaryrefslogtreecommitdiffstats
path: root/com32/cmenu/adv_menu.tpl
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/adv_menu.tpl
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/adv_menu.tpl')
-rw-r--r--com32/cmenu/adv_menu.tpl21
1 files changed, 16 insertions, 5 deletions
diff --git a/com32/cmenu/adv_menu.tpl b/com32/cmenu/adv_menu.tpl
index 7e738cc5..22932fcb 100644
--- a/com32/cmenu/adv_menu.tpl
+++ b/com32/cmenu/adv_menu.tpl
@@ -40,6 +40,7 @@ modify this template to suit your needs
#include "com32io.h"
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#define MAX_CMD_LINE_LENGTH 514
@@ -194,7 +195,13 @@ TIMEOUTCODE ontotaltimeout()
void keys_handler(t_menuitem *mi,unsigned int scancode)
{
- char nc;
+ int nc, nr;
+
+ if (getscreensize(1, &nr, &nc)) {
+ /* Unknown screen size? */
+ nc = 80;
+ nr = 24;
+ }
if ( ((scancode >> 8) == F1) && (mi->helpid != 0xFFFF) ) { // If scancode of F1 and non-trivial helpid
runhelpsystem(mi->helpid);
@@ -203,9 +210,8 @@ void keys_handler(t_menuitem *mi,unsigned int scancode)
// If user hit TAB, and item is an "executable" item
// and user has privileges to edit it, edit it in place.
if (((scancode & 0xFF) == 0x09) && (mi->action == OPT_RUN) &&
- (EDIT_ROW < getnumrows()) && (EDIT_ROW > 0) &&
+ (EDIT_ROW < nr) && (EDIT_ROW > 0) &&
(isallowed(username,"editcmd") || isallowed(username,"root"))) {
- nc = getnumcols();
// User typed TAB and has permissions to edit command line
gotoxy(EDIT_ROW,1);
csprint("Command line:",0x07);
@@ -220,14 +226,19 @@ t_handler_return login_handler(t_menuitem *mi)
(void)mi; // Unused
char pwd[40];
char login[40];
- char nc;
+ int nc, nr;
t_handler_return rv;
rv = ACTION_INVALID;
if (PWD_ROW < 0) return rv; // No need to authenticate
if (mi->item == loginstr) { /* User wants to login */
- nc = getnumcols();
+ if (getscreensize(1, &nr, &nc)) {
+ /* Unknown screen size? */
+ nc = 80;
+ nr = 24;
+ }
+
gotoxy(PWD_ROW,1);
csprint("Enter Username: ",0x07);
getstring(login, sizeof username);