Author Topic: xretrace - cursor retrace macro  (Read 32960 times)

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
xretrace - cursor retrace macro
« on: April 05, 2009, 02:26:21 AM »

Attached is some macro code that provides a cursor retrace and modified lines retrace facility.  It's kind of beta/ use at your own risk software but even if it gives you a slick C stack error, you should still be able to save your files and restart slick.  By default, it doesn't start running when slick starts so if it gives you problems, restarting slick is one easy way to stop it running and the best way to recover.  If you find it reliable, you can configure it to start automatically when slick starts - call the command xretrace_show_control_panel or press the INSERT key when the xretrace popup window is visible and un-check "retrace delayed start". xretrace option settings are stored in xretrace_config.ini in your config folder.

Line markers with associated bitmaps are used to keep track of the cursor.  These bitmaps can be made "invisible" but sometimes, strange unwanted bitmaps turn up in the margin instead of the "blank/ invisible" bitmap.  I don't know the cause of this.  The visible bitmaps are mainly useful for debugging.

To load it, unzip all the files into a folder e.g. create a "macros" folder in your configuration folder, then load the following three files in this order
  DLinkList.e
  xretrace_popup.e
  xretrace.e

Use the "load module" command on the macro menu to load the files and the unload module command to remove them.  I recommend unloading these modules before upgrading to a new version of SlickEdit, since it's possible an error could occur if you let SlickEdit load them automatically.

At the start of xretrace.e there is some documentation on what it's all about and how to use it.

The main commands it provides are

 1. xretrace_modified_line    - go to the most recently modified line/region
 2. xretrace_cursor           - go to the most recent cursor location/region
 3. xretrace_modified_line_steps  - step through modified regions using an event loop
 4. xretrace_cursor_steps         - step through visited regions using an event loop

The keys that I bind to these are Ctrl-Alt-Right, C-A-Left, Alt-Shift-Up, C-A-Up respectively  - I don't have a use for the s-expression thing that these keys default to.

xretrace_cursor can be used to alternate between the last two places you've visited.

xretrace_modified_line goes to the last place where you modified code, except if you're already on the last line you modified, it goes to the second to last region you modified, so it also alternates between two places when you use it repeatedly.

It doesn't treat inserted lines as "modified" and it also doesn't register deleted lines as "modified regions".

The event loop versions produce a popup window reminding you of the "key bindings" in the event loop.

If you have "color modified lines" enabled, you might not want to use xretrace because it interferes with this  - read the documentation about it at the start of xretrace.e.  I endeavoured to compensate for this but since I personally don't normally have "color modified lines" enabled I'm not sure how big an issue this is.

DLinkList.e provides a doubly linked list "container" slightly similar to C++ STL list container.  It has some documentation at the start on how to use it.

xretrace_control_panel.e provides a configuration dialog for xretrace.  If you make changes to the code/dialog you might encounter a spurious Slick C stack problem from which the only way I know of to recover is to delete vslick.sta and reload the code.  I don't know the cause of this either but I've reported it to slick support.

The name xretrace was chosen to hopefully avoid any name clash with shipped Slick C code.

Graeme
« Last Edit: December 17, 2011, 12:27:21 AM by Graeme »

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: xretrace - cursor retrace macro
« Reply #1 on: May 10, 2009, 09:07:47 AM »
Here's the latest version of xretrace.  It includes two new commands for stepping backwards and forwards through the list without using an event loop - xretrace_cursor_back and xretrace_cursor_fwd.  Hopefully it also fixes a problem with finding the path to the location of the xretrace module which previously caused the bitmap files and "help" file to be not found.

Installation/ uninstallation
To load it, create an "xretrace" folder in your configuration folder and unzip all the files into xretrace. , then load the following three files in this order.
  DLinkList.e
  xretrace_popup.e
  xretrace.e

Note the xretrace.e file must be open and active in the editor at the time that it is loaded so before loading xretrace.e, first open it in the editor, then use the load module command to load it.

Use the "load module" command on the macro menu to load the files and the unload module command to remove them.  I recommend unloading these modules before upgrading to a new version of SlickEdit, since it's possible an error could occur if you let SlickEdit load them automatically.  Also, if you run multiple versions of slickedit, it's probably not desirable to share .ex files between different versions of SE.

Written for
SE 2009 but probably works in earlier versions.  Tested on Windows XP only but is likely to work on any platform.

Documentation
See comments at the start of xretrace.e and DLinkList.e

Configuration
After loading the macros, run the command xretrace_show_control_panel to configure.  Try the default options to start with, then consider turning off "xretrace delayed start" (so that xretrace is operational as soon as slickedit is started) and turning on "track modified lines" (if you have "color modified lines enabled" then see the first post in this thread).  The configuration dialog can also be accessed by pressing the "insert" key when one of the "event loop" commands is active - xretrace_cursor_steps or xretrace_modified_line_steps

Commands
  • xretrace_cursor   - go to the most recent cursor location/region.
  • xretrace_modified_line - go to the most recently modified line/region.
  • xretrace_modified_line_steps - step through modified regions using an event loop.
  • xretrace_cursor_steps  - step through visited regions using an event loop.
  • xretrace_cursor_back - go to the previous cursor location in the retrace list.
  • xretrace_cursor_fwd  - go to the next cursor location in the retrace list.
  • xretrace_show_control_panel   - set options

Usage
By default, xretrace doesn't start running when you start slickedit (you can change this by turning off the "delayed start" option).  If you use one of the retrace commands when xretrace isn't running, you'll be prompted to start xretrace.

xretrace maintains a list of lines/regions that the cursor has visited and a second list of lines/regions that have been modified.  xretrace_cursor goes to the most recently visited region and alternates between the last two visited regions/lines.  xretrace_cursor_back steps through the cursor retrace list without using an event loop but if the cursor is moved off the line, the next use of xretrace_cursor_back will start at the start of the list again.  xretrace_cursor_fwd goes in the opposite direction to xretrace_cursor_back.

Limitations
xretrace doesn't treat inserted lines as "modified" and it also doesn't register deleted lines as "modified regions".  If you have "color modified lines" enabled, you might not want to enable the "track modified lines" option because it clears the modified line flags - however, these flags can be restored.  See the comments at the start of xretrace for more detail.


« Last Edit: December 17, 2011, 12:17:27 AM by Graeme »

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: xretrace - cursor retrace macro
« Reply #2 on: November 25, 2009, 10:35:59 AM »
It has been reported that when xretrace starts running it can sometimes produce an error about bitmap files not being found.  A temporary workaround is to open the xretrace.e file in the editor before loading it.  I've updated the installation instructions to say this and will post a better fix sometime.

Graeme

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: xretrace - cursor retrace macro
« Reply #3 on: August 19, 2011, 01:19:05 PM »
Here's a new version of xretrace.  The zip file contains a folder called xretrace that you need to place in your configuration folder.  Apart from that, installation and usage is pretty much the same as before but with a few minorish problems hopefully fixed - nothing especially significant I don't think.  This version is tested on Win 7 slick 16.0.2 64 bit but should work on "some" other versions too.  If you're tracking modified lines, this version tries to record inserted or deleted lines as "modified" by noticing the number of lines in the file has changed.

xretrace creates an .ini folder in your config folder to keep your settings and it also modifies the def_xretrace_no_delayed_start variable if you change the "no delayed start" setting.

If you find a problem, please let me know asap.

« Last Edit: February 22, 2015, 01:58:58 AM by Graeme »

ewendt

  • Community Member
  • Posts: 42
  • Hero Points: 2
Re: xretrace - cursor retrace macro
« Reply #4 on: December 20, 2011, 09:42:13 PM »
Some of the *.e files did not compile

xretrace.e
      p_GrabbarLocation=SSTAB_GRABBARLOCATION_TOP; <- expecting constant expression


using Beta 5

tuchman

  • Senior Community Member
  • Posts: 144
  • Hero Points: 7
Re: xretrace - cursor retrace macro
« Reply #5 on: May 06, 2012, 01:17:53 PM »
Hi Graeme,
Using Win7-64, SE V16.x and V17.x, I have noticed strange xretrace behavior WRT full line selections. After the procedure described below, the lines between the last trace points are selected after xretrace_cursor_back, and the multi-line selection is then extended/modified when moving the cursor to different lines.  The only way to recover is to deselect all lines. 

To reproduce:
1) Open attached file with cursor at pos1 line 1, select the complete line 2, then the complete line 52.
2) Issue xretrace_cursor_back
=> Lines 2..52 are selected!
3) Move cursor to any position in line1
=> The selection is extended  to lines 1..52

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: xretrace - cursor retrace macro
« Reply #6 on: May 08, 2012, 10:21:00 AM »
Hi Graeme,
Using Win7-64, SE V16.x and V17.x, I have noticed strange xretrace behavior WRT full line selections. After the procedure described below, the lines between the last trace points are selected after xretrace_cursor_back, and the multi-line selection is then extended/modified when moving the cursor to different lines.  The only way to recover is to deselect all lines. 

To reproduce:
1) Open attached file with cursor at pos1 line 1, select the complete line 2, then the complete line 52.
2) Issue xretrace_cursor_back
=> Lines 2..52 are selected!
3) Move cursor to any position in line1
=> The selection is extended  to lines 1..52

Hi, I suspect this is normal slickedit behavior but I can't tell exactly what you're doing.

If I have the cursor on line 5 (say) of any file, then do Edit -> Select -> Line, line 5 gets selected.  Then if I click the mouse in line 10, lines 5 to 10 get selected.  So in step 1, when you say select the complete line 2, then the complete line 52, what exactly are you doing?

Instead of doing the xretrace_cursor_back command in your sequence of steps, you could try typing the line number you want to go to on the slickedit command line and see if you get the same behavior as xretrace_cursor_back.

Possibly all of the xretrace commands should have a call to deselect() at the start  - you could try adding that and see if you get any different behavior.

I have xretrace_cursor bound to the numeric keypad plus key and I've just discovered that if I have an active selection at the time I press numpad+, the selection gets deleted (using 16.0.3).  I think this is a slickedit bug.


tuchman

  • Senior Community Member
  • Posts: 144
  • Hero Points: 7
Re: xretrace - cursor retrace macro
« Reply #7 on: May 08, 2012, 07:30:12 PM »
Hi Graeme,
I have uploaded a short click that I hope will clarify the steps.
The tool-button I click at the end of the clip is bound to xretrace_cursor_back
Thanks and regards,
-ken

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: xretrace - cursor retrace macro
« Reply #8 on: May 08, 2012, 09:18:52 PM »
ok, adding a deselect() call seems to fix it.  I don't have time to post another version right at the moment.  Are you able to fix this yourself  - if not, I'll probably get it done in a few days.
BTW - I didn't get the selection being extended to line one in the final step but maybe we have different selection options set.

Thanks for reporting it.

Code: [Select]
_command void xretrace_cursor_back() name_info(',')
{
   if (!check_xretrace_is_running())
      return;
   if (dlist_is_empty(retrace_cursor_list)) {
      message('xretrace list is empty');
      xretrace_cursor_fwd_back_state = 0;
      return;
   }
   deselect();
   if (xretrace_cursor_fwd_back_state <= 0) {
      // force where we are now onto the retrace list
      update_retrace_cursor_list(true);
      xretrace_cursor_fwd_back_state = 1;
      fwd_back_iter = dlist_begin(retrace_cursor_list);
   }
   dlist_iterator xiter = fwd_back_iter;
   if (!dlist_next(xiter)) {
      return;
   }
   fwd_back_iter = xiter;
   retrace_steps_event_loop2(true, -1, true, xiter);
   return;
}

tuchman

  • Senior Community Member
  • Posts: 144
  • Hero Points: 7
Re: xretrace - cursor retrace macro
« Reply #9 on: May 09, 2012, 05:08:33 AM »
Hi Graeme,
Thanks - that solved the problem!
-ken

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: xretrace - cursor retrace macro
« Reply #10 on: August 26, 2012, 11:05:27 AM »
Attached files
xretrace-slickV17-2012.zip  - is for version 17/ 18

xretrace-Slick-V16-2011.zip - is for version 16 or earlier
« Last Edit: February 22, 2015, 01:58:28 AM by Graeme »

tenggui

  • Community Member
  • Posts: 26
  • Hero Points: 0
Re: xretrace - cursor retrace macro
« Reply #11 on: December 25, 2015, 01:08:57 PM »
xretrace has not been upgraded for many years, so does it support for slickedit v20?

Attached files
xretrace-slickV17-2012.zip  - is for version 17/ 18

xretrace-Slick-V16-2011.zip - is for version 16 or earlier

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: xretrace - cursor retrace macro
« Reply #12 on: December 26, 2015, 05:43:42 AM »
Yes, it works with V19 and V20.

tenggui

  • Community Member
  • Posts: 26
  • Hero Points: 0
Re: xretrace - cursor retrace macro
« Reply #13 on: September 11, 2018, 09:28:22 AM »
Hi Graeme, does xretrace work with Slickedit 2017 V22? Is there a plan to release new version?

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: xretrace - cursor retrace macro
« Reply #14 on: September 11, 2018, 11:29:26 AM »
Hi,
yes it works with V22 and V23.  If you find a problem let me know and I will try and fix it.