Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Sublime text 3 plugin

Advisor ,
Mar 10, 2015 Mar 10, 2015

Hello everyone!  It's been a while since i posted here and the forum seems unrecognizable.

Anyway.. here is a plugin i wrote for running and partially debugging indesign scripts straight from Sublime text:

vamitul/RunInIndesign · GitHub

I know there are quite a lot of build systems for this already, but this plugin adds some very nice features:

  • $.write() and $.writeln() are redirected to a sublime text output console so you can see your messages straight in ST, without opening ESTK
  • Errors in the script (both runtime and syntax) are picked up, displayed in the sublime output console, and, the line that generated the error is highlighted.

Stuff to do:

  • Make it work on OSX. Simple to implement, but i don't have a Mac yet.
  • target different versions of Indesign. So far indesign CC is hardcoded as a target. Most of the code for it is already in, so it's going to be quite simple.
  • add menus and keybindings
  • #targetengine support: the jsRunner.jsx adapter uses $.evalFile() to run the script, so it can get the errors and line numbers. Unfortunately evalFile will ignore any targetengine directives. To fix this, the plugin will have to scan the script for targetengines and run the whole adaptor in that engine.
  • investigate the possibility of using of using BridgeTalk to pass the script and messages to Indesign. Studying the jsx files in ESTK's folder it became clear that estk uses the bridgetalk for communicating with indesign. If this can be replicated, it opens up the possibility of using ST3 as a full debugger for Indesign (breakpoints -- actually those can be implemented even now, without brigetalk, step into etc.)

That's about it, i guess. Download it, play with it, enjoy.

Ps. This is my first python project, i am just beginning to learn it, so go easy on me

TOPICS
Scripting
5.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 10, 2015 Mar 10, 2015

Hi Vamitul,

This is an fantastic tool -- especially for those who think that Adobe has a thing or two to answer for (w.r.t to the ESTK editor). I've done just a couple of simple tests and it works very well and looks great.

Thanks very much for sharing. No doubt it will be a popular tool.

Peter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Mar 10, 2015 Mar 10, 2015

I was wondering if you were the same bloke

See sublimetext3 - Sublime Text Build For Executing Indesign .jsx Scripts on Windows - Stack Overflow for a bit of discussion on it.

The 1st windows build (the one in the question) which Vlad said there how to get it to work dose handle #target and #targetengine, $.writeln() get displayed in the ESTK and not the ST console which is a minus point compared to Vlad's version.

I was planning to get the $.writeln to write to the  ST console and will take a look to see how it's done

By that link is a build for Macs.

I have a very good auto-complete for sublime text which I plan on putting out in about a months time.

I'll post a link here then.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Mar 10, 2015 Mar 10, 2015

I had a problem with my keyboard and it messed up the post above, in it's format and content, I corrected it now

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Mar 11, 2015 Mar 11, 2015

Updated:

  • added Key shortcut (default Ctrl+E)
  • added Menu (Tools->Indesign Tools)
  • added the ability to select the version of Indesign you wish to run the scripts into.

Now, if someone could help me with the proper visual basic application identifiers ( CreateObject("InDesign.Application.???????") ) it would be great:

{           "identifier": "",

            "name": "(default)"

        },

        {

            "identifier": "CS6",

            "name": "CS6"

        },

        {

            "identifier": "CC",

            "name": "CC (x32)"

        },

        {

            "identifier": "CC",

            "name": "CC (x64)"

        },

        {

            "identifier": "",

            "name": "CC 2014 (x32)"

        },

        {

            "identifier": "CC.2014",

            "name": "CC 2014 (x64)"

        }

Next stop: #targetengine support

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Mar 12, 2015 Mar 12, 2015

Updated.
Added #targetengine support, plus some cosmetic changes

Next: minimal debugging support, by implementing $.bp() breakpoints

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Mar 30, 2015 Mar 30, 2015

I have just added OSX compatibility. Seems to be working ok, but applescript is not my forte, so please test.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 30, 2015 Mar 30, 2015

Thanks for doing this, Vamitul

MAC OSX 10.8 InDesign CS 5.5

I have to link to InDesign 5.5 after the error message, but after this it works.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 30, 2015 Mar 30, 2015

I added CS5.5 to RunInIndesign.sublime-settings on my install to bypass the error. Is it going to be a problem? I do not see anything wrong so far. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Mar 30, 2015 Mar 30, 2015

nicolaik‌ that is how you are supposed to do it

I didn't add it since i don't have CS 5.5 on my systems.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Mar 30, 2015 Mar 30, 2015

Vamitul,

AppleScript is compiled and decompiled for editing, unless you take care to store it in source code. The compiled form of 'tell application "xyz" ' will be translated into a form using the "creator code" that is the same for all versions of InDesign. Therefor all your carefully chosen version specific names in that "exists" test chain won't survive the roundtrip, as you also can see if you revisit the current source at github.


Instead of adressing InDesign by versioned name, you can use the "id" specifier form, which refers to the version independent "bundle id" and survives the roundtrip:

tell application id "com.adobe.indesign"

-- do your thing here

end tell

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Mar 30, 2015 Mar 30, 2015

Thank you, DIrk.

I have to admit AppleScript doesn't make much sense to me, so all the code i did for the osxRun part of the plugin is crap at the least.

I noticed the stuff with the compilation, and that is why the plugin calls the already compiled script runJS.scpt instead of the source one.

My question is, if i switch to using bundle id, how can i target specific versions of indesign? Right now i have on my system 3 of them (cs6, cc and cc2014), and that is because it's a newly installed setup (on the windows machine i have everything from cs5 to current + indesign server). The whole point of those runner scripts are so the plugin can target different versions of indesign on the fly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Mar 31, 2015 Mar 31, 2015

I haven't yet tried your Sublime plugin but assume that you try to mimic ESTK's target dropdown.

Before we get too deep into that problem - and I don't yet have the answer - I want to question whether it is worth the effort at all.

ESTK enumerates the ExtendScript target applications through some private registry of target names that include the version number, somewhere down in the guts of the "BridgeTalk" subsystem. For completeness sake you should actually also consider something similar, there are also ExtendScript scripters that will want to target InCopy, Illustrator, Bridge etc. My ESTK target dropdown right now has 31 entries, 3 of them InDesign versions CS5, 5.5 and 6 and that is on a machine without any CC.

It should also mention InDesign CS4 and Server CS4 which are still installed, but those installations are screwed up anyway, and ESTK is notorious in finding InDesign Server instances. Did you know you it is pretty usual to launch multiple InDesign Server instances in parallel processes?

Here's another problem: In ESTK the same versions are lumped together in one target id, so it is sheer luck whether ESTK launches the one you intended.In my case that could be the latest US English debug build of InDesign CS4, or either the English or German localization of CS5.5 ...

In other words, I also have multiple copies of InDesign, even with the same major version. Others will have MiddleEast versions installed in parallel.

Instead of bothering, I just launch the correct version myself. If you go the "id" way, the already running process is preferred. Unlike plugin programming with XCode where you have to restart the application for every other build of your executable plugin, this step is only needed once in a while.

If you want to continue with your choice UI, I'd first decide whether to use AppleScript at all - or use the command line of ESTK instead.

Then, the best test for installed applications - after a little google search - appears to be the command line util for launch services, as shown here:

http://sohu.io/questions/551731/enumerate-all-installed-applications-on-os-x

We'd then have to figure out how to run an application by posix path.

You can also enumerate the running applications (processes) via "System Events".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Mar 31, 2015 Mar 31, 2015

Btw, another program to play with is the command line "open".

See "man 1 open" for details.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 10, 2015 Apr 10, 2015

Just a quick heads-up, the plugin is now available through the sublime package manager (Package Control - the Sublime Text package manager).

To install the plugin

1) install the package manager (if you don't have it already)

2) open it and look for Run in Indesign

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 08, 2018 Aug 08, 2018
LATEST

Hi Vamitul,

Thank you for your impressive plugin!! I use it since 2 years.

Since, did you implement "$.bp() breakpoints" ?

Did you find a wait in order to debug directly from ST and not ExtendScript Toolkit?

And a way for see the "Data folding" (the panel in ExtendScript Toolkit, I'm not sure of the translation, "Navigateur de données" in French), and the "Javascript Console".

Thank you and have a good day!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines