////////////////////// d = Document.current; d.string; d.title = "d"; e = Document("e"); where I type, except it is always one letter behind.... d.keyDownAction = { arg ... args; fork { 0.01.wait; e.string = d.string; }; }; e.keyDownAction = { arg ... args; fork { 0.01.wait; e.string = d.string; }; }; error: d.string is a string. /////////////////////
+ Document { /*bugs:*/ background { // quick fix for background bug: background is sometimes a document. ^if (background.isKindOf(Color), background, nil); } title { // quick fix for title bug: title is sometimes a document. var t; t = this.prgetTitle; ^if (t.isString) { t } { t.dump; nil; }; } title_ { arg t; t !? { title = t; this.prSetName(t) } } /*loading proerties*/ *scanFor { arg dataptrString; ^allDocuments.detect({ |doc| doc.dataptr.asString == dataptrString }); } *getAllProperties { ^allDocuments.collect({ arg doc; doc.dataptr.asString -> doc.getProperties; }); } *setAllProperties { arg propAssocs; var doc; propAssocs.do({ arg assoc; doc = this.scanFor(assoc.key); if (doc.notNil) { doc.setProperties(*assoc.value) } { ("doc not found for:" + assoc.key).warn }; }); ^allDocuments.collect({ arg doc; doc.dataptr -> doc.getProperties; }); } getProperties { ^[ this.title, this.background, this.stringColor, onClose.asClosedFunction, this.editable, this.path, keyDownAction.asClosedFunction, mouseDownAction.asClosedFunction, toFrontAction.asClosedFunction, endFrontAction.asClosedFunction ]; } setProperties { arg title, background, stringColor, onClose, editable, path, keyDownAction, mouseDownAction, toFrontAction, endFrontAction; this.title_(title); this.background_(background); this.stringColor_(stringColor); this.onClose_(onClose); this.editable_(editable); this.path_(path); this.keyDownAction_(keyDownAction); this.mouseDownAction_(mouseDownAction); this.toFrontAction_(toFrontAction); this.endFrontAction_(endFrontAction); } *storeAllProperties { var file; file = File("DocAllProps_temp", "w"); protect { file.write(this.getAllProperties.asCompileString); } { file.close; }; } *loadAllProperties { var newProps; newProps = "DocAllProps_temp".load; if (newProps.notNil) { this.setAllProperties(newProps); } } } +Function { asClosedFunction { ^if(this.isClosed, { this }, { nil }) } } +Nil { asClosedFunction { ^this } } /**** z = Document.current.dataptr; Document.scanFor(z.asString).dump *****/ //also add load and store in startup/shutdown Main.sc Main : Process { startup { super.startup; Document.startup; Document.loadAllProperties; // set the 's' interpreter variable to the default server. interpreter.s = Server.default; // make server window Server.internal.makeWindow; Server.local.makeWindow; "~/scwork/startup.rtf".loadPaths; } shutdown { // at recompile, quit Document.storeAllProperties; Server.quitAll; HIDDeviceService.releaseDeviceList; super.shutdown; } //-- bugs: doc var visible should have a getter doc var unused unused - comment out? doc is not updating path when re-saving. background is set to Document in the primitive keyUp method should call globalKeyUpAction background is sometimes a document title is sometimes a document //title not updating Document.allDocuments.do{|d| d.title.postln} Document.current.title_("hej") Document.allDocuments.do{|d| d.title.postln} //string colour misses last char d= Document("test123", "test123") d.stringColor_(Color.green, 0, 30) //last char not red to fix line 239 in GUIPrimitives.M if(rangeStart + rangeSize >= length) rangeSize = length - rangeStart - 1; should be... if(rangeStart + rangeSize >= length) rangeSize = length - rangeStart; //Document-initAction Document-initAction isn't called when starting up sc by dragging&dropping a document onto the sc icon //EnvirDocument can not set separate EnvirDocument-initAction. overwrites Document-initAction why does EnvirDocument-new have default backgroundcolor? //-- design issues: prSetName should be called prSetTitle prgetTitle should be called prGetTitle (well.) why have a variable for title when only the state in the actual window counts?