Implement a dialog/rxvt workaround

Work around dialogs non being drawn on rxvt-based
terminals unless the user resizes the window.
Thanks to Phillip Warner for raising the issue.

Signed-off-by: Mauro Giachero <mauro.giachero@gmail.com>
This commit is contained in:
mauro.giachero 2009-02-16 17:36:40 +00:00
parent 5e0c45b1c2
commit 334aa785fa
2 changed files with 25 additions and 0 deletions

View File

@ -29,4 +29,6 @@ enhancements:
* Allow the usage of the -d, -f and -v command-line options in dialog mode,
and spit an error message when the command line contains unrecognized
tokens.
* Implement a workaround so that the dialog interface now works with
rxvt-based terminals. Thanks to Phillip Warner for raising the issue.
+--------------------------+

View File

@ -45,6 +45,28 @@ CWD="$(pwd)"
SBOVER=svn_r$(cat ${0} | grep '$Id: ' | head -1 | \
sed -e 's/^.*Id: sbopkg \([0-9.]*\) .*$/\1/')
dialog_rxvt_workaround() {
# Dialog and rxvt-based terminals have some problems -- the user often
# has to resize the terminal window to force a redraw, without which
# the dialogs are not drawn on the screen.
# This function enables a workaround, consisting on a background task
# sending SIGWINCH to any new dialog istance.
# Despite being probably harmless on xterm-based terminals, this function
# should really be called only on problematic terminals.
DIALOG_RXVT_WORKAROUND_SBOPKG_PID=$$
( # The background task runs in a separate shell
olddialogs=
while [[ $(ps h --pid $DIALOG_RXVT_WORKAROUND_SBOPKG_PID) ]]; do
dialogs=$(ps h |grep "[0-9]. dialog" |grep -o "^[ 0-9]*")
if [[ "$dialogs" != "$olddialogs" ]]; then
[[ "$dialogs" ]] && kill -WINCH $dialogs
olddialogs="$dialogs"
fi
sleep 0.1
done
) &
}
crunch() {
# The inspiration for this and the next function comes from the crunch()
# in installpkg. Both take one argument - the first reduces runs of spaces
@ -2861,6 +2883,7 @@ directory_checks
pid_check
if [[ "$DIAG" ]]; then
[[ "$TERM" = "rxvt" ]] && dialog_rxvt_workaround
main_menu
cleanup
else