diff options
author | dteske <dteske@FreeBSD.org> | 2013-05-31 19:07:17 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2013-05-31 19:07:17 +0000 |
commit | a0eece46063b1db33804c35b64793e3afc2424c1 (patch) | |
tree | 2634f68f77f7c057b30aa67f1c494a01df2e22a7 /usr.sbin/bsdconfig/share/media/ftp.subr | |
parent | 838ba827a2bbb59d8184419cf6632b7afa203afa (diff) | |
download | FreeBSD-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/share/media/ftp.subr')
-rw-r--r-- | usr.sbin/bsdconfig/share/media/ftp.subr | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/usr.sbin/bsdconfig/share/media/ftp.subr b/usr.sbin/bsdconfig/share/media/ftp.subr index 4f6add0..639f7c3 100644 --- a/usr.sbin/bsdconfig/share/media/ftp.subr +++ b/usr.sbin/bsdconfig/share/media/ftp.subr @@ -229,13 +229,13 @@ f_dialog_menu_media_ftp() ' $msg_usa #15' 'ftp15.us.freebsd.org' " # END-QUOTE - local size - 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 dialog_menu retval mtag value dialog_menu=$( eval $DIALOG \ @@ -244,7 +244,8 @@ f_dialog_menu_media_ftp() --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ - --menu \"\$prompt\" $size \ + --menu \"\$prompt\" \ + $height $width $rows \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) |