summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/console
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-06-02 09:02:12 +0000
committerdteske <dteske@FreeBSD.org>2013-06-02 09:02:12 +0000
commit373aa5232d0043556e802e93d9f70bec70f121c7 (patch)
tree826a3cea2f1f978a5386dfa3b219f0c60dccae42 /usr.sbin/bsdconfig/console
parent5b05f067655217732e94ad77b1c57a3cb7a3945e (diff)
downloadFreeBSD-src-373aa5232d0043556e802e93d9f70bec70f121c7.zip
FreeBSD-src-373aa5232d0043556e802e93d9f70bec70f121c7.tar.gz
Improve the dialog(1) API in dialog.subr by adding f_dialog_default_store()
and f_dialog_default_fetch(). Operating similar to functions introduced by SVN r251236 and r251242, these functions operate as a pair for helping track the default-item data (for the --menu, --checklist, and --radiolist widgets). This replaces the direct usage of a global to store the data with an abstract method for readability and to centralize the code.
Diffstat (limited to 'usr.sbin/bsdconfig/console')
-rwxr-xr-xusr.sbin/bsdconfig/console/console24
1 files changed, 14 insertions, 10 deletions
diff --git a/usr.sbin/bsdconfig/console/console b/usr.sbin/bsdconfig/console/console
index 630d071..6fe5bab 100755
--- a/usr.sbin/bsdconfig/console/console
+++ b/usr.sbin/bsdconfig/console/console
@@ -51,6 +51,7 @@ dialog_menu_main()
local menu_list
local hline="$hline_configure_system_console_settings"
local prompt="$msg_console_menu_text"
+ local defaultitem= # Calculated below
menu_list="
'X $msg_exit' '$msg_exit_this_menu'
@@ -70,23 +71,26 @@ dialog_menu_main()
\"\$hline\" \
$menu_list
+ # Obtain default-item from previously stored selection
+ f_dialog_default_fetch defaultitem
+
local menu_choice
menu_choice=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --default-item \"\$DEFAULTITEM_$$\" \
- --menu \"\$prompt\" \
- $height $width $rows \
- $menu_list \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --default-item \"\$defaultitem\" \
+ --menu \"\$prompt\" \
+ $height $width $rows \
+ $menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
f_dialog_data_sanitize menu_choice
f_dialog_menutag_store "$menu_choice"
- setvar DEFAULTITEM_$$ "$menu_choice"
+ f_dialog_default_store "$menu_choice"
return $retval
}
OpenPOWER on IntegriCloud