[PD-cvs] SF.net SVN: pure-data:[10616] branches/pd-devel/0.41.4/src

eighthave at users.sourceforge.net eighthave at users.sourceforge.net
Sat Jan 24 08:58:48 CET 2009


Revision: 10616
          http://pure-data.svn.sourceforge.net/pure-data/?rev=10616&view=rev
Author:   eighthave
Date:     2009-01-24 07:58:48 +0000 (Sat, 24 Jan 2009)

Log Message:
-----------
- rewrote pdtk_enquote as enquote_filename and got all characters working
  except " doesn't work on SaveAs.  " does work on Open and Save though.

- sorted out global pd_opendir and pd_untitleddir and handled if they are
  renamed while in use

Modified Paths:
--------------
    branches/pd-devel/0.41.4/src/pd.tk
    branches/pd-devel/0.41.4/src/pd_menucommands.tcl
    branches/pd-devel/0.41.4/src/pdtk_canvas.tcl
    branches/pd-devel/0.41.4/src/wheredoesthisgo.tcl

Modified: branches/pd-devel/0.41.4/src/pd.tk
===================================================================
--- branches/pd-devel/0.41.4/src/pd.tk	2009-01-24 06:42:44 UTC (rev 10615)
+++ branches/pd-devel/0.41.4/src/pd.tk	2009-01-24 07:58:48 UTC (rev 10616)
@@ -26,8 +26,7 @@
 set windowingsystem ""
 
 set pd_opendir [pwd]
-set pd_savedir [pwd]
-set pd_saveasdir [pwd]
+set pd_untitleddir [pwd]
 
 #------------------------------------------------------------------------------#
 # packages for this project
@@ -77,18 +76,7 @@
 # canvas    manipulates a canvas
 # text      manipulates a Tk 'text' widget
 
-
 # ------------------------------------------------------------------------------
-# quoting functions
-
-# enquote a string to send it to a tcl function
-proc pdtk_enquote {x} {
-    set foo [string map {"," "" ";" "" \" ""} $x]
-    set foo2 [string map {" " "\\ "} $foo]
-    concat $foo2
-}
-
-# ------------------------------------------------------------------------------
 # init functions
 
 proc init {} {
@@ -138,7 +126,7 @@
 	pdtk_post "args: $args"
 	set oldtclversion 0
 	set fontlist "8 5 10 9 6 11 10 6 13 12 7 15 14 8 17 16 10 20 18 11 22 24 14 30 30 18 37 36 22 45"
-	pdsend "pd init [pdtk_enquote [pwd]] $oldtclversion $fontlist"
+	pdsend "pd init [enquote_filename [pwd]] $oldtclversion $fontlist"
 	# TODO what else is needed from the original?
 }
 

Modified: branches/pd-devel/0.41.4/src/pd_menucommands.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/pd_menucommands.tcl	2009-01-24 06:42:44 UTC (rev 10615)
+++ branches/pd-devel/0.41.4/src/pd_menucommands.tcl	2009-01-24 07:58:48 UTC (rev 10616)
@@ -5,7 +5,6 @@
 
 namespace eval ::pd_menucommands:: {
     variable untitled_number "1"
-    variable untitled_directory [pwd]
 
 	namespace export menu_*
 
@@ -16,14 +15,15 @@
 
 proc ::pd_menucommands::menu_new {} {
     variable untitled_number
-    variable untitled_directory
-    pdsend "pd filename Untitled-$untitled_number $untitled_directory"
+	if { ! [file isdirectory $::pd_untitleddir]} {set ::pd_untitleddir [pwd]}
+    pdsend "pd filename Untitled-$untitled_number [enquote_filename $::pd_untitleddir]"
     pdsend "#N canvas"
 	pdsend "#X pop 1"
     set untitled_number [expr $untitled_number + 1]
 }
 
 proc ::pd_menucommands::menu_open {} {
+	if { ! [file isdirectory $::pd_opendir]} {set ::pd_opendir [pwd]}
 	set files [tk_getOpenFile -defaultextension .pd \
 					   -multiple true \
 					   -filetypes $::filetypes \

Modified: branches/pd-devel/0.41.4/src/pdtk_canvas.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/pdtk_canvas.tcl	2009-01-24 06:42:44 UTC (rev 10615)
+++ branches/pd-devel/0.41.4/src/pdtk_canvas.tcl	2009-01-24 07:58:48 UTC (rev 10616)
@@ -44,6 +44,7 @@
 }
 
 proc pdtk_canvas_saveas {name initialfile initialdir} {
+	if { ! [file isdirectory $initialdir]} {set initialdir [pwd]}
     set filename [tk_getSaveFile -initialfile $initialfile -initialdir $initialdir \
 					  -defaultextension .pd -filetypes $::filetypes]
     if {$filename eq ""} return; # they clicked cancel
@@ -62,8 +63,8 @@
 	}
 	set dirname [file dirname $filename]
 	set basename [file tail $filename]
-	pdsend "$name savetofile [pdtk_enquote $basename] [pdtk_enquote $dirname]"
-	set ::untitled_directory $dirname
+	pdsend "$name savetofile [enquote_filename $basename] [enquote_filename $dirname]"
+	set ::pd_untitleddir $dirname
 }
 
 #------------------------------------------------------------------------------#

Modified: branches/pd-devel/0.41.4/src/wheredoesthisgo.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/wheredoesthisgo.tcl	2009-01-24 06:42:44 UTC (rev 10615)
+++ branches/pd-devel/0.41.4/src/wheredoesthisgo.tcl	2009-01-24 07:58:48 UTC (rev 10616)
@@ -22,15 +22,23 @@
 
 
 proc open_file {filename} {
-    set directory [string range $filename 0 [expr [string last / $filename] - 1]]
-    set ::pd_opendir $directory
-    set basename [string range $filename [expr [string last / $filename] + 1] end]
+    set directory [file dirname $filename]
+    set basename [file tail $filename]
     if {[regexp -nocase -- "\.(pd|pat|mxt)$" $filename]} {
-        pdsend "pd open [pdtk_enquote $basename] [pdtk_enquote $directory]"
+        pdsend "pd open [enquote_filename $basename] [enquote_filename $directory]"
+		set ::pd_opendir $directory
     }
 }
 
+# ------------------------------------------------------------------------------
+# quoting functions
 
+# enquote a filename to send it to pd, " isn't handled properly tho...
+proc enquote_filename {message} {
+	string map {"," "\\," ";" "\\;" " " "\\ "} $message
+}
+
+
 #------------------------------------------------------------------------------#
 # key usage
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Pd-cvs mailing list