Advertisement
devinteske

Don't obscure backtitle line

Jul 9th, 2013
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.43 KB | None | 0 0
  1. --- /usr/share/bsdconfig/dialog.subr.orig   2013-07-09 09:32:56.000000000 -0700
  2. +++ /usr/share/bsdconfig/dialog.subr    2013-07-09 11:11:09.000000000 -0700
  3. @@ -292,7 +292,31 @@ f_dialog_max_size()
  4.         __max_size=$( stty size 2> /dev/null ) # usually "24 80"
  5.         : ${__max_size:=$DEFAULT_TERMINAL_SIZE}
  6.     fi
  7. -   [ "$__var_height" ] && setvar "$__var_height" "${__max_size%%[$IFS]*}"
  8. +   if [ "$__var_height" ]; then
  9. +       local __height="${__max_size%%[$IFS]*}"
  10. +       #
  11. +       # If we're not using Xdialog(1), we should assume that $DIALOG
  12. +       # will render --backtitle behind the widget. In such a case, we
  13. +       # should prevent the widget from obscuring the backtitle (unless
  14. +       # $NO_BACKTITLE is set and non-NULL, allowing a trap-door).
  15. +       #
  16. +       if [ ! "$USE_XDIALOG" ] && [ ! "$NO_BACKTITLE" ]; then
  17. +           #
  18. +           # If use_shadow (in ~/.dialogrc) is OFF, we need to
  19. +           # subtract 4, otherwise 5. However, don't check this
  20. +           # every time, rely on an initialization variable set
  21. +           # by f_dialog_init().
  22. +           #
  23. +           local __adjust=5
  24. +           [ "$NO_SHADOW" ] && __adjust=4
  25. +
  26. +           # Don't adjust the height if already too small (allowing
  27. +           # obscured backtitle for small values of __height).
  28. +           [ ${__height:-0} -gt 11 ] &&
  29. +               __height=$(( $__height - $__adjust ))
  30. +       fi
  31. +       setvar "$__var_height" "$__height"
  32. +   fi
  33.     [ "$__var_width" ] && setvar "$__var_width" "${__max_size##*[$IFS]}"
  34.  }
  35.  
  36. @@ -1999,6 +2023,12 @@ f_dialog_menutag2index_with_help()
  37.  #                that (while running as root) sudo(8) authentication is
  38.  #                required to proceed.
  39.  #
  40. +# Also reads ~/.dialogrc for the following information:
  41. +#
  42. +#  NO_SHADOW     Either NULL or Non-NULL. If use_shadow is OFF (case-
  43. +#                insensitive) in ~/.dialogrc this is set to "1" (otherwise
  44. +#                unset).
  45. +#
  46.  f_dialog_init()
  47.  {
  48.     DIALOG_SELF_INITIALIZE=
  49. @@ -2058,6 +2088,22 @@ f_dialog_init()
  50.     fi
  51.  
  52.     #
  53. +   # Read ~/.dialogrc (unless using Xdialog(1)) for properties
  54. +   #
  55. +   if [ -f ~/.dialogrc ]; then
  56. +       eval "$(
  57. +           awk -v param=use_shadow -v expect=OFF \
  58. +               -v set="NO_SHADOW=1" '
  59. +           !/^[[:space:]]*(#|$)/ && \
  60. +           tolower($1) ~ "^"param"(=|$)" && \
  61. +           /[^#]*=/ {
  62. +               sub(/^[^=]*=[[:space:]]*/, "")
  63. +               if ( toupper($1) == expect ) print set";"
  64. +           }' ~/.dialogrc
  65. +       )"
  66. +   fi
  67. +
  68. +   #
  69.     # If we're already running as root but we got there by way of sudo(8)
  70.     # and we have X11, we should merge the xauth(1) credentials from our
  71.     # original user.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement