|
From: <cre...@us...> - 2006-05-20 18:37:12
|
Revision: 1387 Author: creecode Date: 2006-05-20 11:37:02 -0700 (Sat, 20 May 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1387&view=rev Log Message: ----------- minor script formatting tweaks factored with new checkOutline to fix bug when in an outline and the current line contains "with" Modified Paths: -------------- ODBs/trunk/frontierRoot/system/callbacks/cmd2Click.fvc Modified: ODBs/trunk/frontierRoot/system/callbacks/cmd2Click.fvc =================================================================== --- ODBs/trunk/frontierRoot/system/callbacks/cmd2Click.fvc 2006-05-20 18:35:15 UTC (rev 1386) +++ ODBs/trunk/frontierRoot/system/callbacks/cmd2Click.fvc 2006-05-20 18:37:02 UTC (rev 1387) @@ -1,98 +1,194 @@ -FrontierVcsFile:1:scpt:system.callbacks.cmd2Click +FrontierVcsFile:2:scpt:system.callbacks.cmd2Click on cmd2Click (name) { - \xC7Changes - \xC71/27/06; 2:27:38 PM by TAC - \xC7if name is "date" most certainly the user wants to see the system.verbs.builtins.date table, not system.verbs.globals.date - \xC71/17/06; 10:35:24 AM by TAC - \xC7if name is "string" most certainly the user wants to see the system.verbs.builtins.string table, not system.verbs.globals.string - \xC76/18/05; 1:34:38 PM by TAC - \xC7use Frontier.createUserCallbacksSubtable to initialize tables - \xC74/20/01; 4:05:40 PM by JES - \xC7Allow callbacks to be addresses or addresses of addresses... - \xC7Tue, Oct 7, 1997 at 11:37:49 AM by PBS - \xC7New callbacks for cmd2click. Callback script returns true if it handled the click, then this script immediately returns true. Otherwise, this script handles the click. - \xC7Wed, Dec 11, 1996 at 11:16:00 PM by DW - \xC74.2, handles macros in web pages - \xC78/15/96 by dmb - \xC7 integrated ssl's "enhanced2click" functionality - \xC73/19/96 by ssl - \xC7moved checkWith etc. to enhanced2click table to simplify distribution - \xC76/17/95 by ssl - \xC7added support for local scripts (via checkScript) - \xC7ssl change notes - \xC7enhanced to walk up the script/outline hierarchy and check every "with" path in an outline window, assume it's a oneLiner - \xC7added support for reserved constants, keywords & builtins - \xC7changes are Pioneerware by Scott S. Lawton - \xC7Internet: ss...@pr..., http://www.tiac.net/prefab/ - \xC7called when you cmd-double-click on an identifier - \xC7It enhances the default, built-in behavior of jumping to the named object. - \xC7It checks for the option key, and closes the front window if it's pressed. - \xC7If the name is a file rather than a db object, it will reveal it in the Finder + «Changes + «4/2/06; 2:10:45 PM by TAC + «minor script formatting tweaks + «3/8/06 by SSL + «factored with new checkOutline to fix bug when in an outline and the current line contains "with" + «12/27/05 by SSL + «tentatively added user.callbacks.cmd2clickPrefs.checkOutlinesFirst + «e.g. so cmd2click on "callbacks" (and other table names in system and such) will first walk up the outline hierarchy if the window is an outline + «prefer system.verbs.builtins to globals (could add a pref if anyone wants the old behavior) + «added Finder.bringToFront + «added string.length(parentOf(name^)) > 0 test so that checkScript has a chance to succeed + «in doIt, wrapped edit (address (objectName)) in try/else (and wrapped several calls via new editIfExists) + «e.g. defined("checkWith") returns true though of course edit yields an error since the script is local + «(I wonder how long this has been broken?) + «deleted "people" from checkOtherTables; it made sense for root.people (years ago) but not suites.people + «refactored restoreTheCursor into new editIfExists; modified callers + «in addition to making the code simpler, it handles cases where defined succeeds but edit fails (e.g. local functions) + «refactored windowType; was already redundant in 2 subroutines; now also need for another test + «refactored initialize and restoreOutline (the nested handlers were from when they were separate scripts) + «cosmetic: moved all the local scripts/handlers together, added whitespace, moved old change notes under here, made local an outline + «upgraded macro code to call bottleneck ==> handles option key + «6/18/05; 1:34:38 PM by TAC + «use Frontier.createUserCallbacksSubtable to initialize tables + «4/20/01; 4:05:40 PM by JES + «Allow callbacks to be addresses or addresses of addresses... + «Saturday, January 24, 1998 at 4:03:20 PM by PBS + «websites table + «Tue, Oct 7, 1997 at 11:37:49 AM by PBS + «New callbacks for cmd2click + «Callback script returns true if it handled the click, + «then this script immediately returns true. + «Otherwise, this script handles the click. + «Wed, Dec 11, 1996 at 11:16:00 PM by DW + «4.2 + «handles macros in web pages + «8/15/96 by dmb + «integrated ssl's "enhanced2click" functionality + «3/19/96 by SSL + «moved checkWith etc. to enhanced2click table to simplify distribution + «6/17/95 by SSL + «added support for local scripts (via checkScript) + «SSL change notes + «enhanced to walk up the script/outline hierarchy and check every "with" path + «in an outline window, assume it's a oneLiner + «added support for reserved constants, keywords & builtins + «changes are Pioneerware by Scott S. Lawton + «Internet: ss...@pr..., (historical note: URL was http://www.tiac.net/prefab/) + «called when you cmd-double-click on an identifier + «It enhances the default, built-in behavior of jumping to the named object. + «It checks for the option key, and closes the front window if it's pressed. + «If the name is a file rather than a db object, it will reveal it in the Finder + «... Frontier invokes this in a "try" ==> errors are suppressed + «design & debug notes + «debugging tip: don't debug by doing a cmd-double-click on something in this script; the debugger looks at the window BEHIND the script being debugged (which is a vital debugging feature!) + «one reason for this script returning the status: can be called by an enhanced "jump" command which bypasses the dialog if the selection exists - on checkWith (name, callbackAction) { - \xC7walk up the script/outline hierarchy checking in "with" for a match: "table.[name]" - \xC7called by my cmd2click, control2click - \xC7Pioneerware by Scott S. Lawton - \xC7revisions - \xC76/13/96: handle menuscripts - \xC75/16/96: now handle an "object database map" - \xC73/19/96: moved to enhanced2click table, updated paths - \xC71/27/96 to handle double-clicking on part of the hierarchy within a single "with" - \xC75/28/95 to handle comment in the "with" - \xC75/15/95 to handle hierarchy within a single "with" - \xC7e.g. "with ObjectModel, QXP, defs" - \xC7(Actually, I only look at pairs. It didn't seem worth the effort to test every combination.) - \xC7possible improvements - \xC7look for nested "with" (as I do for outlines & an "object database map"), e.g. - \xC7with Player - \xC7with Keys - \xC7look for all combinations with multiple "fields" (not just pairs), e.g. - \xC7with QXP, ObjectModel, defs - \xC7look at every "with" in an outline oneLiner - \xC7call Simple.window.frontmostType to handle menuscripts - \xC7but then the enhanced2click package wouldn't stand on its own + local (i); + + bundle { // user.callbacks.cmd2click (which may handle it) + Frontier.createUserCallbacksSubtable (nameOf (this^)); + «if not defined (user.callbacks.cmd2click) // old code + «new (tabletype, @user.callbacks.cmd2click) + if not defined (user.callbacks.cmd2clickPrefs) { // SSL 12/26/05 + new (tabletype, @user.callbacks.cmd2clickPrefs); + «enable the new feature by default since it's generally an improvement (but added this setting so that users can disable it to restore the previous behavior) + «note that it's dangerous to apply to scripts (vs. outlines) since it's generally important there for cmd2click to do the same thing that Frontier's interpreter does (vs. having false confidence in something that looks strictly local) + user.callbacks.cmd2clickPrefs.checkOutlinesFirst = true}; + for i = 1 to sizeof (user.callbacks.cmd2click) { + local (adrScript = @user.callbacks.cmd2click [i]); + try { + while typeOf (adrScript^) == addressType { + adrScript = adrScript^}; + if adrScript^ (name) { + return (true)}}}}; + + local { + bracketedName; + windowType = "Unknown"; // modified below... + windowAdr = window.frontmost(); + alreadyCheckedWith = false; + + whereAmI; + displayStatus; + leftOfSelection = 0; + rightOfSelection = 0}; + + bundle { // windowType + try { + windowType = typeOf(windowAdr^)} // this fails for a few cases, see Simple.window.frontmostType() ... the only one we need is handled in the else + else { + if window.isMenuScript(windowAdr) { + windowType = scriptType}}}; + + on pathToBracketedPath (s) { + «Sunday, January 25, 1998 at 4:21:03 PM by PBS + local (path, flinquotes, flinbrackets, fladd, flend); + local (i, ch = "", lastch = "", piece); + local (oneElement = "", elementList = {}); + for i = 1 to sizeOf (s) { + fladd = false; + flend = false; + lastch = ch; + ch = s [i]; + case ch { + '"' { + if lastch == '\\' { + fladd = true} + else { + if !flinquotes { + flinquotes = true} + else { + flinquotes = false}}}; + '[' { + if !flinquotes { + flinbrackets = true}}; + ']' { + if !flinquotes { + flinbrackets = false}}; + '.' { + if !flinquotes and !flinbrackets { + flend = true} + else { + fladd = true}}} + else { + fladd = true}; + if fladd { + oneElement = oneElement + ch}; + if flend { + elementList = elementList + oneElement; + oneElement = ""}}; + elementList = elementList + oneElement; + for oneElement in elementList { + path = path + "[\"" + oneElement + "\"]."}; + path = string.mid (path, 1, sizeOf (path) - 1); // strip off trailing dot + return (path)}; + + on initializeOutline() { + displayStatus = op.getDisplay(); // want to restore it to original state + op.setDisplay(false); // no need to show the user our travels + case windowType { + outlineType; // added 5/16/96 ==> changed to a case statement + scriptType { + whereAmI = op.getCursor()}}; // uniqueID, to restore at end + + if wp.inTextMode() { // doesn't apply to cmd2Click, but may to Jump + wp.getSelect(@leftOfSelection, @rightOfSelection)}}; + «else: the left/right of selection are correct at zero + + on restoreOutline() { + case windowType { + outlineType; // added 5/16/96 ==> changed to a case statement + scriptType { + op.setCursor(whereAmI)}}; + wp.setTextMode(true); + wp.setSelect(leftOfSelection, rightOfSelection); + op.setDisplay(displayStatus)}; + + on checkWith (name, getLongestMatch = false) { + «walk up the script/outline hierarchy checking in "with" for a match: "table.[name]" + «called by my cmd2click, control2click + «Pioneerware by Scott S. Lawton + «revisions + «6/13/96: handle menuscripts + «5/16/96: now handle an "object database map" + «3/19/96: moved to enhanced2click table, updated paths + «1/27/96 to handle double-clicking on part of the hierarchy within a single "with" + «5/28/95 to handle comment in the "with" + «5/15/95 to handle hierarchy within a single "with" + «e.g. "with ObjectModel, QXP, defs" + «(Actually, I only look at pairs. It didn't seem worth the effort to test every combination.) + «possible improvements + «look for nested "with" (as I do for outlines & an "object database map"), e.g. + «with Player + «with Keys + «look for all combinations with multiple "fields" (not just pairs), e.g. + «with QXP, ObjectModel, defs + «look at every "with" in an outline oneLiner + local { categorizedName = name; theLine; - space = " "; - windowType = "Unknown"; \xC7 modified below... - windowName = window.frontmost(); - whereAmI; - displayStatus; - leftOfSelection = 0; - rightOfSelection = 0}; - try { - \xC7the following fails for a few cases, see Simple.window.frontmostType() ... the only one we need is handled in the else - windowType = typeOf(windowName^)} - else { \xC7 6/13/96 - if window.isMenuScript(windowName) { - windowType = scriptType}}; - on initialize() { - displayStatus = op.getDisplay(); \xC7 want to restore it to original state - op.setDisplay(false); \xC7 no need to show the user our travels - case windowType { - outlineType; \xC7 added 5/16/96 ==> changed to a case statement - scriptType { - whereAmI = op.getCursor()}}; \xC7 uniqueID, to restore at end - - if wp.inTextMode() { \xC7 doesn't apply to cmd2Click, but may to Jump - wp.getSelect(@leftOfSelection, @rightOfSelection)}}; - \xC7else: the left/right of selection are correct at zero - on restoreOutline() { - case windowType { - outlineType; \xC7 added 5/16/96 ==> changed to a case statement - scriptType { - op.setCursor(whereAmI)}}; - wp.setTextMode(true); - wp.setSelect(leftOfSelection, rightOfSelection); - op.setDisplay(displayStatus)}; + space = " "}; on checkAllFields() { - \xC7globals - \xC7theLine \xC7 which has the spaces removed - \xC7name - \xC7whereAmI + «globals + «theLine // which has the spaces removed + «name + «whereAmI local { comma = ","; fieldCount; @@ -101,196 +197,135 @@ fieldCount = string.countFields(theLine, comma); for i = 1 to fieldCount { categorizedName = string.nthField(theLine, comma, i) + "." + name; - if defined (categorizedName^) { - restoreOutline(); - callbackAction^(categorizedName, true); \xC7 second parameter: yes it's in a "with" + if editIfExists(categorizedName, restoreTheCursor: true) { return (true)}}; - for i = 1 to fieldCount { \xC7 5/15/95: check pairs next (less likely) + for i = 1 to fieldCount { // 5/15/95: check pairs next (less likely) previous = string.nthField(theLine, comma, i); for j = i+1 to fieldCount { categorizedName = previous + "." + string.nthField(theLine, comma, j) + "." + name; - if defined (categorizedName^) { - restoreOutline(); - callbackAction^(categorizedName, true); \xC7 second parameter: yes it's in a "with" + if editIfExists(categorizedName, restoreTheCursor: true) { return (true)}}}; - return false}; \xC7 won't get here if it finds a match + return false}; // won't get here if it finds a match on handleWith() { - \xC71/27/96: call twice ==> moved to a subroutine + «1/27/96: call twice ==> moved to a subroutine theLine = string.popLeading( string.lower(op.getLineText()), space ); if theLine beginsWith "with " { - theLine = string.commentDelete(theLine); \xC7 5/28/95 - \xC7get rid of the with, then strip out spaces so they don't interfere with nthField + theLine = string.commentDelete(theLine); // 5/28/95 + «get rid of the with, then strip out spaces so they don't interfere with nthField theLine = string.replaceAll( theLine - "with", space, "" ); - if checkAllFields() { - \xC7it also performs the callbackAction + if checkAllFields() { // it edits too return true} else { return false}} else { return false}}; on handleOutlineHierarchy() { - \xC75/16/96: doesn't actually check "with", but something similar - \xC7it's easier to add here than as a separate script since it calls initialize & restoreOutline + «5/16/96: doesn't actually check "with", but something similar + «it's easier to add here than as a separate script since it calls initialize & restoreOutline categorizedName = string.nthField(string.popLeading(op.getLineText(), space), space, 1) + "." + categorizedName; - if defined (categorizedName^) { - restoreOutline(); - callbackAction^(categorizedName, true); \xC7 second parameter: yes it's in a "with" + if editIfExists(categorizedName, restoreTheCursor: true) { return (true)} else { return false}}; + on checkOutline() { + «unlike "with", do NOT check the current line + «categorizedName starts out as just name; that's what we want here too + if getLongestMatch { + local { + theList = {name}; // use a list to avoid parsing AND allow embedded period + theName; + nthItem}; + while op.go(left, 1) { + theName = string.nthField(string.popLeading(op.getLineText(), space), space, 1) + "."; + theList = {theName} + theList; // prepend + categorizedName = theName + categorizedName}; + for nthItem = 1 to sizeOf(theList) { + if editIfExists(categorizedName, restoreTheCursor: true) { + return (true)} + else { + «strip the top item and fall through to check again + categorizedName = string.delete(categorizedName, 1, string.length(theList[nthItem]))}}} + else { // go bottom up + «obsolete, e.g. callbacks.opRightClick exists in system and Frontier.tools.nodeTypes + «but leave here in case someone prefers the old behavior (which they get if user.callbacks.cmd2clickPrefs.checkOutlinesFirst is false) + while op.go(left, 1) { // 5/16/96 + if handleOutlineHierarchy() { + return true}}}; // i.e. out of the whole script + + return false}; // if it gets here case windowType { scriptType { - initialize(); - if handleWith () { \xC7 1/27/96: for cases like "with Player, keys"; 2click on keys - return true}; \xC7 i.e. out of the whole script + initializeOutline(); + if handleWith () { // 1/27/96: for cases like "with Player, keys"; 2click on keys + return true}; // i.e. out of the whole script while op.go (left, 1) { if handleWith () { - return true}}; \xC7 i.e. out of the whole script - restoreOutline (); + return true}}; // i.e. out of the whole script + restoreOutline (); // i.e. no match ==> clean up return false}; - outlineType { \xC7 assume it's a oneLiner (5/16/96: also handle an "object database map") - initialize(); + outlineType { // assume it's a oneLiner (5/16/96: also handle an "object database map") + initializeOutline(); local { theLine = string.lower(op.getLineText())}; - if theLine contains "with " { \xC7 at present: only looks at the FIRST "with" + + if theLine contains "with " { // at present: only looks at the FIRST "with" (which could be after a semicolon) + «this case is primarily for "one liner" outlines, but falls thru to walk the hierarchy local { fromPosition = string.patternMatch("with ", theLine) + 5; toPosition = string.patternMatch("{", theLine); numChars = toPosition - fromPosition}; - \xC7get rid of the with, then strip out spaces so they don't interfere with nthField + «get rid of the with, then strip out spaces so they don't interfere with nthField theLine = string.replaceAll(string.mid(theLine, fromPosition, numChars), space, ""); - if checkAllFields() { - \xC7it also performs the callbackAction - return true}} \xC7 i.e. out of the whole script - else { \xC7 modified 5/16/96 to walk up the hierarchy - \xC7unlike "with", do NOT check the current line - \xC7categorizedName starts out as just name; that's what we want here too - while op.go(left, 1) { \xC7 5/16/96 - if handleOutlineHierarchy() { - return true}}; \xC7 i.e. out of the whole script - restoreOutline(); - return false}}} + if checkAllFields() or checkOutline() { // 3/8/06 + return true}} // i.e. out of the whole script + «else: fall thru + else { // modified 5/16/96 to walk up the hierarchy + if checkOutline() { // 3/8/06 + return true}}; // i.e. out of the whole script + «else: fall thru + + restoreOutline(); // i.e. no match ==> clean up + return false}} else { return false}}; - on pathToBracketedPath (s) { - \xC7Sunday, January 25, 1998 at 4:21:03 PM by PBS - local (path, flinquotes, flinbrackets, fladd, flend); - local (i, ch = "", lastch = "", piece); - local (oneElement = "", elementList = {}); - for i = 1 to sizeOf (s) { - fladd = false; - flend = false; - lastch = ch; - ch = s [i]; - case ch { - '"' { - if lastch == '\\' { - fladd = true} - else { - if !flinquotes { - flinquotes = true} - else { - flinquotes = false}}}; - '[' { - if !flinquotes { - flinbrackets = true}}; - ']' { - if !flinquotes { - flinbrackets = false}}; - '.' { - if !flinquotes and !flinbrackets { - flend = true} - else { - fladd = true}}} - else { - fladd = true}; - if fladd { - oneElement = oneElement + ch}; - if flend { - elementList = elementList + oneElement; - oneElement = ""}}; - elementList = elementList + oneElement; - for oneElement in elementList { - path = path + "[\"" + oneElement + "\"]."}; - path = string.mid (path, 1, sizeOf (path) - 1); // strip off trailing dot - return (path)}; - Frontier.createUserCallbacksSubtable (nameOf (this^)); - \xC7if not defined (user.callbacks.cmd2click) // old code - \xC7new (tabletype, @user.callbacks.cmd2click) - - local (i); - local (bracketedName); - for i = 1 to sizeof (user.callbacks.cmd2click) { - local (adrScript = @user.callbacks.cmd2click [i]); - try { - while typeOf (adrScript^) == addressType { - adrScript = adrScript^}; - if adrScript^ (name) { - return (true)}}}; - - on checkOtherTables (name, callbackAction) { - \xC7look in tables that UserTalk references, but aren't global ... to match "table.[name]" - \xC7called by my cmd2click, Cmd-Jump & possibly others - \xC7Pioneerware by Scott S. Lawton - \xC7revisions - \xC73/19/96: moved to enhanced2click table, updated paths - \xC75/15/95: handle subtables, e.g. "dialog.getFile" (in Simple) should NOT be bracketed + on checkOtherTables (name) { + «look in tables that UserTalk references, but aren't global ... to match "table.[name]" + «called by my cmd2click, Cmd-Jump & possibly others + «Pioneerware by Scott S. Lawton + «revisions + «3/19/96: moved to enhanced2click table, updated paths + «5/15/95: handle subtables, e.g. "dialog.getFile" (in Simple) should NOT be bracketed local { - jumpPaths = { "system.compiler.language.constants", "system.compiler.language.builtins", "system.compiler.language.keywords", "system.misc", "people", "system.verbs", "Simple"}; + jumpPaths = { "system.compiler.language.constants", "system.compiler.language.builtins", "system.compiler.language.keywords", "system.misc", "system.verbs", "Simple"}; path; test}; for path in jumpPaths { - test = path + "." + name; \xC7 added 5/15/95 - if defined (test^) { - callbackAction^ (test); + test = path + "." + name; // added 5/15/95 + if editIfExists (test) { return true}; test = path + "." + "[\"" + name + "\"]"; - if defined (test^) { - callbackAction^ (test); + if editIfExists (test) { return true}}; - return false}; \xC7 will only get here if the above fails + return false}; // will only get here if the above fails + on checkScript (name) { - \xC7look in the script itself for a local "handler" - \xC7called by my cmd2click, control2click, Cmd-Jump & possibly others - \xC7Pioneerware by Scott S. Lawton - \xC7revisions - \xC73/19/96: moved to enhanced2click table, updated paths - \xC76/17/95: created - local { - windowType = "Unknown"; \xC7 modified below... - whereAmI; - displayStatus; - leftOfSelection = 0; - rightOfSelection = 0}; - try { - \xC7the following fails for a few cases, see Simple.window.frontmostType() ... though it isn't needed here - windowType = typeOf (window.frontmost()^)}; - on initialize() { - displayStatus = op.getDisplay(); \xC7 want to restore it to original state - op.setDisplay (false); \xC7 no need to show the user our travels - if windowType equals scriptType { - whereAmI = op.getCursor()}; \xC7 uniqueID, to restore at end - - if wp.inTextMode() { \xC7 doesn't apply to cmd2Click, but may to Jump - wp.getSelect(@leftOfSelection, @rightOfSelection)}}; - \xC7else: the left/right of selection are correct at zero - on restoreOutline() { - if windowType equals scriptType { - op.setCursor(whereAmI)}; - wp.setTextMode(true); - wp.setSelect(leftOfSelection, rightOfSelection); - op.setDisplay(displayStatus)}; + «look in the script itself for a local "handler" + «called by my cmd2click, control2click, Cmd-Jump & possibly others + «Pioneerware by Scott S. Lawton + «revisions + «3/19/96: moved to enhanced2click table, updated paths + «6/17/95: created if windowType equals scriptType { - initialize(); - bundle { \xC7 set the search parameters + initializeOutline(); + bundle { // set the search parameters user.prefs.search.casesensitive = false; user.prefs.search.wholewords = false; user.prefs.search.wraparound = true}; - op.firstSummit (); \xC7 FIND seems to take current heading as its scope - if op.find ("on " + name) { \xC7 look for the "category" text + op.firstSummit (); // FIND seems to take current heading as its scope + if op.find ("on " + name) { // look for the "category" text wp.setTextMode (true); op.setDisplay (displayStatus); return true} @@ -299,65 +334,85 @@ return false}} else { return false}}; - on doIt (objectName, fromWith = false) { \xC7SSL: moved standard behavior here + + on doIt (objectName, restoreTheCursor = false) { + try { + edit (address (objectName))} + else { + return false}; // continue trying other options + + if restoreTheCursor { + target.set (windowAdr); // since we only get here after edit() succeeds + restoreOutline (); + target.set (address (objectName))}; + if kb.optionKey () { - local (front = window.frontMost ()); - edit (address (objectName)); - if window.getFile (front) == nil { - window.close (front)} + if window.getFile (windowAdr) == nil { + window.close (windowAdr)} else { - window.hide (front)}} + window.hide (windowAdr)}}}; + + on editIfExists(objectName, restoreTheCursor = false) { + «the following takes advantage of Frontier's left-to-right evaluation, i.e. doIt will only be called if defined succeeds + if defined (objectName^) and doIt (objectName, restoreTheCursor) { + return (true)} else { - edit (address (objectName))}}; + return (false)}}; - case string.lower (name) { // override some globals with builtins - "date"; - "string" { - name = "system.verbs.builtins." + name}}; + if user.callbacks.cmd2clickPrefs.checkOutlinesFirst and (windowType equals outlineType) { + if checkWith (name, getLongestMatch: true) { // check every "with" (also handles outlines) + return (true)}; + alreadyCheckedWith = true}; - if defined (name^) { \xC7simple: just jump to it - doIt (name); + if string.length(parentOf(name^)) > 0 { // it exists in the ODB somewhere (e.g. vs. being a local script) + «start with a simple case (though check it after checkOutlinesFirst above) + if defined(system.verbs.globals.[name]) and defined(system.verbs.builtins.[name]) { + «the existing code prefers globals (which is just the type coercion script) but I always want the builtins table + «SSL 12/06/00 + edit(@system.verbs.builtins.[name]); + return true}; // handled here + + if editIfExists (name) { + return (true)}; + + bracketedName = pathToBracketedPath (name); + if editIfExists (bracketedName) { + return (true)}} + else { // need this below + bracketedName = pathToBracketedPath (name)}; + + if editIfExists ("websites." + name) { return (true)}; - bracketedName = pathToBracketedPath (name); - if defined (bracketedName^) { - doIt (bracketedName); + if editIfExists ("websites." + bracketedName) { return (true)}; - if defined (("websites." + name)^) { //it's in the websites table - \xC7Saturday, January 24, 1998 at 4:03:20 PM by PBS - doIt ("websites." + name); - return (true)}; - if defined (("websites." + bracketedName)^) { //it's in the websites table - \xC7Saturday, January 24, 1998 at 4:03:20 PM by PBS - doIt ("websites." + bracketedName); - return (true)}; - bundle { \xC74.2 -- make cmd-2clicking work for macros - \xC7Wed, Dec 11, 1996 at 7:30:25 PM by DW - try { - if defined (websites.["#data"].tools) { - if defined (websites.["#data"].tools^.[name]) { - edit (@websites.["#data"].tools^.[name]); - return (true)}}}; - try { - if defined (user.html.macros.[name]) { - edit (@user.html.macros.[name]); + bundle { // 4.2 -- make cmd-2clicking work for macros + if defined (websites.["#data"].tools) { + if editIfExists (@websites.["#data"].tools^.[name]) { return (true)}}; - try { - if defined (user.html.renderers.[name]) { - edit (@user.html.renderers.[name]); + + if defined(user.html.macros) { + if editIfExists (@user.html.macros.[name]) { + return (true)}; + if editIfExists (@user.html.renderers.[name]) { return (true)}}; - try { - if defined (html.data.standardMacros.[name]) { - edit (@html.data.standardMacros.[name]); + + if defined (html.data.standardMacros) { + if editIfExists (@html.data.standardMacros.[name]) { return (true)}}}; - if checkOtherTables (name, @doIt) { \xC7check reserved words + + if checkOtherTables (name) { // check reserved tables return (true)}; - if checkWith (name, @doIt) { \xC7check every "with" + if not alreadyCheckedWith { + if checkWith (name) { // check every "with" (also handles outlines) + return (true)}}; + if checkScript (name) { // check this script return (true)}; - if checkScript (name) { \xC7check this script - return (true)}; + if file.exists (name) { // maybe it's a filename if sys.os () == "MacOS" { - return (Finder.reveal (name))} + Finder.reveal (name); // returns objspec ==> no use in checking return value (and, we know the file exists) + Finder.bringToFront(); // 12/27/05 + return (true)} else { return (webBrowser.openDocument (file.folderFromPath (name)))}}; if name beginsWith "http://" or name beginsWith "www." { // it's a URL @@ -366,7 +421,20 @@ if webBrowser.openURL (name) { webBrowser.bringToFront ()}; return (true)}; + return (false)}; -\xC7bundle // testing - \xC7cmd2Click ("string") \ No newline at end of file +«bundle // testing + «fixed 12/27/05 + «cmd2Click ("init") + «cmd2Click ("callbacks") + «cmd2Click ("checkWith") // should debug checkScript from another script so that parentOf does what we want + «cmd2Click (string(Frontier.getFilePath())) + «cmd2click("opRightClick") // buried n levels ==> want longest match + «a good test case (copy to an outline) + «e.g. callbacks used to match system.callbacks; opRightClick too (which required a deeper fix) + «system.verbs.builtins.Frontier.tools // (old) vs. system.verbs.builtins.Frontier.toolsA5 (new) + «init // was changed + «nodeTypes + «callbacks + «opRightClick // was changed \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |