*** GvimExt.orig\gvimext.h	Mon Apr 24 09:18:36 2006
--- GvimExt\gvimext.h	Wed May 21 08:21:46 2008
***************
*** 129,142 ****
  	    LPCSTR pszWorkingDir,
  	    LPCSTR pszCmd,
  	    LPCSTR pszParam,
- 	    int iShowCmd);
- 
-     STDMETHODIMP InvokeSingleGvim(HWND hParent,
- 	    LPCSTR pszWorkingDir,
- 	    LPCSTR pszCmd,
- 	    LPCSTR pszParam,
  	    int iShowCmd,
! 	    int useDiff);
  
  public:
      int		 m_cntOfHWnd;
--- 129,137 ----
  	    LPCSTR pszWorkingDir,
  	    LPCSTR pszCmd,
  	    LPCSTR pszParam,
  	    int iShowCmd,
! 	    int useDiff,
! 	    int useTabs);
  
  public:
      int		 m_cntOfHWnd;
*** GvimExt.orig\gvimext.cpp	Mon May 07 13:16:10 2007
--- GvimExt\gvimext.cpp	Wed May 21 08:52:49 2008
***************
*** 1,6 ****
--- 1,8 ----
  /* vi:set ts=8 sts=4 sw=4:
   *
   * VIM - Vi IMproved	gvimext by Tianmiao Hu
+  *                      Tab support added by Erik Falor
+  *                                           <ewfalor@gmail.com>
   *
   * Do ":help uganda"  in Vim to read copying and usage conditions.
   * Do ":help credits" in Vim to see a list of people who contributed.
***************
*** 15,20 ****
--- 17,25 ----
   */
  
  #include "gvimext.h"
+ #ifdef _DEBUG
+ # include <stdio.h>
+ #endif
  
  #ifdef __BORLANDC__
  # include <dir.h>
***************
*** 42,47 ****
--- 47,61 ----
   * enough */
  #define BUFSIZE 1100
  
+ #define NODIFF  0
+ #define USEDIFF 1
+ #define NOTABS  0
+ #define USETABS 1
+ 
+ #define SINGLEGVIM 0 
+ #define TABBEDGVIM 1 
+ #define DIFFGVIM   2 
+ 
  //
  // Get the name of the Gvim executable to use, with the path.
  // When "runtime" is non-zero, we were called to find the runtime directory.
***************
*** 578,596 ****
      // Retrieve all the vim instances
      EnumWindows(EnumWindowsProc, (LPARAM)this);
  
!     if (cbFiles > 1)
      {
  	InsertMenu(hMenu,
  		indexMenu++,
  		MF_STRING|MF_BYPOSITION,
! 		idCmd++,
! 		_("Edit with &multiple Vims"));
  
  	InsertMenu(hMenu,
  		indexMenu++,
  		MF_STRING|MF_BYPOSITION,
! 		idCmd++,
! 		_("Edit with single &Vim"));
  
  	if (cbFiles <= 4)
  	{
--- 592,610 ----
      // Retrieve all the vim instances
      EnumWindows(EnumWindowsProc, (LPARAM)this);
  
!     if (cbFiles > 1) //multiple files selected
      {
  	InsertMenu(hMenu,
  		indexMenu++,
  		MF_STRING|MF_BYPOSITION,
! 		idCmd + SINGLEGVIM, //0
! 		_("Edit with &Vim"));
  
  	InsertMenu(hMenu,
  		indexMenu++,
  		MF_STRING|MF_BYPOSITION,
! 		idCmd + TABBEDGVIM, //1
! 		_("Edit with Vim, &tabbed"));
  
  	if (cbFiles <= 4)
  	{
***************
*** 598,619 ****
  	    InsertMenu(hMenu,
  		    indexMenu++,
  		    MF_STRING|MF_BYPOSITION,
! 		    idCmd++,
! 		    _("Diff with Vim"));
! 	    m_edit_existing_off = 3;
  	}
! 	else
! 	    m_edit_existing_off = 2;
! 
      }
      else
      {
  	InsertMenu(hMenu,
  		indexMenu++,
  		MF_STRING|MF_BYPOSITION,
! 		idCmd++,
  		_("Edit with &Vim"));
! 	m_edit_existing_off = 1;
      }
  
      // Now display all the vim instances
--- 612,633 ----
  	    InsertMenu(hMenu,
  		    indexMenu++,
  		    MF_STRING|MF_BYPOSITION,
! 		    idCmd + DIFFGVIM, //2
! 		    _("&Diff with Vim"));
  	}
! 	idCmd += DIFFGVIM + 1;
! 	m_edit_existing_off = 3;
      }
      else
      {
  	InsertMenu(hMenu,
  		indexMenu++,
  		MF_STRING|MF_BYPOSITION,
! 		idCmd + SINGLEGVIM,
  		_("Edit with &Vim"));
! 	
! 	idCmd += DIFFGVIM + 1;
! 	m_edit_existing_off = 3;
      }
  
      // Now display all the vim instances
***************
*** 671,676 ****
--- 685,705 ----
      // and lpVerb is a command that should be invoked.  Otherwise, the shell
      // has called us, and LOWORD(lpcmi->lpVerb) is the menu ID the user has
      // selected.  Actually, it's (menu ID - idCmdFirst) from QueryContextMenu().
+     
+ #ifdef _DEBUG
+     /*
+      * DEBUGGING
+      */
+     char msg[80];
+     UINT idCmd2 = LOWORD(lpcmi->lpVerb);
+     sprintf(msg, "idCmd = %d", idCmd2);
+     MessageBox(
+ 	    lpcmi->hwnd,
+ 	    msg,
+ 	    _("Hello from InvokeCommand"),
+ 	    MB_OK);
+ #endif
+ 
      if (!HIWORD(lpcmi->lpVerb))
      {
  	UINT idCmd = LOWORD(lpcmi->lpVerb);
***************
*** 689,716 ****
  	{
  	    switch (idCmd)
  	    {
! 		case 0:
  		    hr = InvokeGvim(lpcmi->hwnd,
  			    lpcmi->lpDirectory,
  			    lpcmi->lpVerb,
  			    lpcmi->lpParameters,
! 			    lpcmi->nShow);
  		    break;
! 		case 1:
! 		    hr = InvokeSingleGvim(lpcmi->hwnd,
  			    lpcmi->lpDirectory,
  			    lpcmi->lpVerb,
  			    lpcmi->lpParameters,
  			    lpcmi->nShow,
! 			    0);
  		    break;
! 		case 2:
! 		    hr = InvokeSingleGvim(lpcmi->hwnd,
  			    lpcmi->lpDirectory,
  			    lpcmi->lpVerb,
  			    lpcmi->lpParameters,
  			    lpcmi->nShow,
! 			    1);
  		    break;
  	    }
  	}
--- 718,751 ----
  	{
  	    switch (idCmd)
  	    {
! 		case SINGLEGVIM:
  		    hr = InvokeGvim(lpcmi->hwnd,
  			    lpcmi->lpDirectory,
  			    lpcmi->lpVerb,
  			    lpcmi->lpParameters,
! 			    lpcmi->nShow,
! 			    NODIFF,
! 			    NOTABS);
  		    break;
! 
! 		case TABBEDGVIM:
! 		    hr = InvokeGvim(lpcmi->hwnd,
  			    lpcmi->lpDirectory,
  			    lpcmi->lpVerb,
  			    lpcmi->lpParameters,
  			    lpcmi->nShow,
! 			    NODIFF,
! 			    USETABS);
  		    break;
! 
! 		case DIFFGVIM:
! 		    hr = InvokeGvim(lpcmi->hwnd,
  			    lpcmi->lpDirectory,
  			    lpcmi->lpVerb,
  			    lpcmi->lpParameters,
  			    lpcmi->nShow,
! 			    USEDIFF,
! 			    NOTABS);
  		    break;
  	    }
  	}
***************
*** 835,841 ****
  		    (LPTSTR)location) > (HINSTANCE)32)
  	    return location;
      }
!     return "";
  }
  # endif
  #endif
--- 870,876 ----
  		    (LPTSTR)location) > (HINSTANCE)32)
  	    return location;
      }
!     return (char *)"";
  }
  # endif
  #endif
***************
*** 844,921 ****
  				   LPCSTR pszWorkingDir,
  				   LPCSTR pszCmd,
  				   LPCSTR pszParam,
- 				   int iShowCmd)
- {
-     char m_szFileUserClickedOn[BUFSIZE];
-     char cmdStr[BUFSIZE];
-     UINT i;
- 
-     for (i = 0; i < cbFiles; i++)
-     {
- 	DragQueryFile((HDROP)medium.hGlobal,
- 		i,
- 		m_szFileUserClickedOn,
- 		sizeof(m_szFileUserClickedOn));
- 
- 	getGvimName(cmdStr, 0);
- 	strcat(cmdStr, " \"");
- 
- 	if ((strlen(cmdStr) + strlen(m_szFileUserClickedOn) + 2) < BUFSIZE)
- 	{
- 	    strcat(cmdStr, m_szFileUserClickedOn);
- 	    strcat(cmdStr, "\"");
- 
- 	    STARTUPINFO si;
- 	    PROCESS_INFORMATION pi;
- 
- 	    ZeroMemory(&si, sizeof(si));
- 	    si.cb = sizeof(si);
- 
- 	    // Start the child process.
- 	    if (!CreateProcess(NULL,	// No module name (use command line).
- 			cmdStr,		// Command line.
- 			NULL,		// Process handle not inheritable.
- 			NULL,		// Thread handle not inheritable.
- 			FALSE,		// Set handle inheritance to FALSE.
- 			0,		// No creation flags.
- 			NULL,		// Use parent's environment block.
- 			NULL,		// Use parent's starting directory.
- 			&si,		// Pointer to STARTUPINFO structure.
- 			&pi)		// Pointer to PROCESS_INFORMATION structure.
- 	       )
- 	    {
- 		MessageBox(
- 		    hParent,
- 		    _("Error creating process: Check if gvim is in your path!"),
- 		    _("gvimext.dll error"),
- 		    MB_OK);
- 	    }
- 	    else
- 	    {
- 		CloseHandle( pi.hProcess );
- 		CloseHandle( pi.hThread );
- 	    }
- 	}
- 	else
- 	{
- 	    MessageBox(
- 		hParent,
- 		_("Path length too long!"),
- 		_("gvimext.dll error"),
- 		MB_OK);
- 	}
-     }
- 
-     return NOERROR;
- }
- 
- 
- STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent,
- 				   LPCSTR pszWorkingDir,
- 				   LPCSTR pszCmd,
- 				   LPCSTR pszParam,
  				   int iShowCmd,
! 				   int useDiff)
  {
      char	m_szFileUserClickedOn[BUFSIZE];
      char	*cmdStr;
--- 879,887 ----
  				   LPCSTR pszWorkingDir,
  				   LPCSTR pszCmd,
  				   LPCSTR pszParam,
  				   int iShowCmd,
! 				   int useDiff,
! 				   int useTabs)
  {
      char	m_szFileUserClickedOn[BUFSIZE];
      char	*cmdStr;
***************
*** 928,933 ****
--- 894,901 ----
      getGvimName(cmdStr, 0);
      if (useDiff)
  	strcat(cmdStr, " -d");
+     if (useTabs)
+ 	strcat(cmdStr, " -p");
      for (i = 0; i < cbFiles; i++)
      {
  	DragQueryFile((HDROP)medium.hGlobal,
