summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/networking
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/networking
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/networking')
-rwxr-xr-xusr.sbin/bsdconfig/networking/networking24
1 files changed, 14 insertions, 10 deletions
diff --git a/usr.sbin/bsdconfig/networking/networking b/usr.sbin/bsdconfig/networking/networking
index 13d5018..e1d30cf 100755
--- a/usr.sbin/bsdconfig/networking/networking
+++ b/usr.sbin/bsdconfig/networking/networking
@@ -50,6 +50,7 @@ dialog_menu_main()
{
local menu_list
local hline="$hline_arrows_tab_enter"
+ local defaultitem= # Calculated below
menu_list="
'X' '$msg_exit'
@@ -67,23 +68,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 \"\" \
- $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 \"\" \
+ $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