Author Topic: Project toolbar addons : new menu items; locate in toolbar; folder MRU  (Read 19042 times)

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
As a result of this thread http://community.slickedit.com/index.php?topic=3430.0 I decided I wanted these features myself so I've written some macros to add extra capability to the right click menus in the project toolbar.  These allow you to right click on a project node, folder node or file node and perform a variety of operations based on the absolute path associated with that node.  These operations are : add new file to project; add new item from template; add new folder; explore; open from folder; shell; change current directory; run folder MRU dialog (see below); copy pathname to clipboard; copy filename to clipboard (file nodes only; open project properties dialog for this project.

These commands work when the project auto-folder mode is either directory view or custom view.  Package view is untested because I don't use it (if you have a problem and can't fix it, let me know).

These macros are in the file ProjectTBExtra.e.  Some pre-modified menu code that calls these new macros is in the file ProjectTBExtraMenus.e.  You can load the menus file directly using load module or if you prefer some other arrangement for the menus, either modify the source in ProjectTBExtraMenus.e or use the "Menus" option on the macro menu and edit the _projecttb_folder_menu, _projecttb_project_menu and _projecttb_file_menu.

As well as the new project toolbar menu macros, the file ProjectTBExtra.e contains a couple of other things.  These are a folder MRU dialog and a facility to locate and select the current buffer in the project toolbar as discussed in this thread http://community.slickedit.com/index.php?topic=3038.0.  The "locate and select current buffer" code is a combination of me and titanandrews http://community.slickedit.com/index.php?action=profile;u=624.  This includes a _switchbuf function - _switchbuf_locate_file_in_project_toolbar that will automatically synch the project toolbar to the current buffer if def_switchbuf_locate_in_project is set to one - use set-var on the slick cmd line to do this.

The folder MRU dialog is a "quick and dirty" textBoxDialog that uese a combo box and SlickEdit's "retrieve dialog data" capability to remember a list of folders.  It provides similar options to the right click menus I've added to the project toolbar but is independent of the project toolbar.  I might do a better version using a treeview if I find myself using it a lot.

This code has been tested in Slick 2008/V13 but is probably ok in V11/V12 and maybe earlier versions.  Miraculously, I didn't need to modify any slick sources to do this but the code does define an on_load event handler for the workspace new form - which might be a problem one day, but is ok in slick V13.  See the start of the ProjectTBExtra.e file for more detail.

This code is not packaged as a hotfix so you need to unpack the zip file manually, copy the files to your config folder and load them using the load module command on the macro menu.  If you make any improvements, please post them back here and report any problems.

Graeme
« Last Edit: May 26, 2008, 09:57:27 PM by Jeffrey »

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Tried to add this to my original post but it didn't work for some reason.

Call activate_and_locate_file_in_project_toolbar (or bind a key to it) to activate the project toolbar and select the current buffer.  This will give focus to the project toolbar.  If you don't want that, you need to make the project toolbar visible and call locate_file_in_project_toolbar.  locate_file_in_project_toolbar does nothing if the project toolbar is not visible  - same goes for the _switchbuf function.  Hooking _add_buffer callback for this is probably undesirable but you can add if you want.

Graeme

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Updated the zip file.  I found a problem with add new file to project if the current node was a file.  projecttbAddNewFile() in wkspace.e expects the current node to be a folder node or project node - so I don't call this any more.

Edit in my haste to fix this problem I stuffed something else up, so now I've made a better fix which hopefully should be fine.
« Last Edit: May 21, 2008, 11:50:31 AM by Graeme »

asandler

  • Senior Community Member
  • Posts: 303
  • Hero Points: 27
In SE2007, when I compile the macro I get "Identifier 'CDN_PATH_MUST_EXIST' not declared" error.

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
I was a bit lazy and never tried it in V11 or V12.  It looks like I can probably use make_path and _cd_form to browse for a folder and create a new one.  I'll look into it in the next day or so.

Edit
Here's some new files.  You need to select your version of slickedit by uncommenting the appropriate macro at the start of each file  - SLICK_V11 or SLICK_V12.  I might improve the "create new folder" mechanism some day but it's usable as is.  I didn't try every command for every menu for every version so let me know if there's any more problems.

Graeme
« Last Edit: May 26, 2008, 11:19:44 AM by Graeme »

asandler

  • Senior Community Member
  • Posts: 303
  • Hero Points: 27
Works great. Thanks for brewing it. It is very useful! ;D
Also, I merged two files into one - it is simpler to load this way. The result attached.

Do you mind if I'll post it on my SE's macros page? I will add a link to this thread and right credentials, of course. The page is here: http://www.alexandersandler.net/stuff/software-projects/slickedit-macros

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Yep, that's fine.  If you want to make any improvements to it, just go ahead.  I kept the menus separate to lessen the chance of someone getting their system menus changed when they didn't want to.

Maybe you could also post a link to Chrisant's excellent "highlight parenthesis" macro.  http://community.slickedit.com/index.php?topic=3236.msg13282#msg13282  I'm puzzled as to why SlickEdit Inc don't provide a user accessible repository for macros.

Graeme
« Last Edit: May 27, 2008, 04:22:29 AM by Graeme »

asandler

  • Senior Community Member
  • Posts: 303
  • Hero Points: 27
Excellent macro indeed. I'll post a link - but, going to ask for permission of course ;D

I am looking for more macros so if you've seen something good, please let me know. The only criteria is: it has to be useful and it has to work out of the box. I've seen few new macros here and there, but unfortunately most of them don't work right away and require modifications.
« Last Edit: May 27, 2008, 03:21:21 PM by asandler »

icambron

  • Community Member
  • Posts: 5
  • Hero Points: 0
awesome! thanks