Author Topic: xretrace and xxutils V2.20 / includes plugins for slick V26  (Read 12641 times)

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
xretrace and xxutils V2.20 / includes plugins for slick V26
« on: August 13, 2021, 11:51:12 AM »
I've updated xretrace and xxutils, a few minor fixes and some extra things.  For xretrace there is a new checkbox in the settings dialog called "don't touch line modify flags".  xretrace tries to track modified lines but it clears the "line modify" flag to keep track of the order of changes.  If you use "colour modified lines" you might not like this.  If you set "don't touch line modify flags" it won't interfere with the "line modify" flags but will still track modified lines, just not always with the correct order.

For slick V26 and later, xretrace and xxutils are supplied as plugins - user_graeme.xxutils.ver.2.20.zip and user_graeme.xretrace.ver.2.20.zip which are installed using the plugin-install command. 

For slick V25 and earlier there is a zip file (xretrace-v2-20-slick-v26-0-0.zip) which you unzip into your configuration folder which will create a UserMacros folder containing an xretrace folder containing the source files and help file pdf.  You must then load firstly xretrace.e then xxutils.e.

Please read the help file for more installation information - page 1 for xretrace, page 12 for xxutils installation.  If you've been using xretrace prior to September 2021 then the location of the xretrace source files is changing and you need to unload some modules before loading the new ones.  See the help file.

These modules have been tested for slick V20 up to V26.

The zip file (and github) includes a help file (attached) xretrace-xxutils-help.pdf plus the OneNote notebook used to create it. 

For github, see the xretrace folder here, it has everything the zip file does
https://github.com/jporkka/slickMacros
The tag is
SLICK-V20-to-V26.0.0

For xxutils, all of the commands now have a prefix of user_graeme_ to ensure they are unique.  If you don't want the prefix, you can change these
#define XUN(a) user_graeme_##a
#define XUNS "user_graeme_"
to this
#define XUN(a) a
#define XUNS
« Last Edit: September 23, 2021, 04:29:23 AM by Graeme »

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: xretrace and xxutils V2.0
« Reply #1 on: September 02, 2021, 04:04:45 PM »
Thanks so much Graeme for this update.

I installed it (using today's github) in beta3 by loading 'xload-macros.e' and got an error message, but it seemed to load, see attached screenshot.

I have yet to use it, if there are problems I will post again.

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: xretrace and xxutils V2.0
« Reply #2 on: September 03, 2021, 05:50:24 PM »
xretrace seems to be working for me.

Today I shut down SE (had to kill it, but not kill -9) and restarted SlickEdit.

Now I am getting 4 dialogs of questions whenever I start SE. I attached screenshots.

Is this normal/expected? Would rather not have to do this every time I run SE.

I then shut down SE normally and restarted and every time I am asked these 4 dialogs.

I also tried 'xtrace-disable', but still when I restart SE I get these 4 dialogs.
« Last Edit: September 03, 2021, 05:58:23 PM by rowbearto »

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: xretrace and xxutils V2.0
« Reply #3 on: September 03, 2021, 10:52:48 PM »
Nope, not expected.  It means that slick is trying to load xload-macros.e every time it starts up - don't know why it would do that.  You can probably fix by using macro -> unload module on xload-macros.e.

This might be a V26 issue.  For V26 I was planning to support only the plugin build but I'll check it out.
I'm probably changing this mechanism anyway.  Sorry about that.

Code: [Select]
definit()
{
   if (arg(1)=="L") {
      // If this is NOT an editor invocation

      int res = _message_box('Load xretrace & xxutils ?' \n \n 'If you are installing a SlickEdit upgrade, you should select NO here.', '', MB_YESNO);
      if (res != IDNO) {
         load_xretrace_modules();
         if ( !load_error && find_index('xretrace_show_control_panel', COMMAND_TYPE) != 0 ) {
            xretrace_show_control_panel();
            _message_box( 'xretrace has been successfully loaded.' \n \n:+
                          'Use the "xretrace_options" command to set xretrace options.' \n \n :+
                               'Uncheck "retrace delayed start" for normal operation.');
         }
      }
      else
      {
         _message_box('Use the load_xretrace_modules command to load xretrace at any time.');
      }
   }
}


Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: xretrace and xxutils V2.0
« Reply #4 on: September 04, 2021, 10:26:37 AM »
Hi Rob

I can't reproduce the problem using beta 3.  The definit in xload-macros.e should do nothing for a normal startup so slickedit must be trying to rebuild it every time.  It might do that if the .ex file is out of date.  You might be able to fix it by manually reloading xload-macros.e and let it build xretrace.

Is it possible the problem you have was caused by the crash?  Had you been restarting slickedit without a problem before the crash.  Also I haven't done any testing on Linux so far.

I did find another problem though - xretrace won't start running unless I call init-xretrace twice at startup.  For some reason the timer callback dies the first time.  Could be a bug in slickedit I guess.  That's with the xretrace github code though, I've made a few changes since then.



rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: xretrace and xxutils V2.0
« Reply #5 on: September 06, 2021, 06:07:27 PM »
Hi Graeme:

Thanks for the replies. I just did the following:

1) Unloaded all the xretrace modules
2) Restarted SE
3) Loaded xload-macros.e
4) Restarted SE (there was no crash this time)
5) When I restart SE I am again getting all of these dialog boxes
6) I unloaded xload-macros.e
7) Now when I restart SE I don't see all of those dialog boxes again.

I have not updated from the latest github when I did all of this, however I used the github from Sep 2 and seems no new commits since then.

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: xretrace and xxutils V2.0
« Reply #6 on: September 06, 2021, 11:22:12 PM »
ok, which version of slickedit are you using?

Do you have any other slick c macro files that get rebuilt every time you start slickedit?

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: xretrace and xxutils V2.0
« Reply #7 on: September 07, 2021, 12:34:23 PM »
I am using v26 beta 3 on Linux x64.

I don't know if I have any other slick c macro files that get rebuilt every time I start SlickEdit. I do have my own .e file that I loaded some time ago, but how to know if it gets rebuilt every time I start slickedit?

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: xretrace and xxutils V2.0
« Reply #8 on: September 07, 2021, 06:56:15 PM »
I printed arg(1) to a message box in definit() as below:

Code: [Select]
definit()
{
   // If this is NOT an editor invocation
   _message_box("arg(1)" arg(1));
   if (arg(1)=="L") {

When I restart SE the arg(1) is 'L' so it gets reloaded.

Not familiar enough with what 'definit()' is? Is that supposed to be called for this macro every time SE starts?

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: xretrace and xxutils V2.0
« Reply #9 on: September 08, 2021, 01:55:27 AM »
The time/date on the .ex file will show when it got rebuilt.
definit is in the help - here's an extract.

Quote
The return value of these functions is always void. You cannot specify an argument to the return statement. To enhance the performance of SlickEdit®, use the defload primitive instead of the definit primitive. The definit primitive forces a module to be loaded when the editor is invoked. When definit is called, the expression arg(1) indicates whether the module was loaded with the load command or when the editor initialized. When a module is loaded, arg(1) returns L. Otherwise arg(1) returns a null string ("").

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: xretrace and xxutils V2.0
« Reply #10 on: September 08, 2021, 12:32:52 PM »
I see that the timestamp of xload-macros.ex is updated when I relaunch SlickEdit.

My custom macros file is not reloaded, it has a timestamp back on September 2 when I first loaded it, even when I relaunch SE. It does not have a definit() or defload() in it.

Seems there is a bug in SE on Linux x64, definit() should return "" when starting the editor, but returns "L" instead.

Did you only try this on Windows and not on Linux?

I started another thread about why is definit() returning "L" at editor startup and not "": https://community.slickedit.com/index.php/topic,18391.0.html

As per the documentation you provided for definit(), why not use defload() instead of definit()? definit() seems to force a reloading at each editor invocation, defload() does not?

Well I just tried changing it to defload() and removed the check on arg(1). Strange is when I start the editor I am getting the 4 dialog boxes from xretrace, however the timestamp on the xload-macros.ex file is NOT updated, whereas using definit() timestamp was upon editor load. In both cases I got the 4 dialogs.

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: xretrace and xxutils V2.0
« Reply #11 on: September 08, 2021, 03:18:07 PM »
I found that restarting SE 2 times with xload-macros.e loaded in Linux x64/beta3 is what is causing my customized toolbar to revert to default:

https://community.slickedit.com/index.php/topic,18388.msg72698.html#msg72698

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: xretrace and xxutils V2.0
« Reply #12 on: September 08, 2021, 08:21:25 PM »
Looks like the problem of having xload-macros.e display the dialogs on SE start happens when you run a second instance of SE. I unknowningly had an instance already running.

So not sure definit() is used properly in xload-macros.e, see:

https://community.slickedit.com/index.php/topic,18391.msg72723.html#msg72723

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: xretrace and xxutils V2.0
« Reply #13 on: September 08, 2021, 11:05:24 PM »
Thanks for tracking that down - I will fix it.  I still can't reproduce it - can you confirm that it's only a second instance that has the problem?  Also, does it make sense that a second instance sees an "L" rather than a non "L" - I do not know.

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: xretrace and xxutils V2.0
« Reply #14 on: September 08, 2021, 11:41:47 PM »
I confirm it is only the second instance that has this problem. First instance has empty '', second instance (while first instance is running) has "L", just like when initially loading the macro. I interpreted that Clark said in the other thread that this is expected behavior. Specifically putting together parts of those messages:

rowbearto:
Quote
Here is what I'm asking.

1) Launch first instance of SlickEdit
2) load myfile.e
   arg(1) is 'L' as expected.
3) Close SlickEdit and make sure no instances
4) Launch SE: "vs"
  arg(1) in definit is '' as expected
5) Don't close first instance of SE, now launch second instance of "vs"
  arg(1) in definit is 'L'

So I can't tell the difference between 2) above and 5). I would like different behavior for 2) and 5).

Clark:
Quote
For case 2 and 5, you should be doing the same thing with your global variables. If you don't, your code won't work right.

and then see my experiment in: https://community.slickedit.com/index.php/topic,18391.msg72719.html#msg72719  It shows that setting a global in a first SE instance to non-default doesn't carry to second SE instance, the second SE instance will get the default value.

Clark then replied:
Quote
cases 2 and 5 are going to look the same. The module is being loaded for the first time. Your global variables need to be initialized the same way for case 2 and 5.

For fixing xretrace: I think the fastest way (and maybe the best way) is just to have a special install macro after loading xload-macros.e, like you had before. Don't use the definit().
« Last Edit: September 08, 2021, 11:43:47 PM by rowbearto »