SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: tradsud on May 07, 2008, 05:20:15 pm

Title: Adding a context menu
Post by: tradsud on May 07, 2008, 05:20:15 pm
I've heard a lot of good things about SlickEdit from other developers and thought I would check it out. I really like what I see. I'm to the point of adding my first customization and could use a hand.
I also use Understand ( ( to navigate my source code. I've setup Understand to use SlickEdit as the editor, but I want to add a custom item to SlickEdit to launch the Understand context menu.
I can get the Understand context menu for any position in the code with:
Code: [Select]
Understand.exe -existing -contextmenu <FILE> -line <LINENUMBER> -col <COLUMNNUMBER>
I think the best way to do this is adding a new menu item, so I'm adding a new item Macro | Menu | _ext_menu_default

I set it up the command with:

Code: [Select]
external-command understand.exe -existing -contextmenu
and I think I'm on the right track, but I'm not sure how to get the Filename, line number and column number into the menu command. I tried searching for this, but wasn't able to find anything - I'm sure I'm searching for the wrong terms, but I figure it's probable a simple answer and someone might be able to answer it easily.
Thanks in advance.
Title: Re: Adding a context menu
Post by: hs2 on May 07, 2008, 08:42:57 pm
Hi tradsud,
you could use this this ( post as starting point.
To get the line number use p_line property of the editor buffer and p_col to retrieve the current column along with the p_buf_name already used in the 'cat' example.
Good luck, HS2
Title: Re: Adding a context menu
Post by: tradsud on May 07, 2008, 11:10:29 pm
Thanks H2,
That provided a perfect starting point. Here is what I ended up with, and it works great:

Code: [Select]
_command void undCMenu () name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
   _str cmdline="understand.exe -existing -contextmenu " :+ maybe_quote_filename( p_buf_name ) :+ " -line " :+p_line :+ " -col " :+ p_col :+ " -text " :+ cur_word(junk,'',1);

Again, many thanks!