2 Subject: Patch 7.2.150 (extra)
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
10 Note: I haven't tested this myself, since I don't have a compiler that
14 Problem: Can't use tab pages from VisVim.
15 Solution: Add tab page support to VisVim. (Adam Slater)
16 Files: src/VisVim/Commands.cpp, src/VisVim/Resource.h,
20 *** ../vim-7.2.149/src/VisVim/Commands.cpp Thu May 10 20:45:34 2007
21 --- src/VisVim/Commands.cpp Mon Mar 2 00:52:15 2009
25 static BOOL g_bEnableVim = TRUE; // Vim enabled
26 static BOOL g_bDevStudioEditor = FALSE; // Open file in Dev Studio editor simultaneously
27 static int g_ChangeDir = CD_NONE; // CD after file open?
29 ! static void VimSetEnableState (BOOL bEnableState);
30 ! static BOOL VimOpenFile (BSTR& FileName, long LineNr);
31 ! static DISPID VimGetDispatchId (COleAutomationControl& VimOle, char* Method);
32 ! static void VimErrDiag (COleAutomationControl& VimOle);
33 ! static void VimChangeDir (COleAutomationControl& VimOle, DISPID DispatchId, BSTR& FileName);
34 ! static void DebugMsg (char* Msg, char* Arg = NULL);
37 /////////////////////////////////////////////////////////////////////////////
40 ! CCommands::CCommands ()
42 // m_pApplication == NULL; M$ Code generation bug!!!
43 m_pApplication = NULL;
46 static BOOL g_bEnableVim = TRUE; // Vim enabled
47 static BOOL g_bDevStudioEditor = FALSE; // Open file in Dev Studio editor simultaneously
48 + static BOOL g_bNewTabs = FALSE;
49 static int g_ChangeDir = CD_NONE; // CD after file open?
51 ! static void VimSetEnableState(BOOL bEnableState);
52 ! static BOOL VimOpenFile(BSTR& FileName, long LineNr);
53 ! static DISPID VimGetDispatchId(COleAutomationControl& VimOle, char* Method);
54 ! static void VimErrDiag(COleAutomationControl& VimOle);
55 ! static void VimChangeDir(COleAutomationControl& VimOle, DISPID DispatchId, BSTR& FileName);
56 ! static void DebugMsg(char* Msg, char* Arg = NULL);
59 /////////////////////////////////////////////////////////////////////////////
62 ! CCommands::CCommands()
64 // m_pApplication == NULL; M$ Code generation bug!!!
65 m_pApplication = NULL;
68 m_pDebuggerEventsObj = NULL;
71 ! CCommands::~CCommands ()
73 ! ASSERT (m_pApplication != NULL);
76 ! m_pApplication->Release ();
77 m_pApplication = NULL;
81 ! void CCommands::SetApplicationObject (IApplication * pApplication)
83 // This function assumes pApplication has already been AddRef'd
84 // for us, which CDSAddIn did in it's QueryInterface call
86 m_pDebuggerEventsObj = NULL;
89 ! CCommands::~CCommands()
91 ! ASSERT(m_pApplication != NULL);
94 ! m_pApplication->Release();
95 m_pApplication = NULL;
99 ! void CCommands::SetApplicationObject(IApplication * pApplication)
101 // This function assumes pApplication has already been AddRef'd
102 // for us, which CDSAddIn did in it's QueryInterface call
107 // Create Application event handlers
108 ! XApplicationEventsObj::CreateInstance (&m_pApplicationEventsObj);
109 if (! m_pApplicationEventsObj)
111 ! ReportInternalError ("XApplicationEventsObj::CreateInstance");
114 ! m_pApplicationEventsObj->AddRef ();
115 ! m_pApplicationEventsObj->Connect (m_pApplication);
116 m_pApplicationEventsObj->m_pCommands = this;
119 // Create Debugger event handler
120 CComPtr < IDispatch > pDebugger;
121 ! if (SUCCEEDED (m_pApplication->get_Debugger (&pDebugger))
122 && pDebugger != NULL)
124 ! XDebuggerEventsObj::CreateInstance (&m_pDebuggerEventsObj);
125 ! m_pDebuggerEventsObj->AddRef ();
126 ! m_pDebuggerEventsObj->Connect (pDebugger);
127 m_pDebuggerEventsObj->m_pCommands = this;
131 // Get settings from registry HKEY_CURRENT_USER\Software\Vim\VisVim
132 ! HKEY hAppKey = GetAppKey ("Vim");
135 ! HKEY hSectionKey = GetSectionKey (hAppKey, "VisVim");
138 ! g_bEnableVim = GetRegistryInt (hSectionKey, "EnableVim",
140 ! g_bDevStudioEditor = GetRegistryInt(hSectionKey,"DevStudioEditor",
141 ! g_bDevStudioEditor);
142 ! g_ChangeDir = GetRegistryInt (hSectionKey, "ChangeDir",
144 ! RegCloseKey (hSectionKey);
146 ! RegCloseKey (hAppKey);
150 ! void CCommands::UnadviseFromEvents ()
152 ! ASSERT (m_pApplicationEventsObj != NULL);
153 if (m_pApplicationEventsObj)
155 ! m_pApplicationEventsObj->Disconnect (m_pApplication);
156 ! m_pApplicationEventsObj->Release ();
157 m_pApplicationEventsObj = NULL;
163 // Create Application event handlers
164 ! XApplicationEventsObj::CreateInstance(&m_pApplicationEventsObj);
165 if (! m_pApplicationEventsObj)
167 ! ReportInternalError("XApplicationEventsObj::CreateInstance");
170 ! m_pApplicationEventsObj->AddRef();
171 ! m_pApplicationEventsObj->Connect(m_pApplication);
172 m_pApplicationEventsObj->m_pCommands = this;
175 // Create Debugger event handler
176 CComPtr < IDispatch > pDebugger;
177 ! if (SUCCEEDED(m_pApplication->get_Debugger(&pDebugger))
178 && pDebugger != NULL)
180 ! XDebuggerEventsObj::CreateInstance(&m_pDebuggerEventsObj);
181 ! m_pDebuggerEventsObj->AddRef();
182 ! m_pDebuggerEventsObj->Connect(pDebugger);
183 m_pDebuggerEventsObj->m_pCommands = this;
187 // Get settings from registry HKEY_CURRENT_USER\Software\Vim\VisVim
188 ! HKEY hAppKey = GetAppKey("Vim");
191 ! HKEY hSectionKey = GetSectionKey(hAppKey, "VisVim");
194 ! g_bEnableVim = GetRegistryInt(hSectionKey, "EnableVim",
196 ! g_bDevStudioEditor = GetRegistryInt(hSectionKey,
197 ! "DevStudioEditor", g_bDevStudioEditor);
198 ! g_bNewTabs = GetRegistryInt(hSectionKey, "NewTabs",
200 ! g_ChangeDir = GetRegistryInt(hSectionKey, "ChangeDir",
202 ! RegCloseKey(hSectionKey);
204 ! RegCloseKey(hAppKey);
208 ! void CCommands::UnadviseFromEvents()
210 ! ASSERT(m_pApplicationEventsObj != NULL);
211 if (m_pApplicationEventsObj)
213 ! m_pApplicationEventsObj->Disconnect(m_pApplication);
214 ! m_pApplicationEventsObj->Release();
215 m_pApplicationEventsObj = NULL;
220 // unadvise from its events (thus the VERIFY_OK below--see
222 CComPtr < IDispatch > pDebugger;
223 ! VERIFY_OK (m_pApplication->get_Debugger (&pDebugger));
224 ! ASSERT (pDebugger != NULL);
225 ! m_pDebuggerEventsObj->Disconnect (pDebugger);
226 ! m_pDebuggerEventsObj->Release ();
227 m_pDebuggerEventsObj = NULL;
231 // unadvise from its events (thus the VERIFY_OK below--see
233 CComPtr < IDispatch > pDebugger;
234 ! VERIFY_OK(m_pApplication->get_Debugger(&pDebugger));
235 ! ASSERT(pDebugger != NULL);
236 ! m_pDebuggerEventsObj->Disconnect(pDebugger);
237 ! m_pDebuggerEventsObj->Release();
238 m_pDebuggerEventsObj = NULL;
244 // Application events
246 ! HRESULT CCommands::XApplicationEvents::BeforeBuildStart ()
248 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
252 ! HRESULT CCommands::XApplicationEvents::BuildFinish (long nNumErrors, long nNumWarnings)
254 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
258 ! HRESULT CCommands::XApplicationEvents::BeforeApplicationShutDown ()
260 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
266 // Application events
268 ! HRESULT CCommands::XApplicationEvents::BeforeBuildStart()
270 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
274 ! HRESULT CCommands::XApplicationEvents::BuildFinish(long nNumErrors, long nNumWarnings)
276 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
280 ! HRESULT CCommands::XApplicationEvents::BeforeApplicationShutDown()
282 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
289 // Vim gets called from here.
291 ! HRESULT CCommands::XApplicationEvents::DocumentOpen (IDispatch * theDocument)
293 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
296 // Vim not enabled or empty command line entered
299 // Vim gets called from here.
301 ! HRESULT CCommands::XApplicationEvents::DocumentOpen(IDispatch * theDocument)
303 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
306 // Vim not enabled or empty command line entered
309 // First get the current file name and line number
311 // Get the document object
312 ! CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (theDocument);
317 // First get the current file name and line number
319 // Get the document object
320 ! CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc(theDocument);
328 // Get the document name
329 ! if (FAILED (pDoc->get_FullName (&FileName)))
334 // Get a selection object dispatch pointer
335 ! if (SUCCEEDED (pDoc->get_Selection (&pDispSel)))
337 // Get the selection object
338 ! CComQIPtr < ITextSelection, &IID_ITextSelection > pSel (pDispSel);
341 // Get the selection line number
342 ! pSel->get_CurrentLine (&LineNr);
344 ! pDispSel->Release ();
347 // Open the file in Vim and position to the current line
348 ! if (VimOpenFile (FileName, LineNr))
350 if (! g_bDevStudioEditor)
355 // Get the document name
356 ! if (FAILED(pDoc->get_FullName(&FileName)))
361 // Get a selection object dispatch pointer
362 ! if (SUCCEEDED(pDoc->get_Selection(&pDispSel)))
364 // Get the selection object
365 ! CComQIPtr < ITextSelection, &IID_ITextSelection > pSel(pDispSel);
368 // Get the selection line number
369 ! pSel->get_CurrentLine(&LineNr);
371 ! pDispSel->Release();
374 // Open the file in Vim and position to the current line
375 ! if (VimOpenFile(FileName, LineNr))
377 if (! g_bDevStudioEditor)
381 CComVariant vSaveChanges = dsSaveChangesPrompt;
384 ! pDoc->Close (vSaveChanges, &Saved);
389 ! SysFreeString (FileName);
393 ! HRESULT CCommands::XApplicationEvents::BeforeDocumentClose (IDispatch * theDocument)
395 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
399 ! HRESULT CCommands::XApplicationEvents::DocumentSave (IDispatch * theDocument)
401 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
405 ! HRESULT CCommands::XApplicationEvents::NewDocument (IDispatch * theDocument)
407 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
410 // Vim not enabled or empty command line entered
412 CComVariant vSaveChanges = dsSaveChangesPrompt;
415 ! pDoc->Close(vSaveChanges, &Saved);
420 ! SysFreeString(FileName);
424 ! HRESULT CCommands::XApplicationEvents::BeforeDocumentClose(IDispatch * theDocument)
426 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
430 ! HRESULT CCommands::XApplicationEvents::DocumentSave(IDispatch * theDocument)
432 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
436 ! HRESULT CCommands::XApplicationEvents::NewDocument(IDispatch * theDocument)
438 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
441 // Vim not enabled or empty command line entered
445 // First get the current file name and line number
447 ! CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (theDocument);
454 ! hr = pDoc->get_FullName (&FileName);
458 // Open the file in Vim and position to the current line
459 ! if (VimOpenFile (FileName, 0))
461 if (! g_bDevStudioEditor)
465 // First get the current file name and line number
467 ! CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc(theDocument);
474 ! hr = pDoc->get_FullName(&FileName);
478 // Open the file in Vim and position to the current line
479 ! if (VimOpenFile(FileName, 0))
481 if (! g_bDevStudioEditor)
485 CComVariant vSaveChanges = dsSaveChangesPrompt;
488 ! pDoc->Close (vSaveChanges, &Saved);
492 ! SysFreeString (FileName);
496 ! HRESULT CCommands::XApplicationEvents::WindowActivate (IDispatch * theWindow)
498 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
502 ! HRESULT CCommands::XApplicationEvents::WindowDeactivate (IDispatch * theWindow)
504 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
508 ! HRESULT CCommands::XApplicationEvents::WorkspaceOpen ()
510 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
514 ! HRESULT CCommands::XApplicationEvents::WorkspaceClose ()
516 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
520 ! HRESULT CCommands::XApplicationEvents::NewWorkspace ()
522 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
528 ! HRESULT CCommands::XDebuggerEvents::BreakpointHit (IDispatch * pBreakpoint)
530 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
535 CComVariant vSaveChanges = dsSaveChangesPrompt;
538 ! pDoc->Close(vSaveChanges, &Saved);
542 ! SysFreeString(FileName);
546 ! HRESULT CCommands::XApplicationEvents::WindowActivate(IDispatch * theWindow)
548 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
552 ! HRESULT CCommands::XApplicationEvents::WindowDeactivate(IDispatch * theWindow)
554 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
558 ! HRESULT CCommands::XApplicationEvents::WorkspaceOpen()
560 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
564 ! HRESULT CCommands::XApplicationEvents::WorkspaceClose()
566 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
570 ! HRESULT CCommands::XApplicationEvents::NewWorkspace()
572 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
578 ! HRESULT CCommands::XDebuggerEvents::BreakpointHit(IDispatch * pBreakpoint)
580 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
586 class CMainDialog : public CDialog
589 ! CMainDialog (CWnd * pParent = NULL); // Standard constructor
591 //{{AFX_DATA(CMainDialog)
592 enum { IDD = IDD_ADDINMAIN };
594 BOOL m_bDevStudioEditor;
597 //{{AFX_VIRTUAL(CMainDialog)
599 ! virtual void DoDataExchange (CDataExchange * pDX); // DDX/DDV support
604 class CMainDialog : public CDialog
607 ! CMainDialog(CWnd * pParent = NULL); // Standard constructor
609 //{{AFX_DATA(CMainDialog)
610 enum { IDD = IDD_ADDINMAIN };
612 BOOL m_bDevStudioEditor;
616 //{{AFX_VIRTUAL(CMainDialog)
618 ! virtual void DoDataExchange(CDataExchange * pDX); // DDX/DDV support
624 afx_msg void OnEnable();
625 afx_msg void OnDisable();
627 ! DECLARE_MESSAGE_MAP ()
630 ! CMainDialog::CMainDialog (CWnd * pParent /* =NULL */ )
631 ! : CDialog (CMainDialog::IDD, pParent)
633 //{{AFX_DATA_INIT(CMainDialog)
635 m_bDevStudioEditor = FALSE;
639 ! void CMainDialog::DoDataExchange (CDataExchange * pDX)
641 ! CDialog::DoDataExchange (pDX);
642 //{{AFX_DATA_MAP(CMainDialog)
643 DDX_Radio(pDX, IDC_CD_SOURCE_PATH, m_ChangeDir);
644 ! DDX_Check (pDX, IDC_DEVSTUDIO_EDITOR, m_bDevStudioEditor);
648 ! BEGIN_MESSAGE_MAP (CMainDialog, CDialog)
649 //{{AFX_MSG_MAP(CMainDialog)
654 /////////////////////////////////////////////////////////////////////////////
657 ! STDMETHODIMP CCommands::VisVimDialog ()
659 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
661 // Use m_pApplication to access the Developer Studio Application
663 // and VERIFY_OK to see error strings in DEBUG builds of your add-in
666 ! VERIFY_OK (m_pApplication->EnableModeless (VARIANT_FALSE));
670 Dlg.m_bDevStudioEditor = g_bDevStudioEditor;
671 Dlg.m_ChangeDir = g_ChangeDir;
672 ! if (Dlg.DoModal () == IDOK)
674 g_bDevStudioEditor = Dlg.m_bDevStudioEditor;
675 g_ChangeDir = Dlg.m_ChangeDir;
677 // Save settings to registry HKEY_CURRENT_USER\Software\Vim\VisVim
678 ! HKEY hAppKey = GetAppKey ("Vim");
681 ! HKEY hSectionKey = GetSectionKey (hAppKey, "VisVim");
684 ! WriteRegistryInt (hSectionKey, "DevStudioEditor",
686 ! WriteRegistryInt (hSectionKey, "ChangeDir", g_ChangeDir);
687 ! RegCloseKey (hSectionKey);
689 ! RegCloseKey (hAppKey);
693 ! VERIFY_OK (m_pApplication->EnableModeless (VARIANT_TRUE));
697 ! STDMETHODIMP CCommands::VisVimEnable ()
699 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
700 ! VimSetEnableState (true);
704 ! STDMETHODIMP CCommands::VisVimDisable ()
706 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
707 ! VimSetEnableState (false);
711 ! STDMETHODIMP CCommands::VisVimToggle ()
713 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
714 ! VimSetEnableState (! g_bEnableVim);
718 ! STDMETHODIMP CCommands::VisVimLoad ()
720 ! AFX_MANAGE_STATE (AfxGetStaticModuleState ());
722 // Use m_pApplication to access the Developer Studio Application object,
723 // and VERIFY_OK to see error strings in DEBUG builds of your add-in
725 afx_msg void OnEnable();
726 afx_msg void OnDisable();
728 ! DECLARE_MESSAGE_MAP()
731 ! CMainDialog::CMainDialog(CWnd * pParent /* =NULL */ )
732 ! : CDialog(CMainDialog::IDD, pParent)
734 //{{AFX_DATA_INIT(CMainDialog)
736 m_bDevStudioEditor = FALSE;
737 + m_bNewTabs = FALSE;
741 ! void CMainDialog::DoDataExchange(CDataExchange * pDX)
743 ! CDialog::DoDataExchange(pDX);
744 //{{AFX_DATA_MAP(CMainDialog)
745 DDX_Radio(pDX, IDC_CD_SOURCE_PATH, m_ChangeDir);
746 ! DDX_Check(pDX, IDC_DEVSTUDIO_EDITOR, m_bDevStudioEditor);
747 ! DDX_Check(pDX, IDC_NEW_TABS, m_bNewTabs);
751 ! BEGIN_MESSAGE_MAP(CMainDialog, CDialog)
752 //{{AFX_MSG_MAP(CMainDialog)
757 /////////////////////////////////////////////////////////////////////////////
760 ! STDMETHODIMP CCommands::VisVimDialog()
762 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
764 // Use m_pApplication to access the Developer Studio Application
766 // and VERIFY_OK to see error strings in DEBUG builds of your add-in
769 ! VERIFY_OK(m_pApplication->EnableModeless(VARIANT_FALSE));
773 Dlg.m_bDevStudioEditor = g_bDevStudioEditor;
774 + Dlg.m_bNewTabs = g_bNewTabs;
775 Dlg.m_ChangeDir = g_ChangeDir;
776 ! if (Dlg.DoModal() == IDOK)
778 g_bDevStudioEditor = Dlg.m_bDevStudioEditor;
779 + g_bNewTabs = Dlg.m_bNewTabs;
780 g_ChangeDir = Dlg.m_ChangeDir;
782 // Save settings to registry HKEY_CURRENT_USER\Software\Vim\VisVim
783 ! HKEY hAppKey = GetAppKey("Vim");
786 ! HKEY hSectionKey = GetSectionKey(hAppKey, "VisVim");
789 ! WriteRegistryInt(hSectionKey, "DevStudioEditor",
791 ! WriteRegistryInt(hSectionKey, "NewTabs",
793 ! WriteRegistryInt(hSectionKey, "ChangeDir", g_ChangeDir);
794 ! RegCloseKey(hSectionKey);
796 ! RegCloseKey(hAppKey);
800 ! VERIFY_OK(m_pApplication->EnableModeless(VARIANT_TRUE));
804 ! STDMETHODIMP CCommands::VisVimEnable()
806 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
807 ! VimSetEnableState(true);
811 ! STDMETHODIMP CCommands::VisVimDisable()
813 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
814 ! VimSetEnableState(false);
818 ! STDMETHODIMP CCommands::VisVimToggle()
820 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
821 ! VimSetEnableState(! g_bEnableVim);
825 ! STDMETHODIMP CCommands::VisVimLoad()
827 ! AFX_MANAGE_STATE(AfxGetStaticModuleState());
829 // Use m_pApplication to access the Developer Studio Application object,
830 // and VERIFY_OK to see error strings in DEBUG builds of your add-in
833 CComPtr < IDispatch > pDispDoc, pDispSel;
835 // Get a document object dispatch pointer
836 ! VERIFY_OK (m_pApplication->get_ActiveDocument (&pDispDoc));
841 CComPtr < IDispatch > pDispDoc, pDispSel;
843 // Get a document object dispatch pointer
844 ! VERIFY_OK(m_pApplication->get_ActiveDocument(&pDispDoc));
852 // Get the document object
853 ! CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (pDispDoc);
858 // Get the document name
859 ! if (FAILED (pDoc->get_FullName (&FileName)))
862 // Get a selection object dispatch pointer
863 ! if (SUCCEEDED (pDoc->get_Selection (&pDispSel)))
865 // Get the selection object
866 ! CComQIPtr < ITextSelection, &IID_ITextSelection > pSel (pDispSel);
869 // Get the selection line number
870 ! pSel->get_CurrentLine (&LineNr);
873 // Open the file in Vim
874 ! VimOpenFile (FileName, LineNr);
876 ! SysFreeString (FileName);
883 // Get the document object
884 ! CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc(pDispDoc);
889 // Get the document name
890 ! if (FAILED(pDoc->get_FullName(&FileName)))
893 // Get a selection object dispatch pointer
894 ! if (SUCCEEDED(pDoc->get_Selection(&pDispSel)))
896 // Get the selection object
897 ! CComQIPtr < ITextSelection, &IID_ITextSelection > pSel(pDispSel);
900 // Get the selection line number
901 ! pSel->get_CurrentLine(&LineNr);
904 // Open the file in Vim
905 ! VimOpenFile(FileName, LineNr);
907 ! SysFreeString(FileName);
914 // Set the enable state and save to registry
916 ! static void VimSetEnableState (BOOL bEnableState)
918 g_bEnableVim = bEnableState;
919 ! HKEY hAppKey = GetAppKey ("Vim");
922 ! HKEY hSectionKey = GetSectionKey (hAppKey, "VisVim");
924 ! WriteRegistryInt (hSectionKey, "EnableVim", g_bEnableVim);
925 ! RegCloseKey (hAppKey);
931 // Set the enable state and save to registry
933 ! static void VimSetEnableState(BOOL bEnableState)
935 g_bEnableVim = bEnableState;
936 ! HKEY hAppKey = GetAppKey("Vim");
939 ! HKEY hSectionKey = GetSectionKey(hAppKey, "VisVim");
941 ! WriteRegistryInt(hSectionKey, "EnableVim", g_bEnableVim);
942 ! RegCloseKey(hAppKey);
949 // 'LineNr' must contain a valid line number or 0, e. g. for a new file
951 ! static BOOL VimOpenFile (BSTR& FileName, long LineNr)
954 // OLE automation object for com. with Vim
957 // 'LineNr' must contain a valid line number or 0, e. g. for a new file
959 ! static BOOL VimOpenFile(BSTR& FileName, long LineNr)
962 // OLE automation object for com. with Vim
965 // Get a dispatch id for the SendKeys method of Vim;
966 // enables connection to Vim if necessary
968 ! DispatchId = VimGetDispatchId (VimOle, "SendKeys");
970 // OLE error, can't obtain dispatch id
973 // Get a dispatch id for the SendKeys method of Vim;
974 // enables connection to Vim if necessary
976 ! DispatchId = VimGetDispatchId(VimOle, "SendKeys");
978 // OLE error, can't obtain dispatch id
983 // Update the current file in Vim if it has been modified.
984 // Disabled, because it could write the file when you don't want to.
985 ! sprintf (VimCmd + 2, ":up\n");
987 ! if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf)))
990 // Change Vim working directory to where the file is if desired
991 if (g_ChangeDir != CD_NONE)
992 ! VimChangeDir (VimOle, DispatchId, FileName);
994 // Make Vim open the file.
995 // In the filename convert all \ to /, put a \ before a space.
996 ! sprintf(VimCmd, ":drop ");
997 sprintf(FileNameTmp, "%S", (char *)FileName);
999 for (p = FileNameTmp; *p != '\0' && s < FileNameTmp + MAX_OLE_STR - 4;
1003 #ifdef SINGLE_WINDOW
1004 // Update the current file in Vim if it has been modified.
1005 // Disabled, because it could write the file when you don't want to.
1006 ! sprintf(VimCmd + 2, ":up\n");
1008 ! if (! VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf)))
1011 // Change Vim working directory to where the file is if desired
1012 if (g_ChangeDir != CD_NONE)
1013 ! VimChangeDir(VimOle, DispatchId, FileName);
1015 // Make Vim open the file.
1016 // In the filename convert all \ to /, put a \ before a space.
1019 ! sprintf(VimCmd, ":tab drop ");
1024 ! sprintf(VimCmd, ":drop ");
1027 sprintf(FileNameTmp, "%S", (char *)FileName);
1028 for (p = FileNameTmp; *p != '\0' && s < FileNameTmp + MAX_OLE_STR - 4;
1036 ! if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf)))
1042 ! sprintf (VimCmd, ":%d\n", LineNr);
1043 ! if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf)))
1047 // Make Vim come to the foreground
1048 ! if (! VimOle.Method ("SetForeground"))
1049 ! VimOle.ErrDiag ();
1057 ! if (! VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf)))
1063 ! sprintf(VimCmd, ":%d\n", LineNr);
1064 ! if (! VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf)))
1068 // Make Vim come to the foreground
1069 ! if (! VimOle.Method("SetForeground"))
1077 // There was an OLE error
1078 // Check if it's the "unknown class string" error
1079 ! VimErrDiag (VimOle);
1085 // There was an OLE error
1086 // Check if it's the "unknown class string" error
1087 ! VimErrDiag(VimOle);
1093 // Create the Vim OLE object if necessary
1094 // Returns a valid dispatch id or null on error
1096 ! static DISPID VimGetDispatchId (COleAutomationControl& VimOle, char* Method)
1098 // Initialize Vim OLE connection if not already done
1099 ! if (! VimOle.IsCreated ())
1101 ! if (! VimOle.CreateObject ("Vim.Application"))
1105 // Get the dispatch id for the SendKeys method.
1106 // By doing this, we are checking if Vim is still there...
1107 ! DISPID DispatchId = VimOle.GetDispatchId ("SendKeys");
1110 // We can't get a dispatch id.
1112 // Create the Vim OLE object if necessary
1113 // Returns a valid dispatch id or null on error
1115 ! static DISPID VimGetDispatchId(COleAutomationControl& VimOle, char* Method)
1117 // Initialize Vim OLE connection if not already done
1118 ! if (! VimOle.IsCreated())
1120 ! if (! VimOle.CreateObject("Vim.Application"))
1124 // Get the dispatch id for the SendKeys method.
1125 // By doing this, we are checking if Vim is still there...
1126 ! DISPID DispatchId = VimOle.GetDispatchId("SendKeys");
1129 // We can't get a dispatch id.
1132 // should not be kept long enough to allow the user to terminate Vim
1133 // to avoid memory corruption (why the heck is there no system garbage
1134 // collection for those damned OLE memory chunks???).
1135 ! VimOle.DeleteObject ();
1136 ! if (! VimOle.CreateObject ("Vim.Application"))
1137 // If this create fails, it's time for an error msg
1140 ! if (! (DispatchId = VimOle.GetDispatchId ("SendKeys")))
1141 // There is something wrong...
1145 // should not be kept long enough to allow the user to terminate Vim
1146 // to avoid memory corruption (why the heck is there no system garbage
1147 // collection for those damned OLE memory chunks???).
1148 ! VimOle.DeleteObject();
1149 ! if (! VimOle.CreateObject("Vim.Application"))
1150 // If this create fails, it's time for an error msg
1153 ! if (! (DispatchId = VimOle.GetDispatchId("SendKeys")))
1154 // There is something wrong...
1159 // Output an error message for an OLE error
1160 // Check on the classstring error, which probably means Vim wasn't registered.
1162 ! static void VimErrDiag (COleAutomationControl& VimOle)
1164 ! SCODE sc = GetScode (VimOle.GetResult ());
1165 if (sc == CO_E_CLASSSTRING)
1168 ! sprintf (Buf, "There is no registered OLE automation server named "
1169 "\"Vim.Application\".\n"
1170 "Use the OLE-enabled version of Vim with VisVim and "
1171 "make sure to register Vim by running \"vim -register\".");
1172 ! MessageBox (NULL, Buf, "OLE Error", MB_OK);
1175 ! VimOle.ErrDiag ();
1178 // Change directory to the directory the file 'FileName' is in or it's parent
1180 // Output an error message for an OLE error
1181 // Check on the classstring error, which probably means Vim wasn't registered.
1183 ! static void VimErrDiag(COleAutomationControl& VimOle)
1185 ! SCODE sc = GetScode(VimOle.GetResult());
1186 if (sc == CO_E_CLASSSTRING)
1189 ! sprintf(Buf, "There is no registered OLE automation server named "
1190 "\"Vim.Application\".\n"
1191 "Use the OLE-enabled version of Vim with VisVim and "
1192 "make sure to register Vim by running \"vim -register\".");
1193 ! MessageBox(NULL, Buf, "OLE Error", MB_OK);
1199 // Change directory to the directory the file 'FileName' is in or it's parent
1205 ! static void VimChangeDir (COleAutomationControl& VimOle, DISPID DispatchId, BSTR& FileName)
1213 ! static void VimChangeDir(COleAutomationControl& VimOle, DISPID DispatchId, BSTR& FileName)
1219 char DirUnix[_MAX_DIR * 2];
1222 ! _splitpath (StrFileName, Drive, Dir, NULL, NULL);
1224 // Convert to Unix path name format, escape spaces.
1227 char DirUnix[_MAX_DIR * 2];
1230 ! _splitpath(StrFileName, Drive, Dir, NULL, NULL);
1232 // Convert to Unix path name format, escape spaces.
1236 OLECHAR Buf[MAX_OLE_STR];
1237 char VimCmd[MAX_OLE_STR];
1239 ! sprintf (VimCmd, ":cd %s%s%s\n", Drive, DirUnix,
1240 g_ChangeDir == CD_SOURCE_PARENT && DirUnix[1] ? ".." : "");
1241 ! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf));
1245 // Print out a debug message
1247 ! static void DebugMsg (char* Msg, char* Arg)
1250 ! sprintf (Buf, Msg, Arg);
1251 ! AfxMessageBox (Buf);
1256 OLECHAR Buf[MAX_OLE_STR];
1257 char VimCmd[MAX_OLE_STR];
1259 ! sprintf(VimCmd, ":cd %s%s%s\n", Drive, DirUnix,
1260 g_ChangeDir == CD_SOURCE_PARENT && DirUnix[1] ? ".." : "");
1261 ! VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf));
1265 // Print out a debug message
1267 ! static void DebugMsg(char* Msg, char* Arg)
1270 ! sprintf(Buf, Msg, Arg);
1271 ! AfxMessageBox(Buf);
1274 *** ../vim-7.2.149/src/VisVim/Resource.h Sun Jun 13 19:17:32 2004
1275 --- src/VisVim/Resource.h Mon Mar 2 00:39:21 2009
1279 #define IDC_CD_SOURCE_PATH 1001
1280 #define IDC_CD_SOURCE_PARENT 1002
1281 #define IDC_CD_NONE 1003
1282 + #define IDC_NEW_TABS 1004
1284 // Next default values for new objects
1286 *** ../vim-7.2.149/src/VisVim/VisVim.rc Sun Jun 13 19:38:03 2004
1287 --- src/VisVim/VisVim.rc Mon Mar 2 00:40:19 2009
1291 CONTROL "&Open file in DevStudio editor simultaneously",
1292 IDC_DEVSTUDIO_EDITOR,"Button",BS_AUTOCHECKBOX | WS_GROUP |
1293 WS_TABSTOP,7,7,153,10
1294 + CONTROL "Open files in new tabs",
1295 + IDC_NEW_TABS,"Button",BS_AUTOCHECKBOX | WS_GROUP |
1296 + WS_TABSTOP,7,21,153,10
1297 GROUPBOX "Current directory",IDC_STATIC,7,35,164,58,WS_GROUP
1298 CONTROL "Set to &source file path",IDC_CD_SOURCE_PATH,"Button",
1299 BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,17,49,85,10
1300 *** ../vim-7.2.149/src/version.c Wed Apr 22 12:53:31 2009
1301 --- src/version.c Wed Apr 22 13:04:32 2009
1305 { /* Add new patch number below this line */
1313 <> !*''# Waka waka bang splat tick tick hash,
1314 ^"`$$- Caret quote back-tick dollar dollar dash,
1315 !*=@$_ Bang splat equal at dollar under-score,
1316 %*<> ~#4 Percent splat waka waka tilde number four,
1317 &[]../ Ampersand bracket bracket dot dot slash,
1318 |{,,SYSTEM HALTED Vertical-bar curly-bracket comma comma CRASH.
1320 Fred Bremmer and Steve Kroese (Calvin College & Seminary of Grand Rapids, MI.)
1322 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
1323 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
1324 \\\ download, build and distribute -- http://www.A-A-P.org ///
1325 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///