imagej.js icon indicating copy to clipboard operation
imagej.js copied to clipboard

Issue with text window

Open LauLauThom opened this issue 4 years ago • 6 comments

Hi all, very nice project, I just noticed a minor issue with the text window used to open macro/scripts. I could not type any text in a new text window open by the menu File > New > Text Window.

Opening a local macro file works though, and editing the code of the newly open file is also possible. However the window shows 2 vertical scroll bar, and it seems like the text panel is displayed twice (once per scrollbar). Indeed, one of the scrollbar move the background text which can be seen at the bottom, see below.

The original macro code is from https://raw.githubusercontent.com/LauLauThom/ObjectDetectionExamples-ImageJ.JS/main/LocalMinimaEmbryos.ijm

image

Tested on windows with google chrome 87.0.4280.88 and microsoft edge 87.0.664.55 (the last version relying on chromium)

LauLauThom avatar Dec 07 '20 09:12 LauLauThom

Thank you @LauLauThom

We will need to fix this by using another syntax highlighting library, one of the candidate is prism.

Please expect some delay on this issue, but I have started testing.

oeway avatar Dec 07 '20 09:12 oeway

I started this branch a while ago, the goal is to use prism-live to replace codemirror.

@gywgithub could you take a look at this issue?

oeway avatar Dec 07 '20 09:12 oeway

@LauLauThom The problem fixed. https://github.com/imjoy-team/imagej.js/pull/46#event-4110957060

gywgithub avatar Dec 15 '20 07:12 gywgithub

I made a new code editor here: https://ij.imjoy.io/?plugin=https://gist.github.com/oeway/9c78d23c101f468e723888d05b6fac6d# Screenshot 2020-12-15 at 22 55 4

Our previous solution was to use js/css/html to patch the generated code editor, it's really painful to work. Despite a lot of efforts being made, the code editor is till buggy.

Now I think we can just go for an ImJoy plugin based editor and if that works we can replace the java implementation entirely.

@mutterer @LauLauThom @gywgithub Could you please test it and let me know what you think? If you click the above link, after loaded, you can go to the imjoy icon and choose the "ImageJScriptEditor" option. We can add it into the ImageJ plugin menu later.

oeway avatar Dec 15 '20 22:12 oeway

@gywgithub thanks for fixing the issue with the original text editor !

@oeway I did some quick testing of the new editor, I like it especially with the line numbering and black background. It also worked as expected with my testing. It's just missing a File > New menu to create a new script (or did I miss it ?).

I think replacing the original code editor is ok, Fiji is also doing it right ? Just make sure to keep the TextWindow class, which is used by this original code editor but also the results tables and macro recorder windows if I'm not mistaking.

LauLauThom avatar Dec 17 '20 22:12 LauLauThom

@LauLauThom Thanks for testing. Thanks for pointing out, I just added the New menu as suggested.

For replacing the code editor, more work need to be done, because the new editor is completely different from the java implementation, it's actually an ImJoy plugin calls the api of imagej. So replacing it means we will need to expose more api from imagej, for example to be able to support the imagej debugger ( @mutterer reminded me that many users would like use that).

Therefore, I think a short term solution is to just add this editor to the imagej menu as an additional option, while keeping the original one. We can use it as the default editor for loading a macro from an URL for example, perhaps also add a menu item for "Open in the imagej code editor".

Any better suggestion are welcome!

oeway avatar Dec 18 '20 00:12 oeway