How to display script libraries?

Is there a way to have SD display the script libraries without having to open them in the Dictionary?
Is there a setting that triggers their detection automatically?

Also, I’m seeing that some can be opened as dictionaries, and others not. For ex. @ShaneStanley’s DefaultsLib.scptd is greyed out when I try to open it as a dictionary. Similarly, @hhas01’s TypeSupport_applescript-stdlib-master.scptd is greyed out.

That’s because it has no dictionary – you call its handlers using standard AppleScript handler calls.

I’m not sure what your first question(s) mean.

The first question means how to have the libraries listed in the “All” category in the side bar. Scripting additions are there by default (I’m assuming they’re automatically detected in the default locations), but not the scripting libraries. Those have to be opened once before appearing (and seemingly staying) in the side bar.

That’s because they’re loaded by default. I’m not sure there’s a lot of value in putting every library in the side-bar – it would be a total pain on my Mac, for example.

I see. But scripting additions are at the top and all together occupy just one slot in the side bar. You can expend the slot to see individual contents.
It would not take much space to have all the libraries grouped into one slot as “Scripting Libraries” just below “Scripting Additions” and allow the user to expend the category to see the individual librairies.

Scripting Additions are shown both collated and separately. I’m not sure the same logistics make sense for libraries.

I can see what you’re saying, but the indications so far are that very few people are using libraries with defined terminology. (I’d love to be proved wrong.) And I guess I’m not convinced the present system is onerous enough to warrant the likely engineering time (consider that it would mean continually monitoring all available script library folders for any changes) at the expense of other issues.

1 Like

I understand. Thank you for the replies.

Hey Jean-Christophe,

This is a job for a script.   :sunglasses:

This one depends upon the Satimage.osax for file-globbing, but it wouldn’t be hard to change that to vanilla AppleScript or ASObjC.

The script presents you with a choose-from dialog to pick 1 or more libraries to open in Script Debugger.

You can also open the ~/Library/Script Libraries folder.

-Chris

------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2017/03/23 21:15
# dMod: 2017/03/23 21:37
# Appl: Script Debugger, Finder
# Task: Open one or more user-script-libraries in SD or open the lib folder in the Finder.
# Libs: None
# Osax: Satimage.osax
# Tags: @Applescript, @Script, @Finder, @Script_Debugger, @Satimage.osax
------------------------------------------------------------------------------

set userScriptLibFolder to alias ((path to library folder from user domain as text) & "Script Libraries")
set frontApp to path to frontmost application as text

# You can filter the found files by changing "*" to "*Lb* for instance.
set userLibList to glob "*" from userScriptLibFolder with names only

set beginning of userLibList to "Open Script Libraries Folder"

tell application frontApp -- ensure the choose-from dialog has focus
   set chosenLibList to choose from list userLibList with title ¬
      "User-Libraries" with prompt ¬
      "Pick a 1 or more User-Libraries to Open:" default items {item 1 of userLibList} ¬
      with multiple selections allowed
end tell

if chosenLibList ≠ false then
   
   if chosenLibList = {"Open Script Libraries Folder"} then
      
      set filesToOpenList to {userScriptLibFolder}
      
      tell application "Finder"
         activate
         open userScriptLibFolder
      end tell
      
   else
      
      set filesToOpenList to {}
      
      repeat with libName in chosenLibList
         set filesToOpenList to filesToOpenList & (glob libName from userScriptLibFolder as alias)
      end repeat
      
      tell application "Script Debugger" to open filesToOpenList
      
   end if
   
end if

------------------------------------------------------------------------------
1 Like

And here’s a script that will open a Library’s dictionary that doesn’t require satimage

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

set scriptLibrariesFolder to path to library folder from user domain as text
set scriptLibrariesFolder to scriptLibrariesFolder & "Script Libraries:"
set myScriptLibraries to my GetFileNames(scriptLibrariesFolder, "scptd")

set listTitle to "Script Libraries"
set listPrompt to "Which script dictionary would you like to try to open?"
set okbuttonName to "This One"
set multipleSelections to true
set emptySelectionAllowed to false
tell application "Script Debugger"
   
   set userChoice to choose from list myScriptLibraries ¬
      with title listTitle ¬
      with prompt listPrompt ¬
      OK button name okbuttonName ¬
      multiple selections allowed multipleSelections ¬
      empty selection allowed emptySelectionAllowed
end tell
if userChoice is false then return
set scriptList to {}
repeat with thisScript in userChoice
   set the end of scriptList to ((scriptLibrariesFolder as text) & thisScript as text) as alias
end repeat

repeat with thisScriptLibrary in scriptList
   tell application "Script Debugger"
      set myLib to open thisScriptLibrary showing script dictionary
   end tell
end repeat

on GetFileNames(folderWithFiles, fileExtension) -- @other stuff
   --SecondLine
   set folderWithFiles to POSIX path of (folderWithFiles)
   set thePaths to current application's NSFileManager's defaultManager()'s contentsOfDirectoryAtPath:folderWithFiles |error|:(missing value)
   set fileNames to (thePaths's pathsMatchingExtensions:{fileExtension}) as list
   return fileNames
end GetFileNames

1 Like