summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/usermgmt
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/usermgmt
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/usermgmt')
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupinput21
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/userinput21
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/usermgmt28
3 files changed, 38 insertions, 32 deletions
diff --git a/usr.sbin/bsdconfig/usermgmt/groupinput b/usr.sbin/bsdconfig/usermgmt/groupinput
index f1c8d68..ac27c98 100755
--- a/usr.sbin/bsdconfig/usermgmt/groupinput
+++ b/usr.sbin/bsdconfig/usermgmt/groupinput
@@ -228,21 +228,22 @@ while :; do
\"\$hline\" \
$menu_items
+ f_dialog_default_fetch defaultitem
mtag=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --default-item \"\$DEFAULTITEM_$$\" \
- --menu \"\$menu_text\" \
- $height $width $rows \
- $menu_items \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --default-item \"\$defaultitem\" \
+ --menu \"\$menu_text\" \
+ $height $width $rows \
+ $menu_items \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
f_dialog_data_sanitize mtag
- setvar DEFAULTITEM_$$ "$mtag"
+ f_dialog_default_store "$mtag"
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
# Exit if user has either pressed ESC or chosen Cancel/No
diff --git a/usr.sbin/bsdconfig/usermgmt/userinput b/usr.sbin/bsdconfig/usermgmt/userinput
index 7df1993..df79ac5 100755
--- a/usr.sbin/bsdconfig/usermgmt/userinput
+++ b/usr.sbin/bsdconfig/usermgmt/userinput
@@ -391,21 +391,22 @@ while :; do
\"\$hline\" \
$menu_items
+ f_dialog_default_fetch defaultitem
mtag=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --default-item \"\$DEFAULTITEM_$$\" \
- --menu \"\$menu_text\" \
- $height $width $rows \
- $menu_items \
+ --title \"\$DIALOG_TITLE\" \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --default-item \"\$defaultitem\" \
+ --menu \"\$menu_text\" \
+ $height $width $rows \
+ $menu_items \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
retval=$?
f_dialog_data_sanitize mtag
- setvar DEFAULTITEM_$$ "$mtag"
+ f_dialog_default_store "$mtag"
f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
# Exit if user has either pressed ESC or chosen Cancel/No
diff --git a/usr.sbin/bsdconfig/usermgmt/usermgmt b/usr.sbin/bsdconfig/usermgmt/usermgmt
index e91b44c..880985f 100755
--- a/usr.sbin/bsdconfig/usermgmt/usermgmt
+++ b/usr.sbin/bsdconfig/usermgmt/usermgmt
@@ -53,6 +53,7 @@ dialog_menu_main()
{
local menu_list
local hline="$hline_arrows_tab_enter"
+ local defaultitem= # Calculated below
menu_list="
'X' '$msg_exit'
@@ -76,20 +77,23 @@ dialog_menu_main()
# When using Xdialog(1) we need to bump the width for the buttons
[ "$USE_XDIALOG" ] && width=40
+ # 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\" \
- --help-button \
- --help-label \"\$msg_help\" \
- ${USE_XDIALOG:+--help \"\"} \
- --default-item \"\$DEFAULTITEM_$$\" \
- --menu \"\" \
- $height $width $rows \
- $menu_list \
+ --backtitle \"\$DIALOG_BACKTITLE\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --help-button \
+ --help-label \"\$msg_help\" \
+ ${USE_XDIALOG:+--help \"\"} \
+ --default-item \"\$defaultitem\" \
+ --menu \"\" \
+ $height $width $rows \
+ $menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
@@ -97,7 +101,7 @@ dialog_menu_main()
f_dialog_menutag_store "$menu_choice"
# Only update default-item on success
- [ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$menu_choice"
+ [ $retval -eq 0 ] && f_dialog_default_store "$menu_choice"
return $retval
}
OpenPOWER on IntegriCloud