From 18439070c7f39c233e548a1fe93a2910aa8a3c23 Mon Sep 17 00:00:00 2001 From: dsl Date: Mon, 16 Jun 2003 20:57:43 +0000 Subject: [PATCH] Do not let the cursor sit on menu lines that do nothing. (Maybe page up/down should behave similarly - but that one is harder) --- usr.bin/menuc/menu_sys.def | 46 +++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/usr.bin/menuc/menu_sys.def b/usr.bin/menuc/menu_sys.def index 9c78bbb82edf..cd267f45bc9e 100644 --- a/usr.bin/menuc/menu_sys.def +++ b/usr.bin/menuc/menu_sys.def @@ -1,4 +1,4 @@ -/* $NetBSD: menu_sys.def,v 1.40 2003/06/10 17:19:04 dsl Exp $ */ +/* $NetBSD: menu_sys.def,v 1.41 2003/06/16 20:57:43 dsl Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -401,23 +401,41 @@ process_req(menudesc *m, void *arg, int num, int req) return; case REQ_NEXT_ITEM: - if (m->cursel >= m->numopts + hasexit - 1) { - mbeep(); - return; + ch = m->cursel; + for (;;) { + ch++; + if (ch >= m->numopts + hasexit) { + mbeep(); + return; + } + if (hasexit && ch == m->numopts) + break; + if (m->opts[ch].opt_flags & OPT_EXIT + || m->opts[ch].opt_menu != -1 + || m->opts[ch].opt_action != NULL) + break; } - m->cursel++; + m->cursel = ch; if (m->mopt & MC_SCROLL && m->cursel >= m->topline + m->h) - m->topline += 1; + m->topline = m->cursel - m->h + 1; break; case REQ_PREV_ITEM: - if (m->cursel <= 0) { - mbeep(); - return; + ch = m->cursel; + for (;;) { + if (ch <= 0) { + mbeep(); + return; + } + ch--; + if (m->opts[ch].opt_flags & OPT_EXIT + || m->opts[ch].opt_menu != -1 + || m->opts[ch].opt_action != NULL) + break; } - m->cursel--; + m->cursel = ch; if (m->cursel < m->topline) - m->topline -= 1; + m->topline = m->cursel; break; case REQ_HELP: @@ -474,6 +492,12 @@ process_req(menudesc *m, void *arg, int num, int req) mbeep(); return; } + if (!(m->opts[ch].opt_flags & OPT_EXIT) + && m->opts[ch].opt_menu == -1 + && m->opts[ch].opt_action == NULL) { + mbeep(); + return; + } m->cursel = ch; }