*** GvimExt.orig/gvimext.cpp	2008-01-31 12:35:40.277158800 -0700
--- GvimExt/gvimext.cpp	2008-02-06 15:52:16.199972800 -0700
***************
*** 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.
***************
*** 42,47 ****
--- 44,58 ----
   * 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.
***************
*** 584,596 ****
  		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)
  	{
--- 595,607 ----
  		indexMenu++,
  		MF_STRING|MF_BYPOSITION,
  		idCmd++,
! 		_("Edit with &Vim"));
  
  	InsertMenu(hMenu,
  		indexMenu++,
  		MF_STRING|MF_BYPOSITION,
  		idCmd++,
! 		_("Edit with Vim, &tabbed"));
  
  	if (cbFiles <= 4)
  	{
***************
*** 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;
  	    }
  	}
--- 700,733 ----
  	{
  	    switch (idCmd)
  	    {
! 		case SINGLEGVIM:
! 		    hr = InvokeSingleGvim(lpcmi->hwnd,
  			    lpcmi->lpDirectory,
  			    lpcmi->lpVerb,
  			    lpcmi->lpParameters,
! 			    lpcmi->nShow,
! 			    NODIFF,
! 			    NOTABS);
  		    break;
! 
! 		case TABBEDGVIM:
  		    hr = InvokeSingleGvim(lpcmi->hwnd,
  			    lpcmi->lpDirectory,
  			    lpcmi->lpVerb,
  			    lpcmi->lpParameters,
  			    lpcmi->nShow,
! 			    NODIFF,
! 			    USETABS);
  		    break;
! 
! 		case DIFFGVIM:
  		    hr = InvokeSingleGvim(lpcmi->hwnd,
  			    lpcmi->lpDirectory,
  			    lpcmi->lpVerb,
  			    lpcmi->lpParameters,
  			    lpcmi->nShow,
! 			    USEDIFF,
! 			    NOTABS);
  		    break;
  	    }
  	}
***************
*** 840,921 ****
  # endif
  #endif
  
- STDMETHODIMP CShellExt::InvokeGvim(HWND hParent,
- 				   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;
--- 857,870 ----
  # endif
  #endif
  
  
  STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent,
  				   LPCSTR pszWorkingDir,
  				   LPCSTR pszCmd,
  				   LPCSTR pszParam,
  				   int iShowCmd,
! 				   int useDiff,
! 				   int useTabs)
  {
      char	m_szFileUserClickedOn[BUFSIZE];
      char	*cmdStr;
***************
*** 928,933 ****
--- 877,884 ----
      getGvimName(cmdStr, 0);
      if (useDiff)
  	strcat(cmdStr, " -d");
+     if (useTabs)
+ 	strcat(cmdStr, " -p");
      for (i = 0; i < cbFiles; i++)
      {
  	DragQueryFile((HDROP)medium.hGlobal,
