1if [ ! "$_PACKAGES_PACKAGES_SUBR" ]; then _PACKAGES_PACKAGES_SUBR=1
2#
3# Copyright (c) 2013 Devin Teske
4# All Rights Reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
--- 10 unchanged lines hidden (view full) ---
19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
27# $FreeBSD: head/usr.sbin/bsdconfig/share/packages/packages.subr 250323 2013-05-07 05:40:20Z dteske $
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." "$0"
34f_include $BSDCFG_SHARE/dialog.subr
35f_include $BSDCFG_SHARE/strings.subr
--- 37 unchanged lines hidden (view full) ---
73#
74f_package_accent_category_menu()
75{
76 local var_to_set="$1" cat desc help varcat menu_buf n
77 shift 1 # var_to_set
78 while [ $# -gt 0 ]; do
79 cat="${1%\*}" desc="${2%%; *}" help="$3"
80 shift 3 # cat/desc/help
81 f_str2varname "${cat# }" varcat
82
83 # Add an asterisk to the category if its index has been cached
84 f_isset _index_page_${varcat}_1 && cat="$cat*"
85
86 # Add number of installed packages for this category (if any)
87 n=0
88 debug= f_getvar "_${varcat}_ninstalled" n &&
89 [ $n -ge 1 ] && desc="$desc; $n installed"
90
91 # Add number of selected packages for this category (if any)
92 n=0
93 debug= f_getvar "_${varcat}_nselected" n &&
94 [ $n -ge 1 ] && desc="$desc; $n selected"
95
96 # Update buffer with modified elements
97 menu_buf="$menu_buf
98 '$cat' '$desc' '$help'" # End-Quote
99 done
100 setvar "$var_to_set" "$menu_buf" # return our buffer
101}
102
103# f_package_select $package ...
--- 256 unchanged lines hidden (view full) ---
360
361 f_isinteger "$page" || return $FAILURE
362
363 f_str2varname "$category" varcat
364 f_package_index_get_page "$category" $page index_page
365
366 # Get number of packages for this category
367 case "$category" in
368 "All"|"") npkgs="${_npkgs:-0}";;
369 *) f_getvar _npkgs_$varcat npkgs
370 esac
371
372 # Calculate number of pages
373 npages=$(( ${npkgs:=0} / $PACKAGE_MENU_PAGESIZE ))
374
375 # Add a page to the pagecount if not evenly divisible
376 [ $(( $npages * $PACKAGE_MENU_PAGESIZE )) -lt $npkgs ] &&
--- 55 unchanged lines hidden (view full) ---
432 printf "\n"
433 }'
434 )
435 ${add_prev:+'> $previous_page' '' ${SHOW_DESC:+''}}
436 ${add_next:+'> $next_page' '' ${SHOW_DESC:+''}}
437 " # End-Quote
438
439 local prompt=""
440 f_category_desc_get "$category" prompt
441 prompt="$prompt $( printf "$msg_page_of_npages" \
442 "$page" "$npages" )"
443
444 local hline="$hline_arrows_tab_punc_enter"
445 local size isize dialog_menu item
446 size=$( eval f_dialog_menu${SHOW_DESC:+_with_help}_size \
447 \"\$DIALOG_TITLE\" \
448 \"\$DIALOG_BACKTITLE\" \
--- 298 unchanged lines hidden ---
2#
3# Copyright (c) 2013 Devin Teske
4# All Rights Reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
--- 10 unchanged lines hidden (view full) ---
19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
27# $FreeBSD: head/usr.sbin/bsdconfig/share/packages/packages.subr 250323 2013-05-07 05:40:20Z dteske $
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." "$0"
34f_include $BSDCFG_SHARE/dialog.subr
35f_include $BSDCFG_SHARE/strings.subr
--- 37 unchanged lines hidden (view full) ---
73#
74f_package_accent_category_menu()
75{
76 local var_to_set="$1" cat desc help varcat menu_buf n
77 shift 1 # var_to_set
78 while [ $# -gt 0 ]; do
79 cat="${1%\*}" desc="${2%%; *}" help="$3"
80 shift 3 # cat/desc/help
81 f_str2varname "${cat# }" varcat
82
83 # Add an asterisk to the category if its index has been cached
84 f_isset _index_page_${varcat}_1 && cat="$cat*"
85
86 # Add number of installed packages for this category (if any)
87 n=0
88 debug= f_getvar "_${varcat}_ninstalled" n &&
89 [ $n -ge 1 ] && desc="$desc; $n installed"
90
91 # Add number of selected packages for this category (if any)
92 n=0
93 debug= f_getvar "_${varcat}_nselected" n &&
94 [ $n -ge 1 ] && desc="$desc; $n selected"
95
96 # Update buffer with modified elements
97 menu_buf="$menu_buf
98 '$cat' '$desc' '$help'" # End-Quote
99 done
100 setvar "$var_to_set" "$menu_buf" # return our buffer
101}
102
103# f_package_select $package ...
--- 256 unchanged lines hidden (view full) ---
360
361 f_isinteger "$page" || return $FAILURE
362
363 f_str2varname "$category" varcat
364 f_package_index_get_page "$category" $page index_page
365
366 # Get number of packages for this category
367 case "$category" in
368 "All"|"") npkgs="${_npkgs:-0}";;
369 *) f_getvar _npkgs_$varcat npkgs
370 esac
371
372 # Calculate number of pages
373 npages=$(( ${npkgs:=0} / $PACKAGE_MENU_PAGESIZE ))
374
375 # Add a page to the pagecount if not evenly divisible
376 [ $(( $npages * $PACKAGE_MENU_PAGESIZE )) -lt $npkgs ] &&
--- 55 unchanged lines hidden (view full) ---
432 printf "\n"
433 }'
434 )
435 ${add_prev:+'> $previous_page' '' ${SHOW_DESC:+''}}
436 ${add_next:+'> $next_page' '' ${SHOW_DESC:+''}}
437 " # End-Quote
438
439 local prompt=""
440 f_category_desc_get "$category" prompt
441 prompt="$prompt $( printf "$msg_page_of_npages" \
442 "$page" "$npages" )"
443
444 local hline="$hline_arrows_tab_punc_enter"
445 local size isize dialog_menu item
446 size=$( eval f_dialog_menu${SHOW_DESC:+_with_help}_size \
447 \"\$DIALOG_TITLE\" \
448 \"\$DIALOG_BACKTITLE\" \
--- 298 unchanged lines hidden ---