From 334aa785fa470da6a700a7b52e85c75df4db8919 Mon Sep 17 00:00:00 2001 From: "mauro.giachero" Date: Mon, 16 Feb 2009 17:36:40 +0000 Subject: [PATCH] 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 --- ChangeLog-current.txt | 2 ++ src/usr/bin/sbopkg | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/ChangeLog-current.txt b/ChangeLog-current.txt index a38b720..d60687e 100644 --- a/ChangeLog-current.txt +++ b/ChangeLog-current.txt @@ -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. +--------------------------+ diff --git a/src/usr/bin/sbopkg b/src/usr/bin/sbopkg index 45b47a6..8331c71 100755 --- a/src/usr/bin/sbopkg +++ b/src/usr/bin/sbopkg @@ -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