Author Topic: Adding a context menu  (Read 8798 times)

tradsud

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Adding a context menu
« on: May 07, 2008, 05:20:15 PM »
Hi,
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 (www.scitools.com) 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.
Tradsud
« Last Edit: May 07, 2008, 11:19:04 PM by tradsud »

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Adding a context menu
« Reply #1 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

tradsud

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Re: Adding a context menu
« Reply #2 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)
{
   _GetBufferContents(mytext)
   _str cmdline="understand.exe -existing -contextmenu " :+ maybe_quote_filename( p_buf_name ) :+ " -line " :+p_line :+ " -col " :+ p_col :+ " -text " :+ cur_word(junk,'',1);
   external_command(cmdline);
}

Again, many thanks!
Tradsud