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/console/screenmap | |
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/console/screenmap')
-rwxr-xr-x | usr.sbin/bsdconfig/console/screenmap | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/usr.sbin/bsdconfig/console/screenmap b/usr.sbin/bsdconfig/console/screenmap index 643e671..7d72c48 100755 --- a/usr.sbin/bsdconfig/console/screenmap +++ b/usr.sbin/bsdconfig/console/screenmap @@ -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="$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 ) |