Author Topic: Help with Custom Tools  (Read 11330 times)

mrhaboobi

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Help with Custom Tools
« on: September 22, 2006, 02:34:58 am »
Hi,

Im trialling the test version of this software to see if it will suit my needs.  Im having some issues.  Im wanting to create a custom tool, with some tools that launch other windows programs.  Eg if i wanted to launch Notepad or something like that.  I cant see how to do this, perhaps im going crazy cos its friday afternoon.

Any help on how to create custom tools that have shortcut keys etc would be much apprecaited.

Cheers
Greg

Graeme

  • Senior Community Member
  • Posts: 2430
  • Hero Points: 322
Re: Help with Custom Tools
« Reply #1 on: September 22, 2006, 12:06:53 pm »
Hi,

Im trialling the test version of this software to see if it will suit my needs.  Im having some issues.  Im wanting to create a custom tool, with some tools that launch other windows programs.  Eg if i wanted to launch Notepad or something like that.  I cant see how to do this, perhaps im going crazy cos its friday afternoon.

Any help on how to create custom tools that have shortcut keys etc would be much apprecaited.

Cheers
Greg

Nope, you're not going crazy.  I don't see a user friendly topic in the help about this.  Bring up the help and use the search tab to search for "external".  You should get two items relating to shell.  You can use the shell command in a macro to run an external tool as in the explore_buffer function below - on Windows, it runs windows explorer showing the directory of the file for the current buffer with the file itself selected in the right hand pane.

Code: [Select]
_command void explore_buffer() name_info(',')
{
   shell( get_env('SystemRoot') :+ '\explorer.exe /n,/e,/select,' :+
      _mdi.p_child.p_buf_name, 'PA' );
}

So to run notepad, on WinXP you can probably use %SystemRoot%\system32\notepad.exe  -  but I guess you don' really want to run notepad when you have slick!

You can bind a key to the above macro, but first you have to load it - so find the file vusrmacs.e in your config directory and add the above code, then use the Load Module command from the Macro menu to load it - check the slick command line says "macro loaded" or something and no error.  To bind a key, go to the key bindings dialog (tools->options->key bindings) - type the name explore_buffer (or select it from the list) - then bind a key.

You can also create your own menu and run an external command from that - see the topic "Menus" that should have been in the list when you searched for "external". 

You can also add icons to existing toolbars or your own toolbar that run an external command or macro.  To create a new toolbar - - select Toolbars from the view menu, then "customize" - select the Toolbars tab, then click new.  Accept the default name for the toolbar (or make one up) and click ok.  You can then dock or float this toolbar anytime you want.  To add icons to it - select Toolbars from the view menu, then "customize" - select the categories tab, then "user definable tools" from the list.  Drag an icon of your choosing to the toolbar.  Right click on that icon and select properties (notice the sideways pointing arrow that lets you add arguments that will be substituted) -  select the command you want to run from the list. 

You can also build your own form with edit boxes and buttons etc if you want (select "new form" from the macro menu).

Graeme

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5145
  • Hero Points: 425
Re: Help with Custom Tools
« Reply #2 on: September 22, 2006, 04:17:08 pm »
When configuring a UI menu item or tool bar button, any place a command is specified you can execute an external program.  The docs for adding a new UI item seem to be difficult to find.  I think the docs could use a "How do I..." section.

To add a tool window button:
  • Select View>Toolbars>Customize... to display the Toolbar Customization dialog
  • We recommend that you create a new toolbar to add buttons to.
    See "To create a new toolbar:" below for steps for creating a new toolbar.  If you add buttons to an existing toolbar, your changes will be lost when you upgrade to a new version of SlickEdit.
  • Click on the Categories Tab.
  • Now you need to select a button graphic. Click on either "Custom Button" or "User Definable Tools" in the Categories list box to view buttons to choose from.
  • Drag drop one of the buttons into your newly created toolbar.
  • Right click on the new button you inserted and selected "Properties..." and enter the command you want. The command field may reference a Slick-C command or an external program. Click on the button to the right of the command field to see the %?? options which allow you to parse in various things into you command.

To create a new toolbar:
  • Select View>Toolbars>Customize... to display the Toolbar Customization dialog.
  • Click on the Toolbars Tab.
  • Type a Name and Click OK.  The "Advanced>>" button is for advanced users that have written a toolbar which contains more than just buttons like the Project tool window.

To add a new menu item to a project:
  • Create a project.  See docs for this.
  • Select Project>Properties... to display the Project properties dialog.
  • Choose an existing Tool Name or click on "New..." to add a new tool.
  • Now enter the command in the Command field. The command field may reference a Slick-C command or an external program. Click on the button to the right of the command field to see the %?? options which allow you to parse in various things into you command.

To add a new menu item:
Note: If you add a menu item this way, SlickEdit WILL NOT transfer your configuration changes when you upgrade. For this reason, we recommend that you add menu items to a project or add a tool window button instead.  See "To add a tool window button" or "To add a new menu item to a project" above.
  • If you want to add a menu item to the MDI menu, Select "Macros>Menus..." to display a list of menus and choose "_mdi_menu".  If you want to add a menu to a right click context menu, right click to display the context menu you wish to edit and choose "Edit This Menu".
  • After you have chosen the menu to edit, you should see the menu editor. Use the menu editor to add or modify menu items. The command field may reference a Slick-C command or an external program.

The SlickEdit command line also lets you execute external commands.  Like the previous messages says, use shell() to run an external program from a Slick-C macro.


Graeme

  • Senior Community Member
  • Posts: 2430
  • Hero Points: 322
Re: Help with Custom Tools
« Reply #3 on: September 23, 2006, 07:00:34 am »
The docs for adding a new UI item seem to be difficult to find.  I think the docs could use a "How do I..." section.

Hi Clark

(I think you're missing a "click new" step in the "create new toolbar" steps.)

I've noticed you make comments on shortcomings in the slick documentation a few times and I'm wondering if comments from you like the one I've quoted above mean that something will actually be done? 

Maybe it would be worth having  a "docs" section in the forum that problems can get reported to.  I suspect not many people email docs@slickedit.com when they see something wrong or can't find something (but I could be wrong).  Some of the things I've reported to docs@slickedit.com haven't been fixed - e.g. missing detail on "parse",  missing mention of 'D' option for mou_last_x/y, spurious topics in the index under undo-steps; truncated code in the mou_capture example.

As far as I can see, the "toolbar control properties" dialog isn't described anywhere in the help.  If you're going to add it, it should include the information relating to your comment "any place a command is specified you can execute an external program" including any of the relevant detail that appears in the "shelling" topic in the "command line" section.

Another topic worth covering in the help is how to copy user configuration to a second config directory or to a new machine.  Also how does a new user find out about commands like list-keydefs.  Perhaps the help file should have a section for new users to describe how to learn slickedit without having to read the entire help file (e.g. list the major things to know and where the detail is).

Another little thing I just noticed today when looking through the registry to see what slick had there was that multiple -# options can be used when invoking slick - this isn't mentioned (maybe it's not advertised for a reason), and the -p and -r descriptions confuse me because they talk about "program name" when the command can be a macro (and maybe an external command??).

It's great that slickedit people are posting information in the forums.  I hope some of it makes it to the help file as well  :)   - I know writing good user documentation is hard (it's sometimes part of my job).

Graeme

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: Help with Custom Tools
« Reply #4 on: September 23, 2006, 10:16:07 am »
As w/ other large help systems (e.g. MSDN) finding the right thing could be difficult ...
BTW: The topic 'Help -> Index -> Command line options' seems to be complete.

I didn't even know that docs@slickedit.com exists, but it would be good to know, which communication path is/will be the preferred one to give some useful feedback.

And a better help could decrease the amount of 'How do I' postings here and would save some valuable time of the Slick people struggling hard to improve the product ;)

Looking up the sources is surely not an option for many or most users.
But having the sources is (again) one of the BIG points for me.

HS2

mrhaboobi

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: Help with Custom Tools
« Reply #5 on: September 24, 2006, 11:56:45 pm »
Ok i just gave this a quick try using the information from Clark.

For my test i just created a tool that loaded Notepad.exe

so i want a tool that will runn a command, i want that command to be started in a specific folder eg.  Most of the times that folder will be either the same folder that the currently selected file is located in, or in the root of the project.

Lets say i have a project in C:\Projects\Proj1

and i wanted to run  Test.exe in that folder.

how can i run my tool and get it to start in that folder eg C:\Projects\Proj1\test.exe ( dont forget the path to my project will be dynamic and depends on what project im currently editing.

Is that a %ProjectPath variable or something like that so i can go %ProjectPath\test.exe  or %CurrentFilePath\test.exe ( Is there a complete list of these variables

If there any way to run that command minimised or hidden and have the output piped to the output panels? 

I should sit down and experiment some more with the macro's as im guessing that will be the only way to accomplish this :)

Finally under the build menu ive managed to add a command or menu item.. can i give this a shortcut key?


Cheers
« Last Edit: September 25, 2006, 12:41:28 am by mrhaboobi »

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: Help with Custom Tools
« Reply #6 on: September 25, 2006, 10:01:52 am »
I derived these simple examples from my stuff. Maybe it's useful for you.
Code: [Select]
#include 'slick.sh'

#define DevEnv             "C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7\\IDE\\devenv.exe"

// example starting a GUI app
_command void devenv () name_info (','VSARG2_EDITORCTL)
{
   _str DevEnvCmd = maybe_quote_filename ( DevEnv );

   // check for current workspace being a Solution
   if ( pos (VISUAL_STUDIO_SOLUTION_EXT, _workspace_filename, 1, 'I') )
      strappend (DevEnvCmd, " " maybe_quote_filename ( _workspace_filename) );

   // HS2: dbg
   message (DevEnvCmd);
   
   shell (DevEnvCmd,"AP");
}

// example starting a console app w/ redirected output to 'Build' tab
_command void ddir () name_info (','VSARG2_EDITORCTL)
{
   _str cwd=_ProjectGet_WorkingDir (_ProjectHandle (_project_name));

   if ( cwd != '' )
   {
      cwd=absolute (cwd,strip_filename (_project_name,'n'));
      cd (cwd, 'm');
   }

   activate_build ();
   _str cmdline=get_env ("COMSPEC") " /c dir" " 2>&1";
   concur_command (cmdline, false, true, false, false);
   // switch focus back to edit win
   // activate_edit ();
}

Good luck !

HS2

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5145
  • Hero Points: 425
Re: Help with Custom Tools
« Reply #7 on: September 25, 2006, 02:38:27 pm »
Unfortunately, there isn't a way to specify a specific directory before executing a command.  This will require a command macro (_command).  Use "chdir" or "cd" (this synchronizes the build window) to change directory.    The macro variable _project_name contains the current project.  Use concur_command if you want to execute your tool in the build window (easy pipe output solution).  _PipeProcess() requires more work.  Since there are no threads in Slick-C you would need to create a timer to read the data.  It does look like the shell() function has a minimize option.  (windows) Use the 'Q' option to prevent creating a DOS window for console applications.

(Graeme) Thanks for the "fix" and suggestions to the documentation.  We add documentation issues to our bug/feature tracking system.  Our primary documentation person thinks the information I provided above should go in the FAQ which is mostly a "How do I..." section.  It would be great if our documentation were available on-line (with downloadable versions) and any of our devopers could easily update it.  Then I could have just added the above text to the appropriate docs and everyone could get it immediately.  Of course, we pull the docs for our APIs from the source code.  It will be a while before we can automate this enough.  Right now we're converting our help to be based on DocBook.  This step will allow ANY developer to modify ANY of the docs!!!!

hs2

  • Senior Community Member
  • Posts: 2744
  • Hero Points: 288
Re: Help with Custom Tools
« Reply #8 on: September 25, 2006, 03:06:39 pm »
Just to avoid that it's overlooked:
The ddir macro example takes care of the project dir.
HS2

Lisa

  • Senior Community Member
  • Posts: 238
  • Hero Points: 23
  • User-friendly geek-speak translator extraordinaire
Re: Help with Custom Tools
« Reply #9 on: September 25, 2006, 05:12:30 pm »
Just a note about docs:

Please do feel free to email docs@slickedit.com; we respond to every request. However, our documentation team gets notified anytime doc reports are sent to SlickEdit in any form (whether reported to Support or Sales). And, we read the forums daily and log all doc issues--when there is a bug reported or a suggestion is made, we file it in our bug/feature tracker.

With each release, we are working hard to get the docs in better shape--this includes making sure we fully document new features, making sure items are indexed correctly, and fixing any reported doc issues. Additionally, we realize there are some topics that need to be rewritten and new topics that need to be added so that the docs are more user-friendly. The forums have been a great inspiration for us.

I apologize for any reported issues that have not been fixed. Please know that we will tackle all issues as soon as possible. Please keep the comments and suggestions coming, and look for more doc fixes and improvements in each release.

Note: Some useful "How do I" topics can be found on our Web site FAQ section. We are trying to incorporate much of that into the docs. But for now, you can access the FAQs from the menu item Help > Frequently Asked Questions.

-Lisa