Author Topic: Visual C++ / SE synchronisation  (Read 7765 times)

at5dapa1

  • Senior Community Member
  • Posts: 285
  • Hero Points: 24
Visual C++ / SE synchronisation
« on: August 15, 2007, 08:49:22 PM »
Hi,
in one very big project I'm using Visual C only for debugging, and of course SE for editing, and I found a simple way to sync SE from VC using bellow macros. I placed them in my vusrmacs.e (I tested with 12.0.2 and latest hotfixes):
Code: [Select]
_command int my_GoTo(...) name_info(','VSARG2_CMDLINE|VSARG2_REQUIRES_EDITORCTL|VSARG2_MARK|VSARG2_READ_ONLY)
{
   typeless nLineNr = 0;
   typeless nColNr = 0;
   _str strFileName = '';
   _str param = arg(1);
   if (param=="") {
      message('Please specify file name and line number');
      return 1;
   }
   parse param with strFileName nLineNr nColNr;
   _str sourceFile = _ProjectWorkspaceFindFile(strFileName);
   
   if (sourceFile == '') {
      //File doesn't exist. Pop up a notification to let the user know.
      message('Could not find 'strFileName);
      return 2;
   }
   
   if(file_exists(sourceFile)) {
      // HS2-ADD: save window id before edit and push_bookmark
      int twid; get_window_id( twid );
      if ( !_no_child_windows() ) {
         _mdi.p_child.push_bookmark();
      }
      int status = edit(maybe_quote_filename(sourceFile), EDIT_DEFAULT_FLAGS);
      goto_line(nLineNr);
      p_col=nColNr;
      //p_RLine = nLineNr;
      // HS2-ADD: restore window id
      //activate_window(twid);
   }
   else {
      message('Could not find 'sourceFile);
      return 3;
   }
   return 0;
}

#include 'tagsdb.sh'
_command int my_GoToPreview(...) name_info(','VSARG2_CMDLINE|VSARG2_REQUIRES_EDITORCTL|VSARG2_MARK|VSARG2_READ_ONLY)
{
   typeless nLineNr = 0;
   typeless nColNr = 0;
   _str strFileName = '';
   _str param = arg(1);
   if (param=="") {
      message('Please specify file name and line number');
      return 1;
   }
   parse param with strFileName nLineNr nColNr;
   _str sourceFile = _ProjectWorkspaceFindFile(strFileName);
   
   if (sourceFile == '') {
      //File doesn't exist. Pop up a notification to let the user know.
      message('Could not find 'strFileName);
      return 2;
   }
   
   if(file_exists(sourceFile)) {
      // find the output tagwin and update it
      struct VS_TAG_BROWSE_INFO cm;
      tag_browse_info_init(cm);
      cm.member_name = sourceFile;
      cm.file_name=sourceFile;
      cm.line_no=nLineNr;
      cm.column_no=nColNr;
      cb_refresh_output_tab(cm, true, true);
   }
   else {
      message('Could not find 'sourceFile);
      return 3;
   }
   return 0;
}

Then for example from Visual C++ Express -> Tools -> External Tools menu I have a tool with:
- title: SlickEdit synchro
- command: C:\Program Files\SlickEdit 2007\win\vs.exe
- arguments: "-# my-Goto $(ItemFileName)$(ItemExt) $(CurLine) $(CurCol)"

The second macro my-GotoPreview can be used if you have an external TraceMonitor (and if you have its sources) and you want to quick Preview where an ASSERT occurred for example.



And because I started this post I have 3 minor patches:
- into tagfind.e, ctl_search_for.on_got_focus() added first line
   
Code: [Select]
_set_sel(1, length(p_text)+1);
- same for tbfilelist.e, ctl_filter.on_got_focus():
   
Code: [Select]
_set_sel(1, length(p_text)+1);
- tagwin.e, _tbtagwin_form.on_got_focus:
commented last line
Quote
//_UpdateTagWindow(true);

First two are because I mainly use Files and FindSymbols tabs, and it's annoying when you have first to delete the old text and then to type the new one.
The third patch is because every time clicking into the Preview it gets resynchronized with the current buffer, which I don't want, especially when it shows code related to References or SearchResults.  ;)


at5dapa1

  • Senior Community Member
  • Posts: 285
  • Hero Points: 24
Re: Visual C++ / SE synchronisation
« Reply #1 on: August 22, 2007, 04:12:03 PM »
Small updates:
1 - I've got troubles with VisualC++2003 and filename+ext > 16 chars. Seems that the solution is to use double quotation marks at the end of the argument: "-# my-Goto $(ItemFileName)$(ItemExt) $(CurLine) $(CurCol)""
2 - in order to get macros working when no file is open, please remove VSARG2_REQUIRES_EDITORCTL!
3 - here's a VisualC++/MFC example of how the preview should be called:
Code: [Select]
                                    CString strParam;
                                    strParam.Format("\"-# my-GotoPreview %s %s 0\"\"",strSource, strLine);
                                    ShellExecute(NULL, NULL, "C:\\Program Files\\SlickEdit 2007\\win\\vs.exe", strParam, NULL, SW_SHOW);


PS: for those who don't not yet, there is a nice dll at http://www.wideopenwest.com/~gary_ash/VSIntegration.htm. My favorite command is VisualStudioNET-ToggleBreakpoint.  ;) It works well with VisualC++2003.


« Last Edit: August 22, 2007, 04:19:32 PM by at5dapa1 »