[GRASS-SVN] r31009 - in grass/branches/releasebranch_6_3: lib/init macosx/app

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Apr 15 13:10:05 EDT 2008


Author: kyngchaos
Date: 2008-04-15 13:10:05 -0400 (Tue, 15 Apr 2008)
New Revision: 31009

Added:
   grass/branches/releasebranch_6_3/lib/init/grass-xterm-mac
Modified:
   grass/branches/releasebranch_6_3/lib/init/Makefile
   grass/branches/releasebranch_6_3/lib/init/variables.html
   grass/branches/releasebranch_6_3/macosx/app/grass.sh.in
Log:
finish OSX backports for xterm wrapper and makefile targets; r30347, r30704, r30773

Modified: grass/branches/releasebranch_6_3/lib/init/Makefile
===================================================================
--- grass/branches/releasebranch_6_3/lib/init/Makefile	2008-04-15 15:03:19 UTC (rev 31008)
+++ grass/branches/releasebranch_6_3/lib/init/Makefile	2008-04-15 17:10:05 UTC (rev 31009)
@@ -55,9 +55,14 @@
 	$(ETC)/grass_dialog.ico \
 	$(ETC)/grass_sql.ico \
 	$(ETC)/grass-run.sh \
-	$(ETC)/grass-xterm-wrapper \
-	$(ETC)/html_browser_mac.sh
+	$(ETC)/grass-xterm-wrapper
 
+ifeq ($(findstring darwin,$(ARCH)),darwin)
+	FILES += \
+		$(ETC)/grass-xterm-mac \
+		$(ETC)/html_browser_mac.sh
+endif
+
 ifneq ($(strip $(MINGW)),)
 	FILES += \
 		$(ARCH_BINDIR)/$(START_UP).bat \
@@ -200,11 +205,13 @@
 $(ETC)/grass-xterm-wrapper: grass-xterm-wrapper
 	$(INSTALL) -m 755 grass-xterm-wrapper $(ETC)
 
+$(ETC)/grass-xterm-mac: grass-xterm-mac
+	$(INSTALL) grass-xterm-mac $(ETC)
+
 $(ETC)/prompt.sh: prompt.sh
 	rm -f $@
 	$(INSTALL) -m 755 prompt.sh $(ETC)
 
 $(ETC)/html_browser_mac.sh: html_browser_mac.sh
-	rm -f $@
-	@if [ "`cat ../../include/Make/Platform.make | grep -i '^ARCH.*darwin'`" ] ; then $(INSTALL) -m 755 html_browser_mac.sh $(ETC) ; fi
+	$(INSTALL) html_browser_mac.sh $(ETC)
 

Added: grass/branches/releasebranch_6_3/lib/init/grass-xterm-mac
===================================================================
--- grass/branches/releasebranch_6_3/lib/init/grass-xterm-mac	                        (rev 0)
+++ grass/branches/releasebranch_6_3/lib/init/grass-xterm-mac	2008-04-15 17:10:05 UTC (rev 31009)
@@ -0,0 +1,73 @@
+#!/bin/sh
+# script to emulate an xterm in OSX Terminal.app
+# 
+# -William Kyngesburye
+
+# just in case accidentally called on another system
+SYSTEMOSX=`uname -s | grep "Darwin"`
+
+if [ "$SYSTEMOSX" ] ; then
+    # manually transfer the necessary env vars
+    TMPSCRIPT="/tmp/grassxterm_$$"
+    touch "$TMPSCRIPT.sh"
+    chmod +x "$TMPSCRIPT.sh"
+    echo "#!/bin/sh" > "$TMPSCRIPT.sh"
+    
+    echo "DISPLAY=$DISPLAY" >> "$TMPSCRIPT.sh"
+    echo "PATH=\"$PATH\"" >> "$TMPSCRIPT.sh"
+    echo "GIS_LOCK=\"$GIS_LOCK\"" >> "$TMPSCRIPT.sh"
+    echo "GISRC=\"$GISRC\"" >> "$TMPSCRIPT.sh"
+    echo "GISBASE=\"$GISBASE\"" >> "$TMPSCRIPT.sh"
+    echo "GRASS_VERSION=\"$GRASS_VERSION\"" >> "$TMPSCRIPT.sh"
+    echo "GRASS_PAGER=$GRASS_PAGER" >> "$TMPSCRIPT.sh"
+    echo "DYLD_LIBRARY_PATH=\"$DYLD_LIBRARY_PATH\"" >> "$TMPSCRIPT.sh"
+    echo "GRASS_LD_LIBRARY_PATH=\"$GRASS_LD_LIBRARY_PATH\"" >> "$TMPSCRIPT.sh"
+    echo "GRASS_WISH=\"$GRASS_WISH\"" >> "$TMPSCRIPT.sh"
+    echo "GRASS_TCLSH=\"$GRASS_TCLSH\"" >> "$TMPSCRIPT.sh"
+    echo "GRASS_HTML_BROWSER=\"$GRASS_HTML_BROWSER\"" >> "$TMPSCRIPT.sh"
+    echo "GRASS_HTML_BROWSER_MACOSX=\"$GRASS_HTML_BROWSER_MACOSX\"" >> "$TMPSCRIPT.sh"
+    echo "export DISPLAY PATH GIS_LOCK GISRC GISBASE GRASS_VERSION GRASS_PAGER DYLD_LIBRARY_PATH GRASS_LD_LIBRARY_PATH GRASS_WISH GRASS_TCLSH GRASS_HTML_BROWSER GRASS_HTML_BROWSER_MACOSX" >> "$TMPSCRIPT.sh"
+    if [ "$GRASS_ADDON_PATH" ] ; then
+        echo "GRASS_ADDON_PATH=\"$GRASS_ADDON_PATH\"" >> "$TMPSCRIPT.sh"
+        echo "export GRASS_ADDON_PATH" >> "$TMPSCRIPT.sh"
+    fi
+    if [ "$TCL_LIBRARY" ] ; then
+        echo "TCL_LIBRARY=\"$TCL_LIBRARY\"" >> "$TMPSCRIPT.sh"
+        echo "export TCL_LIBRARY" >> "$TMPSCRIPT.sh"
+    fi
+    if [ "$TK_LIBRARY" ] ; then
+        echo "TK_LIBRARY=\"$TK_LIBRARY\"" >> "$TMPSCRIPT.sh"
+        echo "export TK_LIBRARY" >> "$TMPSCRIPT.sh"
+    fi
+
+    # get command, ignore all other xterm flags
+    while true ; do
+        if [ "$1" = "-e" ] ; then break ; fi
+        shift
+    done
+    shift
+    # and add it to end of script
+    echo "$@" >> "$TMPSCRIPT.sh"
+
+    # execute
+    # save current active app/window, return to it when script finishes.
+    osascript - <<EOF
+--tell application "System Events"
+--	set save_app to item 1 of (get name of processes whose frontmost is true)
+--end tell
+tell application "Terminal"
+	activate
+	-- start new window with env/cmd script
+	do script "$TMPSCRIPT.sh; exit"
+	tell window 1
+		-- wait for it to finish
+		repeat while (processes is not equal to {})
+			delay 1
+		end repeat
+		close
+	end tell
+end tell
+--tell application save_app to activate
+EOF
+    rm -f "$TMPSCRIPT.sh"
+fi


Property changes on: grass/branches/releasebranch_6_3/lib/init/grass-xterm-mac
___________________________________________________________________
Name: svn:executable
   + *

Modified: grass/branches/releasebranch_6_3/lib/init/variables.html
===================================================================
--- grass/branches/releasebranch_6_3/lib/init/variables.html	2008-04-15 15:03:19 UTC (rev 31008)
+++ grass/branches/releasebranch_6_3/lib/init/variables.html	2008-04-15 17:10:05 UTC (rev 31009)
@@ -197,7 +197,11 @@
 
 <p>GRASS_XTERM
 <br>lib/init/grass-xterm-wrapper
-<br>&nbsp; set to any value (e.g. rxvt, aterm, gnome-terminal, konsole, Terminal.app) to substitute 'x-terminal-emulator' or 'xterm'
+<br>lib/init/grass-xterm-mac
+<br>&nbsp; set to any value (e.g. rxvt, aterm, gnome-terminal, konsole) to
+substitute 'x-terminal-emulator' or 'xterm'. The Mac OS X app
+startup defaults to an internal '$GISBASE/etc/grass-xterm-mac',
+which emulates the necessary xterm functionality in Terminal.app.
 
 <p>GRASS_UI_TERM
 <br>&nbsp; set to any value to use the terminal based parser

Modified: grass/branches/releasebranch_6_3/macosx/app/grass.sh.in
===================================================================
--- grass/branches/releasebranch_6_3/macosx/app/grass.sh.in	2008-04-15 15:03:19 UTC (rev 31008)
+++ grass/branches/releasebranch_6_3/macosx/app/grass.sh.in	2008-04-15 17:10:05 UTC (rev 31009)
@@ -75,18 +75,35 @@
 fi
 export GRASS_FONT_CAP
 
+# default xterm Terminal emulator
+# note: only app startup defaults this way, CLI build still defaults to xterm
+if [ ! "$GRASS_XTERM" ] ; then
+	GRASS_XTERM="$GISBASE/etc/grass-xterm-mac"
+	export GRASS_XTERM
+fi
+
+# determine current term application (when grass.sh is run directly by the user)
+# use osascript so we can get name of term app, not shell process
+USERTERM=`osascript -e 'tell application "System Events" to item 1 of (get name of processes whose frontmost is true)'`
+if [ ! "$USERTERM" ] ; then
+	USERTERM="Terminal"
+fi
+
 ### X11 stuff
 
-# start X11 if not running - no need to check if running when using 'open'
+# start X11 if not running
 # some users may be annoyed by this, but X11 required for some stuff for now
 if [ -d "/Applications/Utilities/X11.app" ] ; then
 	# no need to start Leopard X11.app
 	if [ ! -d "/usr/X11" ] ; then
-		open /Applications/Utilities/X11.app
+		# check if running anyways, even though not necessary with "open"
+		if [ ! "`ps -axc | grep 'X11$'`" ] ; then
+			open /Applications/Utilities/X11.app
+		fi
 	fi
 fi
 
-# xterm - make sure X11 is in PATH
+# make sure X11 is in PATH
 pathX11=`echo "$PATH" | grep '/usr/X11\(R6\)\?/bin'`
 if [ ! "$pathX11" ] ; then
 	if [ -d "/usr/X11" ] ; then
@@ -118,19 +135,22 @@
 	DISPLAY=:0.0
 	export DISPLAY
 fi
+
 ### end X11 block
 
 # if gisrc has text startup, switch back to Terminal (gotta duplicate some init.sh stuff)
 # eventually, when TclTk optional, can run appropriate apps per GUI here (ie X11)
 GISRCRC="$HOME/.grassrc6"
-if [ -f "$GISRCRC" ] ; then
-	GRASS_GUI=`awk '/GRASS_GUI/ {print $2}' "$GISRCRC"`
-fi
 if [ ! "$GRASS_GUI" ] ; then
-	GRASS_GUI="tcltk"
+	if [ -f "$GISRCRC" ] ; then
+		GRASS_GUI=`awk '/GRASS_GUI/ {print $2}' "$GISRCRC"`
+	fi
+	if [ ! "$GRASS_GUI" ] ; then
+		GRASS_GUI="tcltk"
+	fi
 fi
 if [ "$GRASS_GUI" = "text" ] ; then
-	osascript -e 'tell application "Terminal" to activate'
+	osascript -e "tell application \"$USERTERM\" to activate"
 fi
 
 exec "$GISBASE/etc/Init.sh" "$@"



More information about the grass-commit mailing list