From owner-svn-src-stable-9@FreeBSD.ORG Wed Jul 10 20:22:31 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9E1AEFDF; Wed, 10 Jul 2013 20:22:31 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8FC9819E4; Wed, 10 Jul 2013 20:22:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AKMVY4072463; Wed, 10 Jul 2013 20:22:31 GMT (envelope-from dteske@svn.freebsd.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AKMVCd072462; Wed, 10 Jul 2013 20:22:31 GMT (envelope-from dteske@svn.freebsd.org) Message-Id: <201307102022.r6AKMVCd072462@svn.freebsd.org> From: Devin Teske Date: Wed, 10 Jul 2013 20:22:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r253169 - stable/9/usr.sbin/bsdconfig/share X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 20:22:31 -0000 Author: dteske Date: Wed Jul 10 20:22:31 2013 New Revision: 253169 URL: http://svnweb.freebsd.org/changeset/base/253169 Log: MFC r253118: Fix conditional (der should match the comment above it). MFC r253117: Do two things: First, don't obscure the backtitle. Second, read ~/.dialogrc if it exists to determine if use_shadow is true (ON) or false (OFF). The purpose of determining the value of use_shadow is to know how many lines to subtract from the maximum height value in assuring that the backtitle is not obscured. The detriment of obscuring the backtitle is that it provides information that is not easily obtained elsewhere. That is the command-line shortcut used to access the current menu. As you navigate from one dialog to the next, invariably transparently corssing module boundaries, the backtitle represents the command-line argument used to get there. Obscuring this information with a widget that is too-tall and/or too-wide would see that data go unnoticed (leaving few other ways to get that information in the same helpful context). So despite the fact that this change reduces the standard maximum height for all widgets, there is a trap-door to prevent this calculation. If you want to utilize the full screen height on the terminal (remember, this adjustment is not made for Xdialog(1)) you can set $NO_BACKTITLE to 1 (or any non-NULL value for that matter) and this calculation will be skipped. You will be able to draw a widget that partially obscures the backtitle if-necessary. Modified: stable/9/usr.sbin/bsdconfig/share/dialog.subr Modified: stable/9/usr.sbin/bsdconfig/share/dialog.subr ============================================================================== --- stable/9/usr.sbin/bsdconfig/share/dialog.subr Wed Jul 10 20:20:23 2013 (r253168) +++ stable/9/usr.sbin/bsdconfig/share/dialog.subr Wed Jul 10 20:22:31 2013 (r253169) @@ -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.