Auto code completion for IJ macro


#21

What about pressing ctrl+space after backspacing?

Would be doable, but more work. Right now @haesleinhuepf populates the autocomplete with data from functions.html. We’d have to also ask ImageJ which menu commands are available:

#@ ModuleService moduleService
runCompletions = moduleService.getModules().stream()
	.filter{ info -> info.getMenuPath().getLeaf() != null }
	.map{ info -> info.getMenuPath().getLeaf().getName() }
	.collect()
println(runCompletions.size() + " completions found:")
runCompletions.forEach{ completion -> println("\t" + completion) }

Which on my up-to-date Fiji installation reports:

Started New_.groovy at Wed Jun 27 11:23:37 CDT 2018
1069 completions found:
	Focus Search Bar
	 Load Particles (.tif file - fast)
	 Open VirtualStack
	 Save Particles (.tif file - fast)
	16-bit
	2D Histogram
	2D Stitching
	3-3-2 RGB
	...

And then feed that information into the IJ macro autocompletion support for run.

I’ll try to get this feature released and uploaded before end of Friday.


#22

Awesome idea @dnmason and @ctrueden!
I might do that before Friday (if Curtis isn’t faster ;-))


#23

Good day Robert,

could you please tell the rest of us whether your elaborated script editor works with plain ImageJ (with Java 8 installed)?

Thanks

Herbie


#24

It certainly will, if you install all of scijava/script-editor's dependencies – which is almost equivalent of running Fiji :slight_smile:


#25

Thanks Jan,

the reason I’ve asked is that the statement at github “Implement ij1macro autocompletion” may lead to the conclusion that the script editor may work with plain ImageJ.

I understand now that “ij1 macro” simply refers to the ImageJ-macro language because I’m not aware of any other ImageJ-macro language (scripting languages excluded).

Best

Herbie


#26

That’ll be it! It’s working fine for me now with the three jars. Thanks for editing the top level post to add in those links :slight_smile:

I second this feature request suggestion:

It’d be great to have as well, but the current state is certainly a major improvement on its own!

Also:

@ctrueden pressing ctrl+space after backspacing does bring back the autocompletion menu for me. Hope that helps.


#27

Hi @dnmason,

there you go:

If you (or anybody else who tried earlier) could just download/install the recent imagej-legacy.jar and confirm that it works, it might make it into the next release.

Thanks for the suggestion! That was a golden one.

Cheers,
Robert


#28

@haesleinhuepf,

great, also with the newest imagej-legacy.jar it works and the menu commands are displayed in my case.

Thanks a lot!


#29

Thank you @haesleinhuepf this is a game changer!


#30

Glorious little thing! Thank you so much!

Poor ImageJ Macro Functions Page, it’s gonna be getting fewer hits now :smiley:


#31

Ah, no worries, the auto-complete plugin pings that page upon first usage when creating a map of macro commands that can be completed. :slight_smile:


#32

Haha true, though will it ping it (or check a hash) periodically? Sometimes the page does get updated, and there are a couple of funtionalities that are not reported there (like close("\\Others");) so it could be nice to update it too.


#33

Cool hint! Do you know any more hidden commands? I’d add them to the autocompletion pulldown then…


#34

Thanks!

I will make a short list as I discover them and post it here.


#35

Well, it actually is documented there, in the paragraph explaining the close(pattern) function:

If ‘pattern’ is “\Others”, all images except the front image are closed.

It’s just a bit difficult to parse all these infos, I guess…


Maybe these can be used to directly improve the functions.html page (@Wayne?), in order to avoid having to maintain yet another list that can get out of sync…


#36

As I caught up on this thread, I kept clicking “Reply” with the intent of chiming in, but the next post was always @imagejan replying with the exact same idea I had planned to write. Thanks @imagejan! :smile:

And thanks again @haesleinhuepf for your efforts on this! :beers:


#37

Awesome work, Robert!

I just started poking at it, and it works like a charm. This will indeed be a game-changer for beginners and seasoned users alike.

I could only spot a couple of minor errors:

  • In the completition of the for comand, there’s a second comma instead of a semicolon:
    for (i = 0; i < 10, i++) {
  • There’s problem with the ampersand in:
    roiManager("add &amp; draw")
  • For Dialog.getNumber() the completed command gets additional text from the doc:
    Dialog.getNumber(), etc. to retrieve the values entered by the user.

As I said, just small details.

Congratulations and many thanks!


#38

Hi @NicoDF,

thanks for the feedback! The first two issues were just fixed and are on the way.

The third issue brings me to the question: @ctrueden, @imagejan : Who has write access to the functions.html on the website? I would like to enter a line break :blush:

Cheers,
Robert


#39

I can update the file at
http://wsr.imagej.net/developer/macro/functions.html

Is this the file you are using?


#40

Hi @Wayne,

thanks for the quick reply. We are using a copy hosted on ImageJ.net. However, I believe we should keep the sites/files in sync.

Could you please insert a line break after <i>Dialog.getNumber()</i> in line 294? Futhermore, in line 2652, there is a quota too much in <a href="#setOption"">. Could you please remove this one as well?

Thanks a lot!

Cheers,
Robert