Since I am used to navigating tabs in Safari, I am starting to use same document tabs (⌥⌘N) to quickly switch from focused project to focused project, etc., tab by tab. Once I have the tabs set up, the workflow is solid for me.
What I want to do is make a script to set up a set of tabs, each with a specific project focused.
Right now, I need to open a new tab of the same document (⌥⌘N), then focus the specific project for that tab, and repeat this for each desired project.
Is there a way to do this in AppleScript or JavaScript?
I don’t think a TaskPaper specific API exists. Instead I would use System Events to call the File > New Tab menu item if needed.
Those methods are class methods on OutlineEditor and can be called like this:
function TaskPaperContextScript(editor, options) {
let editors = OutlineEditor.getOutlineEditors()
for (var i = 0; i < editors.length; i++) {
let editor = editors[i]
...
}
}
Application("TaskPaper").documents[0].evaluate({
script: TaskPaperContextScript.toString()
});
I think to get such a script working you would need to:
Find and count TaskPaper top level projects
Exit out of that TaskPaperContext and use AppleScript to call File > New Tab once for each project
Enter back into TaskPaper context and use OutlineEditor.getOutlineEditors() to get each editor and focus it into projects in order.
Also note that TaskPaper’s state restoration is restoring tab state for you. If you just leave your TaskPaper document open when you quit then you shouldn’t have to rebuild tabs each time, just manually create once and then you should be done.