Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/menuc If a menu starts with disabled options, skip t...



details:   https://anonhg.NetBSD.org/src/rev/691f67bf988c
branches:  trunk
changeset: 447149:691f67bf988c
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Jan 02 16:32:59 2019 +0000

description:
If a menu starts with disabled options, skip those and start at the
first enabled one instead.

diffstat:

 usr.bin/menuc/menu_sys.def |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (30 lines):

diff -r 0168ca15a9a0 -r 691f67bf988c usr.bin/menuc/menu_sys.def
--- a/usr.bin/menuc/menu_sys.def        Wed Jan 02 16:27:04 2019 +0000
+++ b/usr.bin/menuc/menu_sys.def        Wed Jan 02 16:32:59 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: menu_sys.def,v 1.60 2018/11/21 20:04:48 martin Exp $   */
+/*     $NetBSD: menu_sys.def,v 1.61 2019/01/02 16:32:59 martin Exp $   */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -684,12 +684,16 @@
        if (m == NULL)
                return;
 
-       /* Default to select option 0 and display from 0 */
+       /* Default to select option 0 and display from 0, skip any
+        * disabled options at the top of the menu. */
        m->topline = 0;
-       if ((m->mopt & (MC_DFLTEXIT | MC_NOEXITOPT)) == MC_DFLTEXIT)
+       if ((m->mopt & (MC_DFLTEXIT | MC_NOEXITOPT)) == MC_DFLTEXIT) {
                m->cursel = -1;
-       else
-               m->cursel = 0;
+       } else {
+               for (m->cursel = 0; m->cursel < m->numopts; m->cursel++)
+                       if ((m->opts[m->cursel].opt_flags & OPT_IGNORE) == 0)
+                               break;
+       }
 
        for (;;) {
                if (isendwin())



Home | Main Index | Thread Index | Old Index