SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => SlickEdit User Macros => Topic started by: Graeme on October 22, 2018, 05:23:08 am

Title: xretrace, xxutils and a few other things
Post by: Graeme on October 22, 2018, 05:23:08 am
I've combined xretrace, xxutils and a few other things into a single zip file.  Backup your current configuration folder then unzip to your config folder so that you have a sub-folder called xretrace that has the macro files and bitmaps needed.

Have a read of the info towards the end of the xload-macros.e source file.
If you want to try this out before changing your normal config folder then create a new empty temporary config folder - start slick with vs.exe +new -sc some-empty-folder   - then import all your settings and load all the files below.

The xload_macros command prompts if you want to force the macro source to be re-compiled.  Normally you should say "yes" to this.

>>>>>>  from xload-macros.e

You can clone the xretrace folder to anywhere you want and load it by loading xload-macros.e then run the macro xload_macros_default_path_silent   - (or xload_macros_dev which will prompt for the location of the xretrace folder if you want to select where it goes).
default path is UserMacros/xretrace in your config folder.

     If you use xload_macros_dev you will be prompted for which modules you want to load.
     dlinklist.e is needed by other modules  - no harm to load it.
     xretrace-whatever  - load all three or none
     xtemp-file-manager is needed by xxutils but it's sort of inactive until you enable it
     xnotepad  -  is needed by xxutils
     xblock-selection-editor - is optional

xretrace now includes a kind of vertical scrollbar.  It creates a bunch of text files - if you don't want these then stick with the old xretrace (link below) and skip loading the three xretrace modules listed above.  xretrace.e has some detail at the start about how to use it.
  https://community.slickedit.com/index.php/topic,4693.msg36784.html#msg36784 (https://community.slickedit.com/index.php/topic,4693.msg36784.html#msg36784)
 
The old version of xxutils.e is here
https://community.slickedit.com/index.php/topic,11186.msg57320.html#msg57320 (https://community.slickedit.com/index.php/topic,11186.msg57320.html#msg57320)

If you want to use the temporary file handler then it's best to create an environment variable called xtemp_files_path to specify where you want the temp files to go - more info in xload-macros.e.  The file xtemp-file-manager has some detail at the start about what it's doing.

Please let me know if there are any problems.

[EDIT Nov 11, 2018]
Uploaded some updated files to fix a couple of things.  There's a new option in the xretrace options dialog  -  "capture retrace data to disk".  It's off by default.  If you want xretrace-scrollbar to show anything useful it needs to be enabled.
Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on December 08, 2019, 04:26:12 pm
Hi Graeme:

Is this the latest version of your tools? I want to try it out but when I search the forum there is more than 1 post, so not sure which one to use.

Maybe you can make a github for it? This way there is one central place to get it and you can even have contributors.
Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on December 08, 2019, 05:51:48 pm
Also, is there a reason why the macros need to be in a subfolder of the config folder? I usually have my macros in a dedicated folder outside of the config.
Title: Re: xretrace, xxutils and a few other things
Post by: Graeme on December 08, 2019, 09:09:44 pm
Hi Rob
This thread is the latest version but I haven't had time to switch to V24 yet and I'm fairly sure that xretrace doesn't work correctly with V24 and it crashes slickedit on Linux.  I should get time to look at it in a couple of weeks.

I have macros in a sub-folder so that when I upgrade to a new config folder, the macros get copied and re-built with the new version.  It allows me to keep using an older version if I want  - the .ex file isn't portable between versions.

I agree that there should be a common git repo for macros - the wiki would be useful too.  jporkkahtc posted a link to his git repo for his macros a while ago but I would prefer that the repo was owned by SlickEdit Inc and publicised on this forum.

I also have to set up an easier way to load my macros using the hotfix mechanism - I started doing it after a suggestion from Dennis but ran into problems and lack of time.
 

Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on December 08, 2019, 09:20:28 pm
I tried to use xretrace with v24 on Linux before your post.

It is not crashing v24,  xretrace_cursor and xtrace_modified_line seem to work.

However when I do xretrace_modified_line_steps or xretrace_cursor_steps, the popup window comes up but then instantly disappears. I set the below:

Code: [Select]
#define  XRETRACE_DATA_PATH  "/tmp/xretrace"
//#define  XRETRACE_USE_SUBFOLDER YES

But I don't see any files created in there when I move the cursor around or start modifying lines.

xretrace seems like it can be really useful so I don't mind debugging it on v24 if you have any pointers for where I should look?

I started a private github repo for my changes but I can easily make it public, if you are interested.
Title: Re: xretrace, xxutils and a few other things
Post by: Graeme on December 08, 2019, 10:16:50 pm
If the popup window is disappearing instantly then maybe the retrace_steps_event_loop2 function is exiting immediately.  You could find the "return" statements in that function and see if you can figure out why it is exiting early?  When the event loop is running you should be able to show and hide the popup window using "F5".

There are some "xretrace_dump" commands that output the current xretrace list  e.g.  xretrace_dump_retrace_cursor_list  -  can be used to check if the cursor position is being added to the list correctly  - and xretrace_dump_modified_lines_list.

Regarding the repo  -jporkkahtc made his public too.  I'll see if SlickEdit support have any comment about it.  Ideally there should be just one repo for all user macros I think.

Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on December 08, 2019, 10:20:41 pm
Graeme: With the addition of many dsay() statements, I found that the popup for xretrace-cursor-steps is disappearing right away because it thinks that "ESC" was hit. My dsay in the below case for 'ESC' is printing out so that is how I know.

Code: [Select]
      _str key = get_event('N');   // refresh screen and get a key
      _str keyt = event2name(key);
      switch (keyt) {
...
         case 'ESC' :
            // exit back where we started
            edit('+Q +BI ' :+ start_buf_id);
            message('');  // clear
            _mdi.p_child.p_line = startline;
            _mdi.p_child.p_col = startcol;
            center_line();
            dsay("Event loop ESC return");
            return;

Any ideas as to why it thinks ESC was hit?

At first I was issuing the 'xretrace-cursor-steps' by pressing esc and typing the command.

But then if I bind it to a key so I don't have to hit ESC, it still exits due to thinking ESC was hit.
Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on December 08, 2019, 10:22:32 pm
Regarding github, I've also had a public github repo for a macro that I took over from chrisant:

https://github.com/rbresalier/sync_project_with_scm
Title: Re: xretrace, xxutils and a few other things
Post by: Graeme on December 08, 2019, 10:22:43 pm
Sorry, missed your question about xretrace_data_path  - there's not much difference in the code regarding this so I would expect it to work.

Maybe you have data capture disabled - from a higher up post I wrote this
Quote
There's a new option in the xretrace options dialog  -  "capture retrace data to disk".  It's off by default.  If you want xretrace-scrollbar to show anything useful it needs to be enabled.

Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on December 08, 2019, 10:29:07 pm
So I modified the event loop code so that the first ESC is ignored, and only the 2nd ESC is looked at.

When I do this it works! The popup is there and I can navigate the cursor changes.
Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on December 08, 2019, 10:32:25 pm
For xretrace github repo, I think it would be nice to have it on its own and not be in a repo with everyone elses macros.

The reason that I think this is so that I can cd to my SE config dir and do a git clone xretrace and it will automatically be in the config/24.0.0/xretrace directory.

This is how I made my private repo.
Title: Re: xretrace, xxutils and a few other things
Post by: Graeme on December 08, 2019, 10:32:45 pm
ok, thanks.  I'll check with slickedit support about it, also Clark offered to help me get xretrace working on V24.

I wonder if it's something to do with the numeric keypad stuff I added because of this.
https://community.slickedit.com/index.php/topic,16592.msg63985.html#msg63985 (https://community.slickedit.com/index.php/topic,16592.msg63985.html#msg63985)
Title: Re: xretrace, xxutils and a few other things
Post by: Graeme on December 08, 2019, 10:34:38 pm
regarding the repo - ok, I'll give it some thought.
Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on December 08, 2019, 10:48:32 pm
It seems like a possible issue with SlickEdit to me and not related to that post. For some reason after running xretrace_cursor_steps macro, the first time one tries to get a key (using code below) it is always ESC. Is xretrace somehow "pressing"/inserting this key?

Code: [Select]
_str key = get_event('N');   // refresh screen and get a key
_str keyt = event2name(key)

UPDATE: I modified the code to remove the numeric keypad stuff as below, it still thinks ESC is pressed and I need to ignore the first ESC, so that is not the problem.

Code: [Select]
      // make numpad keys work properly
      //int orig_auto_map_pad_keys=_default_option(VSOPTION_AUTO_MAP_PAD_KEYS);
      //_default_option(VSOPTION_AUTO_MAP_PAD_KEYS,0);
      _str key = get_event('N');   // refresh screen and get a key
      _str keyt = event2name(key);
      //_default_option(VSOPTION_AUTO_MAP_PAD_KEYS,orig_auto_map_pad_keys);
Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on December 08, 2019, 11:11:48 pm
After removing my debug prints it seems I now need to ignore the first 2 ESC keypresses and not just the first one.

Something seems strange.

UPDATE: I modified my local xretrace.e to ignore any ESC character within the first 500msec from when the event loop starts, this seems to work. But would be nice to understand why this is needed.
Title: Re: xretrace, xxutils and a few other things
Post by: Graeme on December 09, 2019, 12:16:30 pm
Thanks for trying it.  I'll send off a request to slick support at some point.  You're welcome to upload your modified files here if you feel like it.

Regarding the github repo.  jporkkahtc mentioned his github repo here - nearly two years ago.  Time flies.
https://community.slickedit.com/index.php/topic,15156.msg57556.html#msg57556 (https://community.slickedit.com/index.php/topic,15156.msg57556.html#msg57556)
https://github.com/jporkka/slickMacros.git

It looks like there is one folder for each different "macro/ utility"  -  would that work for you ??  Everything really needs to be tagged with the version of slickedit it works for so you can download the right version of every macro in one go.  Then there needs to be a loader utility that lets people choose which macros to "install" - or at least some easy way of installing.

BTW - I gave up coding on Linux because I couldn't get xretrace to run without crashing/killing slickedit.  We're using centos in vmware like you.

Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on December 09, 2019, 03:22:15 pm
It would be annoying to use anything other than its own repo due to the requirement for xretrace directory being directly under the config directory.

By having dedicated xretrace repo, I can git clone it right into my config directory and get xretrace subdirectory. Then if I have changes, I can edit them right there and the push back to git. Then when I was done in Linux and wanted to try it in windows, I easily cloned it under my windows config dir and got working very fast.

If I use a common repository, the xretrace files will not be under the config directory - cloning directly under there won't put them in the right directory. So I would clone somewhere else. Then I would have to copy the files over - which is error prone. Then if I make changes to the files, I have to make sure to copy them back to the git repo for pushing, this is also error prone.

This is why I prefer a dedicated repository for now.

If being a subdirectory of config dir was not a requirement, or if the combined repo could be cloned directly under the config directory and the xretrace macro files could be updated to take this into account, then it would be better. But I don't have the time to invest right now to change this, or to create a loader utility. Perhaps if someone took the time to do that then we could have a common repo, but I can't do it at the moment. So I would propose to make my private repo public and then when someone can invest in making it so that one can clone the combined repo directly under the config directory, or make xretrace usable outside the config directory, then can move it into a common repo.

xretrace works fine for me in Linux x64, CentOS under SlickEdit v24 with my changes. I had to make another minor change to get it to work, change all the #import "dlinklist.e" to #import 'DLinkList.e' as Linux file system is case sensitive.
Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on December 13, 2019, 02:16:22 pm
I've attached a xretrace.zip file with the modifications I've made (mentioned in earlier posts) to get xretrace working in my Linux x64 environment.
Title: Re: xretrace, xxutils and a few other things
Post by: Graeme on December 13, 2019, 10:20:00 pm
Thanks.  I'll have time to look at it in a week or so.  I'm keen to get it on github and I'll look at making it location independent too - it's difficult, if not impossible, to find the location of the source code at runtime from within the macro unless it's in a "known location".  There's a problem to find as well - step through modified lines sometimes goes to the end of a file when it shouldn't  - it started going wrong only a few months ago.
Title: Re: xretrace, xxutils and a few other things
Post by: Graeme on January 09, 2021, 04:40:16 am
The latest xretrace & xxutils etc. is now available in github - see this thread
https://community.slickedit.com/index.php/topic,15156.msg69252.html#msg69252 (https://community.slickedit.com/index.php/topic,15156.msg69252.html#msg69252)

xxutilis includes these macros which have slight differences to the built-in macros.

xcursor_to_next_token
xcursor_to_prev_token
xselect_to_next_token
xselect_to_prev_token
xfind_next_whole_word_at_cursor
xfind_prev_whole_word_at_cursor
xquick_search
xquick_reverse_search
Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on January 11, 2021, 02:13:14 pm
Thanks Graeme!

I think it would be useful if you added the instructions in the github. Maybe a text file or readme markup in the xretrace folder in the github?

I'm finding myself looking back through this thread for the instructions on what to do when I install the new xretrace.
Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on April 25, 2021, 03:17:36 am
Hi Graeme:

Thanks again for the wonderful xretrace macro.

I loaded up your latest one but I was still having issues similar to what I reported before. This time after pressing any key in the menu SE was reporting that I pressed ESC even though I was not pressing ESC. So I made a pull request where I filter out ESC for 500msec after any key is pressed.

Here is the pull request:

https://github.com/jporkka/slickMacros/pull/2

Thanks,
Rob
Title: Re: xretrace, xxutils and a few other things
Post by: Graeme on April 25, 2021, 09:36:28 am
Hi Rob
Thanks.  I'm not sure what the effect of your change is but I've merged and committed.  If you have the user rights, feel free to update xretrace in the master branch yourself.

It's a shame that user macros aren't a bit easier for people to find and download.  I haven't done a very good job of indicating which version of slickedit my macros work with though.
Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on April 25, 2021, 03:42:37 pm
Hi Grame:

Thanks for merging it. Since you 'own' this macro I wanted your review first so that is why I didn't attempt to push it to master myself, preferred your buy-in.

In your readme.txt you point to: https://community.slickedit.com/index.php/topic,16598.msg64005.html#msg64005

The instructions in that post first say: "Have a read of the info towards the end of the xload-macros.e source file."

But towards the end of xload-macros it states:

Quote
4) Load this module xload-macros.e then run the command xload_macros.

But there is no 'xload_macros' anymore. So I think this text needs updating.

I ended up going back to your post in the forum and did the "loading xload-macros.e then run the macro xload_macros_default_path_silent"

So the text at the end of xload_macros.e needs an update. I think there is even more outdated stuff there that needs update such as:

Quote
  #define XRETRACE_PATH _ConfigPath() :+ 'xretrace' :+ FILESEP
  #define XRETRACE_MODULE_NAME XRETRACE_PATH :+ 'xretrace.e'
  #define  XRETRACE_DATA_PATH  'c:/temp'
  #define  XRETRACE_USE_SUBFOLDER YES

  It is recommended that XRETRACE_PATH be left as is - anything else is untested.

Thanks again for this great macro!

Rob
Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on April 25, 2021, 04:02:09 pm
Hi Graeme:

I have some more confusion maybe you can help.

Initially I did the following:

1. Cloned the github repo in a directory outside the config directory
2. Copied the 'xretrace' directory from the git clone to my <configdir>/25.0.1/xretrace
3. Loaded the file "<configdir>/25.0.1/xretrace/xload-macros.e' into the editor
4. Ran 'load'
5. Ran 'xload_macros_default_path_silent'
6. Ran 'xretrace_cursor_steps' and enabled the macro

Then I noticed the problem with the 'ESC' key so I modified the <configdir>/25.0.1/xretrace/xretrace.e file with my modifications and did 'load'.

But now I notice I have 2 directories with xretrace:

<configdir>/25.0.1/xretrace
<configdir>/25.0.1/UserMacros/xretrace

The one in 'UserMacros' doesn't have my updated xretrace.e.

I tried running 'xload_macros_default_path_silent' thinking that it somehow copied these files to 'UserMacros', but after doing that 'UserMacros' still has the old xretrace.e. However it seems that SE is using my modified xretrace.e from the other config directory outside UserMacros.

Now I would like to have only 1 xretrace directory, and I would like it to migrate when I update SE to a new version.

So which one should stick around? The 'UserMacros' one or the other one under my config?

Now that I don't plan to modify the macro anymore, what is the best way that I should have it installed in just one directory under my config instead of in 2 directories?

I also could not find instructions to 'uninstall' it.

Thanks,
Rob
Title: Re: xretrace, xxutils and a few other things
Post by: rowbearto on April 25, 2021, 04:11:41 pm
I ended up doing Macro->List User Loaded Modules.

It showed all my xtrace .ex files in the UserMacros except for the xload in my <config>/25.0.1/xretrace dir.

I then used this menu to unload all xretrace's .ex files.

I then deleted both:

<config>/25.0.1/xretrace
<config>/25.0.1/UserMacros/xretrace

Then I copied from the git clone:

cp -rp <gitclone>/xretrace <config>/25.0.1/UserMacros/xretrace

The I loaded the xload-macros.e from the UserMacros dir and ran:

xload_macros_default_path_silent

Then I saw from 'Macro->List User Loaded Modules' that all xretrace .ex files were from the 'UserMacros' directory. And all the .e in UserMacros are the latest ones.

Seems like this is the best way to continue forward and have xretrace kept when I upgrade SE to next version?
Title: Re: xretrace, xxutils and a few other things
Post by: Graeme on April 25, 2021, 11:18:49 pm
Hi Rob

Thanks for all your comments.  I have a sore wrist at the moment and I'm trying to minimise my typing but I will try to get this sorted out in the next few days.  I'm not sure what the status of the slick plugin mechanism is at the moment but at some stage I will switch it to use that too.