SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: Graeme on June 14, 2021, 11:35:26 am

Title: is the plugin mechanism useable in 25.0.2
Post by: Graeme on June 14, 2021, 11:35:26 am
Is the plugin mechanism useable in V25.0.2 - it's not mentioned in the help file at all.
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Clark on June 14, 2021, 05:17:32 pm
It has not been documented yet because we still don't have the website side of this implemented yet. It is quite usable.

If you have multiple instances of v25.0.2 running, loading a plugin is not a applied to all instances. We have fixed this for v26.

I use this plugin mechanism for my add on macros. It's just easier to deal with. I invoke SlickEdit via a script which specifies the path to my plugins directory. Not sure if you'll need to get that fancy. I do because I have to run different versions of SlickEdit for testing and I constantly create and delete config directories.

bin/vs +new -sc config -sp /f/se64/vmacros/plugins "$@"&
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Graeme on June 16, 2021, 01:29:35 am
Hi Clark

Thanks.  The xretrace plugin you created here is working for me in 25.0.2.
https://community.slickedit.com/index.php/topic,17704.msg69296.html#msg69296 (https://community.slickedit.com/index.php/topic,17704.msg69296.html#msg69296)

I tried uninstalling the plugin and found the content of the folder did get deleted and the commands were all removed but slickedit reported
unable to remove plugin C:
\GP\SlickConfig ...

and if I repeat the plugin_uninstall command it shows xretrace as still being a plugin  - even though it is actually gone except for the folder.
When I first ran the uninstall command I actually had two of the associated files open in slick  - slick then prompted me that the two files had been deleted etc. and I closed them but the uninstall still said failure.

So now I tried trying to load the plugin with a slightly different name (graeme_nz instead of graeme) but I forgot to change over something in the xretrace.sh folder so I deleted the second plugin and this time it deleted ok.

So I fix the problem and the plugin loads ok now  - but it doesn't report that the plugin loaded successfully.  Maybe it should have a message box saying success, plus maybe open up the dialog that shows the list of active plugins.

Graeme
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Clark on June 16, 2021, 01:50:31 am
I’ll check into this
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Graeme on June 16, 2021, 11:52:05 pm
A question  - if I need to shut down xretrace before the plugin is loaded so that the timer callback doesn't misbehave, is the definit and _on_load_module_xretrace that I have below ok for this.

Code: [Select]

void _on_load_module_xretrace(_str module_name)
{
   _str sm = strip(module_name, "B", "\'\"");
   if (strip_filename(sm, 'PD') == 'xretrace.e') {
      xretrace_kill_timer();
      xretrace_clear_all_markers();
   }
}

definit()
{
   //myerror();
   if (arg(1)=="L") {
      //If this is NOT an editor invocation
      xretrace_load_config();
      xretrace_kill_timer();
       //buffer_history_suspend = true;
      // this shouldn't be necessary because _on_load_module does it
      xretrace_clear_all_markers();
      buffer_retrace_cursor_list._makeempty();
      buffer_retrace_modified_lines_list._makeempty();
      buffer_bookmark_list._makeempty();
   }
   files_active_since_startup._makeempty();
   retrace_no_re_entry = 0;
   goback_is_loaded = false;
   if (def_xretrace_no_delayed_start && !file_exists(_ConfigPath() :+ 'DontRunMyMacros.txt')) {
      init_xretrace();
      xretrace_not_running = false;
   } else {
      xretrace_not_running = true;
      xretrace_has_been_started_id = 0;
   }
}

_command void xretrace_kill_timer() name_info(',')
{
   if ( retrace_timer_handle != -1 ) {
      _kill_timer(retrace_timer_handle);
      retrace_timer_handle = -1;
   }
}

Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Clark on June 17, 2021, 02:02:29 pm
I'm not sure I understand what you are trying to do. Usually, definit() is used to initial global and/or static variables as if you loaded your module for the first time. Unlike C++, Slick-C can store the value of global and/or static variables in vslick.sta and often these variables need a specific initial state. _on_load_module only gets called when your module is loaded. definit() gets called either when the module is loaded or when the editor is invoked. The extra argument passed to definit(), let you know which case you are handling.

The first time the module is loaded or on invocation, your timer won't be running until you start it. If a module is reloaded (already loaded and you are loading it again), then you may or may not want to reset your timer. Most of the time you can get away with leaving your timer running.
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Graeme on June 18, 2021, 06:20:08 am
Thanks.  I often get a slick stack if I leave a timer running.  I think I will remove the _on_load_module thing I have, since definit can do it.
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Graeme on June 18, 2021, 09:15:37 am
I'm trying to improve the documentation for xretrace at the moment.  I think I will use OneNote and export it to pdf.  I was wondering if each plugin should maybe have two pdfs  <plugin-name>.usage.pdf for how to use and <plugin-name>.dev.pdf for developer notes  - or maybe just <plugin-name>.pdf and all in the one file.  I think I will need to separate xxutils from xretrace.  Also it would be nice if all plugin source was in github so people can diff to see what has changed - or get older copies of the source.

my plugin.xml file currently has this
   <plugin title="Graeme's XRetrace Macros" min_ver="25"/>

I wonder if a max_ver is also needed, if it's not there then there's no max.
my plugin folder name is currently this
user_graeme_nz.xretrace.ver.1.0
If this gets updated to a new version, will the existing folder remain in the plugins folder when the new version is installed  - or will the plugin loader unload all of the ex files in the older version before loading the new one?

Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Graeme on June 18, 2021, 11:12:16 am
One more thing, until the plugin website is working, the plugin name needs to indicate what minimum version of slickedit is needed to use that file

so this
user_graeme_nz.xretrace.ver.1.0
becomes
user_graeme_nz.xretrace.ver.1.0_slick_min_ver_25.0.0
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Graeme on June 27, 2021, 11:16:16 pm
I'm getting some problems with loading bitmaps using _find_or_add_picture - for the xretrace plugin the bitmaps don't seem to work until I manually reload the xretrace source file.  I'm still investigating.  In the process I discovered that if I have xretrace_scrollbar.e open in the editor and use macro => load module I get this filename showing in the open dialog
plugin:\\user_graeme_nz.xretrace\xretrace_scrollbar.e
which gives an error, it should be
C:\GP\SlickConfig\temp\25.0.2\plugins\user_graeme_nz.xretrace.ver.1.0\xretrace_scrollbar.e
For some reason the file tab for this file in slickedit has
plugin:\\user_graeme_nz.xretrace.ver.1.0\xretrace_scrollbar.e
but I can't remember what I did that made it do that.  If I figure it out I'll update this thread.


Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Graeme on June 27, 2021, 11:59:56 pm
Not sure what's going on but for the code below I get debug output of
pic 32933 33486 33483
if I re-install the plugin then restart slick and the bitmaps don't work.
If I then manually reload xretrace.e using menu -> load module (without restarting slick), the bitmaps start working
and I get
pic 33470 33486 33487
If I now restart slick the bitmaps stop working.
Maybe the bitmap path doesn't work at startup.
#define XRETRACE_PATH "plugin://user_graeme_nz.xretrace/"
#define XRETRACE_BITMAPS_PATH  XRETRACE_PATH :+ "bitmaps" :+ FILESEP

Code: [Select]
   retrace_line_marker_pic_index_cur = _find_or_add_picture(XRETRACE_BITMAPS_PATH :+ '_xretrcur.png@native');
   retrace_line_marker_pic_index_mod = _find_or_add_picture(XRETRACE_BITMAPS_PATH :+ '_xretrmod.png@native');
   retrace_line_marker_pic_index_demod = _find_or_add_picture(XRETRACE_BITMAPS_PATH :+ '_xretrdemod.png@native');
   //retrace_line_marker_pic_index_inv = _find_or_add_picture(XRETRACE_BITMAPS_PATH :+ '_xretrinv.png');
   retrace_line_marker_pic_index_inv = 0;

   say("pic " :+ retrace_line_marker_pic_index_cur :+  " " :+ retrace_line_marker_pic_index_mod :+ " " :+ retrace_line_marker_pic_index_demod);

Title: Re: is the plugin mechanism useable in 25.0.2
Post by: patrick on June 28, 2021, 01:24:25 pm
Haven't been able to reproduce this.  Can we get your config directory?  (We're assuming the plugin location is the default, so the config directory will be included).

We'll PM you with instructions on how to upload the zipped/tarred config directory shortly.
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: SlickEdit Support on June 28, 2021, 01:48:23 pm
PM sent.

Best,
SlickEdit Support

Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Graeme on June 28, 2021, 10:55:15 pm
Here's the plugin I'm loading into a clean empty config.  I've uploaded the config folder to support.  I notice that if the plugin source has changed and the ex file is out of date, slick automatically rebuilds the plugin at startup.  As with a manual re-load, this also results in the bitmaps working.  If there is no re-load after a restart, the bitmaps don't work.
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Graeme on June 28, 2021, 11:09:32 pm
I should mention that the bitmaps show up in the margin at the left hand side - same place as bookmark icons.  By default the bitmaps are turned off and also by default, xretrace doesn't start running until you try to use it  - this is in case it causes a problem for someone you can just restart to get xretrace turned off.  To change these settings, run xretrace-show-control-panel  - then enable the top left three "show marker" settings, turn off "retrace delayed start".  I also enable "capture retrace data to disk".
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Graeme on June 28, 2021, 11:40:44 pm
I tried making the bitmap path a normal pathname but it didn't help.


// xretrace_plugin.sh is copied to xretrace.sh when packaging the xretrace plugin
#define XRETRACE_IS_PLUGIN yes

//#define XRETRACE_PATH "plugin://user_graeme_nz.xretrace/"

#define XRETRACE_PATH _ConfigPath() :+ "/plugins/user_graeme_nz.xretrace/"

#define XRETRACE_BITMAPS_PATH  XRETRACE_PATH :+ "bitmaps" :+ FILESEP

Title: Re: is the plugin mechanism useable in 25.0.2
Post by: patrick on June 29, 2021, 07:29:24 pm
Ok, I do see this with the plugin you posted, with a clean config.  I'll quit SlickEdit, restart, and I don't see the bitmaps in the gutter.  Showing the xretrace options shows everything I selected is still selected.  Loading the module makes the bitmaps appear for that session, till I quit again.  And I get the say() output, so I know the init function is being called.

I'll see if I can trace why this is happening. 
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Graeme on June 30, 2021, 03:56:18 am
I've tried fiddling with the definit and on-load-module code to see if I can see what is the difference between a manual load and a restart - but I got nowhere.  If I comment out some of the code, a manual load still makes the bitmaps work.  I did notice that after a manual load, on the next restart, the bitmaps work but not on the restart after that.

I've found another way to get the bitmaps working is to disable xretrace (using the config dialog), then restart xretrace by running the xretrace-cursor-steps command.  - it calls init-xretrace.  So it seems that init-xretrace works sometimes and sometimes not.  I  don't normally have bitmaps showing so I can't really tell whether this problem is because it's a plugin or because it sometimes happens anyway.  In my "normal" 25.0.2 config the bitmaps always appear so far.
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: patrick on July 01, 2021, 02:52:46 pm
I don't think you can do anything that isn't extremely hacky to work around this.  I've gotten far enough to see that it is specific to the plugin loading process, and that your image indexes are getting removed after your init.  So we're closing in on what the problem is. 

And I do see the behavior you mention of it working once after a reload - it looks like in this case xretrace.e is getting loaded outside of the plugin loads.  I haven't looked closely as to why this is yet,  but I suspect it's something outside of the plugin system deciding it needs a reload.   Something to look at after the main load problem is fixed.
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: patrick on July 01, 2021, 07:35:44 pm
Found the problem.  I'll put the fix in for the next hotfix.  In the meantime,  you can load the attached copy of cfg.e to get the fix.

Title: Re: is the plugin mechanism useable in 25.0.2
Post by: patrick on July 01, 2021, 07:39:03 pm
Ack, attached the wrong version.  Load the cfg.e in this post to get the fix.
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Graeme on July 22, 2021, 11:52:22 am
My xretrace macro needs the source files to be loaded in a certain order.  Currently I get a slick stack when trying to install the plugin because definit in xretrace.e tries to call a function that doesn't exist.  I had to use task manager to kill slickedit.  Is there any way to handle this?
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Graeme on July 23, 2021, 11:50:03 am
I'm trying to work around this problem by loading the missing macro file from xretrace def_init if find_index doesn't find a particular function - dlist_construct   - but find_index says the function is in the names table but when I call the function, I get a slick stack.  Is it possible that a #import adds names to the names table and makes find_index return non zero even though the module containing dlist_construct hasn't been loaded yet?

Code: [Select]
   int vv1 = find_index('dlist_construct', PROC_TYPE);
   say("ggg " :+ vv1);

- the code above gives me 33104 but calling dlist_construct crashes.
 
For the plugin version of xretrace, I will probably have to load DLinkList.e from xretrace.e def_init every time xretrace.e is loaded.  It seems to work.
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Clark on July 23, 2021, 02:10:30 pm
How did you create your plug-in? If you just zip up your files, you can’t rely on order of macro loading. You have to use the plug-in creation commands. If I remember correctly the manifest (written by plug-in creation commands) specifies the macro load order and is generated automatically.
Title: Re: is the plugin mechanism useable in 25.0.2
Post by: Graeme on July 23, 2021, 10:17:31 pm
Yes, I just zipped it.  I didn't know there was a plugin creator.  I'll give it a try.  Thanks.