Karsten Hopp 81c285
To: vim-dev@vim.org
Karsten Hopp 81c285
Subject: Patch 7.2.150 (extra)
Karsten Hopp 81c285
Fcc: outbox
Karsten Hopp 81c285
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 81c285
Mime-Version: 1.0
Karsten Hopp 81c285
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 81c285
Content-Transfer-Encoding: 8bit
Karsten Hopp 81c285
------------
Karsten Hopp 81c285
Karsten Hopp 81c285
Note: I haven't tested this myself, since I don't have a compiler that
Karsten Hopp 81c285
works for this code.
Karsten Hopp 81c285
Karsten Hopp 81c285
Patch 7.2.150 (extra)
Karsten Hopp 81c285
Problem:    Can't use tab pages from VisVim.
Karsten Hopp 81c285
Solution:   Add tab page support to VisVim. (Adam Slater)
Karsten Hopp 81c285
Files:	    src/VisVim/Commands.cpp, src/VisVim/Resource.h,
Karsten Hopp 81c285
	    src/VisVim/VisVim.rc
Karsten Hopp 81c285
Karsten Hopp 81c285
Karsten Hopp 81c285
*** ../vim-7.2.149/src/VisVim/Commands.cpp	Thu May 10 20:45:34 2007
Karsten Hopp 81c285
--- src/VisVim/Commands.cpp	Mon Mar  2 00:52:15 2009
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 20,39 ****
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  static BOOL g_bEnableVim = TRUE;	// Vim enabled
Karsten Hopp 81c285
  static BOOL g_bDevStudioEditor = FALSE;	// Open file in Dev Studio editor simultaneously
Karsten Hopp 81c285
  static int g_ChangeDir = CD_NONE;	// CD after file open?
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! static void VimSetEnableState (BOOL bEnableState);
Karsten Hopp 81c285
! static BOOL VimOpenFile (BSTR& FileName, long LineNr);
Karsten Hopp 81c285
! static DISPID VimGetDispatchId (COleAutomationControl& VimOle, char* Method);
Karsten Hopp 81c285
! static void VimErrDiag (COleAutomationControl& VimOle);
Karsten Hopp 81c285
! static void VimChangeDir (COleAutomationControl& VimOle, DISPID DispatchId, BSTR& FileName);
Karsten Hopp 81c285
! static void DebugMsg (char* Msg, char* Arg = NULL);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /////////////////////////////////////////////////////////////////////////////
Karsten Hopp 81c285
  // CCommands
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! CCommands::CCommands ()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  	// m_pApplication == NULL; M$ Code generation bug!!!
Karsten Hopp 81c285
  	m_pApplication = NULL;
Karsten Hopp 81c285
--- 20,40 ----
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  static BOOL g_bEnableVim = TRUE;	// Vim enabled
Karsten Hopp 81c285
  static BOOL g_bDevStudioEditor = FALSE;	// Open file in Dev Studio editor simultaneously
Karsten Hopp 81c285
+ static BOOL g_bNewTabs = FALSE;
Karsten Hopp 81c285
  static int g_ChangeDir = CD_NONE;	// CD after file open?
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! static void VimSetEnableState(BOOL bEnableState);
Karsten Hopp 81c285
! static BOOL VimOpenFile(BSTR& FileName, long LineNr);
Karsten Hopp 81c285
! static DISPID VimGetDispatchId(COleAutomationControl& VimOle, char* Method);
Karsten Hopp 81c285
! static void VimErrDiag(COleAutomationControl& VimOle);
Karsten Hopp 81c285
! static void VimChangeDir(COleAutomationControl& VimOle, DISPID DispatchId, BSTR& FileName);
Karsten Hopp 81c285
! static void DebugMsg(char* Msg, char* Arg = NULL);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /////////////////////////////////////////////////////////////////////////////
Karsten Hopp 81c285
  // CCommands
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! CCommands::CCommands()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  	// m_pApplication == NULL; M$ Code generation bug!!!
Karsten Hopp 81c285
  	m_pApplication = NULL;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 41,57 ****
Karsten Hopp 81c285
  	m_pDebuggerEventsObj = NULL;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! CCommands::~CCommands ()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	ASSERT (m_pApplication != NULL);
Karsten Hopp 81c285
  	if (m_pApplication)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 		m_pApplication->Release ();
Karsten Hopp 81c285
  		m_pApplication = NULL;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! void CCommands::SetApplicationObject (IApplication * pApplication)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  	// This function assumes pApplication has already been AddRef'd
Karsten Hopp 81c285
  	// for us, which CDSAddIn did in it's QueryInterface call
Karsten Hopp 81c285
--- 42,58 ----
Karsten Hopp 81c285
  	m_pDebuggerEventsObj = NULL;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! CCommands::~CCommands()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	ASSERT(m_pApplication != NULL);
Karsten Hopp 81c285
  	if (m_pApplication)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 		m_pApplication->Release();
Karsten Hopp 81c285
  		m_pApplication = NULL;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! void CCommands::SetApplicationObject(IApplication * pApplication)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  	// This function assumes pApplication has already been AddRef'd
Karsten Hopp 81c285
  	// for us, which CDSAddIn did in it's QueryInterface call
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 61,115 ****
Karsten Hopp 81c285
  		return;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Create Application event handlers
Karsten Hopp 81c285
! 	XApplicationEventsObj::CreateInstance (&m_pApplicationEventsObj);
Karsten Hopp 81c285
  	if (! m_pApplicationEventsObj)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 		ReportInternalError ("XApplicationEventsObj::CreateInstance");
Karsten Hopp 81c285
  		return;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
! 	m_pApplicationEventsObj->AddRef ();
Karsten Hopp 81c285
! 	m_pApplicationEventsObj->Connect (m_pApplication);
Karsten Hopp 81c285
  	m_pApplicationEventsObj->m_pCommands = this;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #ifdef NEVER
Karsten Hopp 81c285
  	// Create Debugger event handler
Karsten Hopp 81c285
  	CComPtr < IDispatch > pDebugger;
Karsten Hopp 81c285
! 	if (SUCCEEDED (m_pApplication->get_Debugger (&pDebugger))
Karsten Hopp 81c285
  	    && pDebugger != NULL)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 		XDebuggerEventsObj::CreateInstance (&m_pDebuggerEventsObj);
Karsten Hopp 81c285
! 		m_pDebuggerEventsObj->AddRef ();
Karsten Hopp 81c285
! 		m_pDebuggerEventsObj->Connect (pDebugger);
Karsten Hopp 81c285
  		m_pDebuggerEventsObj->m_pCommands = this;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get settings from registry HKEY_CURRENT_USER\Software\Vim\VisVim
Karsten Hopp 81c285
! 	HKEY hAppKey = GetAppKey ("Vim");
Karsten Hopp 81c285
  	if (hAppKey)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 		HKEY hSectionKey = GetSectionKey (hAppKey, "VisVim");
Karsten Hopp 81c285
  		if (hSectionKey)
Karsten Hopp 81c285
  		{
Karsten Hopp 81c285
! 			g_bEnableVim = GetRegistryInt (hSectionKey, "EnableVim",
Karsten Hopp 81c285
  						       g_bEnableVim);
Karsten Hopp 81c285
! 			g_bDevStudioEditor = GetRegistryInt(hSectionKey,"DevStudioEditor",
Karsten Hopp 81c285
! 							    g_bDevStudioEditor);
Karsten Hopp 81c285
! 			g_ChangeDir = GetRegistryInt (hSectionKey, "ChangeDir",
Karsten Hopp 81c285
  						      g_ChangeDir);
Karsten Hopp 81c285
! 			RegCloseKey (hSectionKey);
Karsten Hopp 81c285
  		}
Karsten Hopp 81c285
! 		RegCloseKey (hAppKey);
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! void CCommands::UnadviseFromEvents ()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	ASSERT (m_pApplicationEventsObj != NULL);
Karsten Hopp 81c285
  	if (m_pApplicationEventsObj)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 		m_pApplicationEventsObj->Disconnect (m_pApplication);
Karsten Hopp 81c285
! 		m_pApplicationEventsObj->Release ();
Karsten Hopp 81c285
  		m_pApplicationEventsObj = NULL;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
--- 62,118 ----
Karsten Hopp 81c285
  		return;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Create Application event handlers
Karsten Hopp 81c285
! 	XApplicationEventsObj::CreateInstance(&m_pApplicationEventsObj);
Karsten Hopp 81c285
  	if (! m_pApplicationEventsObj)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 		ReportInternalError("XApplicationEventsObj::CreateInstance");
Karsten Hopp 81c285
  		return;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
! 	m_pApplicationEventsObj->AddRef();
Karsten Hopp 81c285
! 	m_pApplicationEventsObj->Connect(m_pApplication);
Karsten Hopp 81c285
  	m_pApplicationEventsObj->m_pCommands = this;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #ifdef NEVER
Karsten Hopp 81c285
  	// Create Debugger event handler
Karsten Hopp 81c285
  	CComPtr < IDispatch > pDebugger;
Karsten Hopp 81c285
! 	if (SUCCEEDED(m_pApplication->get_Debugger(&pDebugger))
Karsten Hopp 81c285
  	    && pDebugger != NULL)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 		XDebuggerEventsObj::CreateInstance(&m_pDebuggerEventsObj);
Karsten Hopp 81c285
! 		m_pDebuggerEventsObj->AddRef();
Karsten Hopp 81c285
! 		m_pDebuggerEventsObj->Connect(pDebugger);
Karsten Hopp 81c285
  		m_pDebuggerEventsObj->m_pCommands = this;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get settings from registry HKEY_CURRENT_USER\Software\Vim\VisVim
Karsten Hopp 81c285
! 	HKEY hAppKey = GetAppKey("Vim");
Karsten Hopp 81c285
  	if (hAppKey)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 		HKEY hSectionKey = GetSectionKey(hAppKey, "VisVim");
Karsten Hopp 81c285
  		if (hSectionKey)
Karsten Hopp 81c285
  		{
Karsten Hopp 81c285
! 			g_bEnableVim = GetRegistryInt(hSectionKey, "EnableVim",
Karsten Hopp 81c285
  						       g_bEnableVim);
Karsten Hopp 81c285
! 			g_bDevStudioEditor = GetRegistryInt(hSectionKey,
Karsten Hopp 81c285
! 					"DevStudioEditor", g_bDevStudioEditor);
Karsten Hopp 81c285
! 			g_bNewTabs = GetRegistryInt(hSectionKey, "NewTabs",
Karsten Hopp 81c285
! 						    g_bNewTabs);
Karsten Hopp 81c285
! 			g_ChangeDir = GetRegistryInt(hSectionKey, "ChangeDir",
Karsten Hopp 81c285
  						      g_ChangeDir);
Karsten Hopp 81c285
! 			RegCloseKey(hSectionKey);
Karsten Hopp 81c285
  		}
Karsten Hopp 81c285
! 		RegCloseKey(hAppKey);
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! void CCommands::UnadviseFromEvents()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	ASSERT(m_pApplicationEventsObj != NULL);
Karsten Hopp 81c285
  	if (m_pApplicationEventsObj)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 		m_pApplicationEventsObj->Disconnect(m_pApplication);
Karsten Hopp 81c285
! 		m_pApplicationEventsObj->Release();
Karsten Hopp 81c285
  		m_pApplicationEventsObj = NULL;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 121,130 ****
Karsten Hopp 81c285
  		// unadvise from its events (thus the VERIFY_OK below--see
Karsten Hopp 81c285
  		// stdafx.h).
Karsten Hopp 81c285
  		CComPtr < IDispatch > pDebugger;
Karsten Hopp 81c285
! 		VERIFY_OK (m_pApplication->get_Debugger (&pDebugger));
Karsten Hopp 81c285
! 		ASSERT (pDebugger != NULL);
Karsten Hopp 81c285
! 		m_pDebuggerEventsObj->Disconnect (pDebugger);
Karsten Hopp 81c285
! 		m_pDebuggerEventsObj->Release ();
Karsten Hopp 81c285
  		m_pDebuggerEventsObj = NULL;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
--- 124,133 ----
Karsten Hopp 81c285
  		// unadvise from its events (thus the VERIFY_OK below--see
Karsten Hopp 81c285
  		// stdafx.h).
Karsten Hopp 81c285
  		CComPtr < IDispatch > pDebugger;
Karsten Hopp 81c285
! 		VERIFY_OK(m_pApplication->get_Debugger(&pDebugger));
Karsten Hopp 81c285
! 		ASSERT(pDebugger != NULL);
Karsten Hopp 81c285
! 		m_pDebuggerEventsObj->Disconnect(pDebugger);
Karsten Hopp 81c285
! 		m_pDebuggerEventsObj->Release();
Karsten Hopp 81c285
  		m_pDebuggerEventsObj = NULL;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 136,156 ****
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  // Application events
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::BeforeBuildStart ()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::BuildFinish (long nNumErrors, long nNumWarnings)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::BeforeApplicationShutDown ()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
--- 139,159 ----
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  // Application events
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::BeforeBuildStart()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::BuildFinish(long nNumErrors, long nNumWarnings)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::BeforeApplicationShutDown()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 158,166 ****
Karsten Hopp 81c285
  // is done.
Karsten Hopp 81c285
  // Vim gets called from here.
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::DocumentOpen (IDispatch * theDocument)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	if (! g_bEnableVim)
Karsten Hopp 81c285
  		// Vim not enabled or empty command line entered
Karsten Hopp 81c285
--- 161,169 ----
Karsten Hopp 81c285
  // is done.
Karsten Hopp 81c285
  // Vim gets called from here.
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::DocumentOpen(IDispatch * theDocument)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	if (! g_bEnableVim)
Karsten Hopp 81c285
  		// Vim not enabled or empty command line entered
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 169,175 ****
Karsten Hopp 81c285
  	// First get the current file name and line number
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get the document object
Karsten Hopp 81c285
! 	CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (theDocument);
Karsten Hopp 81c285
  	if (! pDoc)
Karsten Hopp 81c285
  		return S_OK;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
--- 172,178 ----
Karsten Hopp 81c285
  	// First get the current file name and line number
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get the document object
Karsten Hopp 81c285
! 	CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc(theDocument);
Karsten Hopp 81c285
  	if (! pDoc)
Karsten Hopp 81c285
  		return S_OK;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 177,202 ****
Karsten Hopp 81c285
  	long LineNr = -1;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get the document name
Karsten Hopp 81c285
! 	if (FAILED (pDoc->get_FullName (&FileName)))
Karsten Hopp 81c285
  		return S_OK;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	LPDISPATCH pDispSel;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get a selection object dispatch pointer
Karsten Hopp 81c285
! 	if (SUCCEEDED (pDoc->get_Selection (&pDispSel)))
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		// Get the selection object
Karsten Hopp 81c285
! 		CComQIPtr < ITextSelection, &IID_ITextSelection > pSel (pDispSel);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  		if (pSel)
Karsten Hopp 81c285
  			// Get the selection line number
Karsten Hopp 81c285
! 			pSel->get_CurrentLine (&LineNr);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 		pDispSel->Release ();
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Open the file in Vim and position to the current line
Karsten Hopp 81c285
! 	if (VimOpenFile (FileName, LineNr))
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		if (! g_bDevStudioEditor)
Karsten Hopp 81c285
  		{
Karsten Hopp 81c285
--- 180,205 ----
Karsten Hopp 81c285
  	long LineNr = -1;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get the document name
Karsten Hopp 81c285
! 	if (FAILED(pDoc->get_FullName(&FileName)))
Karsten Hopp 81c285
  		return S_OK;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	LPDISPATCH pDispSel;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get a selection object dispatch pointer
Karsten Hopp 81c285
! 	if (SUCCEEDED(pDoc->get_Selection(&pDispSel)))
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		// Get the selection object
Karsten Hopp 81c285
! 		CComQIPtr < ITextSelection, &IID_ITextSelection > pSel(pDispSel);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  		if (pSel)
Karsten Hopp 81c285
  			// Get the selection line number
Karsten Hopp 81c285
! 			pSel->get_CurrentLine(&LineNr);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 		pDispSel->Release();
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Open the file in Vim and position to the current line
Karsten Hopp 81c285
! 	if (VimOpenFile(FileName, LineNr))
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		if (! g_bDevStudioEditor)
Karsten Hopp 81c285
  		{
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 204,233 ****
Karsten Hopp 81c285
  			CComVariant vSaveChanges = dsSaveChangesPrompt;
Karsten Hopp 81c285
  			DsSaveStatus Saved;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 			pDoc->Close (vSaveChanges, &Saved);
Karsten Hopp 81c285
  		}
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// We're done here
Karsten Hopp 81c285
! 	SysFreeString (FileName);
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::BeforeDocumentClose (IDispatch * theDocument)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::DocumentSave (IDispatch * theDocument)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::NewDocument (IDispatch * theDocument)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	if (! g_bEnableVim)
Karsten Hopp 81c285
  		// Vim not enabled or empty command line entered
Karsten Hopp 81c285
--- 207,236 ----
Karsten Hopp 81c285
  			CComVariant vSaveChanges = dsSaveChangesPrompt;
Karsten Hopp 81c285
  			DsSaveStatus Saved;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 			pDoc->Close(vSaveChanges, &Saved);
Karsten Hopp 81c285
  		}
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// We're done here
Karsten Hopp 81c285
! 	SysFreeString(FileName);
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::BeforeDocumentClose(IDispatch * theDocument)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::DocumentSave(IDispatch * theDocument)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::NewDocument(IDispatch * theDocument)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	if (! g_bEnableVim)
Karsten Hopp 81c285
  		// Vim not enabled or empty command line entered
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 235,253 ****
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// First get the current file name and line number
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (theDocument);
Karsten Hopp 81c285
  	if (! pDoc)
Karsten Hopp 81c285
  		return S_OK;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	BSTR FileName;
Karsten Hopp 81c285
  	HRESULT hr;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	hr = pDoc->get_FullName (&FileName);
Karsten Hopp 81c285
! 	if (FAILED (hr))
Karsten Hopp 81c285
  		return S_OK;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Open the file in Vim and position to the current line
Karsten Hopp 81c285
! 	if (VimOpenFile (FileName, 0))
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		if (! g_bDevStudioEditor)
Karsten Hopp 81c285
  		{
Karsten Hopp 81c285
--- 238,256 ----
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// First get the current file name and line number
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc(theDocument);
Karsten Hopp 81c285
  	if (! pDoc)
Karsten Hopp 81c285
  		return S_OK;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	BSTR FileName;
Karsten Hopp 81c285
  	HRESULT hr;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	hr = pDoc->get_FullName(&FileName);
Karsten Hopp 81c285
! 	if (FAILED(hr))
Karsten Hopp 81c285
  		return S_OK;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Open the file in Vim and position to the current line
Karsten Hopp 81c285
! 	if (VimOpenFile(FileName, 0))
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		if (! g_bDevStudioEditor)
Karsten Hopp 81c285
  		{
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 255,303 ****
Karsten Hopp 81c285
  			CComVariant vSaveChanges = dsSaveChangesPrompt;
Karsten Hopp 81c285
  			DsSaveStatus Saved;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 			pDoc->Close (vSaveChanges, &Saved);
Karsten Hopp 81c285
  		}
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	SysFreeString (FileName);
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::WindowActivate (IDispatch * theWindow)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::WindowDeactivate (IDispatch * theWindow)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::WorkspaceOpen ()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::WorkspaceClose ()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::NewWorkspace ()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  // Debugger event
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XDebuggerEvents::BreakpointHit (IDispatch * pBreakpoint)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
--- 258,306 ----
Karsten Hopp 81c285
  			CComVariant vSaveChanges = dsSaveChangesPrompt;
Karsten Hopp 81c285
  			DsSaveStatus Saved;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 			pDoc->Close(vSaveChanges, &Saved);
Karsten Hopp 81c285
  		}
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	SysFreeString(FileName);
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::WindowActivate(IDispatch * theWindow)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::WindowDeactivate(IDispatch * theWindow)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::WorkspaceOpen()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::WorkspaceClose()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XApplicationEvents::NewWorkspace()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  // Debugger event
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! HRESULT CCommands::XDebuggerEvents::BreakpointHit(IDispatch * pBreakpoint)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 308,324 ****
Karsten Hopp 81c285
  class CMainDialog : public CDialog
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      public:
Karsten Hopp 81c285
! 	CMainDialog (CWnd * pParent = NULL);	// Standard constructor
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	//{{AFX_DATA(CMainDialog)
Karsten Hopp 81c285
  	enum { IDD = IDD_ADDINMAIN };
Karsten Hopp 81c285
  	int	m_ChangeDir;
Karsten Hopp 81c285
  	BOOL	m_bDevStudioEditor;
Karsten Hopp 81c285
  	//}}AFX_DATA
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	//{{AFX_VIRTUAL(CMainDialog)
Karsten Hopp 81c285
      protected:
Karsten Hopp 81c285
! 	virtual void DoDataExchange (CDataExchange * pDX);	// DDX/DDV support
Karsten Hopp 81c285
  	//}}AFX_VIRTUAL
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      protected:
Karsten Hopp 81c285
--- 311,328 ----
Karsten Hopp 81c285
  class CMainDialog : public CDialog
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
      public:
Karsten Hopp 81c285
! 	CMainDialog(CWnd * pParent = NULL);	// Standard constructor
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	//{{AFX_DATA(CMainDialog)
Karsten Hopp 81c285
  	enum { IDD = IDD_ADDINMAIN };
Karsten Hopp 81c285
  	int	m_ChangeDir;
Karsten Hopp 81c285
  	BOOL	m_bDevStudioEditor;
Karsten Hopp 81c285
+ 	BOOL	m_bNewTabs;
Karsten Hopp 81c285
  	//}}AFX_DATA
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	//{{AFX_VIRTUAL(CMainDialog)
Karsten Hopp 81c285
      protected:
Karsten Hopp 81c285
! 	virtual void DoDataExchange(CDataExchange * pDX);	// DDX/DDV support
Karsten Hopp 81c285
  	//}}AFX_VIRTUAL
Karsten Hopp 81c285
  
Karsten Hopp 81c285
      protected:
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 326,425 ****
Karsten Hopp 81c285
  	afx_msg void OnEnable();
Karsten Hopp 81c285
  	afx_msg void OnDisable();
Karsten Hopp 81c285
  	//}}AFX_MSG
Karsten Hopp 81c285
! 	DECLARE_MESSAGE_MAP ()
Karsten Hopp 81c285
  };
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! CMainDialog::CMainDialog (CWnd * pParent /* =NULL */ )
Karsten Hopp 81c285
! 	: CDialog (CMainDialog::IDD, pParent)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  	//{{AFX_DATA_INIT(CMainDialog)
Karsten Hopp 81c285
  	m_ChangeDir = -1;
Karsten Hopp 81c285
  	m_bDevStudioEditor = FALSE;
Karsten Hopp 81c285
  	//}}AFX_DATA_INIT
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! void CMainDialog::DoDataExchange (CDataExchange * pDX)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	CDialog::DoDataExchange (pDX);
Karsten Hopp 81c285
  	//{{AFX_DATA_MAP(CMainDialog)
Karsten Hopp 81c285
  	DDX_Radio(pDX, IDC_CD_SOURCE_PATH, m_ChangeDir);
Karsten Hopp 81c285
! 	DDX_Check (pDX, IDC_DEVSTUDIO_EDITOR, m_bDevStudioEditor);
Karsten Hopp 81c285
  	//}}AFX_DATA_MAP
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! BEGIN_MESSAGE_MAP (CMainDialog, CDialog)
Karsten Hopp 81c285
  	//{{AFX_MSG_MAP(CMainDialog)
Karsten Hopp 81c285
  	//}}AFX_MSG_MAP
Karsten Hopp 81c285
! END_MESSAGE_MAP ()
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /////////////////////////////////////////////////////////////////////////////
Karsten Hopp 81c285
  // CCommands methods
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! STDMETHODIMP CCommands::VisVimDialog ()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Use m_pApplication to access the Developer Studio Application
Karsten Hopp 81c285
  	// object,
Karsten Hopp 81c285
  	// and VERIFY_OK to see error strings in DEBUG builds of your add-in
Karsten Hopp 81c285
  	// (see stdafx.h)
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	VERIFY_OK (m_pApplication->EnableModeless (VARIANT_FALSE));
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	CMainDialog Dlg;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	Dlg.m_bDevStudioEditor = g_bDevStudioEditor;
Karsten Hopp 81c285
  	Dlg.m_ChangeDir = g_ChangeDir;
Karsten Hopp 81c285
! 	if (Dlg.DoModal () == IDOK)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		g_bDevStudioEditor = Dlg.m_bDevStudioEditor;
Karsten Hopp 81c285
  		g_ChangeDir = Dlg.m_ChangeDir;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  		// Save settings to registry HKEY_CURRENT_USER\Software\Vim\VisVim
Karsten Hopp 81c285
! 		HKEY hAppKey = GetAppKey ("Vim");
Karsten Hopp 81c285
  		if (hAppKey)
Karsten Hopp 81c285
  		{
Karsten Hopp 81c285
! 			HKEY hSectionKey = GetSectionKey (hAppKey, "VisVim");
Karsten Hopp 81c285
  			if (hSectionKey)
Karsten Hopp 81c285
  			{
Karsten Hopp 81c285
! 				WriteRegistryInt (hSectionKey, "DevStudioEditor",
Karsten Hopp 81c285
  						  g_bDevStudioEditor);
Karsten Hopp 81c285
! 				WriteRegistryInt (hSectionKey, "ChangeDir", g_ChangeDir);
Karsten Hopp 81c285
! 				RegCloseKey (hSectionKey);
Karsten Hopp 81c285
  			}
Karsten Hopp 81c285
! 			RegCloseKey (hAppKey);
Karsten Hopp 81c285
  		}
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	VERIFY_OK (m_pApplication->EnableModeless (VARIANT_TRUE));
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! STDMETHODIMP CCommands::VisVimEnable ()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
! 	VimSetEnableState (true);
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! STDMETHODIMP CCommands::VisVimDisable ()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
! 	VimSetEnableState (false);
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! STDMETHODIMP CCommands::VisVimToggle ()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
! 	VimSetEnableState (! g_bEnableVim);
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! STDMETHODIMP CCommands::VisVimLoad ()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Use m_pApplication to access the Developer Studio Application object,
Karsten Hopp 81c285
  	// and VERIFY_OK to see error strings in DEBUG builds of your add-in
Karsten Hopp 81c285
--- 330,435 ----
Karsten Hopp 81c285
  	afx_msg void OnEnable();
Karsten Hopp 81c285
  	afx_msg void OnDisable();
Karsten Hopp 81c285
  	//}}AFX_MSG
Karsten Hopp 81c285
! 	DECLARE_MESSAGE_MAP()
Karsten Hopp 81c285
  };
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! CMainDialog::CMainDialog(CWnd * pParent /* =NULL */ )
Karsten Hopp 81c285
! 	: CDialog(CMainDialog::IDD, pParent)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  	//{{AFX_DATA_INIT(CMainDialog)
Karsten Hopp 81c285
  	m_ChangeDir = -1;
Karsten Hopp 81c285
  	m_bDevStudioEditor = FALSE;
Karsten Hopp 81c285
+ 	m_bNewTabs = FALSE;
Karsten Hopp 81c285
  	//}}AFX_DATA_INIT
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! void CMainDialog::DoDataExchange(CDataExchange * pDX)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	CDialog::DoDataExchange(pDX);
Karsten Hopp 81c285
  	//{{AFX_DATA_MAP(CMainDialog)
Karsten Hopp 81c285
  	DDX_Radio(pDX, IDC_CD_SOURCE_PATH, m_ChangeDir);
Karsten Hopp 81c285
! 	DDX_Check(pDX, IDC_DEVSTUDIO_EDITOR, m_bDevStudioEditor);
Karsten Hopp 81c285
! 	DDX_Check(pDX, IDC_NEW_TABS, m_bNewTabs);
Karsten Hopp 81c285
  	//}}AFX_DATA_MAP
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! BEGIN_MESSAGE_MAP(CMainDialog, CDialog)
Karsten Hopp 81c285
  	//{{AFX_MSG_MAP(CMainDialog)
Karsten Hopp 81c285
  	//}}AFX_MSG_MAP
Karsten Hopp 81c285
! END_MESSAGE_MAP()
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  /////////////////////////////////////////////////////////////////////////////
Karsten Hopp 81c285
  // CCommands methods
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! STDMETHODIMP CCommands::VisVimDialog()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Use m_pApplication to access the Developer Studio Application
Karsten Hopp 81c285
  	// object,
Karsten Hopp 81c285
  	// and VERIFY_OK to see error strings in DEBUG builds of your add-in
Karsten Hopp 81c285
  	// (see stdafx.h)
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	VERIFY_OK(m_pApplication->EnableModeless(VARIANT_FALSE));
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	CMainDialog Dlg;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	Dlg.m_bDevStudioEditor = g_bDevStudioEditor;
Karsten Hopp 81c285
+ 	Dlg.m_bNewTabs = g_bNewTabs;
Karsten Hopp 81c285
  	Dlg.m_ChangeDir = g_ChangeDir;
Karsten Hopp 81c285
! 	if (Dlg.DoModal() == IDOK)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		g_bDevStudioEditor = Dlg.m_bDevStudioEditor;
Karsten Hopp 81c285
+ 		g_bNewTabs = Dlg.m_bNewTabs;
Karsten Hopp 81c285
  		g_ChangeDir = Dlg.m_ChangeDir;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  		// Save settings to registry HKEY_CURRENT_USER\Software\Vim\VisVim
Karsten Hopp 81c285
! 		HKEY hAppKey = GetAppKey("Vim");
Karsten Hopp 81c285
  		if (hAppKey)
Karsten Hopp 81c285
  		{
Karsten Hopp 81c285
! 			HKEY hSectionKey = GetSectionKey(hAppKey, "VisVim");
Karsten Hopp 81c285
  			if (hSectionKey)
Karsten Hopp 81c285
  			{
Karsten Hopp 81c285
! 				WriteRegistryInt(hSectionKey, "DevStudioEditor",
Karsten Hopp 81c285
  						  g_bDevStudioEditor);
Karsten Hopp 81c285
! 				WriteRegistryInt(hSectionKey, "NewTabs",
Karsten Hopp 81c285
! 						  g_bNewTabs);
Karsten Hopp 81c285
! 				WriteRegistryInt(hSectionKey, "ChangeDir", g_ChangeDir);
Karsten Hopp 81c285
! 				RegCloseKey(hSectionKey);
Karsten Hopp 81c285
  			}
Karsten Hopp 81c285
! 			RegCloseKey(hAppKey);
Karsten Hopp 81c285
  		}
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	VERIFY_OK(m_pApplication->EnableModeless(VARIANT_TRUE));
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! STDMETHODIMP CCommands::VisVimEnable()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
! 	VimSetEnableState(true);
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! STDMETHODIMP CCommands::VisVimDisable()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
! 	VimSetEnableState(false);
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! STDMETHODIMP CCommands::VisVimToggle()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
! 	VimSetEnableState(! g_bEnableVim);
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! STDMETHODIMP CCommands::VisVimLoad()
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	AFX_MANAGE_STATE(AfxGetStaticModuleState());
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Use m_pApplication to access the Developer Studio Application object,
Karsten Hopp 81c285
  	// and VERIFY_OK to see error strings in DEBUG builds of your add-in
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 430,436 ****
Karsten Hopp 81c285
  	CComPtr < IDispatch > pDispDoc, pDispSel;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get a document object dispatch pointer
Karsten Hopp 81c285
! 	VERIFY_OK (m_pApplication->get_ActiveDocument (&pDispDoc));
Karsten Hopp 81c285
  	if (! pDispDoc)
Karsten Hopp 81c285
  		return S_OK;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
--- 440,446 ----
Karsten Hopp 81c285
  	CComPtr < IDispatch > pDispDoc, pDispSel;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get a document object dispatch pointer
Karsten Hopp 81c285
! 	VERIFY_OK(m_pApplication->get_ActiveDocument(&pDispDoc));
Karsten Hopp 81c285
  	if (! pDispDoc)
Karsten Hopp 81c285
  		return S_OK;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 438,467 ****
Karsten Hopp 81c285
  	long LineNr = -1;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get the document object
Karsten Hopp 81c285
! 	CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (pDispDoc);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	if (! pDoc)
Karsten Hopp 81c285
  		return S_OK;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get the document name
Karsten Hopp 81c285
! 	if (FAILED (pDoc->get_FullName (&FileName)))
Karsten Hopp 81c285
  		return S_OK;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get a selection object dispatch pointer
Karsten Hopp 81c285
! 	if (SUCCEEDED (pDoc->get_Selection (&pDispSel)))
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		// Get the selection object
Karsten Hopp 81c285
! 		CComQIPtr < ITextSelection, &IID_ITextSelection > pSel (pDispSel);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  		if (pSel)
Karsten Hopp 81c285
  			// Get the selection line number
Karsten Hopp 81c285
! 			pSel->get_CurrentLine (&LineNr);
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Open the file in Vim
Karsten Hopp 81c285
! 	VimOpenFile (FileName, LineNr);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	SysFreeString (FileName);
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
--- 448,477 ----
Karsten Hopp 81c285
  	long LineNr = -1;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get the document object
Karsten Hopp 81c285
! 	CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc(pDispDoc);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	if (! pDoc)
Karsten Hopp 81c285
  		return S_OK;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get the document name
Karsten Hopp 81c285
! 	if (FAILED(pDoc->get_FullName(&FileName)))
Karsten Hopp 81c285
  		return S_OK;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get a selection object dispatch pointer
Karsten Hopp 81c285
! 	if (SUCCEEDED(pDoc->get_Selection(&pDispSel)))
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		// Get the selection object
Karsten Hopp 81c285
! 		CComQIPtr < ITextSelection, &IID_ITextSelection > pSel(pDispSel);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  		if (pSel)
Karsten Hopp 81c285
  			// Get the selection line number
Karsten Hopp 81c285
! 			pSel->get_CurrentLine(&LineNr);
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Open the file in Vim
Karsten Hopp 81c285
! 	VimOpenFile(FileName, LineNr);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	SysFreeString(FileName);
Karsten Hopp 81c285
  	return S_OK;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 472,487 ****
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  // Set the enable state and save to registry
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
! static void VimSetEnableState (BOOL bEnableState)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  	g_bEnableVim = bEnableState;
Karsten Hopp 81c285
! 	HKEY hAppKey = GetAppKey ("Vim");
Karsten Hopp 81c285
  	if (hAppKey)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 		HKEY hSectionKey = GetSectionKey (hAppKey, "VisVim");
Karsten Hopp 81c285
  		if (hSectionKey)
Karsten Hopp 81c285
! 			WriteRegistryInt (hSectionKey, "EnableVim", g_bEnableVim);
Karsten Hopp 81c285
! 		RegCloseKey (hAppKey);
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
--- 482,497 ----
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  // Set the enable state and save to registry
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
! static void VimSetEnableState(BOOL bEnableState)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  	g_bEnableVim = bEnableState;
Karsten Hopp 81c285
! 	HKEY hAppKey = GetAppKey("Vim");
Karsten Hopp 81c285
  	if (hAppKey)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 		HKEY hSectionKey = GetSectionKey(hAppKey, "VisVim");
Karsten Hopp 81c285
  		if (hSectionKey)
Karsten Hopp 81c285
! 			WriteRegistryInt(hSectionKey, "EnableVim", g_bEnableVim);
Karsten Hopp 81c285
! 		RegCloseKey(hAppKey);
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 490,496 ****
Karsten Hopp 81c285
  // letter.
Karsten Hopp 81c285
  // 'LineNr' must contain a valid line number or 0, e. g. for a new file
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
! static BOOL VimOpenFile (BSTR& FileName, long LineNr)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// OLE automation object for com. with Vim
Karsten Hopp 81c285
--- 500,506 ----
Karsten Hopp 81c285
  // letter.
Karsten Hopp 81c285
  // 'LineNr' must contain a valid line number or 0, e. g. for a new file
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
! static BOOL VimOpenFile(BSTR& FileName, long LineNr)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// OLE automation object for com. with Vim
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 507,513 ****
Karsten Hopp 81c285
  	// Get a dispatch id for the SendKeys method of Vim;
Karsten Hopp 81c285
  	// enables connection to Vim if necessary
Karsten Hopp 81c285
  	DISPID DispatchId;
Karsten Hopp 81c285
! 	DispatchId = VimGetDispatchId (VimOle, "SendKeys");
Karsten Hopp 81c285
  	if (! DispatchId)
Karsten Hopp 81c285
  		// OLE error, can't obtain dispatch id
Karsten Hopp 81c285
  		goto OleError;
Karsten Hopp 81c285
--- 517,523 ----
Karsten Hopp 81c285
  	// Get a dispatch id for the SendKeys method of Vim;
Karsten Hopp 81c285
  	// enables connection to Vim if necessary
Karsten Hopp 81c285
  	DISPID DispatchId;
Karsten Hopp 81c285
! 	DispatchId = VimGetDispatchId(VimOle, "SendKeys");
Karsten Hopp 81c285
  	if (! DispatchId)
Karsten Hopp 81c285
  		// OLE error, can't obtain dispatch id
Karsten Hopp 81c285
  		goto OleError;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 525,544 ****
Karsten Hopp 81c285
  #ifdef SINGLE_WINDOW
Karsten Hopp 81c285
  	// Update the current file in Vim if it has been modified.
Karsten Hopp 81c285
  	// Disabled, because it could write the file when you don't want to.
Karsten Hopp 81c285
! 	sprintf (VimCmd + 2, ":up\n");
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
! 	if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf)))
Karsten Hopp 81c285
  		goto OleError;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Change Vim working directory to where the file is if desired
Karsten Hopp 81c285
  	if (g_ChangeDir != CD_NONE)
Karsten Hopp 81c285
! 		VimChangeDir (VimOle, DispatchId, FileName);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Make Vim open the file.
Karsten Hopp 81c285
  	// In the filename convert all \ to /, put a \ before a space.
Karsten Hopp 81c285
! 	sprintf(VimCmd, ":drop ");
Karsten Hopp 81c285
  	sprintf(FileNameTmp, "%S", (char *)FileName);
Karsten Hopp 81c285
- 	s = VimCmd + 6;
Karsten Hopp 81c285
  	for (p = FileNameTmp; *p != '\0' && s < FileNameTmp + MAX_OLE_STR - 4;
Karsten Hopp 81c285
  									  ++p)
Karsten Hopp 81c285
  		if (*p == '\\')
Karsten Hopp 81c285
--- 535,562 ----
Karsten Hopp 81c285
  #ifdef SINGLE_WINDOW
Karsten Hopp 81c285
  	// Update the current file in Vim if it has been modified.
Karsten Hopp 81c285
  	// Disabled, because it could write the file when you don't want to.
Karsten Hopp 81c285
! 	sprintf(VimCmd + 2, ":up\n");
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
! 	if (! VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf)))
Karsten Hopp 81c285
  		goto OleError;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Change Vim working directory to where the file is if desired
Karsten Hopp 81c285
  	if (g_ChangeDir != CD_NONE)
Karsten Hopp 81c285
! 		VimChangeDir(VimOle, DispatchId, FileName);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Make Vim open the file.
Karsten Hopp 81c285
  	// In the filename convert all \ to /, put a \ before a space.
Karsten Hopp 81c285
! 	if (g_bNewTabs)
Karsten Hopp 81c285
! 	{
Karsten Hopp 81c285
! 		sprintf(VimCmd, ":tab drop ");
Karsten Hopp 81c285
! 		s = VimCmd + 11;
Karsten Hopp 81c285
! 	}
Karsten Hopp 81c285
! 	else
Karsten Hopp 81c285
! 	{
Karsten Hopp 81c285
! 		sprintf(VimCmd, ":drop ");
Karsten Hopp 81c285
! 		s = VimCmd + 6;
Karsten Hopp 81c285
! 	}
Karsten Hopp 81c285
  	sprintf(FileNameTmp, "%S", (char *)FileName);
Karsten Hopp 81c285
  	for (p = FileNameTmp; *p != '\0' && s < FileNameTmp + MAX_OLE_STR - 4;
Karsten Hopp 81c285
  									  ++p)
Karsten Hopp 81c285
  		if (*p == '\\')
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 552,571 ****
Karsten Hopp 81c285
  	*s++ = '\n';
Karsten Hopp 81c285
  	*s = '\0';
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf)))
Karsten Hopp 81c285
  		goto OleError;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	if (LineNr > 0)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		// Goto line
Karsten Hopp 81c285
! 		sprintf (VimCmd, ":%d\n", LineNr);
Karsten Hopp 81c285
! 		if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf)))
Karsten Hopp 81c285
  			goto OleError;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Make Vim come to the foreground
Karsten Hopp 81c285
! 	if (! VimOle.Method ("SetForeground"))
Karsten Hopp 81c285
! 		VimOle.ErrDiag ();
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// We're done
Karsten Hopp 81c285
  	return true;
Karsten Hopp 81c285
--- 570,589 ----
Karsten Hopp 81c285
  	*s++ = '\n';
Karsten Hopp 81c285
  	*s = '\0';
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	if (! VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf)))
Karsten Hopp 81c285
  		goto OleError;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	if (LineNr > 0)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		// Goto line
Karsten Hopp 81c285
! 		sprintf(VimCmd, ":%d\n", LineNr);
Karsten Hopp 81c285
! 		if (! VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf)))
Karsten Hopp 81c285
  			goto OleError;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Make Vim come to the foreground
Karsten Hopp 81c285
! 	if (! VimOle.Method("SetForeground"))
Karsten Hopp 81c285
! 		VimOle.ErrDiag();
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// We're done
Karsten Hopp 81c285
  	return true;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 573,579 ****
Karsten Hopp 81c285
      OleError:
Karsten Hopp 81c285
  	// There was an OLE error
Karsten Hopp 81c285
  	// Check if it's the "unknown class string" error
Karsten Hopp 81c285
! 	VimErrDiag (VimOle);
Karsten Hopp 81c285
  	return false;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
--- 591,597 ----
Karsten Hopp 81c285
      OleError:
Karsten Hopp 81c285
  	// There was an OLE error
Karsten Hopp 81c285
  	// Check if it's the "unknown class string" error
Karsten Hopp 81c285
! 	VimErrDiag(VimOle);
Karsten Hopp 81c285
  	return false;
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 581,598 ****
Karsten Hopp 81c285
  // Create the Vim OLE object if necessary
Karsten Hopp 81c285
  // Returns a valid dispatch id or null on error
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
! static DISPID VimGetDispatchId (COleAutomationControl& VimOle, char* Method)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  	// Initialize Vim OLE connection if not already done
Karsten Hopp 81c285
! 	if (! VimOle.IsCreated ())
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 		if (! VimOle.CreateObject ("Vim.Application"))
Karsten Hopp 81c285
  			return NULL;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get the dispatch id for the SendKeys method.
Karsten Hopp 81c285
  	// By doing this, we are checking if Vim is still there...
Karsten Hopp 81c285
! 	DISPID DispatchId = VimOle.GetDispatchId ("SendKeys");
Karsten Hopp 81c285
  	if (! DispatchId)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		// We can't get a dispatch id.
Karsten Hopp 81c285
--- 599,616 ----
Karsten Hopp 81c285
  // Create the Vim OLE object if necessary
Karsten Hopp 81c285
  // Returns a valid dispatch id or null on error
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
! static DISPID VimGetDispatchId(COleAutomationControl& VimOle, char* Method)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  	// Initialize Vim OLE connection if not already done
Karsten Hopp 81c285
! 	if (! VimOle.IsCreated())
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
! 		if (! VimOle.CreateObject("Vim.Application"))
Karsten Hopp 81c285
  			return NULL;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Get the dispatch id for the SendKeys method.
Karsten Hopp 81c285
  	// By doing this, we are checking if Vim is still there...
Karsten Hopp 81c285
! 	DISPID DispatchId = VimOle.GetDispatchId("SendKeys");
Karsten Hopp 81c285
  	if (! DispatchId)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		// We can't get a dispatch id.
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 604,615 ****
Karsten Hopp 81c285
  		// should not be kept long enough to allow the user to terminate Vim
Karsten Hopp 81c285
  		// to avoid memory corruption (why the heck is there no system garbage
Karsten Hopp 81c285
  		// collection for those damned OLE memory chunks???).
Karsten Hopp 81c285
! 		VimOle.DeleteObject ();
Karsten Hopp 81c285
! 		if (! VimOle.CreateObject ("Vim.Application"))
Karsten Hopp 81c285
  			// If this create fails, it's time for an error msg
Karsten Hopp 81c285
  			return NULL;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 		if (! (DispatchId = VimOle.GetDispatchId ("SendKeys")))
Karsten Hopp 81c285
  			// There is something wrong...
Karsten Hopp 81c285
  			return NULL;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
--- 622,633 ----
Karsten Hopp 81c285
  		// should not be kept long enough to allow the user to terminate Vim
Karsten Hopp 81c285
  		// to avoid memory corruption (why the heck is there no system garbage
Karsten Hopp 81c285
  		// collection for those damned OLE memory chunks???).
Karsten Hopp 81c285
! 		VimOle.DeleteObject();
Karsten Hopp 81c285
! 		if (! VimOle.CreateObject("Vim.Application"))
Karsten Hopp 81c285
  			// If this create fails, it's time for an error msg
Karsten Hopp 81c285
  			return NULL;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 		if (! (DispatchId = VimOle.GetDispatchId("SendKeys")))
Karsten Hopp 81c285
  			// There is something wrong...
Karsten Hopp 81c285
  			return NULL;
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 620,639 ****
Karsten Hopp 81c285
  // Output an error message for an OLE error
Karsten Hopp 81c285
  // Check on the classstring error, which probably means Vim wasn't registered.
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
! static void VimErrDiag (COleAutomationControl& VimOle)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	SCODE sc = GetScode (VimOle.GetResult ());
Karsten Hopp 81c285
  	if (sc == CO_E_CLASSSTRING)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		char Buf[256];
Karsten Hopp 81c285
! 		sprintf (Buf, "There is no registered OLE automation server named "
Karsten Hopp 81c285
  			 "\"Vim.Application\".\n"
Karsten Hopp 81c285
  			 "Use the OLE-enabled version of Vim with VisVim and "
Karsten Hopp 81c285
  			 "make sure to register Vim by running \"vim -register\".");
Karsten Hopp 81c285
! 		MessageBox (NULL, Buf, "OLE Error", MB_OK);
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  	else
Karsten Hopp 81c285
! 		VimOle.ErrDiag ();
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  // Change directory to the directory the file 'FileName' is in or it's parent
Karsten Hopp 81c285
--- 638,657 ----
Karsten Hopp 81c285
  // Output an error message for an OLE error
Karsten Hopp 81c285
  // Check on the classstring error, which probably means Vim wasn't registered.
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
! static void VimErrDiag(COleAutomationControl& VimOle)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
! 	SCODE sc = GetScode(VimOle.GetResult());
Karsten Hopp 81c285
  	if (sc == CO_E_CLASSSTRING)
Karsten Hopp 81c285
  	{
Karsten Hopp 81c285
  		char Buf[256];
Karsten Hopp 81c285
! 		sprintf(Buf, "There is no registered OLE automation server named "
Karsten Hopp 81c285
  			 "\"Vim.Application\".\n"
Karsten Hopp 81c285
  			 "Use the OLE-enabled version of Vim with VisVim and "
Karsten Hopp 81c285
  			 "make sure to register Vim by running \"vim -register\".");
Karsten Hopp 81c285
! 		MessageBox(NULL, Buf, "OLE Error", MB_OK);
Karsten Hopp 81c285
  	}
Karsten Hopp 81c285
  	else
Karsten Hopp 81c285
! 		VimOle.ErrDiag();
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  // Change directory to the directory the file 'FileName' is in or it's parent
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 644,650 ****
Karsten Hopp 81c285
  //	CD_SOURCE_PATH
Karsten Hopp 81c285
  //	CD_SOURCE_PARENT
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
! static void VimChangeDir (COleAutomationControl& VimOle, DISPID DispatchId, BSTR& FileName)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  	// Do a :cd first
Karsten Hopp 81c285
  
Karsten Hopp 81c285
--- 662,668 ----
Karsten Hopp 81c285
  //	CD_SOURCE_PATH
Karsten Hopp 81c285
  //	CD_SOURCE_PARENT
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
! static void VimChangeDir(COleAutomationControl& VimOle, DISPID DispatchId, BSTR& FileName)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  	// Do a :cd first
Karsten Hopp 81c285
  
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 655,661 ****
Karsten Hopp 81c285
  	char DirUnix[_MAX_DIR * 2];
Karsten Hopp 81c285
  	char *s, *t;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	_splitpath (StrFileName, Drive, Dir, NULL, NULL);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Convert to Unix path name format, escape spaces.
Karsten Hopp 81c285
  	t = DirUnix;
Karsten Hopp 81c285
--- 673,679 ----
Karsten Hopp 81c285
  	char DirUnix[_MAX_DIR * 2];
Karsten Hopp 81c285
  	char *s, *t;
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	_splitpath(StrFileName, Drive, Dir, NULL, NULL);
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  	// Convert to Unix path name format, escape spaces.
Karsten Hopp 81c285
  	t = DirUnix;
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 676,694 ****
Karsten Hopp 81c285
  	OLECHAR Buf[MAX_OLE_STR];
Karsten Hopp 81c285
  	char VimCmd[MAX_OLE_STR];
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	sprintf (VimCmd, ":cd %s%s%s\n", Drive, DirUnix,
Karsten Hopp 81c285
  		 g_ChangeDir == CD_SOURCE_PARENT && DirUnix[1] ? ".." : "");
Karsten Hopp 81c285
! 	VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf));
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #ifdef _DEBUG
Karsten Hopp 81c285
  // Print out a debug message
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
! static void DebugMsg (char* Msg, char* Arg)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  	char Buf[400];
Karsten Hopp 81c285
! 	sprintf (Buf, Msg, Arg);
Karsten Hopp 81c285
! 	AfxMessageBox (Buf);
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
- 
Karsten Hopp 81c285
--- 694,711 ----
Karsten Hopp 81c285
  	OLECHAR Buf[MAX_OLE_STR];
Karsten Hopp 81c285
  	char VimCmd[MAX_OLE_STR];
Karsten Hopp 81c285
  
Karsten Hopp 81c285
! 	sprintf(VimCmd, ":cd %s%s%s\n", Drive, DirUnix,
Karsten Hopp 81c285
  		 g_ChangeDir == CD_SOURCE_PARENT && DirUnix[1] ? ".." : "");
Karsten Hopp 81c285
! 	VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf));
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  #ifdef _DEBUG
Karsten Hopp 81c285
  // Print out a debug message
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
! static void DebugMsg(char* Msg, char* Arg)
Karsten Hopp 81c285
  {
Karsten Hopp 81c285
  	char Buf[400];
Karsten Hopp 81c285
! 	sprintf(Buf, Msg, Arg);
Karsten Hopp 81c285
! 	AfxMessageBox(Buf);
Karsten Hopp 81c285
  }
Karsten Hopp 81c285
  #endif
Karsten Hopp 81c285
*** ../vim-7.2.149/src/VisVim/Resource.h	Sun Jun 13 19:17:32 2004
Karsten Hopp 81c285
--- src/VisVim/Resource.h	Mon Mar  2 00:39:21 2009
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 16,21 ****
Karsten Hopp 81c285
--- 16,22 ----
Karsten Hopp 81c285
  #define IDC_CD_SOURCE_PATH		1001
Karsten Hopp 81c285
  #define IDC_CD_SOURCE_PARENT		1002
Karsten Hopp 81c285
  #define IDC_CD_NONE			1003
Karsten Hopp 81c285
+ #define IDC_NEW_TABS			1004
Karsten Hopp 81c285
  
Karsten Hopp 81c285
  // Next default values for new objects
Karsten Hopp 81c285
  //
Karsten Hopp 81c285
*** ../vim-7.2.149/src/VisVim/VisVim.rc	Sun Jun 13 19:38:03 2004
Karsten Hopp 81c285
--- src/VisVim/VisVim.rc	Mon Mar  2 00:40:19 2009
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 122,127 ****
Karsten Hopp 81c285
--- 122,130 ----
Karsten Hopp 81c285
      CONTROL         "&Open file in DevStudio editor simultaneously",
Karsten Hopp 81c285
                      IDC_DEVSTUDIO_EDITOR,"Button",BS_AUTOCHECKBOX | WS_GROUP | 
Karsten Hopp 81c285
                      WS_TABSTOP,7,7,153,10
Karsten Hopp 81c285
+     CONTROL         "Open files in new tabs",
Karsten Hopp 81c285
+                     IDC_NEW_TABS,"Button",BS_AUTOCHECKBOX | WS_GROUP | 
Karsten Hopp 81c285
+                     WS_TABSTOP,7,21,153,10
Karsten Hopp 81c285
      GROUPBOX        "Current directory",IDC_STATIC,7,35,164,58,WS_GROUP
Karsten Hopp 81c285
      CONTROL         "Set to &source file path",IDC_CD_SOURCE_PATH,"Button",
Karsten Hopp 81c285
                      BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,17,49,85,10
Karsten Hopp 81c285
*** ../vim-7.2.149/src/version.c	Wed Apr 22 12:53:31 2009
Karsten Hopp 81c285
--- src/version.c	Wed Apr 22 13:04:32 2009
Karsten Hopp 81c285
***************
Karsten Hopp 81c285
*** 678,679 ****
Karsten Hopp 81c285
--- 678,681 ----
Karsten Hopp 81c285
  {   /* Add new patch number below this line */
Karsten Hopp 81c285
+ /**/
Karsten Hopp 81c285
+     150,
Karsten Hopp 81c285
  /**/
Karsten Hopp 81c285
Karsten Hopp 81c285
-- 
Karsten Hopp 81c285
A poem:                read aloud:
Karsten Hopp 81c285
Karsten Hopp 81c285
<> !*''#               Waka waka bang splat tick tick hash,
Karsten Hopp 81c285
^"`$$-                 Caret quote back-tick dollar dollar dash,
Karsten Hopp 81c285
!*=@$_                 Bang splat equal at dollar under-score,
Karsten Hopp 81c285
%*<> ~#4               Percent splat waka waka tilde number four,
Karsten Hopp 81c285
&[]../                 Ampersand bracket bracket dot dot slash,
Karsten Hopp 81c285
|{,,SYSTEM HALTED      Vertical-bar curly-bracket comma comma CRASH.
Karsten Hopp 81c285
Karsten Hopp 81c285
Fred Bremmer and Steve Kroese (Calvin College & Seminary of Grand Rapids, MI.)
Karsten Hopp 81c285
Karsten Hopp 81c285
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 81c285
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 81c285
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 81c285
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///