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/device.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/device.subr')
-rw-r--r-- | usr.sbin/bsdconfig/share/device.subr | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/usr.sbin/bsdconfig/share/device.subr b/usr.sbin/bsdconfig/share/device.subr index c1a7b16..f973bb8 100644 --- a/usr.sbin/bsdconfig/share/device.subr +++ b/usr.sbin/bsdconfig/share/device.subr @@ -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 ) |