Author Topic: A few utility functions  (Read 2086 times)

Graeme

  • Senior Community Member
  • Posts: 1929
  • Hero Points: 223
A few utility functions
« on: February 28, 2015, 06:35:05 am »
See the last post in this thread for the latest version.

This code provides diff region, beautify project and a few other things. 
Tested in V19.0.2 only.  Most things should work in older versions.
Use the "load module" command on the macro menu to load.  Use the "unload module" command to unload.  Recommend : backup your configuration folder before loading.

show_xmenu1 : popup menu of my favourite commands.

xbeautify_project : beautifies all files in the active project.  By default it prompts with each file until you select "yes to all".  By default, files are automatically saved.

xset_diff_region, xcompare_diff_region :
Used to compare a set of lines - saves trekking through the diff dialog and setting up pathnames and line ranges.  The regions can be in the same or different buffers.  Use xset to assign the first region, move the cursor to the second region and use xcompare to compare.  xset_diff_region will use selected lines if there are any, otherwise it chooses 50 lines from current cursor position.  xcompare uses selected lines if any, otherwise compares from cursor position for a length equal to the number of lines in the first region, plus 20.

xsearch_workspace_cur_word_now : searches the current workspace for the word at the cursor, bypassing the find in files dialog.

xsearch_cur_word : opens the find in files dialog with word at cursor pre-selected.

Plus miscellaneous explore / copy / open commands.
« Last Edit: January 28, 2017, 03:46:55 am by Graeme »

flethuseo

  • Senior Community Member
  • Posts: 168
  • Hero Points: 2
Re: A few utility functions
« Reply #1 on: December 25, 2015, 05:02:38 am »
Hi Graeme,

Awesome tools! Specially really like that new diff feature you added. Will be tremendously useful. I also am following a convention like this to label my hotkeyed letters:

Code: [Select]
   "|&Set diff region", "xset_diff_region", "","","";
   "Compare |&Diff region", "xcompare_diff_region", "","","";
   "|&Beautify project", "xbeautify_project", "","","";

Ted

Graeme

  • Senior Community Member
  • Posts: 1929
  • Hero Points: 223
Re: A few utility functions
« Reply #2 on: January 28, 2017, 03:43:51 am »
28 January 2017  - updated with some new things.

This code provides diff region, beautify project, save/ restore toolwindow layout, float window at x:y, save / restore bookmarks.

Tested mostly in in V21.0.1 .  Most things should work in older versions.
Use the "load module" command on the macro menu to load.  Use the "unload module" command to unload.  Recommend : backup your configuration folder before loading.

show_xmenu1 : popup menu of my favourite commands including all the stuff below.  Accelerator keys 1/2/3 do xfloat1/2/3.

xbeautify_project : beautifies all files in the active project.  By default it prompts with each file until you select "yes to all".  By default, files are automatically saved.

xset_diff_region, xcompare_diff_region :
Used to compare a set of lines - saves trekking through the diff dialog and setting up pathnames and line ranges.  The regions can be in the same or different buffers.  Use xset to assign the first region, move the cursor to the second region and use xcompare to compare.  xset_diff_region will use selected lines if there are any, otherwise it chooses 50 lines from current cursor position.  xcompare uses selected lines if any, otherwise compares from cursor position for a length equal to the number of lines in the first region, plus 20.

xsearch_workspace_cur_word_now : searches the current workspace for the word at the cursor, bypassing the find in files dialog.

xsearch_cur_word : opens the find in files dialog with word at cursor pre-selected.

xfloat1/2/3 shows floating window at position 1/2/3 with layout as previously set by xset_float1/2/3.  Data is read/ written to xuser-data.ini in the configuration folder.

xsave_named_toolwindow_layout : saves layout / position of all docked and floating toolwindows.  Data is saved to xtoolwindow-layouts.ini in the configuration folder.

xload_named_toolwindow_layout : restores layout / position of docked and floating toolwindows.  Data is read from xtoolwindow-layouts.ini in the configuration folder.

xsave_bookmarks : saves bookmarks to a file of your choosing in a "Bookmarks" folder in the configuration folder.

xrestore_bookmarks : loads bookmarks from a file of your choosing in a "Bookmarks" folder in the configuration folder.

Plus miscellaneous explore / copy / open commands.
« Last Edit: June 10, 2017, 12:23:56 pm by Graeme »

onlyflyer

  • Community Member
  • Posts: 12
  • Hero Points: 0
Re: A few utility functions
« Reply #3 on: May 17, 2017, 02:30:41 pm »
cool features! It is good example to learn slick C.

jporkkahtc

  • Senior Community Member
  • Posts: 1248
  • Hero Points: 91
  • Text
Re: A few utility functions
« Reply #4 on: June 09, 2017, 05:30:32 pm »
calling xset_float1() causes Slickedit (21.0.3) to terminate immediately - no stacks, crashes or anything -- poof.
Even with modified buffers open.

The problem is with _MDICurrentFloating() -- if there are no floating windows it gets very upset apparently.

I added some _message_box() calls.
When I have no floating windows, "1" shows up, then slick quits without getting to "2" or "8"
_command void xset_float1() name_info(',')
{
   _message_box('1');

   wid := _MDICurrentFloating();
   if ( wid ) {
      _message_box('2');
     ...
    }
   _message_box('8');
}

Graeme

  • Senior Community Member
  • Posts: 1929
  • Hero Points: 223
Re: A few utility functions
« Reply #5 on: June 10, 2017, 12:34:05 pm »
Poof?  :)  That's a good description.
Sorry about the modified buffers.  I have autosave set to save every ten seconds for this reason. 

Thanks for the report.  I've changed it to use _MDICurrent() as well as automatically save buffers first and prompt for continuing.

SlickEdit Support

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 244
  • Hero Points: 23
Re: A few utility functions
« Reply #6 on: June 13, 2017, 01:19:26 pm »
Logged for Dev.

Thanks,
SlickEdit Support