diff options
Diffstat (limited to 'usr.sbin/bsdconfig/share/dialog.subr')
-rw-r--r-- | usr.sbin/bsdconfig/share/dialog.subr | 58 |
1 files changed, 52 insertions, 6 deletions
diff --git a/usr.sbin/bsdconfig/share/dialog.subr b/usr.sbin/bsdconfig/share/dialog.subr index 62954b8..bde3753 100644 --- a/usr.sbin/bsdconfig/share/dialog.subr +++ b/usr.sbin/bsdconfig/share/dialog.subr @@ -1,7 +1,7 @@ if [ ! "$_DIALOG_SUBR" ]; then _DIALOG_SUBR=1 # # Copyright (c) 2006-2013 Devin Teske -# All Rights Reserved. +# All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -13,11 +13,11 @@ if [ ! "$_DIALOG_SUBR" ]; then _DIALOG_SUBR=1 # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY @@ -195,8 +195,8 @@ f_dialog_line_sanitize() # argument is NULL, the current title is returned. # # Each time this function is called, a backup of the current values is made -# allowing a one-time (single-level) restoration of the previous title using the -# f_dialog_title_restore() function (below). +# allowing a one-time (single-level) restoration of the previous title using +# the f_dialog_title_restore() function (below). # f_dialog_title() { @@ -292,7 +292,31 @@ f_dialog_max_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]*}" + if [ "$__var_height" ]; then + local __height="${__max_size%%[$IFS]*}" + # + # If we're not using Xdialog(1), we should assume that $DIALOG + # will render --backtitle behind the widget. In such a case, we + # should prevent a widget from obscuring the backtitle (unless + # $NO_BACKTITLE is set and non-NULL, allowing a trap-door). + # + if [ ! "$USE_XDIALOG" ] && [ ! "$NO_BACKTITLE" ]; then + # + # If use_shadow (in ~/.dialogrc) is OFF, we need to + # subtract 4, otherwise 5. However, don't check this + # every time, rely on an initialization variable set + # by f_dialog_init(). + # + local __adjust=5 + [ "$NO_SHADOW" ] && __adjust=4 + + # Don't adjust height if already too small (allowing + # obscured backtitle for small values of __height). + [ ${__height:-0} -gt 11 ] && + __height=$(( $__height - $__adjust )) + fi + setvar "$__var_height" "$__height" + fi [ "$__var_width" ] && setvar "$__var_width" "${__max_size##*[$IFS]}" } @@ -1999,6 +2023,12 @@ f_dialog_menutag2index_with_help() # that (while running as root) sudo(8) authentication is # required to proceed. # +# Also reads ~/.dialogrc for the following information: +# +# NO_SHADOW Either NULL or Non-NULL. If use_shadow is OFF (case- +# insensitive) in ~/.dialogrc this is set to "1" (otherwise +# unset). +# f_dialog_init() { DIALOG_SELF_INITIALIZE= @@ -2058,6 +2088,22 @@ f_dialog_init() fi # + # Read ~/.dialogrc (unless using Xdialog(1)) for properties + # + if [ -f ~/.dialogrc -a ! "$USE_XDIALOG" ]; then + eval "$( + awk -v param=use_shadow -v expect=OFF \ + -v set="NO_SHADOW=1" ' + !/^[[:space:]]*(#|$)/ && \ + tolower($1) ~ "^"param"(=|$)" && \ + /[^#]*=/ { + sub(/^[^=]*=[[:space:]]*/, "") + if ( toupper($1) == expect ) print set";" + }' ~/.dialogrc + )" + fi + + # # If we're already running as root but we got there by way of sudo(8) # and we have X11, we should merge the xauth(1) credentials from our # original user. |