[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-dev] SF.net SVN: supercollider:[8265] trunk
Revision: 8265
http://supercollider.svn.sourceforge.net/supercollider/?rev=8265&view=rev
Author: danstowell
Date: 2008-12-23 20:21:16 +0000 (Tue, 23 Dec 2008)
Log Message:
-----------
Various changes as part of making help things work on windows:
* Help.findHelpFile method - a platform-agnostic way to find a help file
* Help.sc use Platform.pathSeparator for platform-neutrality
* embryonic PsycolliderDocument class provides rudimentary Document interface
* Change String:pathMatch behaviour in 3 ways to match unixy behaviour: (1) doesn't match . or .. folders; (2) leaves trailing slash on folder names; (3) matches folders with a trailing slash on their name.
These changes along with another patch posted to sc-dev move towards the help GUIs almost nicely working on windows :)
Modified Paths:
--------------
trunk/Headers/common/SC_Win32Utils.h
trunk/Source/lang/LangPrimSource/PyrStringPrim.cpp
trunk/build/SCClassLibrary/Common/Files/Help.sc
trunk/build/SCClassLibrary/Common/GUI/Document.sc
trunk/build/SCClassLibrary/Platform/windows/extString.sc
trunk/windows/distrowin.py
Added Paths:
-----------
trunk/build/SCClassLibrary/Platform/windows/PsycolliderDocument.sc
Modified: trunk/Headers/common/SC_Win32Utils.h
===================================================================
--- trunk/Headers/common/SC_Win32Utils.h 2008-12-23 18:03:57 UTC (rev 8264)
+++ trunk/Headers/common/SC_Win32Utils.h 2008-12-23 20:21:16 UTC (rev 8265)
@@ -34,6 +34,7 @@
#define pipe win32_pipe
void win32_ReplaceCharInString(char* string, int len, char src, char dst);
+// Finds the parent folder of a specified path pattern (including trailing slash)
void win32_ExtractContainingFolder(char* folder,const char* pattern,int maxChars);
void win32_synctimes();
void win32_gettimeofday(timeval* tv, void*);
Modified: trunk/Source/lang/LangPrimSource/PyrStringPrim.cpp
===================================================================
--- trunk/Source/lang/LangPrimSource/PyrStringPrim.cpp 2008-12-23 18:03:57 UTC (rev 8264)
+++ trunk/Source/lang/LangPrimSource/PyrStringPrim.cpp 2008-12-23 20:21:16 UTC (rev 8265)
@@ -320,7 +320,11 @@
if (err) return err;
win32_ReplaceCharInString(pattern,1024,'/','\\');
- // extract the containing folder, including backslash
+ // Remove trailing slash if found, to allow folders to be matched
+ if(pattern[strlen(pattern)-1]=='\\'){
+ pattern[strlen(pattern)-1] = 0;
+ }
+ // extract the containing folder, including backslash
char folder[1024];
win32_ExtractContainingFolder(folder,pattern,1024);
@@ -343,11 +347,14 @@
}
do {
- nbPaths++;
+ if(strcmp(findData.cFileName, "..")!=0 && strcmp(findData.cFileName, "..")!=0){
+ nbPaths++;
+ }
} while( ::FindNextFile(hFind, &findData));
::FindClose(hFind);
-// PASS 2
+ // PASS 2
+
hFind = ::FindFirstFile(pattern, &findData);
if (hFind == INVALID_HANDLE_VALUE) {
nbPaths = 0;
@@ -361,14 +368,19 @@
int i = 0;
do {
- std::string strPath(folder);
- strPath += std::string(findData.cFileName);
- const char* fullPath = strPath.c_str();
- PyrObject *string = (PyrObject*)newPyrString(g->gc, fullPath, 0, true);
- SetObject(array->slots+i, string);
- g->gc->GCWrite(array, string);
- array->size++;
- i++;
+ if(strcmp(findData.cFileName, "..")!=0 && strcmp(findData.cFileName, ".")!=0){
+ std::string strPath(folder);
+ strPath += std::string(findData.cFileName);
+ if(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){
+ strPath += std::string("\\"); // Append trailing slash, to match behaviour on unix (used by sclang to detect folderness)
+ }
+ const char* fullPath = strPath.c_str();
+ PyrObject *string = (PyrObject*)newPyrString(g->gc, fullPath, 0, true);
+ SetObject(array->slots+i, string);
+ g->gc->GCWrite(array, string);
+ array->size++;
+ i++;
+ }
} while( ::FindNextFile(hFind, &findData));
::FindClose(hFind);
return errNone;
Modified: trunk/build/SCClassLibrary/Common/Files/Help.sc
===================================================================
--- trunk/build/SCClassLibrary/Common/Files/Help.sc 2008-12-23 18:03:57 UTC (rev 8264)
+++ trunk/build/SCClassLibrary/Common/Files/Help.sc 2008-12-23 20:21:16 UTC (rev 8265)
@@ -88,20 +88,20 @@
if ( helppath == Platform.helpDir,
{
- subc = path[helpRootLen..].split($/);
+ subc = path[helpRootLen..].split(Platform.pathSeparator);
subc = subc[0..subc.size-2]; // Ignore "Help" and the filename at the end
},{
//helpRootLen = "~".standardizePath;
if ( helppath == Platform.systemExtensionDir,
{
- subc = path[helpRootLen..].split($/);
+ subc = path[helpRootLen..].split(Platform.pathSeparator);
subc = [ "SystemExtensions" ] ++ subc;
//subc.postcs;
});
if ( helppath == Platform.userExtensionDir,
{
helpRootLen = "~/".absolutePath.size; // + 1;
- subc = path[helpRootLen..].split($/);
+ subc = path[helpRootLen..].split(Platform.pathSeparators);
subc = [ "UserExtensions" ] ++ subc;
// check for common superfluous names that may confuse the categorisation;
filterUserDirEntries.do{ |spath|
@@ -538,6 +538,13 @@
^results
}
+ // This iterates the Help.tree to find the file. Can be used instead of platform-specific approaches
+ *findHelpFile { |str|
+ var ret = nil;
+ str = str.asString;
+ block{|break| this.do{|key, val| if(key==str){ ret=val; break.value }}};
+ ^ret;
+ }
} // End class
Modified: trunk/build/SCClassLibrary/Common/GUI/Document.sc
===================================================================
--- trunk/build/SCClassLibrary/Common/GUI/Document.sc 2008-12-23 18:03:57 UTC (rev 8264)
+++ trunk/build/SCClassLibrary/Common/GUI/Document.sc 2008-12-23 20:21:16 UTC (rev 8265)
@@ -33,7 +33,7 @@
*open { arg path, selectionStart=0, selectionLength=0, envir;
var doc, env;
env = currentEnvironment;
- this.current.restoreCurrentEnvironment;
+ if(this.current.notNil){this.current.restoreCurrentEnvironment};
doc = Document.implementationClass.prBasicNew.initFromPath(path, selectionStart, selectionLength);
if (doc.notNil) {
doc.envir_(envir)
Added: trunk/build/SCClassLibrary/Platform/windows/PsycolliderDocument.sc
===================================================================
--- trunk/build/SCClassLibrary/Platform/windows/PsycolliderDocument.sc (rev 0)
+++ trunk/build/SCClassLibrary/Platform/windows/PsycolliderDocument.sc 2008-12-23 20:21:16 UTC (rev 8265)
@@ -0,0 +1,29 @@
+/*
+The BEGINNINGS of a Document class for psycollider.
+Currently has limitations compared to other Document implementations,
+doesn't connect to all of psyco's potential.
+*/
+PsycolliderDocument : Document {
+ var <path;
+
+ *initClass{
+ Document.implementationClass = PsycolliderDocument;
+ }
+
+ *new { arg title="Untitled", string="", makeListener=false;
+ ^super.prBasicNew.initByString(title, string.asString, makeListener);
+ }
+ initByString { arg title="Untitled", string="", makeListener=false;
+ var tempFile;
+ path = "temp_newTextWindow";
+ tempFile = File(path, "w");
+ tempFile.write(string);
+ tempFile.close;
+ path.openWinTextFile;
+ }
+
+ *findHelpFile { |str|
+ ^Help.findHelpFile(str)
+ }
+}
+
\ No newline at end of file
Modified: trunk/build/SCClassLibrary/Platform/windows/extString.sc
===================================================================
--- trunk/build/SCClassLibrary/Platform/windows/extString.sc 2008-12-23 18:03:57 UTC (rev 8264)
+++ trunk/build/SCClassLibrary/Platform/windows/extString.sc 2008-12-23 20:21:16 UTC (rev 8265)
@@ -1,5 +1,6 @@
+ String {
+/*
// used in methodReferences lookup
newTextWindow { arg title="Untitled", makeListener=false;
@@ -20,6 +21,7 @@
}
+*/
openTextFile { arg selectionStart=0, selectionLength=0;
^this.openWinTextFile(selectionStart, selectionLength);
@@ -28,4 +30,4 @@
}
-
\ No newline at end of file
+
\ No newline at end of file
Modified: trunk/windows/distrowin.py
===================================================================
--- trunk/windows/distrowin.py 2008-12-23 18:03:57 UTC (rev 8264)
+++ trunk/windows/distrowin.py 2008-12-23 20:21:16 UTC (rev 8265)
@@ -26,9 +26,9 @@
print("ERROR:\n Path %s not detected.\n Generating executable (using py2exe) probably failed." % detectpath)
sys.exit(1)
# Also copy PySCLang.pyd out of its "site-packages" location
-shutil.copy(os.getenv('PYTHONPATH', 'C:/python26') + '/Lib/site-packages/PySCLang.pyd', '../Psycollider/Psycollider/dist/')
+shutil.copy(os.getenv('PYTHONPATH', sys.exec_prefix) + '/Lib/site-packages/PySCLang.pyd', '../Psycollider/Psycollider/dist/')
# and a dll we need
-shutil.copy(os.getenv('PYTHONPATH', 'C:/python26') + '/Lib/site-packages/wx-2.8-msw-unicode/wx/gdiplus.dll', '../Psycollider/Psycollider/dist/')
+shutil.copy(os.getenv('PYTHONPATH', sys.exec_prefix) + '/Lib/site-packages/wx-2.8-msw-unicode/wx/gdiplus.dll', '../Psycollider/Psycollider/dist/')
########################################
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
_______________________________________________
sc-dev mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-dev/
search: https://listarc.bham.ac.uk/lists/sc-dev/search/