Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Sep 2012 02:56:50 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r303457 - in head/Tools/scripts: . dialogwrapper
Message-ID:  <201209010256.q812uo66037976@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Sat Sep  1 02:56:50 2012
New Revision: 303457
URL: http://svn.freebsd.org/changeset/ports/303457

Log:
  By request, move dialogwrapper to the main folder and fix the readme.
  
  Additionally, document the wrapper in the main readme

Added:
  head/Tools/scripts/dialogwrapper.sh
     - copied unchanged from r303448, head/Tools/scripts/dialogwrapper/dialogwrapper.sh
  head/Tools/scripts/dialogwrapper.txt
     - copied, changed from r303448, head/Tools/scripts/dialogwrapper/readme.txt
Deleted:
  head/Tools/scripts/dialogwrapper/
Modified:
  head/Tools/scripts/README

Modified: head/Tools/scripts/README
==============================================================================
--- head/Tools/scripts/README	Sat Sep  1 02:52:46 2012	(r303456)
+++ head/Tools/scripts/README	Sat Sep  1 02:56:50 2012	(r303457)
@@ -19,6 +19,8 @@ chkorigin.sh - checks all ports in the t
 close-pr  - a slightly hacked version of edit-pr(1) to quickly close PR.
 de-pkg-comment - converts pkg-comment to COMMENT (will be obsoleted when
                  the mass conversion is finished)
+dialogwrapper.sh - a wrapper for dialog(1) which provides extra features
+			and compatability
 distclean - compare md5 sums of distfiles in ports/distfiles with currently
             installed ports collection in ports/* and prompt to remove
             unmatched entries

Copied: head/Tools/scripts/dialogwrapper.sh (from r303448, head/Tools/scripts/dialogwrapper/dialogwrapper.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/Tools/scripts/dialogwrapper.sh	Sat Sep  1 02:56:50 2012	(r303457, copy of r303448, head/Tools/scripts/dialogwrapper/dialogwrapper.sh)
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+# $FreeBSD$
+
+# 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

Copied and modified: head/Tools/scripts/dialogwrapper.txt (from r303448, head/Tools/scripts/dialogwrapper/readme.txt)
==============================================================================
--- head/Tools/scripts/dialogwrapper/readme.txt	Fri Aug 31 22:36:00 2012	(r303448, copy source)
+++ head/Tools/scripts/dialogwrapper.txt	Sat Sep  1 02:56:50 2012	(r303457)
@@ -29,17 +29,11 @@ more features:
 
 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
@@ -65,8 +59,6 @@ Open a terminal window and resize it, ma
   # cd /usr/ports/print/ghostscript9
   # make config
 
-
-
 Work remaining to be done
 
 Cleanup of the code and additional comments.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209010256.q812uo66037976>