SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => SlickEdit User Macros => Topic started by: Graeme on August 13, 2021, 11:51:12 AM

Title: xretrace and xxutils V2.20 / includes plugins for slick V26
Post by: Graeme 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
Title: Re: xretrace and xxutils V2.0
Post by: rowbearto 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.
Title: Re: xretrace and xxutils V2.0
Post by: rowbearto 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.
Title: Re: xretrace and xxutils V2.0
Post by: Graeme 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.');
      }
   }
}

Title: Re: xretrace and xxutils V2.0
Post by: Graeme 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.


Title: Re: xretrace and xxutils V2.0
Post by: rowbearto 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.
Title: Re: xretrace and xxutils V2.0
Post by: Graeme 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?
Title: Re: xretrace and xxutils V2.0
Post by: rowbearto 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?
Title: Re: xretrace and xxutils V2.0
Post by: rowbearto 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?
Title: Re: xretrace and xxutils V2.0
Post by: Graeme 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 ("").
Title: Re: xretrace and xxutils V2.0
Post by: rowbearto 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.
Title: Re: xretrace and xxutils V2.0
Post by: rowbearto 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
Title: Re: xretrace and xxutils V2.0
Post by: rowbearto 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
Title: Re: xretrace and xxutils V2.0
Post by: Graeme 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.
Title: Re: xretrace and xxutils V2.0
Post by: rowbearto 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().
Title: Re: xretrace and xxutils V2.0
Post by: rowbearto on September 09, 2021, 02:05:12 AM
FYI: I'm always using the "+new" option when launching vs. So for first and second instance of vs I launch with "vs +new". This is embedded in my script that invokes SE, so it is always there. Maybe this is what you need for reproduction.

Also in Linux I also always launch SE with the "-st 0" option to minimize corruption. Learned from: https://community.slickedit.com/index.php?topic=11353.15
Title: Re: xretrace and xxutils V2.0
Post by: Graeme on September 09, 2021, 06:56:28 AM
Should be fixed now.  I put it back to the old way - after loading xload-macros.e you have to manually call xxutils-xretrace-load on the command line.  It's in github.  Thanks for all your testing and information.

For V26 I was hoping to only support the plugin version of xretrace.  For V26 in xretrace definit I had to call init-xretrace() twice otherwise the time doesn't start running.  Another weird thing is that when xxutils-xretrace-load runs, it brings up the xretrace settings dialog  - but it brings up the previous form of the dialog  e.g. V2.0 instead of V2.01.  I don't feel motivated enough to investigate!

Title: Re: xretrace and xxutils V2.0
Post by: rowbearto on September 09, 2021, 01:15:06 PM
Thanks Graeme, so far so good.

How to use the plugin to install? I don't see any instructions on how to do that in the pdf file? If I knew how to do this I would.

I also see some other definit() in other .e files using arg(1) and checking it against 'L'. Now that we know that we can see 'L' in second instance as well as loading maybe these need to be re-reviewed to decide if they are appropriate?

Also in xretrace.e does this need to be set to an initial value in its declaration?

Code: [Select]
static int xretrace_has_been_started_id;
I say this because xretrace_clear_all_markers() checks it and xretrace_clear_all_markers() is called in the definit() of xretrace.e when arg(1) is "L".

Code: [Select]
_command void xretrace_clear_all_markers() name_info(',')
{
   if (xretrace_has_been_started_id == XRETRACE_HAS_BEEN_STARTED_ID) {
      dlist_reset(track_demodified_list);
      _LineMarkerRemoveAllType(retrace_marker_type_id);
      _LineMarkerRemoveAllType(retrace_marker_type_id_mod);
      _LineMarkerRemoveAllType(retrace_marker_type_id_demod);
   }
}
Title: Re: xretrace and xxutils V2.0
Post by: Graeme on September 12, 2021, 06:44:02 AM
I've uploaded a new version that I've been working on for a couple of weeks.  xretrace is now a single module (single ex file) which makes it easier for it to be a plugin.  I also free some line marker types which I wasn't doing before.  I'm still looking into the plugin - I have to consider prefixing all macro commands with "user_graeme_" to make them unique.  Currently I have an x prefix which hopefully means they don't clash with the "normal" commands.

I fixed the definit issues a few days ago with help from Clark here
https://community.slickedit.com/index.php/topic,18338.msg72378.html#msg72378 (https://community.slickedit.com/index.php/topic,18338.msg72378.html#msg72378)

xretrace_has_been_started_id is a static variable that is assigned by definit regardless of whether it's a load or a restart.

For slick V26 the xretrace timer doesn't start running at startup - it does in older versions.  I have no idea why so I've posted a report in the beta forum.
https://community.slickedit.com/index.php/topic,18414.0.html (https://community.slickedit.com/index.php/topic,18414.0.html)
When you first use one of the xretrace commands e.g. xretrace_cursor, it will check if the timer is running and ask if you want to start it if it isn't running.
Title: Re: xretrace and xxutils V2.0
Post by: Graeme on September 13, 2021, 02:52:08 AM
Updated to V2.11 to fix an issue with a debug variable.

Title: Re: xretrace and xxutils V2.0
Post by: Graeme on September 16, 2021, 04:37:06 AM
xretrace V2.12 fixes a problem with detecting inserted lines as modified lines.
updated in github also.
Title: Re: xretrace and xxutils V2.0
Post by: rowbearto on September 16, 2021, 01:05:37 PM
Thanks Graeme.

What is the best way to upgrade an existing install? I've been unloading each module then doing the 'normal' install, but is there a better way? Can I just reload the xload-macros.e and rerun the install command without unloading?
Title: Re: xretrace and xxutils V2.0
Post by: Graeme on September 16, 2021, 10:55:25 PM
Yes, just reload and re-run, you don't need to manually unload any modules.  I'll put that in the help file.

I'm changing xxutils to be a "single module" rather than multiple ex files, to make the plugin easier.  For this situation (and some others) it's necessary to manually unload the ex files and also to remove unwanted files from the tag file.  I'll make this clearer in the help file.  Once you're using the plugin you don't need to manually do anything, except load or update the plugin.


Title: Re: xretrace and xxutils V2.20 / includes plugins for slick V26
Post by: Graeme on September 23, 2021, 04:35:33 AM
I've updated xretrace to V2.20, the zip file is in the first post of this thread, plus there are plugins for V26 there as well.

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
Title: Re: xretrace and xxutils V2.20 / includes plugins for slick V26
Post by: rowbearto on November 26, 2021, 07:36:24 PM
I installed the plugin today. After selecting the .zip file with 'plugin_install' I got the attached error message about "no_touch_line_modify_flag_checkbox". After clicking OK the plugin does seem to work fine.

EDIT: I am also seeing this warning upon a restart of SE.
Title: Re: xretrace and xxutils V2.20 / includes plugins for slick V26
Post by: Graeme on December 08, 2021, 09:19:17 AM
Hi Rob

Sorry for the delay.  I can't reproduce this problem but I have seen it before.  It's possible it is the result of switching from the non plugin version to the plugin version.  My previous comments in this thread are probably out of date about how to do that and not what I ended up putting in the help file.  I suggest that you try uninstalling everything, then reinstall the plugin
1.  run the command xretrace_disable
2.  run plugin_uninstall from the cmdline and uninstall xretrace
3. use the unload_module command in the macro menu and unload all the xretrace.ex files if any  - xretrace.ex  xretrace_scrollbar.ex  xretrace_popup.ex  DLinkList.ex
4. remove any xretrace files from the slickc tag file
5. use the plugin_install command to reinstall xretrace.

Let me know if it doesn't fix the problem.

Edit : Once you have the plugin installed and working, to install an update you just run plugin_install again.  You don't have to uninstall anything.  If you change the source files in the plugin folder you can rebuild by macro -> load module -> xretrace.e.  xretrace.e is the only file you need to load - it #includes all the other needed files.  slick also automatically rebuilds the plugin at startup if needed  - although the #include mechanism might defeat this  - I don't know.  Some of the #included xretrace source files have an "esh" extension instead of an "e" extension.  This is so that the plugin manager doesn't try to build them into individual .ex files.

Title: Re: xretrace and xxutils V2.20 / includes plugins for slick V26
Post by: niexin.liu on January 15, 2022, 07:51:58 AM
This plugin is really too good, thank you very much.
Title: Re: xretrace and xxutils V2.20 / includes plugins for slick V26
Post by: Graeme on January 15, 2022, 10:57:35 AM
This plugin is really too good, thank you very much.

Thanks.  Let me know if you have any problems or suggestions.