summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/mouse
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-05-31 19:07:17 +0000
committerdteske <dteske@FreeBSD.org>2013-05-31 19:07:17 +0000
commita0eece46063b1db33804c35b64793e3afc2424c1 (patch)
tree2634f68f77f7c057b30aa67f1c494a01df2e22a7 /usr.sbin/bsdconfig/mouse
parent838ba827a2bbb59d8184419cf6632b7afa203afa (diff)
downloadFreeBSD-src-a0eece46063b1db33804c35b64793e3afc2424c1.zip
FreeBSD-src-a0eece46063b1db33804c35b64793e3afc2424c1.tar.gz
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).
Diffstat (limited to 'usr.sbin/bsdconfig/mouse')
-rwxr-xr-xusr.sbin/bsdconfig/mouse/disable18
-rwxr-xr-xusr.sbin/bsdconfig/mouse/mouse18
-rwxr-xr-xusr.sbin/bsdconfig/mouse/port18
-rwxr-xr-xusr.sbin/bsdconfig/mouse/type18
4 files changed, 38 insertions, 34 deletions
diff --git a/usr.sbin/bsdconfig/mouse/disable b/usr.sbin/bsdconfig/mouse/disable
index 89ec176..09142a5 100755
--- a/usr.sbin/bsdconfig/mouse/disable
+++ b/usr.sbin/bsdconfig/mouse/disable
@@ -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
diff --git a/usr.sbin/bsdconfig/mouse/mouse b/usr.sbin/bsdconfig/mouse/mouse
index 7c333c8..6e297cd 100755
--- a/usr.sbin/bsdconfig/mouse/mouse
+++ b/usr.sbin/bsdconfig/mouse/mouse
@@ -48,7 +48,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
#
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
)
diff --git a/usr.sbin/bsdconfig/mouse/port b/usr.sbin/bsdconfig/mouse/port
index c0bc61e..c8d9586 100755
--- a/usr.sbin/bsdconfig/mouse/port
+++ b/usr.sbin/bsdconfig/mouse/port
@@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
#
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
)
diff --git a/usr.sbin/bsdconfig/mouse/type b/usr.sbin/bsdconfig/mouse/type
index 92745c6..0cd3fb7 100755
--- a/usr.sbin/bsdconfig/mouse/type
+++ b/usr.sbin/bsdconfig/mouse/type
@@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
#
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
)
OpenPOWER on IntegriCloud