Author Topic: is the plugin mechanism useable in 25.0.2  (Read 847 times)

Graeme

  • Senior Community Member
  • Posts: 2548
  • Hero Points: 329
is the plugin mechanism useable in 25.0.2
« 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.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5784
  • Hero Points: 461
Re: is the plugin mechanism useable in 25.0.2
« Reply #1 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 "$@"&

Graeme

  • Senior Community Member
  • Posts: 2548
  • Hero Points: 329
Re: is the plugin mechanism useable in 25.0.2
« Reply #2 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

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

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5784
  • Hero Points: 461
Re: is the plugin mechanism useable in 25.0.2
« Reply #3 on: June 16, 2021, 01:50:31 am »
I’ll check into this

Graeme

  • Senior Community Member
  • Posts: 2548
  • Hero Points: 329
Re: is the plugin mechanism useable in 25.0.2
« Reply #4 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;
   }
}


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5784
  • Hero Points: 461
Re: is the plugin mechanism useable in 25.0.2
« Reply #5 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.

Graeme

  • Senior Community Member
  • Posts: 2548
  • Hero Points: 329
Re: is the plugin mechanism useable in 25.0.2
« Reply #6 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.

Graeme

  • Senior Community Member
  • Posts: 2548
  • Hero Points: 329
Re: is the plugin mechanism useable in 25.0.2
« Reply #7 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?


Graeme

  • Senior Community Member
  • Posts: 2548
  • Hero Points: 329
Re: is the plugin mechanism useable in 25.0.2
« Reply #8 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

Graeme

  • Senior Community Member
  • Posts: 2548
  • Hero Points: 329
Re: is the plugin mechanism useable in 25.0.2
« Reply #9 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.



Graeme

  • Senior Community Member
  • Posts: 2548
  • Hero Points: 329
Re: is the plugin mechanism useable in 25.0.2
« Reply #10 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);


patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1527
  • Hero Points: 139
Re: is the plugin mechanism useable in 25.0.2
« Reply #11 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.

SlickEdit Support

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 339
  • Hero Points: 26
Re: is the plugin mechanism useable in 25.0.2
« Reply #12 on: June 28, 2021, 01:48:23 pm »
PM sent.

Best,
SlickEdit Support


Graeme

  • Senior Community Member
  • Posts: 2548
  • Hero Points: 329
Re: is the plugin mechanism useable in 25.0.2
« Reply #13 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.

Graeme

  • Senior Community Member
  • Posts: 2548
  • Hero Points: 329
Re: is the plugin mechanism useable in 25.0.2
« Reply #14 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".