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