Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 May 2013 19:07:17 +0000 (UTC)
From:      Devin Teske <dteske@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r251190 - in head/usr.sbin/bsdconfig: . console mouse networking networking/share password/share security share share/media startup startup/share timezone timezone/share usermgmt usermg...
Message-ID:  <201305311907.r4VJ7Hp8022745@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dteske
Date: Fri May 31 19:07:17 2013
New Revision: 251190
URL: http://svnweb.freebsd.org/changeset/base/251190

Log:
  Improve portion of the dialog(1) API in dialog.subr responsible for
  calculating widget sizes. Instead of forking a sub-shell to calculate the
  optimum size for a widget, use a byRef style call-out to set variables in
  the parent namespace. For example, instead of:
  
  	size=$( f_dialog_buttonbox_size title btitle msg )
  	$DIALOG --title title --backtitle btitle --msgbox msg $size
  
  The new API replaces the above with the following:
  
  	f_dialog_buttonbox_size height width title btitle msg
  	$DIALOG --title title --backtitle btitle --msgbox msg $height $width
  
  This reduces the number of forks, improves performance, and makes the code
  more readable by revealing the argument-order for widget sizing. It also
  makes performing minor adjustments to the calculated values easier as
  you no longer have to split-out the response (which required knowledge of
  ordering so was counter-intuitive).

Modified:
  head/usr.sbin/bsdconfig/bsdconfig
  head/usr.sbin/bsdconfig/console/console
  head/usr.sbin/bsdconfig/console/font
  head/usr.sbin/bsdconfig/console/keymap
  head/usr.sbin/bsdconfig/console/repeat
  head/usr.sbin/bsdconfig/console/saver
  head/usr.sbin/bsdconfig/console/screenmap
  head/usr.sbin/bsdconfig/console/ttys
  head/usr.sbin/bsdconfig/mouse/disable
  head/usr.sbin/bsdconfig/mouse/mouse
  head/usr.sbin/bsdconfig/mouse/port
  head/usr.sbin/bsdconfig/mouse/type
  head/usr.sbin/bsdconfig/networking/networking
  head/usr.sbin/bsdconfig/networking/share/device.subr
  head/usr.sbin/bsdconfig/networking/share/resolv.subr
  head/usr.sbin/bsdconfig/password/share/password.subr
  head/usr.sbin/bsdconfig/security/kern_securelevel
  head/usr.sbin/bsdconfig/security/security
  head/usr.sbin/bsdconfig/share/device.subr
  head/usr.sbin/bsdconfig/share/dialog.subr
  head/usr.sbin/bsdconfig/share/media/any.subr
  head/usr.sbin/bsdconfig/share/media/ftp.subr
  head/usr.sbin/bsdconfig/share/media/options.subr
  head/usr.sbin/bsdconfig/share/mustberoot.subr
  head/usr.sbin/bsdconfig/startup/misc
  head/usr.sbin/bsdconfig/startup/rcadd
  head/usr.sbin/bsdconfig/startup/rcconf
  head/usr.sbin/bsdconfig/startup/rcdelete
  head/usr.sbin/bsdconfig/startup/rcvar
  head/usr.sbin/bsdconfig/startup/share/rcconf.subr
  head/usr.sbin/bsdconfig/startup/startup
  head/usr.sbin/bsdconfig/timezone/share/zones.subr
  head/usr.sbin/bsdconfig/timezone/timezone
  head/usr.sbin/bsdconfig/usermgmt/groupinput
  head/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
  head/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
  head/usr.sbin/bsdconfig/usermgmt/userinput
  head/usr.sbin/bsdconfig/usermgmt/usermgmt

Modified: head/usr.sbin/bsdconfig/bsdconfig
==============================================================================
--- head/usr.sbin/bsdconfig/bsdconfig	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/bsdconfig	Fri May 31 19:07:17 2013	(r251190)
@@ -145,7 +145,7 @@ dialog_menu_main()
 	local title="$DIALOG_TITLE"
 	local btitle="$DIALOG_BACKTITLE"
 	local prompt="$msg_menu_text"
-	local menu_list size
+	local menu_list
 
 	menu_list="
 		'X' '$msg_exit'  '$msg_exit_bsdconfig'
@@ -179,12 +179,13 @@ dialog_menu_main()
 		index=$(( $index + 1 ))
 	done
 
-	size=$( eval f_dialog_menu_with_help_size \
-	        	\"\$title\"  \
-	        	\"\$btitle\" \
-	        	\"\$prompt\" \
-	        	\"\"         \
-	        	$menu_list   )
+	local height width rows
+	eval f_dialog_menu_with_help_size height width rows \
+	                                  \"\$title\"  \
+	                                  \"\$btitle\" \
+	                                  \"\$prompt\" \
+	                                  \"\"         \
+	                                  $menu_list
 
 	local dialog_menu
 	dialog_menu=$( eval $DIALOG \
@@ -198,7 +199,9 @@ dialog_menu_main()
 		--help-label \"\$msg_help\"             \
 		${USE_XDIALOG:+--help \"\"}             \
 		--default-item \"\$DEFAULTITEM_$$\"     \
-		--menu \"\$prompt\" $size $menu_list    \
+		--menu \"\$prompt\"                     \
+		$height $width $rows                    \
+		$menu_list                              \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
 	local retval=$?

Modified: head/usr.sbin/bsdconfig/console/console
==============================================================================
--- head/usr.sbin/bsdconfig/console/console	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/console/console	Fri May 31 19:07:17 2013	(r251190)
@@ -48,7 +48,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_
 #
 dialog_menu_main()
 {
-	local menu_list size
+	local menu_list
 	local hline="$hline_configure_system_console_settings"
 	local prompt="$msg_console_menu_text"
 
@@ -62,12 +62,13 @@ dialog_menu_main()
 		'7 $msg_ttys'      '$msg_choose_console_terminal_type'
 	" # END-QUOTE
 
-	size=$( eval f_dialog_menu_size \
-	        	\"\$DIALOG_TITLE\"     \
-	        	\"\$DIALOG_BACKTITLE\" \
-	                \"\$prompt\"           \
-	        	\"\$hline\"            \
-	        	$menu_list             )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$DIALOG_TITLE\"     \
+	                        \"\$DIALOG_BACKTITLE\" \
+	                        \"\$prompt\"           \
+	                        \"\$hline\"            \
+	                        $menu_list
 
 	local dialog_menu
 	dialog_menu=$( eval $DIALOG \
@@ -77,7 +78,8 @@ dialog_menu_main()
 		--ok-label \"\$msg_ok\"             \
 		--cancel-label \"\$msg_cancel\"     \
 		--default-item \"\$DEFAULTITEM_$$\" \
-		--menu \"\$prompt\" $size           \
+		--menu \"\$prompt\"                 \
+		$height $width $rows                \
 		$menu_list                          \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)

Modified: head/usr.sbin/bsdconfig/console/font
==============================================================================
--- head/usr.sbin/bsdconfig/console/font	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/console/font	Fri May 31 19:07:17 2013	(r251190)
@@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_
 #
 dialog_menu_main()
 {
-	local menu_list size defaultitem=
+	local menu_list defaultitem=
 	local hline="$hline_choose_a_font"
 	local prompt="$msg_font_menu_text"
 
@@ -70,12 +70,13 @@ dialog_menu_main()
 		'e $msg_swiss'       '$msg_swiss_desc'
 	" # END-QUOTE
 
-	size=$( eval f_dialog_menu_size \
-	        	\"\$DIALOG_TITLE\"     \
-	        	\"\$DIALOG_BACKTITLE\" \
-	                \"\$prompt\"           \
-	        	\"\$hline\"            \
-	        	$menu_list             )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$DIALOG_TITLE\"     \
+	                        \"\$DIALOG_BACKTITLE\" \
+	                        \"\$prompt\"           \
+	                        \"\$hline\"            \
+	                        $menu_list
 
 	case "$( f_sysrc_get font8x8 )" in
 	[Nn][Oo]|'') defaultitem="1 $msg_none";;
@@ -102,7 +103,8 @@ dialog_menu_main()
 		--ok-label \"\$msg_ok\"            \
 		--cancel-label \"\$msg_cancel\"    \
 		--default-item \"\$defaultitem\"   \
-		--menu \"\$prompt\" $size          \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
 		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)

Modified: head/usr.sbin/bsdconfig/console/keymap
==============================================================================
--- head/usr.sbin/bsdconfig/console/keymap	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/console/keymap	Fri May 31 19:07:17 2013	(r251190)
@@ -77,7 +77,7 @@ KEYMAP_NAMES="
 #
 dialog_menu_main()
 {
-	local menu_list size defaultitem=
+	local menu_list defaultitem=
 	local hline="$hline_choose_a_keyboard_map"
 	local prompt="$msg_keymap_menu_text"
 
@@ -110,12 +110,13 @@ dialog_menu_main()
 		}'
 	)
 
-	size=$( eval f_dialog_menu_size \
-	        	\"\$DIALOG_TITLE\"     \
-	        	\"\$DIALOG_BACKTITLE\" \
-	                \"\$prompt\"           \
-	        	\"\$hline\"            \
-	        	$menu_list             )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$DIALOG_TITLE\"     \
+	                        \"\$DIALOG_BACKTITLE\" \
+	                        \"\$prompt\"           \
+	                        \"\$hline\"            \
+	                        $menu_list
 
 	case "$( f_sysrc_get keymap )" in
 	be.iso) defaultitem="$msg_belgian";;
@@ -200,7 +201,8 @@ dialog_menu_main()
 		--ok-label \"\$msg_ok\"            \
 		--cancel-label \"\$msg_cancel\"    \
 		--default-item \"\$defaultitem\"   \
-		--menu \"\$prompt\" $size          \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
 		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)

Modified: head/usr.sbin/bsdconfig/console/repeat
==============================================================================
--- head/usr.sbin/bsdconfig/console/repeat	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/console/repeat	Fri May 31 19:07:17 2013	(r251190)
@@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_
 #
 dialog_menu_main()
 {
-	local menu_list size defaultitem=
+	local menu_list defaultitem=
 	local hline="$hline_choose_a_keyboard_repeat_rate"
 	local prompt="$msg_repeat_menu_text"
 
@@ -60,12 +60,13 @@ dialog_menu_main()
 		'$msg_fast'    '$msg_fast_desc'
 	" # END-QUOTE
 
-	size=$( eval f_dialog_menu_size \
-	        	\"\$DIALOG_TITLE\"     \
-	        	\"\$DIALOG_BACKTITLE\" \
-	                \"\$prompt\"           \
-	        	\"\$hline\"            \
-	        	$menu_list             )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$DIALOG_TITLE\"     \
+	                        \"\$DIALOG_BACKTITLE\" \
+	                        \"\$prompt\"           \
+	                        \"\$hline\"            \
+	                        $menu_list
 
 	case "$( f_sysrc_get keyrate )" in
 	slow) defaultitem="$msg_slow";;
@@ -82,7 +83,8 @@ dialog_menu_main()
 		--ok-label \"\$msg_ok\"            \
 		--cancel-label \"\$msg_cancel\"    \
 		--default-item \"\$defaultitem\"   \
-		--menu \"\$prompt\" $size          \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
 		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)

Modified: head/usr.sbin/bsdconfig/console/saver
==============================================================================
--- head/usr.sbin/bsdconfig/console/saver	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/console/saver	Fri May 31 19:07:17 2013	(r251190)
@@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_
 #
 dialog_menu_main()
 {
-	local menu_list size defaultitem=
+	local menu_list defaultitem=
 	local hline="$hline_choose_a_screen_saver"
 	local prompt="$msg_saver_menu_text"
 
@@ -70,12 +70,13 @@ dialog_menu_main()
 		'$msg_timeout'   '$msg_timeout_desc'
 	" # END-QUOTE
 
-	size=$( eval f_dialog_menu_size \
-	        	\"\$DIALOG_TITLE\"     \
-	        	\"\$DIALOG_BACKTITLE\" \
-	                \"\$prompt\"           \
-	        	\"\$hline\"            \
-	        	$menu_list             )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$DIALOG_TITLE\"     \
+	                        \"\$DIALOG_BACKTITLE\" \
+	                        \"\$prompt\"           \
+	                        \"\$hline\"            \
+	                        $menu_list
 
 	case "$( f_sysrc_get saver )" in
 	blank)       defaultitem="1 $msg_blank"  ;;
@@ -101,7 +102,8 @@ dialog_menu_main()
 		--ok-label \"\$msg_ok\"            \
 		--cancel-label \"\$msg_cancel\"    \
 		--default-item \"\$defaultitem\"   \
-		--menu \"\$prompt\" $size          \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
 		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)

Modified: head/usr.sbin/bsdconfig/console/screenmap
==============================================================================
--- head/usr.sbin/bsdconfig/console/screenmap	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/console/screenmap	Fri May 31 19:07:17 2013	(r251190)
@@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_
 #
 dialog_menu_main()
 {
-	local menu_list size defaultitem=
+	local menu_list defaultitem=
 	local hline="$hline_choose_a_screen_map"
 	local prompt="$msg_screenmap_menu_text"
 
@@ -62,12 +62,13 @@ dialog_menu_main()
 		'6 $msg_koi8_u_to_ibm866u'    '$msg_koi8_u_to_ibm866u_desc'
 	" # END-QUOTE
 
-	size=$( eval f_dialog_menu_size \
-	        	\"\$DIALOG_TITLE\"     \
-	        	\"\$DIALOG_BACKTITLE\" \
-	                \"\$prompt\"           \
-	        	\"\$hline\"            \
-	        	$menu_list             )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$DIALOG_TITLE\"     \
+	                        \"\$DIALOG_BACKTITLE\" \
+	                        \"\$prompt\"           \
+	                        \"\$hline\"            \
+	                        $menu_list
 
 	case "$( f_sysrc_get scrnmap )" in
 	[Nn][Oo]|'')         defaultitem="1 $msg_none"                 ;;
@@ -86,7 +87,8 @@ dialog_menu_main()
 		--ok-label \"\$msg_ok\"            \
 		--cancel-label \"\$msg_cancel\"    \
 		--default-item \"\$defaultitem\"   \
-		--menu \"\$prompt\" $size          \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
 		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)

Modified: head/usr.sbin/bsdconfig/console/ttys
==============================================================================
--- head/usr.sbin/bsdconfig/console/ttys	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/console/ttys	Fri May 31 19:07:17 2013	(r251190)
@@ -72,16 +72,16 @@ TTY_MENU_LIST="
 #
 dialog_menu_main()
 {
-	local size
 	local hline="$hline_choose_a_terminal_type"
 	local prompt="$msg_ttys_menu_text"
 
-	size=$( eval f_dialog_menu_size \
-	        	\"\$DIALOG_TITLE\"     \
-	        	\"\$DIALOG_BACKTITLE\" \
-	                \"\$prompt\"           \
-	        	\"\$hline\"            \
-	        	$TTY_MENU_LIST         )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$DIALOG_TITLE\"     \
+	                        \"\$DIALOG_BACKTITLE\" \
+	                        \"\$prompt\"           \
+	                        \"\$hline\"            \
+	                        $TTY_MENU_LIST
 
 	local dialog_menu
 	dialog_menu=$( eval $DIALOG \
@@ -90,7 +90,8 @@ dialog_menu_main()
 		--hline \"\$hline\"                \
 		--ok-label \"\$msg_ok\"            \
 		--cancel-label \"\$msg_cancel\"    \
-		--menu \"\$prompt\" $size          \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
 		$TTY_MENU_LIST                     \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)

Modified: head/usr.sbin/bsdconfig/mouse/disable
==============================================================================
--- head/usr.sbin/bsdconfig/mouse/disable	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/mouse/disable	Fri May 31 19:07:17 2013	(r251190)
@@ -86,16 +86,14 @@ f_sysrc_delete moused_flags || f_die
 f_dialog_title "$msg_message"
 hline="$hline_press_enter_or_space"
 prompt="$msg_mouse_daemon_is_disabled"
-size=$( f_dialog_buttonbox_size \
-        	"$DIALOG_TITLE"     \
-        	"$DIALOG_BACKTITLE" \
-        	"$prompt"           )
-eval $DIALOG \
-	--title \"\$DIALOG_TITLE\"         \
-	--backtitle \"\$DIALOG_BACKTITLE\" \
-	--hline \"\$hline\"                \
-	--ok-label \"\$msg_ok\"            \
-	--msgbox \"\$prompt\" $size
+f_dialog_buttonbox_size height width \
+	"$DIALOG_TITLE" "$DIALOG_BACKTITLE" "$prompt"
+$DIALOG \
+	--title "$DIALOG_TITLE"         \
+	--backtitle "$DIALOG_BACKTITLE" \
+	--hline "$hline"                \
+	--ok-label "$msg_ok"            \
+	--msgbox "$prompt" $height $width
 
 exit $SUCCESS
 

Modified: head/usr.sbin/bsdconfig/mouse/mouse
==============================================================================
--- head/usr.sbin/bsdconfig/mouse/mouse	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/mouse/mouse	Fri May 31 19:07:17 2013	(r251190)
@@ -48,7 +48,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_
 #
 dialog_menu_main()
 {
-	local menu_list size
+	local menu_list
 	local hline=""
 	local prompt="$msg_menu_text"
 
@@ -61,12 +61,13 @@ dialog_menu_main()
 		'6 $msg_disable' '$msg_disable_the_mouse_daemon'
 	" # END-QUOTE
 
-	size=$( eval f_dialog_menu_size \
-	        	\"\$DIALOG_TITLE\"     \
-	        	\"\$DIALOG_BACKTITLE\" \
-	                \"\$prompt\"           \
-	        	\"\$hline\"            \
-	        	$menu_list             )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$DIALOG_TITLE\"     \
+	                        \"\$DIALOG_BACKTITLE\" \
+	                        \"\$prompt\"           \
+	                        \"\$hline\"            \
+	                        $menu_list
 
 	local dialog_menu
 	dialog_menu=$( eval $DIALOG \
@@ -76,7 +77,8 @@ dialog_menu_main()
 		--ok-label \"\$msg_ok\"             \
 		--cancel-label \"\$msg_cancel\"     \
 		--default-item \"\$DEFAULTITEM_$$\" \
-		--menu \"\$prompt\" $size           \
+		--menu \"\$prompt\"                 \
+		$height $width $rows                \
 		$menu_list                          \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)

Modified: head/usr.sbin/bsdconfig/mouse/port
==============================================================================
--- head/usr.sbin/bsdconfig/mouse/port	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/mouse/port	Fri May 31 19:07:17 2013	(r251190)
@@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_
 #
 dialog_menu_main()
 {
-	local menu_list size defaultitem=
+	local menu_list defaultitem=
 	local hline=""
 	local prompt="$msg_port_menu_text"
 
@@ -62,12 +62,13 @@ dialog_menu_main()
 		'6 $msg_busmouse' '$msg_busmouse_desc'
 	" # END-QUOTE
 
-	size=$( eval f_dialog_menu_size \
-	        	\"\$DIALOG_TITLE\"     \
-	        	\"\$DIALOG_BACKTITLE\" \
-	                \"\$prompt\"           \
-	        	\"\$hline\"            \
-	        	$menu_list             )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$DIALOG_TITLE\"     \
+	                        \"\$DIALOG_BACKTITLE\" \
+	                        \"\$prompt\"           \
+	                        \"\$hline\"            \
+	                        $menu_list
 
 	case "$( f_sysrc_get moused_port )" in
 	/dev/psm0)  defaultitem="1 $msg_ps2"      ;;
@@ -86,7 +87,8 @@ dialog_menu_main()
 		--ok-label \"\$msg_ok\"            \
 		--cancel-label \"\$msg_cancel\"    \
 		--default-item \"\$defaultitem\"   \
-		--menu \"\$prompt\" $size          \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
 		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)

Modified: head/usr.sbin/bsdconfig/mouse/type
==============================================================================
--- head/usr.sbin/bsdconfig/mouse/type	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/mouse/type	Fri May 31 19:07:17 2013	(r251190)
@@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_
 #
 dialog_menu_main()
 {
-	local menu_list size defaultitem=
+	local menu_list defaultitem=
 	local hline=""
 	local prompt="$msg_protocol_menu_text"
 
@@ -66,12 +66,13 @@ dialog_menu_main()
 		'A $msg_thinkingmouse' '$msg_thinkingmouse_desc'
 	" # END-QUOTE
 
-	size=$( eval f_dialog_menu_size \
-	        	\"\$DIALOG_TITLE\"     \
-	        	\"\$DIALOG_BACKTITLE\" \
-	                \"\$prompt\"           \
-	        	\"\$hline\"            \
-	        	$menu_list             )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$DIALOG_TITLE\"     \
+	                        \"\$DIALOG_BACKTITLE\" \
+	                        \"\$prompt\"           \
+	                        \"\$hline\"            \
+	                        $menu_list
 
 	case "$( f_sysrc_get moused_type )" in
 	auto)          defaultitem="1 $msg_auto"          ;;
@@ -94,7 +95,8 @@ dialog_menu_main()
 		--ok-label \"\$msg_ok\"            \
 		--cancel-label \"\$msg_cancel\"    \
 		--default-item \"\$defaultitem\"   \
-		--menu \"\$prompt\" $size          \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
 		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)

Modified: head/usr.sbin/bsdconfig/networking/networking
==============================================================================
--- head/usr.sbin/bsdconfig/networking/networking	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/networking/networking	Fri May 31 19:07:17 2013	(r251190)
@@ -48,7 +48,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_
 #
 dialog_menu_main()
 {
-	local menu_list size
+	local menu_list
 	local hline="$hline_arrows_tab_enter"
 
 	menu_list="
@@ -59,12 +59,13 @@ dialog_menu_main()
 		'4' '$msg_dns_nameservers'
 	" # END-QUOTE
 
-	size=$( eval f_dialog_menu_size \
-	        	\"\$DIALOG_TITLE\"     \
-	        	\"\$DIALOG_BACKTITLE\" \
-	                \"\"                   \
-	        	\"\$hline\"            \
-	        	$menu_list             )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$DIALOG_TITLE\"     \
+	                        \"\$DIALOG_BACKTITLE\" \
+	                        \"\"                   \
+	                        \"\$hline\"            \
+	                        $menu_list
 
 	local dialog_menu
 	dialog_menu=$( eval $DIALOG \
@@ -74,7 +75,9 @@ dialog_menu_main()
 		--ok-label \"\$msg_ok\"             \
 		--cancel-label \"\$msg_cancel\"     \
 		--default-item \"\$DEFAULTITEM_$$\" \
-		--menu \"\" $size $menu_list        \
+		--menu \"\"                         \
+		$height $width $rows                \
+		$menu_list                          \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
 	local retval=$?

Modified: head/usr.sbin/bsdconfig/networking/share/device.subr
==============================================================================
--- head/usr.sbin/bsdconfig/networking/share/device.subr	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/networking/share/device.subr	Fri May 31 19:07:17 2013	(r251190)
@@ -142,14 +142,15 @@ f_dialog_menu_netdev()
 	#
 	# Ask user to select an interface
 	#
-	local prompt size
+	local prompt
 	prompt="$msg_select_network_interface"
-	size=$( eval f_dialog_menu_size \
-	        	\"\$DIALOG_TITLE\"     \
-	        	\"\$DIALOG_BACKTITLE\" \
-	        	\"\$prompt\"           \
-	        	\"\$hline\"            \
-	        	$interfaces            )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$DIALOG_TITLE\"     \
+	                        \"\$DIALOG_BACKTITLE\" \
+	                        \"\$prompt\"           \
+	                        \"\$hline\"            \
+	                        $interfaces
 	local dialog_menu
 	dialog_menu=$( eval $DIALOG \
 		--title \"\$DIALOG_TITLE\"         \
@@ -158,7 +159,8 @@ f_dialog_menu_netdev()
 		--ok-label \"\$msg_ok\"            \
 		--cancel-label \"\$msg_cancel\"    \
 		--default-item \"\$defaultitem\"   \
-		--menu \"\$prompt\" $size          \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
 		$interfaces                        \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
@@ -175,7 +177,7 @@ f_dialog_menu_netdev()
 f_dialog_menu_netdev_edit()
 {
 	local interface="$1" ipaddr="$2" netmask="$3" options="$4" dhcp="$5"
-	local prompt menu_list size
+	local prompt menu_list height width rows
 
 	#
 	# Create a duplicate set of variables for change-tracking...
@@ -216,12 +218,12 @@ f_dialog_menu_netdev_edit()
 			'4 $msg_netmask'   '$netmask'
 			'5 $msg_options'   '$options'
 		"
-		size=$( eval f_dialog_menu_size \
-		        	\"\$DIALOG_TITLE\"     \
-		        	\"\$DIALOG_BACKTITLE\" \
-		        	\"\$prompt\"           \
-		        	\"\$hline\"            \
-		        	$menu_list             )
+		eval f_dialog_menu_size height width rows \
+		                        \"\$DIALOG_TITLE\"     \
+		                        \"\$DIALOG_BACKTITLE\" \
+		                        \"\$prompt\"           \
+		                        \"\$hline\"            \
+		                        $menu_list
 		local dialog_menu
 		dialog_menu=$( eval $DIALOG \
 			--title \"\$DIALOG_TITLE\"         \
@@ -233,7 +235,8 @@ f_dialog_menu_netdev_edit()
 			--help-label \"\$msg_help\"        \
 			${USE_XDIALOG:+--help \"\"}        \
 			--default-item \"\$defaultitem\"   \
-			--menu \"\$prompt\" $size          \
+			--menu \"\$prompt\"                \
+			$height $width $rows               \
 			$menu_list                         \
 			2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 		)

Modified: head/usr.sbin/bsdconfig/networking/share/resolv.subr
==============================================================================
--- head/usr.sbin/bsdconfig/networking/share/resolv.subr	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/networking/share/resolv.subr	Fri May 31 19:07:17 2013	(r251190)
@@ -393,10 +393,12 @@ f_dialog_input_nameserver()
 #
 f_dialog_menu_nameservers()
 {
+
+	local height width rows
 	local opt_exit="$msg_return_to_previous_menu"
 	local opt_add="$msg_add_nameserver"
 	local hline="$hline_arrows_tab_enter"
-	local prompt size defaultitem=
+	local prompt defaultitem=
 
 	#
 	# Loop forever until the user has finished configuring nameservers
@@ -427,12 +429,12 @@ f_dialog_menu_nameservers()
 		#
 		# Display configuration-edit menu
 		#
-		size=$( eval f_dialog_menu_size \
-		        	\"\$DIALOG_TITLE\"     \
-		        	\"\$DIALOG_BACKTITLE\" \
-		        	\"\$prompt\"           \
-		        	\"\$hline\"            \
-		        	$menu_list             )
+		eval f_dialog_menu_size height width rows \
+		                        \"\$DIALOG_TITLE\"     \
+		                        \"\$DIALOG_BACKTITLE\" \
+		                        \"\$prompt\"           \
+		                        \"\$hline\"            \
+		                        $menu_list
 		local dialog_menu
 		dialog_menu=$( eval $DIALOG \
 			--title \"\$DIALOG_TITLE\"         \
@@ -441,7 +443,8 @@ f_dialog_menu_nameservers()
 			--ok-label \"\$msg_ok\"            \
 			--cancel-label \"\$msg_cancel\"    \
 			--default-item \"\$defaultitem\"   \
-			--menu \"\$prompt\" $size          \
+			--menu \"\$prompt\"                \
+			$height $width $rows               \
 			$menu_list                         \
 			2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 		)

Modified: head/usr.sbin/bsdconfig/password/share/password.subr
==============================================================================
--- head/usr.sbin/bsdconfig/password/share/password.subr	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/password/share/password.subr	Fri May 31 19:07:17 2013	(r251190)
@@ -46,23 +46,25 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/inc
 f_dialog_input_password()
 {
 	local hline="$hline_alnum_punc_tab_enter"
-	local msg size rmsg rsize
+	local msg rmsg
 
 	msg=$( printf "$msg_enter_new_password" )
-	size=$( f_dialog_inputbox_size \
-	        	"$DIALOG_TITLE"     \
-	        	"$DIALOG_BACKTITLE" \
-	        	"$msg"              \
-	        	""                  \
-	        	"$hline"            )
+	local height1 width1
+	f_dialog_inputbox_size height1 width1 \
+	                       "$DIALOG_TITLE"     \
+	                       "$DIALOG_BACKTITLE" \
+	                       "$msg"              \
+	                       ""                  \
+	                       "$hline"
 
 	rmsg=$( printf "$msg_reenter_password" )
-	rsize=$( f_dialog_inputbox_size \
-	        	"$DIALOG_TITLE"     \
-	        	"$DIALOG_BACKTITLE" \
-	        	"$rmsg"             \
-	        	""                  \
-	        	"$hline"            )
+	local height2 width2
+	f_dialog_inputbox_size height2 width2 \
+	                       "$DIALOG_TITLE"     \
+	                       "$DIALOG_BACKTITLE" \
+	                       "$rmsg"             \
+	                       ""                  \
+	                       "$hline"
 
 	#
 	# Loop until the user provides taint-free/valid input
@@ -70,14 +72,15 @@ f_dialog_input_password()
 	local retval _password1 _password2
 	while :; do
 		local dialog_inputbox
-		dialog_inputbox=$( eval $DIALOG \
-			--title \"\$DIALOG_TITLE\"         \
-			--backtitle \"\$DIALOG_BACKTITLE\" \
-			--hline \"\$hline\"                \
-			--ok-label \"\$msg_ok\"            \
-			--cancel-label \"\$msg_cancel\"    \
-			--insecure                         \
-			--passwordbox \"\$msg\" $size      \
+		dialog_inputbox=$( $DIALOG \
+			--title "$DIALOG_TITLE"         \
+			--backtitle "$DIALOG_BACKTITLE" \
+			--hline "$hline"                \
+			--ok-label "$msg_ok"            \
+			--cancel-label "$msg_cancel"    \
+			--insecure                      \
+			--passwordbox "$msg"            \
+			$height1 $width1                \
 			2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 		)
 
@@ -88,14 +91,15 @@ f_dialog_input_password()
 		# Return if user has either pressed ESC or chosen Cancel/No
 		[ $retval -eq $SUCCESS ] || return $retval
 
-		dialog_inputbox=$( eval $DIALOG \
-			--title \"\$DIALOG_TITLE\"         \
-			--backtitle \"\$DIALOG_BACKTITLE\" \
-			--hline \"\$hline\"                \
-			--ok-label \"\$msg_ok\"            \
-			--cancel-label \"\$msg_cancel\"    \
-			--insecure                         \
-			--passwordbox \"\$rmsg\" $rsize    \
+		dialog_inputbox=$( $DIALOG \
+			--title "$DIALOG_TITLE"         \
+			--backtitle "$DIALOG_BACKTITLE" \
+			--hline "$hline"                \
+			--ok-label "$msg_ok"            \
+			--cancel-label "$msg_cancel"    \
+			--insecure                      \
+			--passwordbox "$rmsg"           \
+			$height2 $width2                \
 			2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 		)
 

Modified: head/usr.sbin/bsdconfig/security/kern_securelevel
==============================================================================
--- head/usr.sbin/bsdconfig/security/kern_securelevel	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/security/kern_securelevel	Fri May 31 19:07:17 2013	(r251190)
@@ -51,7 +51,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_
 #
 dialog_menu_main()
 {
-	local menu_list size defaultitem=
+	local menu_list defaultitem=
 	local hline="$hline_select_securelevel_to_operate_at"
 	local prompt="$msg_securelevels_menu_text"
 
@@ -62,12 +62,13 @@ dialog_menu_main()
 		'$msg_network_secure' '$msg_network_secure_mode'
 	" # END-QUOTE
 
-	size=$( eval f_dialog_menu_size \
-	        	\"\$DIALOG_TITLE\"     \
-	        	\"\$DIALOG_BACKTITLE\" \
-	                \"\$prompt\"           \
-	        	\"\$hline\"            \
-	        	$menu_list             )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$DIALOG_TITLE\"     \
+	                        \"\$DIALOG_BACKTITLE\" \
+	                        \"\$prompt\"           \
+	                        \"\$hline\"            \
+	                        $menu_list
 
 	case "$( f_sysrc_get kern_securelevel_enable )" in
 	[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
@@ -91,7 +92,8 @@ dialog_menu_main()
 		--help-label \"\$msg_help\"        \
 		${USE_XDIALOG:+--help \"\"}        \
 		--default-item \"\$defaultitem\"   \
-		--menu \"\$prompt\" $size          \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
 		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)

Modified: head/usr.sbin/bsdconfig/security/security
==============================================================================
--- head/usr.sbin/bsdconfig/security/security	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/security/security	Fri May 31 19:07:17 2013	(r251190)
@@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_
 #
 dialog_menu_main()
 {
-	local menu_list size mark=" " defaultitem=
+	local menu_list mark=" " defaultitem=
 	local hline="$hline_arrows_tab_enter"
 	local prompt="$msg_menu_text"
 
@@ -97,12 +97,13 @@ dialog_menu_main()
 	# Update default-item if appropriate
 	[ "$ditem" = 3 ] && defaultitem="3 [$mark] $msg_nfs_port"
 
-	size=$( eval f_dialog_menu_size \
-	        	\"\$DIALOG_TITLE\"     \
-	        	\"\$DIALOG_BACKTITLE\" \
-	                \"\$prompt\"           \
-	        	\"\$hline\"            \
-	        	$menu_list             )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$DIALOG_TITLE\"     \
+	                        \"\$DIALOG_BACKTITLE\" \
+	                        \"\$prompt\"           \
+	                        \"\$hline\"            \
+	                        $menu_list
 
 	local dialog_menu
 	dialog_menu=$( eval $DIALOG \
@@ -112,7 +113,8 @@ dialog_menu_main()
 		--ok-label \"\$msg_ok\"            \
 		--cancel-label \"\$msg_cancel\"    \
 		--default-item \"\$defaultitem\"   \
-		--menu \"\$prompt\" $size          \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
 		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)

Modified: head/usr.sbin/bsdconfig/share/device.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/device.subr	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/share/device.subr	Fri May 31 19:07:17 2013	(r251190)
@@ -607,13 +607,13 @@ f_device_menu()
 		menu_list="$menu_list '$dev' '$desc'"
 	done
 
-	local size mtag
-	size=$( eval f_dialog_menu_size \
-	         	\"\$title\"  \
-	         	\"\$btitle\" \
-	         	\"\$prompt\" \
-	         	\"\$hline\"  \
-	         	$menu_list   )
+	local height width rows
+	eval f_dialog_menu_size height width rows \
+	                        \"\$title\"  \
+	                        \"\$btitle\" \
+	                        \"\$prompt\" \
+	                        \"\$hline\"  \
+	                        $menu_list
 
 	local errexit=
 	case $- in *e*) errexit=1; esac
@@ -630,7 +630,8 @@ f_device_menu()
 			  --help-label \"\$msg_help\"   \
 			  ${USE_XDIALOG:+--help \"\"}   \
 			}                               \
-			--menu \"\$prompt\" $size       \
+			--menu \"\$prompt\"             \
+			$height $width $rows            \
 			$menu_list                      \
 			2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 		)

Modified: head/usr.sbin/bsdconfig/share/dialog.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/dialog.subr	Fri May 31 18:27:21 2013	(r251189)
+++ head/usr.sbin/bsdconfig/share/dialog.subr	Fri May 31 19:07:17 2013	(r251190)
@@ -83,6 +83,28 @@ unset XDIALOG_INFOBOX_TIMEOUT
 #
 : ${DEFAULT_TERMINAL_SIZE:=24 80}
 
+#
+# Minimum width(s) for various dialog(1) implementations (sensible global
+# default(s) for all widgets of a given variant)
+#
+: ${DIALOG_MIN_WIDTH:=24}
+: ${XDIALOG_MIN_WIDTH:=35}
+
+#
+# When manually sizing Xdialog(1) widgets such as calendar and timebox, you'll
+# need to know the size of the embedded GUI objects because the height passed
+# to Xdialog(1) for these widgets has to be tall enough to accomodate them.
+#
+# These values are helpful when manually sizing with dialog(1) too, but in a
+# different way. dialog(1) does not make you accomodate the custom items in the
+# height (but does for width) -- a height of 3 will display three lines and a
+# full calendar, for example (whereas Xdialog will truncate the calendar if
+# given a height of 3). For dialog(1), use these values for making sure that
+# the height does not exceed max_height (obtained by f_dialog_max_size()).
+#
+DIALOG_CALENDAR_HEIGHT=15
+DIALOG_TIMEBOX_HEIGHT=6
+
 ############################################################ GENERIC FUNCTIONS
 
 # f_dialog_title [$new_title]
@@ -174,889 +196,1163 @@ f_dialog_backtitle_restore()
 
 ############################################################ SIZE FUNCTIONS
 
-# f_dialog_infobox_size $title $backtitle $prompt [$hline]
-#
-# Not all versions of dialog(1) perform auto-sizing of the width and height of
-# `--infobox' boxes sensibly.
+# f_dialog_max_size $var_height $var_width
 #
-# This function helps solve this issue by taking as arguments (in order of
-# appearance) the title, backtitle, prompt, and [optionally] hline returning
-# the optimal width and height for the box (not exceeding the actual terminal
-# width or height).
+# Get the maximum height and width for a dialog widget and store the values in
+# $var_height and $var_width (respectively).
 #
-# Newline character sequences (``\n'') in $prompt are expanded as-is done by
-# dialog(1).
-#
-# Output is in the format of "height width".
-#
-f_dialog_infobox_size()
+f_dialog_max_size()
 {
-	local title="$1" btitle="$2" prompt="$3" hline="$4" n=0
-	local min_width max_size
-
+	local __var_height="$1" __var_width="$2" __max_size
+	[ "$__var_height" -o "$__var_width" ] || return $FAILURE
 	if [ "$USE_XDIALOG" ]; then
-		min_width=35
-		max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
+		__max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION
 	else
-		min_width=24
-		max_size=$( stty size 2> /dev/null ) # usually "24 80"
-		: ${max_size:=$DEFAULT_TERMINAL_SIZE}
+		__max_size=$( stty size 2> /dev/null ) # usually "24 80"
+		: ${__max_size:=$DEFAULT_TERMINAL_SIZE}
 	fi
+	[ "$__var_height" ] && setvar "$__var_height" "${__max_size%%[$IFS]*}"
+	[ "$__var_width" ] && setvar "$__var_width" "${__max_size##*[$IFS]}"
+}
 
-	local max_height="${max_size%%[$IFS]*}"
-	local max_width="${max_size##*[$IFS]}"
-	local height width=$min_width
+# f_dialog_size_constrain $var_height $var_width [$min_height [$min_width]]
+#
+# Modify $var_height to be no-less-than $min_height (if given; zero otherwise)
+# and no-greater-than terminal height (or screen height if $USE_XDIALOG is
+# set).
+#
+# Also modify $var_width to be no-less-than $XDIALOG_MIN_WIDTH (or
+# $XDIALOG_MIN_WIDTH if $_USE_XDIALOG is set) and no-greater-than terminal
+# or screen width. The use of $[X]DIALOG_MIN_WIDTH can be overridden by
+# passing $min_width.
+#
+# Return status is success unless one of the passed arguments is invalid
+# or all of the $var_* arguments are either NULL or missing.
+#
+f_dialog_size_constrain()
+{
+	local __var_height="$1" __var_width="$2"
+	local __min_height="$3" __min_width="$4"
+	local __retval=$SUCCESS
+
+	# Return failure unless at least one var_* argument is passed
+	[ "$__var_height" -o "$__var_width" ] || return $FAILURE
 
 	#
-	# Bump width for long titles (but don't exceed terminal width).
+	# Print debug warnings if any given (non-NULL) argument are invalid
+	# NOTE: Don't change the name of $__{var,min,}{height,width}
 	#
-	n=$(( ${#title} + 4 ))
-	if [ $n -gt $width -a $n -gt $min_width ]; then
-		# Add 16.6% width for Xdialog(1)
-		[ "$USE_XDIALOG" ] && n=$(( $n + $n / 6 ))
+	local __height __width
+	local __arg __cp __fname=f_dialog_size_constrain 
+	for __arg in height width; do
+		debug= f_getvar __var_$__arg __cp
+		[ "$__cp" ] || continue
+		if ! f_getvar "$__cp" __$__arg; then
+			f_dprintf "%s: var_%s variable \`%s' not set" \
+			          $__fname $__arg "$__cp"
+			__retval=$FAILURE
+		elif ! eval f_isinteger \$__$__arg; then
+			f_dprintf "%s: var_%s variable value not a number" \
+			          $__fname $__arg
+			__retval=$FAILURE
+		fi
+	done
+	for __arg in height width; do
+		debug= f_getvar __min_$__arg __cp
+		[ "$__cp" ] || continue
+		f_isinteger "$__cp" && continue
+		f_dprintf "%s: min_%s value not a number" $__fname $__arg
+		__retval=$FAILURE
+		setvar __min_$__arg ""
+	done
 
-		if [ $n -lt $max_width ]; then
-			width=$n
-		else
-			width=$max_width
+	# Obtain maximum height and width values
+	# NOTE: Function name appended to prevent __var_{height,width} values
+	#       from becoming local (and thus preventing setvar from working).
+	local __max_height_size_constain __max_width_size_constrain
+	f_dialog_max_size \
+		__max_height_size_constrain __max_width_size_constrain
+
+	# Adjust height if desired
+	if [ "$__var_height" ]; then
+		if [ $__height -lt ${__min_height:-0} ]; then
+			setvar "$__var_height" $__min_height
+		elif [ $__height -gt $__max_height_size_constrain ]; then
+			setvar "$__var_height" $__max_height_size_constrain
 		fi
 	fi
 
-	#
-	# For Xdialog(1), bump width for long backtitles (which appear within
-	# the window; don't exceed maximum width).
-	#
-	if [ "$USE_XDIALOG" ]; then
-		n=$(( ${#btitle} + 4 ))
-		n=$(( $n + $n / 6 ))

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201305311907.r4VJ7Hp8022745>