Deleted Added
full compact
dialog.subr (253169) dialog.subr (263791)
1if [ ! "$_DIALOG_SUBR" ]; then _DIALOG_SUBR=1
2#
1if [ ! "$_DIALOG_SUBR" ]; then _DIALOG_SUBR=1
2#
3# Copyright (c) 2006-2013 Devin Teske
3# Copyright (c) 2006-2014 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:
9# 1. Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright

--- 7 unchanged lines hidden (view full) ---

19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INCLUDING, 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#
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:
9# 1. Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright

--- 7 unchanged lines hidden (view full) ---

19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INCLUDING, 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: stable/9/usr.sbin/bsdconfig/share/dialog.subr 253169 2013-07-10 20:22:31Z dteske $
27# $FreeBSD: stable/9/usr.sbin/bsdconfig/share/dialog.subr 263791 2014-03-27 03:20:47Z dteske $
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." dialog.subr
34f_include $BSDCFG_SHARE/strings.subr
35f_include $BSDCFG_SHARE/variable.subr

--- 33 unchanged lines hidden (view full) ---

69# Declare that we are fully-compliant with Xdialog(1) by unset'ing all
70# compatibility settings.
71#
72unset XDIALOG_HIGH_DIALOG_COMPAT
73unset XDIALOG_FORCE_AUTOSIZE
74unset XDIALOG_INFOBOX_TIMEOUT
75
76#
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." dialog.subr
34f_include $BSDCFG_SHARE/strings.subr
35f_include $BSDCFG_SHARE/variable.subr

--- 33 unchanged lines hidden (view full) ---

69# Declare that we are fully-compliant with Xdialog(1) by unset'ing all
70# compatibility settings.
71#
72unset XDIALOG_HIGH_DIALOG_COMPAT
73unset XDIALOG_FORCE_AUTOSIZE
74unset XDIALOG_INFOBOX_TIMEOUT
75
76#
77# Exit codes for [X]dialog(1)
78#
79DIALOG_OK=${SUCCESS:-0}
80DIALOG_CANCEL=${FAILURE:-1}
81DIALOG_HELP=2
82DIALOG_ITEM_HELP=2
83DIALOG_EXTRA=3
84DIALOG_ITEM_HELP=4
85export DIALOG_ERROR=254 # sh(1) can't handle the default of `-1'
86DIALOG_ESC=255
87
88#
77# Default behavior is to call f_dialog_init() automatically when loaded.
78#
79: ${DIALOG_SELF_INITIALIZE=1}
80
81#
82# Default terminal size (used if/when running without a controlling terminal)
83#
84: ${DEFAULT_TERMINAL_SIZE:=24 80}

--- 194 unchanged lines hidden (view full) ---

279
280# f_dialog_max_size $var_height $var_width
281#
282# Get the maximum height and width for a dialog widget and store the values in
283# $var_height and $var_width (respectively).
284#
285f_dialog_max_size()
286{
89# Default behavior is to call f_dialog_init() automatically when loaded.
90#
91: ${DIALOG_SELF_INITIALIZE=1}
92
93#
94# Default terminal size (used if/when running without a controlling terminal)
95#
96: ${DEFAULT_TERMINAL_SIZE:=24 80}

--- 194 unchanged lines hidden (view full) ---

291
292# f_dialog_max_size $var_height $var_width
293#
294# Get the maximum height and width for a dialog widget and store the values in
295# $var_height and $var_width (respectively).
296#
297f_dialog_max_size()
298{
299 local funcname=f_dialog_max_size
287 local __var_height="$1" __var_width="$2" __max_size
288 [ "$__var_height" -o "$__var_width" ] || return $FAILURE
289 if [ "$USE_XDIALOG" ]; then
290 __max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
291 else
300 local __var_height="$1" __var_width="$2" __max_size
301 [ "$__var_height" -o "$__var_width" ] || return $FAILURE
302 if [ "$USE_XDIALOG" ]; then
303 __max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
304 else
292 __max_size=$( stty size 2> /dev/null ) # usually "24 80"
305 if __max_size=$( $DIALOG --print-maxsize \
306 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD )
307 then
308 f_dprintf "$funcname: %s --print-maxsize = [%s]" \
309 "$DIALOG" "$__max_size"
310 # usually "MaxSize: 24, 80"
311 __max_size="${__max_size#*: }"
312 f_replaceall "$__max_size" "," "" __max_size
313 else
314 f_eval_catch -dk __max_size $funcname stty \
315 'stty size' || __max_size=
316 # usually "24 80"
317 fi
293 : ${__max_size:=$DEFAULT_TERMINAL_SIZE}
294 fi
295 if [ "$__var_height" ]; then
296 local __height="${__max_size%%[$IFS]*}"
297 #
298 # If we're not using Xdialog(1), we should assume that $DIALOG
299 # will render --backtitle behind the widget. In such a case, we
300 # should prevent a widget from obscuring the backtitle (unless

--- 97 unchanged lines hidden (view full) ---

398 setvar "$__var_width" $__min_width
399 elif [ $__width -gt $__max_width_size_constrain ]; then
400 setvar "$__var_width" $__max_width_size_constrain
401 fi
402 fi
403
404 if [ "$debug" ]; then
405 # Print final constrained values to debugging
318 : ${__max_size:=$DEFAULT_TERMINAL_SIZE}
319 fi
320 if [ "$__var_height" ]; then
321 local __height="${__max_size%%[$IFS]*}"
322 #
323 # If we're not using Xdialog(1), we should assume that $DIALOG
324 # will render --backtitle behind the widget. In such a case, we
325 # should prevent a widget from obscuring the backtitle (unless

--- 97 unchanged lines hidden (view full) ---

423 setvar "$__var_width" $__min_width
424 elif [ $__width -gt $__max_width_size_constrain ]; then
425 setvar "$__var_width" $__max_width_size_constrain
426 fi
427 fi
428
429 if [ "$debug" ]; then
430 # Print final constrained values to debugging
406 f_quietly f_getvar "$__var_height"
407 f_quietly f_getvar "$__var_width"
431 [ "$__var_height" ] && f_quietly f_getvar "$__var_height"
432 [ "$__var_width" ] && f_quietly f_getvar "$__var_width"
408 fi
409
410 return $__retval # success if no debug warnings were printed
411}
412
413# f_dialog_menu_constrain $var_height $var_width $var_rows "$prompt" \
414# [$min_height [$min_width [$min_rows]]]
415#

--- 23 unchanged lines hidden (view full) ---

439 # Return failure unless at least one var_* argument is passed
440 [ "$__var_height" -o "$__var_width" -o "$__var_rows" ] ||
441 return $FAILURE
442
443 #
444 # Print debug warnings if any given (non-NULL) argument are invalid
445 # NOTE: Don't change the name of $__{var,min,}{height,width,rows}
446 #
433 fi
434
435 return $__retval # success if no debug warnings were printed
436}
437
438# f_dialog_menu_constrain $var_height $var_width $var_rows "$prompt" \
439# [$min_height [$min_width [$min_rows]]]
440#

--- 23 unchanged lines hidden (view full) ---

464 # Return failure unless at least one var_* argument is passed
465 [ "$__var_height" -o "$__var_width" -o "$__var_rows" ] ||
466 return $FAILURE
467
468 #
469 # Print debug warnings if any given (non-NULL) argument are invalid
470 # NOTE: Don't change the name of $__{var,min,}{height,width,rows}
471 #
447 local __height __width __rows
472 local __height_menu_constrain __width_menu_constrain
473 local __rows_menu_constrain
448 local __arg __cp __fname=f_dialog_menu_constrain
449 for __arg in height width rows; do
450 debug= f_getvar __var_$__arg __cp
451 [ "$__cp" ] || continue
474 local __arg __cp __fname=f_dialog_menu_constrain
475 for __arg in height width rows; do
476 debug= f_getvar __var_$__arg __cp
477 [ "$__cp" ] || continue
452 if ! debug= f_getvar "$__cp" __$__arg; then
478 if ! debug= f_getvar "$__cp" __${__arg}_menu_constrain; then
453 f_dprintf "%s: var_%s variable \`%s' not set" \
454 $__fname $__arg "$__cp"
455 __retval=$FAILURE
479 f_dprintf "%s: var_%s variable \`%s' not set" \
480 $__fname $__arg "$__cp"
481 __retval=$FAILURE
456 elif ! eval f_isinteger \$__$__arg; then
482 elif ! eval f_isinteger \$__${__arg}_menu_constrain; then
457 f_dprintf "%s: var_%s variable value not a number" \
458 $__fname $__arg
459 __retval=$FAILURE
460 fi
461 done
462 for __arg in height width rows; do
463 debug= f_getvar __min_$__arg __cp
464 [ "$__cp" ] || continue

--- 7 unchanged lines hidden (view full) ---

472 # NOTE: Function name appended to prevent __var_{height,width} values
473 # from becoming local (and thus preventing setvar from working).
474 local __max_height_menu_constrain __max_width_menu_constrain
475 f_dialog_max_size \
476 __max_height_menu_constrain __max_width_menu_constrain
477
478 # Adjust height if desired
479 if [ "$__var_height" ]; then
483 f_dprintf "%s: var_%s variable value not a number" \
484 $__fname $__arg
485 __retval=$FAILURE
486 fi
487 done
488 for __arg in height width rows; do
489 debug= f_getvar __min_$__arg __cp
490 [ "$__cp" ] || continue

--- 7 unchanged lines hidden (view full) ---

498 # NOTE: Function name appended to prevent __var_{height,width} values
499 # from becoming local (and thus preventing setvar from working).
500 local __max_height_menu_constrain __max_width_menu_constrain
501 f_dialog_max_size \
502 __max_height_menu_constrain __max_width_menu_constrain
503
504 # Adjust height if desired
505 if [ "$__var_height" ]; then
480 if [ $__height -lt ${__min_height:-0} ]; then
506 if [ $__height_menu_constrain -lt ${__min_height:-0} ]; then
481 setvar "$__var_height" $__min_height
507 setvar "$__var_height" $__min_height
482 elif [ $__height -gt $__max_height_menu_constrain ]; then
508 elif [ $__height_menu_constrain -gt \
509 $__max_height_menu_constrain ]
510 then
483 setvar "$__var_height" $__max_height_menu_constrain
484 fi
485 fi
486
487 # Adjust width if desired
488 if [ "$__var_width" ]; then
489 if [ "$USE_XDIALOG" ]; then
490 : ${__min_width:=${XDIALOG_MIN_WIDTH:-35}}
491 else
492 : ${__min_width:=${DIALOG_MIN_WIDTH:-24}}
493 fi
511 setvar "$__var_height" $__max_height_menu_constrain
512 fi
513 fi
514
515 # Adjust width if desired
516 if [ "$__var_width" ]; then
517 if [ "$USE_XDIALOG" ]; then
518 : ${__min_width:=${XDIALOG_MIN_WIDTH:-35}}
519 else
520 : ${__min_width:=${DIALOG_MIN_WIDTH:-24}}
521 fi
494 if [ $__width -lt $__min_width ]; then
522 if [ $__width_menu_constrain -lt $__min_width ]; then
495 setvar "$__var_width" $__min_width
523 setvar "$__var_width" $__min_width
496 elif [ $__width -gt $__max_width_menu_constrain ]; then
524 elif [ $__width_menu_constrain -gt \
525 $__max_width_menu_constrain ]
526 then
497 setvar "$__var_width" $__max_width_menu_constrain
498 fi
499 fi
500
501 # Adjust rows if desired
502 if [ "$__var_rows" ]; then
503 if [ "$USE_XDIALOG" ]; then
504 : ${__min_rows:=1}
505 else
506 : ${__min_rows:=0}
507 fi
508
527 setvar "$__var_width" $__max_width_menu_constrain
528 fi
529 fi
530
531 # Adjust rows if desired
532 if [ "$__var_rows" ]; then
533 if [ "$USE_XDIALOG" ]; then
534 : ${__min_rows:=1}
535 else
536 : ${__min_rows:=0}
537 fi
538
509 local __max_rows=$(( $__max_height_menu_constrain - 8 ))
539 local __max_rows_menu_constrain=$((
540 $__max_height_menu_constrain - 7
541 ))
510 # If prompt_len is zero (no prompt), bump the max-rows by 1
511 # Default assumption is (if no argument) that there's no prompt
542 # If prompt_len is zero (no prompt), bump the max-rows by 1
543 # Default assumption is (if no argument) that there's no prompt
512 [ ${__prompt_len:-0} -gt 0 ] ||
513 __max_rows=$(( $__max_rows + 1 ))
544 [ ${__prompt_len:-0} -gt 0 ] || __max_rows_menu_constrain=$((
545 $__max_rows_menu_constrain + 1
546 ))
514
547
515 if [ $__rows -lt $__min_rows ]; then
548 if [ $__rows_menu_constrain -lt $__min_rows ]; then
516 setvar "$__var_rows" $__min_rows
549 setvar "$__var_rows" $__min_rows
517 elif [ $__rows -gt $__max_rows ]; then
518 setvar "$__var_rows" $__max_rows
550 elif [ $__rows_menu_constrain -gt $__max_rows_menu_constrain ]
551 then
552 setvar "$__var_rows" $__max_rows_menu_constrain
519 fi
520 fi
521
522 if [ "$debug" ]; then
553 fi
554 fi
555
556 if [ "$debug" ]; then
523 # Print final constrained values to debuggin
524 f_quietly f_getvar "$__var_height"
525 f_quietly f_getvar "$__var_width"
526 f_quietly f_getvar "$__var_rows"
557 # Print final constrained values to debugging
558 [ "$__var_height" ] && f_quietly f_getvar "$__var_height"
559 [ "$__var_width" ] && f_quietly f_getvar "$__var_width"
560 [ "$__var_rows" ] && f_quietly f_getvar "$__var_rows"
527 fi
528
529 return $__retval # success if no debug warnings were printed
530}
531
532# f_dialog_infobox_size [-n] $var_height $var_width \
533# $title $backtitle $prompt [$hline]
534#

--- 535 unchanged lines hidden (view full) ---

1070 "${__var_width:+__width_rlist_size}" \
1071 "$__title" "$__btitle" "$__prompt" "$__hline"
1072
1073 #
1074 # Always process the menu-item arguments to get the longest tag-length,
1075 # longest item-length (both used to bump the width), and the number of
1076 # rows (used to bump the height).
1077 #
561 fi
562
563 return $__retval # success if no debug warnings were printed
564}
565
566# f_dialog_infobox_size [-n] $var_height $var_width \
567# $title $backtitle $prompt [$hline]
568#

--- 535 unchanged lines hidden (view full) ---

1104 "${__var_width:+__width_rlist_size}" \
1105 "$__title" "$__btitle" "$__prompt" "$__hline"
1106
1107 #
1108 # Always process the menu-item arguments to get the longest tag-length,
1109 # longest item-length (both used to bump the width), and the number of
1110 # rows (used to bump the height).
1111 #
1078 local __longest_tag=0 __longest_item=0 __rows=0
1112 local __longest_tag=0 __longest_item=0 __rows_rlist_size=0
1079 while [ $# -ge 3 ]; do
1080 local __tag="$1" __item="$2"
1081 shift 3 # tag/item/status
1082 [ ${#__tag} -gt $__longest_tag ] && __longest_tag=${#__tag}
1083 [ ${#__item} -gt $__longest_item ] && __longest_item=${#__item}
1113 while [ $# -ge 3 ]; do
1114 local __tag="$1" __item="$2"
1115 shift 3 # tag/item/status
1116 [ ${#__tag} -gt $__longest_tag ] && __longest_tag=${#__tag}
1117 [ ${#__item} -gt $__longest_item ] && __longest_item=${#__item}
1084 __rows=$(( $__rows + 1 ))
1118 __rows_rlist_size=$(( $__rows_rlist_size + 1 ))
1085 done
1086
1087 # Adjust rows early (for up-coming height calculation)
1088 if [ "$__var_height" -o "$__var_rows" ]; then
1089 # Add a row for visual aid if using Xdialog(1)
1119 done
1120
1121 # Adjust rows early (for up-coming height calculation)
1122 if [ "$__var_height" -o "$__var_rows" ]; then
1123 # Add a row for visual aid if using Xdialog(1)
1090 [ "$USE_XDIALOG" ] && __rows=$(( $__rows + 1 ))
1124 [ "$USE_XDIALOG" ] &&
1125 __rows_rlist_size=$(( $__rows_rlist_size + 1 ))
1091 fi
1092
1093 # Adjust height if desired
1094 if [ "$__var_height" ]; then
1095 # Add rows to height
1096 if [ "$USE_XDIALOG" ]; then
1097 __height_rlist_size=$((
1126 fi
1127
1128 # Adjust height if desired
1129 if [ "$__var_height" ]; then
1130 # Add rows to height
1131 if [ "$USE_XDIALOG" ]; then
1132 __height_rlist_size=$((
1098 $__height_rlist_size + $__rows + 7 ))
1133 $__height_rlist_size + $__rows_rlist_size + 7
1134 ))
1099 else
1100 __height_rlist_size=$((
1135 else
1136 __height_rlist_size=$((
1101 $__height_rlist_size + $__rows + 4 ))
1137 $__height_rlist_size + $__rows_rlist_size + 4
1138 ))
1102 fi
1103 setvar "$__var_height" $__height_rlist_size
1104 fi
1105
1106 # Adjust width if desired
1107 if [ "$__var_width" ]; then
1108 # Sum total between longest tag-length, longest item-length,
1109 # and radio-button width should be used to bump menu width
1110 local __n=$(( $__longest_tag + $__longest_item + 13 ))
1111 [ "$USE_XDIALOG" ] && __n=$(( $__n + $__n / 6 )) # plus 16.6%
1112 [ $__n -gt $__width_rlist_size ] && __width_rlist_size=$__n
1113
1114 setvar "$__var_width" $__width_rlist_size
1115 fi
1116
1117 # Store adjusted rows if desired
1139 fi
1140 setvar "$__var_height" $__height_rlist_size
1141 fi
1142
1143 # Adjust width if desired
1144 if [ "$__var_width" ]; then
1145 # Sum total between longest tag-length, longest item-length,
1146 # and radio-button width should be used to bump menu width
1147 local __n=$(( $__longest_tag + $__longest_item + 13 ))
1148 [ "$USE_XDIALOG" ] && __n=$(( $__n + $__n / 6 )) # plus 16.6%
1149 [ $__n -gt $__width_rlist_size ] && __width_rlist_size=$__n
1150
1151 setvar "$__var_width" $__width_rlist_size
1152 fi
1153
1154 # Store adjusted rows if desired
1118 [ "$__var_rows" ] && setvar "$__var_rows" $__rows
1155 [ "$__var_rows" ] && setvar "$__var_rows" $__rows_rlist_size
1119
1120 # Constrain height, width, and rows to sensible minimum/maximum values
1121 # Return success if no-constrain, else return status from constrain
1122 [ ! "$__constrain" ] || f_dialog_menu_constrain \
1123 "$__var_height" "$__var_width" "$__var_rows" "$__prompt"
1124}
1125
1126# f_dialog_checklist_size [-n] $var_height $var_width $var_rows \

--- 63 unchanged lines hidden (view full) ---

1190
1191 #
1192 # Always process the menu-item arguments to get the longest tag-length,
1193 # longest item-length, longest help-length (help-length only considered
1194 # if using Xdialog(1), as it places the help string in the widget) --
1195 # all used to bump the width -- and the number of rows (used to bump
1196 # the height).
1197 #
1156
1157 # Constrain height, width, and rows to sensible minimum/maximum values
1158 # Return success if no-constrain, else return status from constrain
1159 [ ! "$__constrain" ] || f_dialog_menu_constrain \
1160 "$__var_height" "$__var_width" "$__var_rows" "$__prompt"
1161}
1162
1163# f_dialog_checklist_size [-n] $var_height $var_width $var_rows \

--- 63 unchanged lines hidden (view full) ---

1227
1228 #
1229 # Always process the menu-item arguments to get the longest tag-length,
1230 # longest item-length, longest help-length (help-length only considered
1231 # if using Xdialog(1), as it places the help string in the widget) --
1232 # all used to bump the width -- and the number of rows (used to bump
1233 # the height).
1234 #
1198 local __longest_tag=0 __longest_item=0 __longest_help=0 __rows=0
1235 local __longest_tag=0 __longest_item=0 __longest_help=0
1236 local __rows_rlist_with_help_size=0
1199 while [ $# -ge 4 ]; do
1200 local __tag="$1" __item="$2" __status="$3" __help="$4"
1201 shift 4 # tag/item/status/help
1202 [ ${#__tag} -gt $__longest_tag ] && __longest_tag=${#__tag}
1203 [ ${#__item} -gt $__longest_item ] && __longest_item=${#__item}
1204 [ ${#__help} -gt $__longest_help ] && __longest_help=${#__help}
1237 while [ $# -ge 4 ]; do
1238 local __tag="$1" __item="$2" __status="$3" __help="$4"
1239 shift 4 # tag/item/status/help
1240 [ ${#__tag} -gt $__longest_tag ] && __longest_tag=${#__tag}
1241 [ ${#__item} -gt $__longest_item ] && __longest_item=${#__item}
1242 [ ${#__help} -gt $__longest_help ] && __longest_help=${#__help}
1205 __rows=$(( $__rows + 1 ))
1243 __rows_rlist_with_help_size=$((
1244 $__rows_rlist_with_help_size + 1
1245 ))
1206 done
1207
1208 # Adjust rows early (for up-coming height calculation)
1209 if [ "$__var_height" -o "$__var_rows" ]; then
1210 # Add a row for visual aid if using Xdialog(1)
1246 done
1247
1248 # Adjust rows early (for up-coming height calculation)
1249 if [ "$__var_height" -o "$__var_rows" ]; then
1250 # Add a row for visual aid if using Xdialog(1)
1211 [ "$USE_XDIALOG" ] && __rows=$(( $__rows + 1 ))
1251 [ "$USE_XDIALOG" ] &&
1252 __rows_rlist_with_help_size=$((
1253 $__rows_rlist_with_help_size + 1
1254 ))
1212 fi
1213
1214 # Adjust height if desired
1215 if [ "$__var_height" ]; then
1216 # Add rows to height
1217 if [ "$USE_XDIALOG" ]; then
1218 __height_rlist_with_help_size=$((
1255 fi
1256
1257 # Adjust height if desired
1258 if [ "$__var_height" ]; then
1259 # Add rows to height
1260 if [ "$USE_XDIALOG" ]; then
1261 __height_rlist_with_help_size=$((
1219 $__height_rlist_with_help_size + $__rows + 7 ))
1262 $__height_rlist_with_help_size +
1263 $__rows_rlist_with_help_size + 7
1264 ))
1220 else
1221 __height_rlist_with_help_size=$((
1265 else
1266 __height_rlist_with_help_size=$((
1222 $__height_rlist_with_help_size + $__rows + 4 ))
1267 $__height_rlist_with_help_size +
1268 $__rows_rlist_with_help_size + 4
1269 ))
1223 fi
1224 setvar "$__var_height" $__height
1225 fi
1226
1227 # Adjust width if desired
1228 if [ "$__var_width" ]; then
1229 # Sum total between longest tag-length, longest item-length,
1230 # and radio-button width should be used to bump menu width

--- 9 unchanged lines hidden (view full) ---

1240 [ $__n -gt $__width_rlist_with_help_size ] &&
1241 __width_rlist_with_help_size=$__n
1242 fi
1243
1244 setvar "$__var_width" $__width_rlist_with_help_size
1245 fi
1246
1247 # Store adjusted rows if desired
1270 fi
1271 setvar "$__var_height" $__height
1272 fi
1273
1274 # Adjust width if desired
1275 if [ "$__var_width" ]; then
1276 # Sum total between longest tag-length, longest item-length,
1277 # and radio-button width should be used to bump menu width

--- 9 unchanged lines hidden (view full) ---

1287 [ $__n -gt $__width_rlist_with_help_size ] &&
1288 __width_rlist_with_help_size=$__n
1289 fi
1290
1291 setvar "$__var_width" $__width_rlist_with_help_size
1292 fi
1293
1294 # Store adjusted rows if desired
1248 [ "$__var_rows" ] && setvar "$__var_rows" $__rows
1295 [ "$__var_rows" ] && setvar "$__var_rows" $__rows_rlist_with_help_size
1249
1250 # Constrain height, width, and rows to sensible minimum/maximum values
1251 # Return success if no-constrain, else return status from constrain
1252 [ ! "$__constrain" ] || f_dialog_menu_constrain \
1253 "$__var_height" "$__var_width" "$__var_rows" "$__prompt"
1254}
1255
1256# f_dialog_checklist_with_help_size [-n] $var_height $var_width $var_rows \

--- 769 unchanged lines hidden (view full) ---

2026# Also reads ~/.dialogrc for the following information:
2027#
2028# NO_SHADOW Either NULL or Non-NULL. If use_shadow is OFF (case-
2029# insensitive) in ~/.dialogrc this is set to "1" (otherwise
2030# unset).
2031#
2032f_dialog_init()
2033{
1296
1297 # Constrain height, width, and rows to sensible minimum/maximum values
1298 # Return success if no-constrain, else return status from constrain
1299 [ ! "$__constrain" ] || f_dialog_menu_constrain \
1300 "$__var_height" "$__var_width" "$__var_rows" "$__prompt"
1301}
1302
1303# f_dialog_checklist_with_help_size [-n] $var_height $var_width $var_rows \

--- 769 unchanged lines hidden (view full) ---

2073# Also reads ~/.dialogrc for the following information:
2074#
2075# NO_SHADOW Either NULL or Non-NULL. If use_shadow is OFF (case-
2076# insensitive) in ~/.dialogrc this is set to "1" (otherwise
2077# unset).
2078#
2079f_dialog_init()
2080{
2081 local funcname=f_dialog_init
2082
2034 DIALOG_SELF_INITIALIZE=
2083 DIALOG_SELF_INITIALIZE=
2084 USE_DIALOG=1
2035
2036 #
2037 # Clone terminal stdout so we can redirect to it from within sub-shells
2038 #
2039 eval exec $DIALOG_TERMINAL_PASSTHRU_FD\>\&1
2040
2041 #
2042 # Add `-S' and `-X' to the list of standard arguments supported by all

--- 27 unchanged lines hidden (view full) ---

2070 done
2071 )
2072 f_dprintf "f_dialog_init: SECURE=[%s] USE_XDIALOG=[%s]" \
2073 "$SECURE" "$USE_XDIALOG"
2074
2075 #
2076 # Process `-X' command-line option
2077 #
2085
2086 #
2087 # Clone terminal stdout so we can redirect to it from within sub-shells
2088 #
2089 eval exec $DIALOG_TERMINAL_PASSTHRU_FD\>\&1
2090
2091 #
2092 # Add `-S' and `-X' to the list of standard arguments supported by all

--- 27 unchanged lines hidden (view full) ---

2120 done
2121 )
2122 f_dprintf "f_dialog_init: SECURE=[%s] USE_XDIALOG=[%s]" \
2123 "$SECURE" "$USE_XDIALOG"
2124
2125 #
2126 # Process `-X' command-line option
2127 #
2078 [ "$USE_XDIALOG" ] && DIALOG=Xdialog
2128 [ "$USE_XDIALOG" ] && DIALOG=Xdialog USE_DIALOG=
2079
2080 #
2081 # Sanity check, or die gracefully
2082 #
2083 if ! f_have $DIALOG; then
2084 unset USE_XDIALOG
2085 local failed_dialog="$DIALOG"
2086 DIALOG=dialog

--- 26 unchanged lines hidden (view full) ---

2113 [ "$SUDO_USER" -a "$DISPLAY" ]
2114 then
2115 if ! f_have xauth; then
2116 # Die gracefully, as we [likely] can't use Xdialog(1)
2117 unset USE_XDIALOG
2118 DIALOG=dialog
2119 f_die 1 "$msg_no_such_file_or_directory" "$pgm" "xauth"
2120 fi
2129
2130 #
2131 # Sanity check, or die gracefully
2132 #
2133 if ! f_have $DIALOG; then
2134 unset USE_XDIALOG
2135 local failed_dialog="$DIALOG"
2136 DIALOG=dialog

--- 26 unchanged lines hidden (view full) ---

2163 [ "$SUDO_USER" -a "$DISPLAY" ]
2164 then
2165 if ! f_have xauth; then
2166 # Die gracefully, as we [likely] can't use Xdialog(1)
2167 unset USE_XDIALOG
2168 DIALOG=dialog
2169 f_die 1 "$msg_no_such_file_or_directory" "$pgm" "xauth"
2170 fi
2121 HOSTNAME=$(hostname)
2171 HOSTNAME=$( hostname )
2122 local displaynum="${DISPLAY#*:}"
2123 eval xauth -if \~$SUDO_USER/.Xauthority extract - \
2124 \"\$HOSTNAME/unix:\$displaynum\" \
2125 \"\$HOSTNAME:\$displaynum\" | sudo sh -c 'xauth -ivf \
2126 ~root/.Xauthority merge - > /dev/null 2>&1'
2127 fi
2128
2129 #
2130 # Probe Xdialog(1) for maximum height/width constraints, or die
2131 # gracefully
2132 #
2133 if [ "$USE_XDIALOG" ]; then
2134 local maxsize
2172 local displaynum="${DISPLAY#*:}"
2173 eval xauth -if \~$SUDO_USER/.Xauthority extract - \
2174 \"\$HOSTNAME/unix:\$displaynum\" \
2175 \"\$HOSTNAME:\$displaynum\" | sudo sh -c 'xauth -ivf \
2176 ~root/.Xauthority merge - > /dev/null 2>&1'
2177 fi
2178
2179 #
2180 # Probe Xdialog(1) for maximum height/width constraints, or die
2181 # gracefully
2182 #
2183 if [ "$USE_XDIALOG" ]; then
2184 local maxsize
2135 if ! maxsize=$( LANG= LC_ALL= $DIALOG --print-maxsize 2>&1 )
2185 if ! f_eval_catch -dk maxsize $funcname "$DIALOG" \
2186 'LANG= LC_ALL= %s --print-maxsize' "$DIALOG"
2136 then
2137 # Xdialog(1) failed, fall back to dialog(1)
2138 unset USE_XDIALOG
2139
2140 # Display the error message produced by Xdialog(1)
2141 local height width
2142 f_dialog_buttonbox_size height width \
2143 "$DIALOG_TITLE" "$DIALOG_BACKTITLE" "$maxsize"

--- 48 unchanged lines hidden ---
2187 then
2188 # Xdialog(1) failed, fall back to dialog(1)
2189 unset USE_XDIALOG
2190
2191 # Display the error message produced by Xdialog(1)
2192 local height width
2193 f_dialog_buttonbox_size height width \
2194 "$DIALOG_TITLE" "$DIALOG_BACKTITLE" "$maxsize"

--- 48 unchanged lines hidden ---