diff options
author | dteske <dteske@FreeBSD.org> | 2013-06-02 20:02:50 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2013-06-02 20:02:50 +0000 |
commit | e9cea3453922d1975e0825166772ffe465661dab (patch) | |
tree | 2c9bf92c5092f58cc207f2fd3418feab48459fea /usr.sbin/bsdconfig/share/packages | |
parent | db074b4e6ec9f60ba7d39270d7bd41bd4d5f6ba8 (diff) | |
download | FreeBSD-src-e9cea3453922d1975e0825166772ffe465661dab.zip FreeBSD-src-e9cea3453922d1975e0825166772ffe465661dab.tar.gz |
Standardize the way functions build their arguments leading up to a dialog
invocation. Specifically, "top-load" your arguments and in the order in-
which they will be displayed. For example, many [if not all] widgets display
information in the following order, top-to-bottom (visually):
+ backtitle (displayed behind the widget at top-left)
+ title (at the top of the `window')
+ prompt text (just below the title and above whatever widget you choose)
+ Depending on widget, _one_ of the following:
- menu list
- radio list
- check list
- text input box with initial text
- [Xdialog(1)] 2x or 3x text input boxes
- [dialog(1)] a multi-part form
- progress bar
- etc. (many more widget choices)
+ buttons (right below the selected widget)
+ [dialog(1)] the hline (displayed at bottom of `window')
NOTE: Xdialog(1) accepts and silently ignores --hline
When building local arguments for your dialog invocation, if the value can't
be cleanly loaded into a local, add "# Calculated below" to the end of the
local declaration while retaining the block order of argument declarations.
Move other local declarations that are not associated with this top-loading
the dialog arguments to right-above where they are first-used.
Also, standardize on the names of the arguments. For example, always use
$prompt (instead of sometimes $msg and sometimes $prompt); use $menu_list
or $shell_list or $radio_list for those respective widgets; ad nauseum.
While we're doing this, flush-out full arguments for many invocations that
were passing NULL strings (making it unapparent if you were staring at this
one invocation what argument that NULL string was supposed to represent).
Last, while we're in startup/rcconf let's remove the unnecessary use of a
GLOBAL (RCCONF_MENU_LIST) for the menu_list.
Diffstat (limited to 'usr.sbin/bsdconfig/share/packages')
-rwxr-xr-x | usr.sbin/bsdconfig/share/packages/packages.subr | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/usr.sbin/bsdconfig/share/packages/packages.subr b/usr.sbin/bsdconfig/share/packages/packages.subr index 3bc37b5..dae80a1 100755 --- a/usr.sbin/bsdconfig/share/packages/packages.subr +++ b/usr.sbin/bsdconfig/share/packages/packages.subr @@ -277,25 +277,26 @@ f_package_calculate_rundeps() # f_package_menu_categories() { - local var_to_get="$1" defaultitem="$2" category_list menu_list + local var_to_get="$1" defaultitem="$2" + local prompt="$msg_please_select_a_category_to_display" + local menu_list=" + '> $msg_review' '$msg_review_desc' '$msg_review_help' + " # End-Quote + local hline= f_package_calculate_rundeps # updates package mark variables and SELECTED_PACKAGES f_package_calculate_totals # creates _{varcat}_ninstalled and _{varcat}_nselected + local category_list debug= f_getvar "$var_to_get" category_list || return $FAILURE # Accent the category menu list with ninstalled/nselected eval f_package_accent_category_menu category_list $category_list - local prompt="$msg_please_select_a_category_to_display" - local hline="" - - menu_list=" - '> $msg_review' '$msg_review_desc' '$msg_review_help' - $category_list - " # End-Quote + # Add list of categories to menu list + menu_list="$menu_list $category_list" local height width rows eval f_dialog_menu_with_help_size height width rows \ @@ -365,22 +366,26 @@ f_package_index_get_page() # f_package_menu_select() { - local category="$1" page="${2:-1}" defaultitem="$3" - local varcat npkgs=0 npages menu_list + local category="$1" page="${2:-1}" + local prompt= # Calculated below + local menu_list # Calculated below + local defaultitem="$3" + local hline="$hline_arrows_tab_punc_enter" f_isinteger "$page" || return $FAILURE + local varcat f_str2varname "$category" varcat - f_package_index_get_page "$category" $page index_page # Get number of packages for this category + local npkgs=0 case "$category" in "$msg_all"|"") npkgs="${_npkgs:-0}";; *) f_getvar _npkgs_$varcat npkgs esac # Calculate number of pages - npages=$(( ${npkgs:=0} / $PACKAGE_MENU_PAGESIZE )) + local npages=$(( ${npkgs:=0} / $PACKAGE_MENU_PAGESIZE )) # Add a page to the pagecount if not evenly divisible [ $(( $npages * $PACKAGE_MENU_PAGESIZE )) -lt $npkgs ] && @@ -407,6 +412,9 @@ f_package_menu_select() next_page="$next_page*" fi + local index_page + f_package_index_get_page "$category" $page index_page + menu_list=" ${add_prev:+'> $previous_page' '' ${SHOW_DESC:+''}} ${add_next:+'> $next_page' '' ${SHOW_DESC:+''}} @@ -446,7 +454,6 @@ f_package_menu_select() ${add_next:+'> $next_page' '' ${SHOW_DESC:+''}} " # End-Quote - local prompt="" # Accept/Translate i18n "All" but other category names must # match tree definitions from INDEX, ports, FTP, etc. case "$category" in @@ -456,7 +463,6 @@ f_package_menu_select() prompt="$prompt $( printf "$msg_page_of_npages" \ "$page" "$npages" )" - local hline="$hline_arrows_tab_punc_enter" local mheight mwidth mrows f_dialog_menu${SHOW_DESC:+_with_help}_size mheight mwidth mrows \ \"\$DIALOG_TITLE\" \"\$DIALOG_BACKTITLE\" \ @@ -509,14 +515,16 @@ f_package_menu_select() # f_package_menu_deselect() { - local package="$1" prompt menu_list - prompt=$( printf "$msg_what_would_you_like_to_do_with" "$package" ) - local hline="$hline_alnum_arrows_punc_tab_enter" - menu_list=" + local package="$1" + local prompt # Calculated below + local menu_list=" 'X $msg_installed' '$msg_installed_desc' 'R $msg_reinstall' '$msg_reinstall_desc' 'U $msg_uninstall' '$msg_uninstall_desc' " # End-Quote + local hline="$hline_alnum_arrows_punc_tab_enter" + + prompt=$( printf "$msg_what_would_you_like_to_do_with" "$package" ) local height width rows eval f_dialog_menu_size height width rows \ @@ -551,12 +559,16 @@ f_package_menu_deselect() # f_package_review() { - local prompt package varpkg mark menu_list= - prompt=$( printf "$msg_reviewing_selected_packages" \ - "$_All_nselected" ) + local prompt # Calculated below + local menu_list # Calculated below local hline="$hline_alnum_arrows_punc_tab_enter" + f_dprintf "f_package_review: SELECTED_PACKAGES=[%s]" \ "$SELECTED_PACKAGES" + + prompt=$( printf "$msg_reviewing_selected_packages" "$_All_nselected" ) + + local package varpkg mark for package in $SELECTED_PACKAGES; do mark= f_str2varname "$package" varpkg |