]>
Commit | Line | Data |
---|---|---|
4c0a682a AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.2.150 (extra) | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Note: I haven't tested this myself, since I don't have a compiler that | |
11 | works for this code. | |
12 | ||
13 | Patch 7.2.150 (extra) | |
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, | |
17 | src/VisVim/VisVim.rc | |
18 | ||
19 | ||
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 | |
22 | *************** | |
23 | *** 20,39 **** | |
24 | ||
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? | |
28 | ||
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); | |
35 | ||
36 | ||
37 | ///////////////////////////////////////////////////////////////////////////// | |
38 | // CCommands | |
39 | ||
40 | ! CCommands::CCommands () | |
41 | { | |
42 | // m_pApplication == NULL; M$ Code generation bug!!! | |
43 | m_pApplication = NULL; | |
44 | --- 20,40 ---- | |
45 | ||
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? | |
50 | ||
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); | |
57 | ||
58 | ||
59 | ///////////////////////////////////////////////////////////////////////////// | |
60 | // CCommands | |
61 | ||
62 | ! CCommands::CCommands() | |
63 | { | |
64 | // m_pApplication == NULL; M$ Code generation bug!!! | |
65 | m_pApplication = NULL; | |
66 | *************** | |
67 | *** 41,57 **** | |
68 | m_pDebuggerEventsObj = NULL; | |
69 | } | |
70 | ||
71 | ! CCommands::~CCommands () | |
72 | { | |
73 | ! ASSERT (m_pApplication != NULL); | |
74 | if (m_pApplication) | |
75 | { | |
76 | ! m_pApplication->Release (); | |
77 | m_pApplication = NULL; | |
78 | } | |
79 | } | |
80 | ||
81 | ! void CCommands::SetApplicationObject (IApplication * pApplication) | |
82 | { | |
83 | // This function assumes pApplication has already been AddRef'd | |
84 | // for us, which CDSAddIn did in it's QueryInterface call | |
85 | --- 42,58 ---- | |
86 | m_pDebuggerEventsObj = NULL; | |
87 | } | |
88 | ||
89 | ! CCommands::~CCommands() | |
90 | { | |
91 | ! ASSERT(m_pApplication != NULL); | |
92 | if (m_pApplication) | |
93 | { | |
94 | ! m_pApplication->Release(); | |
95 | m_pApplication = NULL; | |
96 | } | |
97 | } | |
98 | ||
99 | ! void CCommands::SetApplicationObject(IApplication * pApplication) | |
100 | { | |
101 | // This function assumes pApplication has already been AddRef'd | |
102 | // for us, which CDSAddIn did in it's QueryInterface call | |
103 | *************** | |
104 | *** 61,115 **** | |
105 | return; | |
106 | ||
107 | // Create Application event handlers | |
108 | ! XApplicationEventsObj::CreateInstance (&m_pApplicationEventsObj); | |
109 | if (! m_pApplicationEventsObj) | |
110 | { | |
111 | ! ReportInternalError ("XApplicationEventsObj::CreateInstance"); | |
112 | return; | |
113 | } | |
114 | ! m_pApplicationEventsObj->AddRef (); | |
115 | ! m_pApplicationEventsObj->Connect (m_pApplication); | |
116 | m_pApplicationEventsObj->m_pCommands = this; | |
117 | ||
118 | #ifdef NEVER | |
119 | // Create Debugger event handler | |
120 | CComPtr < IDispatch > pDebugger; | |
121 | ! if (SUCCEEDED (m_pApplication->get_Debugger (&pDebugger)) | |
122 | && pDebugger != NULL) | |
123 | { | |
124 | ! XDebuggerEventsObj::CreateInstance (&m_pDebuggerEventsObj); | |
125 | ! m_pDebuggerEventsObj->AddRef (); | |
126 | ! m_pDebuggerEventsObj->Connect (pDebugger); | |
127 | m_pDebuggerEventsObj->m_pCommands = this; | |
128 | } | |
129 | #endif | |
130 | ||
131 | // Get settings from registry HKEY_CURRENT_USER\Software\Vim\VisVim | |
132 | ! HKEY hAppKey = GetAppKey ("Vim"); | |
133 | if (hAppKey) | |
134 | { | |
135 | ! HKEY hSectionKey = GetSectionKey (hAppKey, "VisVim"); | |
136 | if (hSectionKey) | |
137 | { | |
138 | ! g_bEnableVim = GetRegistryInt (hSectionKey, "EnableVim", | |
139 | g_bEnableVim); | |
140 | ! g_bDevStudioEditor = GetRegistryInt(hSectionKey,"DevStudioEditor", | |
141 | ! g_bDevStudioEditor); | |
142 | ! g_ChangeDir = GetRegistryInt (hSectionKey, "ChangeDir", | |
143 | g_ChangeDir); | |
144 | ! RegCloseKey (hSectionKey); | |
145 | } | |
146 | ! RegCloseKey (hAppKey); | |
147 | } | |
148 | } | |
149 | ||
150 | ! void CCommands::UnadviseFromEvents () | |
151 | { | |
152 | ! ASSERT (m_pApplicationEventsObj != NULL); | |
153 | if (m_pApplicationEventsObj) | |
154 | { | |
155 | ! m_pApplicationEventsObj->Disconnect (m_pApplication); | |
156 | ! m_pApplicationEventsObj->Release (); | |
157 | m_pApplicationEventsObj = NULL; | |
158 | } | |
159 | ||
160 | --- 62,118 ---- | |
161 | return; | |
162 | ||
163 | // Create Application event handlers | |
164 | ! XApplicationEventsObj::CreateInstance(&m_pApplicationEventsObj); | |
165 | if (! m_pApplicationEventsObj) | |
166 | { | |
167 | ! ReportInternalError("XApplicationEventsObj::CreateInstance"); | |
168 | return; | |
169 | } | |
170 | ! m_pApplicationEventsObj->AddRef(); | |
171 | ! m_pApplicationEventsObj->Connect(m_pApplication); | |
172 | m_pApplicationEventsObj->m_pCommands = this; | |
173 | ||
174 | #ifdef NEVER | |
175 | // Create Debugger event handler | |
176 | CComPtr < IDispatch > pDebugger; | |
177 | ! if (SUCCEEDED(m_pApplication->get_Debugger(&pDebugger)) | |
178 | && pDebugger != NULL) | |
179 | { | |
180 | ! XDebuggerEventsObj::CreateInstance(&m_pDebuggerEventsObj); | |
181 | ! m_pDebuggerEventsObj->AddRef(); | |
182 | ! m_pDebuggerEventsObj->Connect(pDebugger); | |
183 | m_pDebuggerEventsObj->m_pCommands = this; | |
184 | } | |
185 | #endif | |
186 | ||
187 | // Get settings from registry HKEY_CURRENT_USER\Software\Vim\VisVim | |
188 | ! HKEY hAppKey = GetAppKey("Vim"); | |
189 | if (hAppKey) | |
190 | { | |
191 | ! HKEY hSectionKey = GetSectionKey(hAppKey, "VisVim"); | |
192 | if (hSectionKey) | |
193 | { | |
194 | ! g_bEnableVim = GetRegistryInt(hSectionKey, "EnableVim", | |
195 | g_bEnableVim); | |
196 | ! g_bDevStudioEditor = GetRegistryInt(hSectionKey, | |
197 | ! "DevStudioEditor", g_bDevStudioEditor); | |
198 | ! g_bNewTabs = GetRegistryInt(hSectionKey, "NewTabs", | |
199 | ! g_bNewTabs); | |
200 | ! g_ChangeDir = GetRegistryInt(hSectionKey, "ChangeDir", | |
201 | g_ChangeDir); | |
202 | ! RegCloseKey(hSectionKey); | |
203 | } | |
204 | ! RegCloseKey(hAppKey); | |
205 | } | |
206 | } | |
207 | ||
208 | ! void CCommands::UnadviseFromEvents() | |
209 | { | |
210 | ! ASSERT(m_pApplicationEventsObj != NULL); | |
211 | if (m_pApplicationEventsObj) | |
212 | { | |
213 | ! m_pApplicationEventsObj->Disconnect(m_pApplication); | |
214 | ! m_pApplicationEventsObj->Release(); | |
215 | m_pApplicationEventsObj = NULL; | |
216 | } | |
217 | ||
218 | *************** | |
219 | *** 121,130 **** | |
220 | // unadvise from its events (thus the VERIFY_OK below--see | |
221 | // stdafx.h). | |
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; | |
228 | } | |
229 | #endif | |
230 | --- 124,133 ---- | |
231 | // unadvise from its events (thus the VERIFY_OK below--see | |
232 | // stdafx.h). | |
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; | |
239 | } | |
240 | #endif | |
241 | *************** | |
242 | *** 136,156 **** | |
243 | ||
244 | // Application events | |
245 | ||
246 | ! HRESULT CCommands::XApplicationEvents::BeforeBuildStart () | |
247 | { | |
248 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
249 | return S_OK; | |
250 | } | |
251 | ||
252 | ! HRESULT CCommands::XApplicationEvents::BuildFinish (long nNumErrors, long nNumWarnings) | |
253 | { | |
254 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
255 | return S_OK; | |
256 | } | |
257 | ||
258 | ! HRESULT CCommands::XApplicationEvents::BeforeApplicationShutDown () | |
259 | { | |
260 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
261 | return S_OK; | |
262 | } | |
263 | ||
264 | --- 139,159 ---- | |
265 | ||
266 | // Application events | |
267 | ||
268 | ! HRESULT CCommands::XApplicationEvents::BeforeBuildStart() | |
269 | { | |
270 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
271 | return S_OK; | |
272 | } | |
273 | ||
274 | ! HRESULT CCommands::XApplicationEvents::BuildFinish(long nNumErrors, long nNumWarnings) | |
275 | { | |
276 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
277 | return S_OK; | |
278 | } | |
279 | ||
280 | ! HRESULT CCommands::XApplicationEvents::BeforeApplicationShutDown() | |
281 | { | |
282 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
283 | return S_OK; | |
284 | } | |
285 | ||
286 | *************** | |
287 | *** 158,166 **** | |
288 | // is done. | |
289 | // Vim gets called from here. | |
290 | // | |
291 | ! HRESULT CCommands::XApplicationEvents::DocumentOpen (IDispatch * theDocument) | |
292 | { | |
293 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
294 | ||
295 | if (! g_bEnableVim) | |
296 | // Vim not enabled or empty command line entered | |
297 | --- 161,169 ---- | |
298 | // is done. | |
299 | // Vim gets called from here. | |
300 | // | |
301 | ! HRESULT CCommands::XApplicationEvents::DocumentOpen(IDispatch * theDocument) | |
302 | { | |
303 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
304 | ||
305 | if (! g_bEnableVim) | |
306 | // Vim not enabled or empty command line entered | |
307 | *************** | |
308 | *** 169,175 **** | |
309 | // First get the current file name and line number | |
310 | ||
311 | // Get the document object | |
312 | ! CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (theDocument); | |
313 | if (! pDoc) | |
314 | return S_OK; | |
315 | ||
316 | --- 172,178 ---- | |
317 | // First get the current file name and line number | |
318 | ||
319 | // Get the document object | |
320 | ! CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc(theDocument); | |
321 | if (! pDoc) | |
322 | return S_OK; | |
323 | ||
324 | *************** | |
325 | *** 177,202 **** | |
326 | long LineNr = -1; | |
327 | ||
328 | // Get the document name | |
329 | ! if (FAILED (pDoc->get_FullName (&FileName))) | |
330 | return S_OK; | |
331 | ||
332 | LPDISPATCH pDispSel; | |
333 | ||
334 | // Get a selection object dispatch pointer | |
335 | ! if (SUCCEEDED (pDoc->get_Selection (&pDispSel))) | |
336 | { | |
337 | // Get the selection object | |
338 | ! CComQIPtr < ITextSelection, &IID_ITextSelection > pSel (pDispSel); | |
339 | ||
340 | if (pSel) | |
341 | // Get the selection line number | |
342 | ! pSel->get_CurrentLine (&LineNr); | |
343 | ||
344 | ! pDispSel->Release (); | |
345 | } | |
346 | ||
347 | // Open the file in Vim and position to the current line | |
348 | ! if (VimOpenFile (FileName, LineNr)) | |
349 | { | |
350 | if (! g_bDevStudioEditor) | |
351 | { | |
352 | --- 180,205 ---- | |
353 | long LineNr = -1; | |
354 | ||
355 | // Get the document name | |
356 | ! if (FAILED(pDoc->get_FullName(&FileName))) | |
357 | return S_OK; | |
358 | ||
359 | LPDISPATCH pDispSel; | |
360 | ||
361 | // Get a selection object dispatch pointer | |
362 | ! if (SUCCEEDED(pDoc->get_Selection(&pDispSel))) | |
363 | { | |
364 | // Get the selection object | |
365 | ! CComQIPtr < ITextSelection, &IID_ITextSelection > pSel(pDispSel); | |
366 | ||
367 | if (pSel) | |
368 | // Get the selection line number | |
369 | ! pSel->get_CurrentLine(&LineNr); | |
370 | ||
371 | ! pDispSel->Release(); | |
372 | } | |
373 | ||
374 | // Open the file in Vim and position to the current line | |
375 | ! if (VimOpenFile(FileName, LineNr)) | |
376 | { | |
377 | if (! g_bDevStudioEditor) | |
378 | { | |
379 | *************** | |
380 | *** 204,233 **** | |
381 | CComVariant vSaveChanges = dsSaveChangesPrompt; | |
382 | DsSaveStatus Saved; | |
383 | ||
384 | ! pDoc->Close (vSaveChanges, &Saved); | |
385 | } | |
386 | } | |
387 | ||
388 | // We're done here | |
389 | ! SysFreeString (FileName); | |
390 | return S_OK; | |
391 | } | |
392 | ||
393 | ! HRESULT CCommands::XApplicationEvents::BeforeDocumentClose (IDispatch * theDocument) | |
394 | { | |
395 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
396 | return S_OK; | |
397 | } | |
398 | ||
399 | ! HRESULT CCommands::XApplicationEvents::DocumentSave (IDispatch * theDocument) | |
400 | { | |
401 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
402 | return S_OK; | |
403 | } | |
404 | ||
405 | ! HRESULT CCommands::XApplicationEvents::NewDocument (IDispatch * theDocument) | |
406 | { | |
407 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
408 | ||
409 | if (! g_bEnableVim) | |
410 | // Vim not enabled or empty command line entered | |
411 | --- 207,236 ---- | |
412 | CComVariant vSaveChanges = dsSaveChangesPrompt; | |
413 | DsSaveStatus Saved; | |
414 | ||
415 | ! pDoc->Close(vSaveChanges, &Saved); | |
416 | } | |
417 | } | |
418 | ||
419 | // We're done here | |
420 | ! SysFreeString(FileName); | |
421 | return S_OK; | |
422 | } | |
423 | ||
424 | ! HRESULT CCommands::XApplicationEvents::BeforeDocumentClose(IDispatch * theDocument) | |
425 | { | |
426 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
427 | return S_OK; | |
428 | } | |
429 | ||
430 | ! HRESULT CCommands::XApplicationEvents::DocumentSave(IDispatch * theDocument) | |
431 | { | |
432 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
433 | return S_OK; | |
434 | } | |
435 | ||
436 | ! HRESULT CCommands::XApplicationEvents::NewDocument(IDispatch * theDocument) | |
437 | { | |
438 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
439 | ||
440 | if (! g_bEnableVim) | |
441 | // Vim not enabled or empty command line entered | |
442 | *************** | |
443 | *** 235,253 **** | |
444 | ||
445 | // First get the current file name and line number | |
446 | ||
447 | ! CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (theDocument); | |
448 | if (! pDoc) | |
449 | return S_OK; | |
450 | ||
451 | BSTR FileName; | |
452 | HRESULT hr; | |
453 | ||
454 | ! hr = pDoc->get_FullName (&FileName); | |
455 | ! if (FAILED (hr)) | |
456 | return S_OK; | |
457 | ||
458 | // Open the file in Vim and position to the current line | |
459 | ! if (VimOpenFile (FileName, 0)) | |
460 | { | |
461 | if (! g_bDevStudioEditor) | |
462 | { | |
463 | --- 238,256 ---- | |
464 | ||
465 | // First get the current file name and line number | |
466 | ||
467 | ! CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc(theDocument); | |
468 | if (! pDoc) | |
469 | return S_OK; | |
470 | ||
471 | BSTR FileName; | |
472 | HRESULT hr; | |
473 | ||
474 | ! hr = pDoc->get_FullName(&FileName); | |
475 | ! if (FAILED(hr)) | |
476 | return S_OK; | |
477 | ||
478 | // Open the file in Vim and position to the current line | |
479 | ! if (VimOpenFile(FileName, 0)) | |
480 | { | |
481 | if (! g_bDevStudioEditor) | |
482 | { | |
483 | *************** | |
484 | *** 255,303 **** | |
485 | CComVariant vSaveChanges = dsSaveChangesPrompt; | |
486 | DsSaveStatus Saved; | |
487 | ||
488 | ! pDoc->Close (vSaveChanges, &Saved); | |
489 | } | |
490 | } | |
491 | ||
492 | ! SysFreeString (FileName); | |
493 | return S_OK; | |
494 | } | |
495 | ||
496 | ! HRESULT CCommands::XApplicationEvents::WindowActivate (IDispatch * theWindow) | |
497 | { | |
498 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
499 | return S_OK; | |
500 | } | |
501 | ||
502 | ! HRESULT CCommands::XApplicationEvents::WindowDeactivate (IDispatch * theWindow) | |
503 | { | |
504 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
505 | return S_OK; | |
506 | } | |
507 | ||
508 | ! HRESULT CCommands::XApplicationEvents::WorkspaceOpen () | |
509 | { | |
510 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
511 | return S_OK; | |
512 | } | |
513 | ||
514 | ! HRESULT CCommands::XApplicationEvents::WorkspaceClose () | |
515 | { | |
516 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
517 | return S_OK; | |
518 | } | |
519 | ||
520 | ! HRESULT CCommands::XApplicationEvents::NewWorkspace () | |
521 | { | |
522 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
523 | return S_OK; | |
524 | } | |
525 | ||
526 | // Debugger event | |
527 | ||
528 | ! HRESULT CCommands::XDebuggerEvents::BreakpointHit (IDispatch * pBreakpoint) | |
529 | { | |
530 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
531 | return S_OK; | |
532 | } | |
533 | ||
534 | --- 258,306 ---- | |
535 | CComVariant vSaveChanges = dsSaveChangesPrompt; | |
536 | DsSaveStatus Saved; | |
537 | ||
538 | ! pDoc->Close(vSaveChanges, &Saved); | |
539 | } | |
540 | } | |
541 | ||
542 | ! SysFreeString(FileName); | |
543 | return S_OK; | |
544 | } | |
545 | ||
546 | ! HRESULT CCommands::XApplicationEvents::WindowActivate(IDispatch * theWindow) | |
547 | { | |
548 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
549 | return S_OK; | |
550 | } | |
551 | ||
552 | ! HRESULT CCommands::XApplicationEvents::WindowDeactivate(IDispatch * theWindow) | |
553 | { | |
554 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
555 | return S_OK; | |
556 | } | |
557 | ||
558 | ! HRESULT CCommands::XApplicationEvents::WorkspaceOpen() | |
559 | { | |
560 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
561 | return S_OK; | |
562 | } | |
563 | ||
564 | ! HRESULT CCommands::XApplicationEvents::WorkspaceClose() | |
565 | { | |
566 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
567 | return S_OK; | |
568 | } | |
569 | ||
570 | ! HRESULT CCommands::XApplicationEvents::NewWorkspace() | |
571 | { | |
572 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
573 | return S_OK; | |
574 | } | |
575 | ||
576 | // Debugger event | |
577 | ||
578 | ! HRESULT CCommands::XDebuggerEvents::BreakpointHit(IDispatch * pBreakpoint) | |
579 | { | |
580 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
581 | return S_OK; | |
582 | } | |
583 | ||
584 | *************** | |
585 | *** 308,324 **** | |
586 | class CMainDialog : public CDialog | |
587 | { | |
588 | public: | |
589 | ! CMainDialog (CWnd * pParent = NULL); // Standard constructor | |
590 | ||
591 | //{{AFX_DATA(CMainDialog) | |
592 | enum { IDD = IDD_ADDINMAIN }; | |
593 | int m_ChangeDir; | |
594 | BOOL m_bDevStudioEditor; | |
595 | //}}AFX_DATA | |
596 | ||
597 | //{{AFX_VIRTUAL(CMainDialog) | |
598 | protected: | |
599 | ! virtual void DoDataExchange (CDataExchange * pDX); // DDX/DDV support | |
600 | //}}AFX_VIRTUAL | |
601 | ||
602 | protected: | |
603 | --- 311,328 ---- | |
604 | class CMainDialog : public CDialog | |
605 | { | |
606 | public: | |
607 | ! CMainDialog(CWnd * pParent = NULL); // Standard constructor | |
608 | ||
609 | //{{AFX_DATA(CMainDialog) | |
610 | enum { IDD = IDD_ADDINMAIN }; | |
611 | int m_ChangeDir; | |
612 | BOOL m_bDevStudioEditor; | |
613 | + BOOL m_bNewTabs; | |
614 | //}}AFX_DATA | |
615 | ||
616 | //{{AFX_VIRTUAL(CMainDialog) | |
617 | protected: | |
618 | ! virtual void DoDataExchange(CDataExchange * pDX); // DDX/DDV support | |
619 | //}}AFX_VIRTUAL | |
620 | ||
621 | protected: | |
622 | *************** | |
623 | *** 326,425 **** | |
624 | afx_msg void OnEnable(); | |
625 | afx_msg void OnDisable(); | |
626 | //}}AFX_MSG | |
627 | ! DECLARE_MESSAGE_MAP () | |
628 | }; | |
629 | ||
630 | ! CMainDialog::CMainDialog (CWnd * pParent /* =NULL */ ) | |
631 | ! : CDialog (CMainDialog::IDD, pParent) | |
632 | { | |
633 | //{{AFX_DATA_INIT(CMainDialog) | |
634 | m_ChangeDir = -1; | |
635 | m_bDevStudioEditor = FALSE; | |
636 | //}}AFX_DATA_INIT | |
637 | } | |
638 | ||
639 | ! void CMainDialog::DoDataExchange (CDataExchange * pDX) | |
640 | { | |
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); | |
645 | //}}AFX_DATA_MAP | |
646 | } | |
647 | ||
648 | ! BEGIN_MESSAGE_MAP (CMainDialog, CDialog) | |
649 | //{{AFX_MSG_MAP(CMainDialog) | |
650 | //}}AFX_MSG_MAP | |
651 | ! END_MESSAGE_MAP () | |
652 | ||
653 | ||
654 | ///////////////////////////////////////////////////////////////////////////// | |
655 | // CCommands methods | |
656 | ||
657 | ! STDMETHODIMP CCommands::VisVimDialog () | |
658 | { | |
659 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
660 | ||
661 | // Use m_pApplication to access the Developer Studio Application | |
662 | // object, | |
663 | // and VERIFY_OK to see error strings in DEBUG builds of your add-in | |
664 | // (see stdafx.h) | |
665 | ||
666 | ! VERIFY_OK (m_pApplication->EnableModeless (VARIANT_FALSE)); | |
667 | ||
668 | CMainDialog Dlg; | |
669 | ||
670 | Dlg.m_bDevStudioEditor = g_bDevStudioEditor; | |
671 | Dlg.m_ChangeDir = g_ChangeDir; | |
672 | ! if (Dlg.DoModal () == IDOK) | |
673 | { | |
674 | g_bDevStudioEditor = Dlg.m_bDevStudioEditor; | |
675 | g_ChangeDir = Dlg.m_ChangeDir; | |
676 | ||
677 | // Save settings to registry HKEY_CURRENT_USER\Software\Vim\VisVim | |
678 | ! HKEY hAppKey = GetAppKey ("Vim"); | |
679 | if (hAppKey) | |
680 | { | |
681 | ! HKEY hSectionKey = GetSectionKey (hAppKey, "VisVim"); | |
682 | if (hSectionKey) | |
683 | { | |
684 | ! WriteRegistryInt (hSectionKey, "DevStudioEditor", | |
685 | g_bDevStudioEditor); | |
686 | ! WriteRegistryInt (hSectionKey, "ChangeDir", g_ChangeDir); | |
687 | ! RegCloseKey (hSectionKey); | |
688 | } | |
689 | ! RegCloseKey (hAppKey); | |
690 | } | |
691 | } | |
692 | ||
693 | ! VERIFY_OK (m_pApplication->EnableModeless (VARIANT_TRUE)); | |
694 | return S_OK; | |
695 | } | |
696 | ||
697 | ! STDMETHODIMP CCommands::VisVimEnable () | |
698 | { | |
699 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
700 | ! VimSetEnableState (true); | |
701 | return S_OK; | |
702 | } | |
703 | ||
704 | ! STDMETHODIMP CCommands::VisVimDisable () | |
705 | { | |
706 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
707 | ! VimSetEnableState (false); | |
708 | return S_OK; | |
709 | } | |
710 | ||
711 | ! STDMETHODIMP CCommands::VisVimToggle () | |
712 | { | |
713 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
714 | ! VimSetEnableState (! g_bEnableVim); | |
715 | return S_OK; | |
716 | } | |
717 | ||
718 | ! STDMETHODIMP CCommands::VisVimLoad () | |
719 | { | |
720 | ! AFX_MANAGE_STATE (AfxGetStaticModuleState ()); | |
721 | ||
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 | |
724 | --- 330,435 ---- | |
725 | afx_msg void OnEnable(); | |
726 | afx_msg void OnDisable(); | |
727 | //}}AFX_MSG | |
728 | ! DECLARE_MESSAGE_MAP() | |
729 | }; | |
730 | ||
731 | ! CMainDialog::CMainDialog(CWnd * pParent /* =NULL */ ) | |
732 | ! : CDialog(CMainDialog::IDD, pParent) | |
733 | { | |
734 | //{{AFX_DATA_INIT(CMainDialog) | |
735 | m_ChangeDir = -1; | |
736 | m_bDevStudioEditor = FALSE; | |
737 | + m_bNewTabs = FALSE; | |
738 | //}}AFX_DATA_INIT | |
739 | } | |
740 | ||
741 | ! void CMainDialog::DoDataExchange(CDataExchange * pDX) | |
742 | { | |
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); | |
748 | //}}AFX_DATA_MAP | |
749 | } | |
750 | ||
751 | ! BEGIN_MESSAGE_MAP(CMainDialog, CDialog) | |
752 | //{{AFX_MSG_MAP(CMainDialog) | |
753 | //}}AFX_MSG_MAP | |
754 | ! END_MESSAGE_MAP() | |
755 | ||
756 | ||
757 | ///////////////////////////////////////////////////////////////////////////// | |
758 | // CCommands methods | |
759 | ||
760 | ! STDMETHODIMP CCommands::VisVimDialog() | |
761 | { | |
762 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
763 | ||
764 | // Use m_pApplication to access the Developer Studio Application | |
765 | // object, | |
766 | // and VERIFY_OK to see error strings in DEBUG builds of your add-in | |
767 | // (see stdafx.h) | |
768 | ||
769 | ! VERIFY_OK(m_pApplication->EnableModeless(VARIANT_FALSE)); | |
770 | ||
771 | CMainDialog Dlg; | |
772 | ||
773 | Dlg.m_bDevStudioEditor = g_bDevStudioEditor; | |
774 | + Dlg.m_bNewTabs = g_bNewTabs; | |
775 | Dlg.m_ChangeDir = g_ChangeDir; | |
776 | ! if (Dlg.DoModal() == IDOK) | |
777 | { | |
778 | g_bDevStudioEditor = Dlg.m_bDevStudioEditor; | |
779 | + g_bNewTabs = Dlg.m_bNewTabs; | |
780 | g_ChangeDir = Dlg.m_ChangeDir; | |
781 | ||
782 | // Save settings to registry HKEY_CURRENT_USER\Software\Vim\VisVim | |
783 | ! HKEY hAppKey = GetAppKey("Vim"); | |
784 | if (hAppKey) | |
785 | { | |
786 | ! HKEY hSectionKey = GetSectionKey(hAppKey, "VisVim"); | |
787 | if (hSectionKey) | |
788 | { | |
789 | ! WriteRegistryInt(hSectionKey, "DevStudioEditor", | |
790 | g_bDevStudioEditor); | |
791 | ! WriteRegistryInt(hSectionKey, "NewTabs", | |
792 | ! g_bNewTabs); | |
793 | ! WriteRegistryInt(hSectionKey, "ChangeDir", g_ChangeDir); | |
794 | ! RegCloseKey(hSectionKey); | |
795 | } | |
796 | ! RegCloseKey(hAppKey); | |
797 | } | |
798 | } | |
799 | ||
800 | ! VERIFY_OK(m_pApplication->EnableModeless(VARIANT_TRUE)); | |
801 | return S_OK; | |
802 | } | |
803 | ||
804 | ! STDMETHODIMP CCommands::VisVimEnable() | |
805 | { | |
806 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
807 | ! VimSetEnableState(true); | |
808 | return S_OK; | |
809 | } | |
810 | ||
811 | ! STDMETHODIMP CCommands::VisVimDisable() | |
812 | { | |
813 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
814 | ! VimSetEnableState(false); | |
815 | return S_OK; | |
816 | } | |
817 | ||
818 | ! STDMETHODIMP CCommands::VisVimToggle() | |
819 | { | |
820 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
821 | ! VimSetEnableState(! g_bEnableVim); | |
822 | return S_OK; | |
823 | } | |
824 | ||
825 | ! STDMETHODIMP CCommands::VisVimLoad() | |
826 | { | |
827 | ! AFX_MANAGE_STATE(AfxGetStaticModuleState()); | |
828 | ||
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 | |
831 | *************** | |
832 | *** 430,436 **** | |
833 | CComPtr < IDispatch > pDispDoc, pDispSel; | |
834 | ||
835 | // Get a document object dispatch pointer | |
836 | ! VERIFY_OK (m_pApplication->get_ActiveDocument (&pDispDoc)); | |
837 | if (! pDispDoc) | |
838 | return S_OK; | |
839 | ||
840 | --- 440,446 ---- | |
841 | CComPtr < IDispatch > pDispDoc, pDispSel; | |
842 | ||
843 | // Get a document object dispatch pointer | |
844 | ! VERIFY_OK(m_pApplication->get_ActiveDocument(&pDispDoc)); | |
845 | if (! pDispDoc) | |
846 | return S_OK; | |
847 | ||
848 | *************** | |
849 | *** 438,467 **** | |
850 | long LineNr = -1; | |
851 | ||
852 | // Get the document object | |
853 | ! CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (pDispDoc); | |
854 | ||
855 | if (! pDoc) | |
856 | return S_OK; | |
857 | ||
858 | // Get the document name | |
859 | ! if (FAILED (pDoc->get_FullName (&FileName))) | |
860 | return S_OK; | |
861 | ||
862 | // Get a selection object dispatch pointer | |
863 | ! if (SUCCEEDED (pDoc->get_Selection (&pDispSel))) | |
864 | { | |
865 | // Get the selection object | |
866 | ! CComQIPtr < ITextSelection, &IID_ITextSelection > pSel (pDispSel); | |
867 | ||
868 | if (pSel) | |
869 | // Get the selection line number | |
870 | ! pSel->get_CurrentLine (&LineNr); | |
871 | } | |
872 | ||
873 | // Open the file in Vim | |
874 | ! VimOpenFile (FileName, LineNr); | |
875 | ||
876 | ! SysFreeString (FileName); | |
877 | return S_OK; | |
878 | } | |
879 | ||
880 | --- 448,477 ---- | |
881 | long LineNr = -1; | |
882 | ||
883 | // Get the document object | |
884 | ! CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc(pDispDoc); | |
885 | ||
886 | if (! pDoc) | |
887 | return S_OK; | |
888 | ||
889 | // Get the document name | |
890 | ! if (FAILED(pDoc->get_FullName(&FileName))) | |
891 | return S_OK; | |
892 | ||
893 | // Get a selection object dispatch pointer | |
894 | ! if (SUCCEEDED(pDoc->get_Selection(&pDispSel))) | |
895 | { | |
896 | // Get the selection object | |
897 | ! CComQIPtr < ITextSelection, &IID_ITextSelection > pSel(pDispSel); | |
898 | ||
899 | if (pSel) | |
900 | // Get the selection line number | |
901 | ! pSel->get_CurrentLine(&LineNr); | |
902 | } | |
903 | ||
904 | // Open the file in Vim | |
905 | ! VimOpenFile(FileName, LineNr); | |
906 | ||
907 | ! SysFreeString(FileName); | |
908 | return S_OK; | |
909 | } | |
910 | ||
911 | *************** | |
912 | *** 472,487 **** | |
913 | ||
914 | // Set the enable state and save to registry | |
915 | // | |
916 | ! static void VimSetEnableState (BOOL bEnableState) | |
917 | { | |
918 | g_bEnableVim = bEnableState; | |
919 | ! HKEY hAppKey = GetAppKey ("Vim"); | |
920 | if (hAppKey) | |
921 | { | |
922 | ! HKEY hSectionKey = GetSectionKey (hAppKey, "VisVim"); | |
923 | if (hSectionKey) | |
924 | ! WriteRegistryInt (hSectionKey, "EnableVim", g_bEnableVim); | |
925 | ! RegCloseKey (hAppKey); | |
926 | } | |
927 | } | |
928 | ||
929 | --- 482,497 ---- | |
930 | ||
931 | // Set the enable state and save to registry | |
932 | // | |
933 | ! static void VimSetEnableState(BOOL bEnableState) | |
934 | { | |
935 | g_bEnableVim = bEnableState; | |
936 | ! HKEY hAppKey = GetAppKey("Vim"); | |
937 | if (hAppKey) | |
938 | { | |
939 | ! HKEY hSectionKey = GetSectionKey(hAppKey, "VisVim"); | |
940 | if (hSectionKey) | |
941 | ! WriteRegistryInt(hSectionKey, "EnableVim", g_bEnableVim); | |
942 | ! RegCloseKey(hAppKey); | |
943 | } | |
944 | } | |
945 | ||
946 | *************** | |
947 | *** 490,496 **** | |
948 | // letter. | |
949 | // 'LineNr' must contain a valid line number or 0, e. g. for a new file | |
950 | // | |
951 | ! static BOOL VimOpenFile (BSTR& FileName, long LineNr) | |
952 | { | |
953 | ||
954 | // OLE automation object for com. with Vim | |
955 | --- 500,506 ---- | |
956 | // letter. | |
957 | // 'LineNr' must contain a valid line number or 0, e. g. for a new file | |
958 | // | |
959 | ! static BOOL VimOpenFile(BSTR& FileName, long LineNr) | |
960 | { | |
961 | ||
962 | // OLE automation object for com. with Vim | |
963 | *************** | |
964 | *** 507,513 **** | |
965 | // Get a dispatch id for the SendKeys method of Vim; | |
966 | // enables connection to Vim if necessary | |
967 | DISPID DispatchId; | |
968 | ! DispatchId = VimGetDispatchId (VimOle, "SendKeys"); | |
969 | if (! DispatchId) | |
970 | // OLE error, can't obtain dispatch id | |
971 | goto OleError; | |
972 | --- 517,523 ---- | |
973 | // Get a dispatch id for the SendKeys method of Vim; | |
974 | // enables connection to Vim if necessary | |
975 | DISPID DispatchId; | |
976 | ! DispatchId = VimGetDispatchId(VimOle, "SendKeys"); | |
977 | if (! DispatchId) | |
978 | // OLE error, can't obtain dispatch id | |
979 | goto OleError; | |
980 | *************** | |
981 | *** 525,544 **** | |
982 | #ifdef SINGLE_WINDOW | |
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"); | |
986 | #endif | |
987 | ! if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf))) | |
988 | goto OleError; | |
989 | ||
990 | // Change Vim working directory to where the file is if desired | |
991 | if (g_ChangeDir != CD_NONE) | |
992 | ! VimChangeDir (VimOle, DispatchId, FileName); | |
993 | ||
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); | |
998 | - s = VimCmd + 6; | |
999 | for (p = FileNameTmp; *p != '\0' && s < FileNameTmp + MAX_OLE_STR - 4; | |
1000 | ++p) | |
1001 | if (*p == '\\') | |
1002 | --- 535,562 ---- | |
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"); | |
1007 | #endif | |
1008 | ! if (! VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf))) | |
1009 | goto OleError; | |
1010 | ||
1011 | // Change Vim working directory to where the file is if desired | |
1012 | if (g_ChangeDir != CD_NONE) | |
1013 | ! VimChangeDir(VimOle, DispatchId, FileName); | |
1014 | ||
1015 | // Make Vim open the file. | |
1016 | // In the filename convert all \ to /, put a \ before a space. | |
1017 | ! if (g_bNewTabs) | |
1018 | ! { | |
1019 | ! sprintf(VimCmd, ":tab drop "); | |
1020 | ! s = VimCmd + 11; | |
1021 | ! } | |
1022 | ! else | |
1023 | ! { | |
1024 | ! sprintf(VimCmd, ":drop "); | |
1025 | ! s = VimCmd + 6; | |
1026 | ! } | |
1027 | sprintf(FileNameTmp, "%S", (char *)FileName); | |
1028 | for (p = FileNameTmp; *p != '\0' && s < FileNameTmp + MAX_OLE_STR - 4; | |
1029 | ++p) | |
1030 | if (*p == '\\') | |
1031 | *************** | |
1032 | *** 552,571 **** | |
1033 | *s++ = '\n'; | |
1034 | *s = '\0'; | |
1035 | ||
1036 | ! if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf))) | |
1037 | goto OleError; | |
1038 | ||
1039 | if (LineNr > 0) | |
1040 | { | |
1041 | // Goto line | |
1042 | ! sprintf (VimCmd, ":%d\n", LineNr); | |
1043 | ! if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf))) | |
1044 | goto OleError; | |
1045 | } | |
1046 | ||
1047 | // Make Vim come to the foreground | |
1048 | ! if (! VimOle.Method ("SetForeground")) | |
1049 | ! VimOle.ErrDiag (); | |
1050 | ||
1051 | // We're done | |
1052 | return true; | |
1053 | --- 570,589 ---- | |
1054 | *s++ = '\n'; | |
1055 | *s = '\0'; | |
1056 | ||
1057 | ! if (! VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf))) | |
1058 | goto OleError; | |
1059 | ||
1060 | if (LineNr > 0) | |
1061 | { | |
1062 | // Goto line | |
1063 | ! sprintf(VimCmd, ":%d\n", LineNr); | |
1064 | ! if (! VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf))) | |
1065 | goto OleError; | |
1066 | } | |
1067 | ||
1068 | // Make Vim come to the foreground | |
1069 | ! if (! VimOle.Method("SetForeground")) | |
1070 | ! VimOle.ErrDiag(); | |
1071 | ||
1072 | // We're done | |
1073 | return true; | |
1074 | *************** | |
1075 | *** 573,579 **** | |
1076 | OleError: | |
1077 | // There was an OLE error | |
1078 | // Check if it's the "unknown class string" error | |
1079 | ! VimErrDiag (VimOle); | |
1080 | return false; | |
1081 | } | |
1082 | ||
1083 | --- 591,597 ---- | |
1084 | OleError: | |
1085 | // There was an OLE error | |
1086 | // Check if it's the "unknown class string" error | |
1087 | ! VimErrDiag(VimOle); | |
1088 | return false; | |
1089 | } | |
1090 | ||
1091 | *************** | |
1092 | *** 581,598 **** | |
1093 | // Create the Vim OLE object if necessary | |
1094 | // Returns a valid dispatch id or null on error | |
1095 | // | |
1096 | ! static DISPID VimGetDispatchId (COleAutomationControl& VimOle, char* Method) | |
1097 | { | |
1098 | // Initialize Vim OLE connection if not already done | |
1099 | ! if (! VimOle.IsCreated ()) | |
1100 | { | |
1101 | ! if (! VimOle.CreateObject ("Vim.Application")) | |
1102 | return NULL; | |
1103 | } | |
1104 | ||
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"); | |
1108 | if (! DispatchId) | |
1109 | { | |
1110 | // We can't get a dispatch id. | |
1111 | --- 599,616 ---- | |
1112 | // Create the Vim OLE object if necessary | |
1113 | // Returns a valid dispatch id or null on error | |
1114 | // | |
1115 | ! static DISPID VimGetDispatchId(COleAutomationControl& VimOle, char* Method) | |
1116 | { | |
1117 | // Initialize Vim OLE connection if not already done | |
1118 | ! if (! VimOle.IsCreated()) | |
1119 | { | |
1120 | ! if (! VimOle.CreateObject("Vim.Application")) | |
1121 | return NULL; | |
1122 | } | |
1123 | ||
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"); | |
1127 | if (! DispatchId) | |
1128 | { | |
1129 | // We can't get a dispatch id. | |
1130 | *************** | |
1131 | *** 604,615 **** | |
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 | |
1138 | return NULL; | |
1139 | ||
1140 | ! if (! (DispatchId = VimOle.GetDispatchId ("SendKeys"))) | |
1141 | // There is something wrong... | |
1142 | return NULL; | |
1143 | } | |
1144 | --- 622,633 ---- | |
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 | |
1151 | return NULL; | |
1152 | ||
1153 | ! if (! (DispatchId = VimOle.GetDispatchId("SendKeys"))) | |
1154 | // There is something wrong... | |
1155 | return NULL; | |
1156 | } | |
1157 | *************** | |
1158 | *** 620,639 **** | |
1159 | // Output an error message for an OLE error | |
1160 | // Check on the classstring error, which probably means Vim wasn't registered. | |
1161 | // | |
1162 | ! static void VimErrDiag (COleAutomationControl& VimOle) | |
1163 | { | |
1164 | ! SCODE sc = GetScode (VimOle.GetResult ()); | |
1165 | if (sc == CO_E_CLASSSTRING) | |
1166 | { | |
1167 | char Buf[256]; | |
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); | |
1173 | } | |
1174 | else | |
1175 | ! VimOle.ErrDiag (); | |
1176 | } | |
1177 | ||
1178 | // Change directory to the directory the file 'FileName' is in or it's parent | |
1179 | --- 638,657 ---- | |
1180 | // Output an error message for an OLE error | |
1181 | // Check on the classstring error, which probably means Vim wasn't registered. | |
1182 | // | |
1183 | ! static void VimErrDiag(COleAutomationControl& VimOle) | |
1184 | { | |
1185 | ! SCODE sc = GetScode(VimOle.GetResult()); | |
1186 | if (sc == CO_E_CLASSSTRING) | |
1187 | { | |
1188 | char Buf[256]; | |
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); | |
1194 | } | |
1195 | else | |
1196 | ! VimOle.ErrDiag(); | |
1197 | } | |
1198 | ||
1199 | // Change directory to the directory the file 'FileName' is in or it's parent | |
1200 | *************** | |
1201 | *** 644,650 **** | |
1202 | // CD_SOURCE_PATH | |
1203 | // CD_SOURCE_PARENT | |
1204 | // | |
1205 | ! static void VimChangeDir (COleAutomationControl& VimOle, DISPID DispatchId, BSTR& FileName) | |
1206 | { | |
1207 | // Do a :cd first | |
1208 | ||
1209 | --- 662,668 ---- | |
1210 | // CD_SOURCE_PATH | |
1211 | // CD_SOURCE_PARENT | |
1212 | // | |
1213 | ! static void VimChangeDir(COleAutomationControl& VimOle, DISPID DispatchId, BSTR& FileName) | |
1214 | { | |
1215 | // Do a :cd first | |
1216 | ||
1217 | *************** | |
1218 | *** 655,661 **** | |
1219 | char DirUnix[_MAX_DIR * 2]; | |
1220 | char *s, *t; | |
1221 | ||
1222 | ! _splitpath (StrFileName, Drive, Dir, NULL, NULL); | |
1223 | ||
1224 | // Convert to Unix path name format, escape spaces. | |
1225 | t = DirUnix; | |
1226 | --- 673,679 ---- | |
1227 | char DirUnix[_MAX_DIR * 2]; | |
1228 | char *s, *t; | |
1229 | ||
1230 | ! _splitpath(StrFileName, Drive, Dir, NULL, NULL); | |
1231 | ||
1232 | // Convert to Unix path name format, escape spaces. | |
1233 | t = DirUnix; | |
1234 | *************** | |
1235 | *** 676,694 **** | |
1236 | OLECHAR Buf[MAX_OLE_STR]; | |
1237 | char VimCmd[MAX_OLE_STR]; | |
1238 | ||
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)); | |
1242 | } | |
1243 | ||
1244 | #ifdef _DEBUG | |
1245 | // Print out a debug message | |
1246 | // | |
1247 | ! static void DebugMsg (char* Msg, char* Arg) | |
1248 | { | |
1249 | char Buf[400]; | |
1250 | ! sprintf (Buf, Msg, Arg); | |
1251 | ! AfxMessageBox (Buf); | |
1252 | } | |
1253 | #endif | |
1254 | - | |
1255 | --- 694,711 ---- | |
1256 | OLECHAR Buf[MAX_OLE_STR]; | |
1257 | char VimCmd[MAX_OLE_STR]; | |
1258 | ||
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)); | |
1262 | } | |
1263 | ||
1264 | #ifdef _DEBUG | |
1265 | // Print out a debug message | |
1266 | // | |
1267 | ! static void DebugMsg(char* Msg, char* Arg) | |
1268 | { | |
1269 | char Buf[400]; | |
1270 | ! sprintf(Buf, Msg, Arg); | |
1271 | ! AfxMessageBox(Buf); | |
1272 | } | |
1273 | #endif | |
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 | |
1276 | *************** | |
1277 | *** 16,21 **** | |
1278 | --- 16,22 ---- | |
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 | |
1283 | ||
1284 | // Next default values for new objects | |
1285 | // | |
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 | |
1288 | *************** | |
1289 | *** 122,127 **** | |
1290 | --- 122,130 ---- | |
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 | |
1302 | *************** | |
1303 | *** 678,679 **** | |
1304 | --- 678,681 ---- | |
1305 | { /* Add new patch number below this line */ | |
1306 | + /**/ | |
1307 | + 150, | |
1308 | /**/ | |
1309 | ||
1310 | -- | |
1311 | A poem: read aloud: | |
1312 | ||
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. | |
1319 | ||
1320 | Fred Bremmer and Steve Kroese (Calvin College & Seminary of Grand Rapids, MI.) | |
1321 | ||
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 /// |