aboutsummaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorEitan Adler <eadler@FreeBSD.org>2012-08-31 16:04:08 +0000
committerEitan Adler <eadler@FreeBSD.org>2012-08-31 16:04:08 +0000
commitbdc98b35f5de2702d581e4c65b31635d06d6409d (patch)
tree0f2e303106ca8907c3a4cabfc33d39a216362384 /Tools
parent04a589dee461871aebdce14781d985b295d8d0cb (diff)
downloadports-bdc98b35f5de2702d581e4c65b31635d06d6409d.tar.gz
ports-bdc98b35f5de2702d581e4c65b31635d06d6409d.zip
Notes
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/scripts/dialogwrapper/dialogwrapper.sh75
-rw-r--r--Tools/scripts/dialogwrapper/readme.txt75
2 files changed, 150 insertions, 0 deletions
diff --git a/Tools/scripts/dialogwrapper/dialogwrapper.sh b/Tools/scripts/dialogwrapper/dialogwrapper.sh
new file mode 100755
index 000000000000..75e3f69b1576
--- /dev/null
+++ b/Tools/scripts/dialogwrapper/dialogwrapper.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+# dialog wrapper script
+
+AWK="/usr/bin/awk"
+DIALOG="/usr/bin/dialog"
+ECHO="/bin/echo"
+SED="/usr/bin/sed"
+STTY="/bin/stty"
+
+# get terminal size
+size=$( ${STTY} size )
+visheight="${size%%[$IFS]*}"
+visheight=$(($visheight-3))
+listheight=$(($visheight-6))
+viswidth="${size#*[$IFS]}"
+viswidth=$(($viswidth-10))
+descwidth=$(($viswidth-22))
+
+# test for a minimum version of dialog(1)
+DIALOG_VER="0"
+DIALOG_MIN="1.1-20100428"
+dialogout=$( ${DIALOG} --print-version 2>&1 )
+if [ $? -eq 0 ]; then
+ DIALOG_VER=$( ${ECHO} "$dialogout" | ${SED} -e 's/^[^0-9]*//' )
+ # only newer versions of dialog have --item-help
+ HAS_ITEM_HELP="1"
+fi
+
+# escape the menu title
+TITLE=$( ${AWK} -v title="$2" \
+ 'BEGIN { gsub(/'\''/, "'\''\\'\'\''", title); print title }' )
+
+cmdstr=""
+[ "${HAS_ITEM_HELP}" ] && cmdstr="--item-help"
+cmdstr="$cmdstr $1 '$2' $visheight $viswidth $listheight"
+shift 5
+
+menulist=$(
+ varlist=
+ _maxvarlen=0
+ while [ $# -gt 0 ]; do
+ var="$1"
+ [ ${#var} -gt $_maxvarlen ] && export _maxvarlen=${#var}
+ varlist="$varlist${varlist:+
+}$var"
+ # build hashed environment variables
+ export _${var}_desc="$2"
+ export _${var}_val="$3"
+ shift 3
+ done
+ ${ECHO} "$varlist" \
+ | ${AWK} -v hasitemhelp="${HAS_ITEM_HELP}" -v viswid="$viswidth" '
+ {
+ var = $1
+ desc = ENVIRON["_" var "_desc"]
+ val = ENVIRON["_" var "_val"]
+ descwid = viswid -(ENVIRON["_maxvarlen"] + 12)
+ extdesc = ""
+ if ( length(desc) > descwid ) {
+ extdesc = substr(desc, descwid)
+ gsub(/'\''/, "'\''\\'\'\''", extdesc)
+ desc = substr(desc, 1, descwid - 1) "+"
+ }
+ gsub(/'\''/, "'\''\\'\'\''", desc)
+ printf "'\''%s'\'' '\''%s'\'' '\''%s'\''", var, desc, val
+ if ( hasitemhelp ) printf " '\''%s'\''", extdesc
+ printf "\n"
+ } '
+)
+
+eval ${DIALOG} $cmdstr $menulist
+status="$?"
+echo
+exit $status
diff --git a/Tools/scripts/dialogwrapper/readme.txt b/Tools/scripts/dialogwrapper/readme.txt
new file mode 100644
index 000000000000..7290d1499771
--- /dev/null
+++ b/Tools/scripts/dialogwrapper/readme.txt
@@ -0,0 +1,75 @@
+Updated August 6, 2012
+
+Bug fix for use on FreeBSD 8.x supplied by Devin Teske. Thanks!
+
+
+What is this?
+
+This is a sh/awk wrapper script to give the ports options setting screen
+more features:
+
+ Extended descriptions for FreeBSD 8.3+ and 9.0+. Port maintainers can
+ make descriptions longer and more explanatory.
+
+ Auto-sizing of the option screen to fit the terminal window. Wider or
+ taller windows can display more of the descriptions, or more options.
+ Windows smaller than 80x24 also work.
+
+ Older versions of dialog(1) had a bug in displaying descriptions that
+ are longer than the available space. When an old version of dialog is
+ detected, descriptions are cut to the available space. These earlier
+ versions of dialog did not support the --item-help feature used to
+ show extended descriptions, so only the trimmed description will be
+ shown. Descriptions that have been trimmed will still end in a "+" to
+ indicate that part of it has been trimmed.
+
+
+
+Installation
+
+Download http://www.wonkity.com/~wblock/dialogwrapper/dialogwrapper.sh
+to /usr/ports/Tools/scripts.
+
+Make it executable.
+
+Edit /etc/make.conf:
+
+ DIALOG="/usr/ports/Tools/scripts/dialogwrapper.sh"
+
+
+
+Testing long descriptions
+
+Open a terminal window and resize it, making it narrower than the
+default 80 columns. Try 60 or 70 columns.
+
+su to root and run 'make config' for a port that uses long descriptions.
+For example:
+
+ # cd /usr/ports/audio/xmms2
+ # make config
+
+Descriptions that are too long to fit in the window are shown ending in
+a "+". Scroll downward through the settings to see that the missing
+part of the description is shown at the bottom of the screen.
+
+
+
+Testing auto-sizing
+
+Open a terminal window and resize it, making it taller than the default
+24 lines. print/ghostscript9 is a good example.
+
+ # cd /usr/ports/print/ghostscript9
+ # make config
+
+
+
+Work remaining to be done
+
+Cleanup of the code and additional comments.
+
+Testing.
+
+The trimming algorithm should break the description on whitespace to
+improve readability. fold(1) may be an easy way to do that.