comparison src/gui_w32.c @ 18788:e1f4e9d78a6a v8.1.2383

patch 8.1.2383: using old C style comments Commit: https://github.com/vim/vim/commit/734a867ffe198886da7365b618be67ab8ed9d9f6 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 2 22:49:38 2019 +0100 patch 8.1.2383: using old C style comments Problem: Using old C style comments. Solution: Use // comments where appropriate.
author Bram Moolenaar <Bram@vim.org>
date Mon, 02 Dec 2019 23:00:04 +0100
parents 38a3bef525e6
children 3ff714d765ba
comparison
equal deleted inserted replaced
18787:06ed2fe62dce 18788:e1f4e9d78a6a
56 float dx_level = 0.0f; 56 float dx_level = 0.0f;
57 int dx_geom = 0; 57 int dx_geom = 0;
58 int dx_renmode = 0; 58 int dx_renmode = 0;
59 int dx_taamode = 0; 59 int dx_taamode = 0;
60 60
61 /* parse string as rendering options. */ 61 // parse string as rendering options.
62 for (p = s; p != NULL && *p != NUL; ) 62 for (p = s; p != NULL && *p != NUL; )
63 { 63 {
64 char_u item[256]; 64 char_u item[256];
65 char_u name[128]; 65 char_u name[128];
66 char_u value[128]; 66 char_u value[128];
117 if (dx_taamode < 0 || dx_taamode > 3) 117 if (dx_taamode < 0 || dx_taamode > 3)
118 return FAIL; 118 return FAIL;
119 } 119 }
120 else if (STRCMP(name, "scrlines") == 0) 120 else if (STRCMP(name, "scrlines") == 0)
121 { 121 {
122 /* Deprecated. Simply ignore it. */ 122 // Deprecated. Simply ignore it.
123 } 123 }
124 else 124 else
125 return FAIL; 125 return FAIL;
126 } 126 }
127 127
128 if (!gui.in_use) 128 if (!gui.in_use)
129 return OK; /* only checking the syntax of the value */ 129 return OK; // only checking the syntax of the value
130 130
131 /* Enable DirectX/DirectWrite */ 131 // Enable DirectX/DirectWrite
132 if (dx_enable) 132 if (dx_enable)
133 { 133 {
134 if (!directx_enabled()) 134 if (!directx_enabled())
135 return FAIL; 135 return FAIL;
136 DWriteContext_SetRenderingParams(s_dwc, NULL); 136 DWriteContext_SetRenderingParams(s_dwc, NULL);
177 # define HANDLE_WM_XBUTTONDBLCLK(hwnd, wParam, lParam, fn) \ 177 # define HANDLE_WM_XBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
178 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L) 178 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
179 #endif 179 #endif
180 180
181 181
182 #include "version.h" /* used by dialog box routine for default title */ 182 #include "version.h" // used by dialog box routine for default title
183 #ifdef DEBUG 183 #ifdef DEBUG
184 # include <tchar.h> 184 # include <tchar.h>
185 #endif 185 #endif
186 186
187 /* cproto fails on missing include files */ 187 // cproto fails on missing include files
188 #ifndef PROTO 188 #ifndef PROTO
189 189
190 # ifndef __MINGW32__ 190 # ifndef __MINGW32__
191 # include <shellapi.h> 191 # include <shellapi.h>
192 # endif 192 # endif
197 197
198 # ifdef GLOBAL_IME 198 # ifdef GLOBAL_IME
199 # include "glbl_ime.h" 199 # include "glbl_ime.h"
200 # endif 200 # endif
201 201
202 #endif /* PROTO */ 202 #endif // PROTO
203 203
204 #ifdef FEAT_MENU 204 #ifdef FEAT_MENU
205 # define MENUHINTS /* show menu hints in command line */ 205 # define MENUHINTS // show menu hints in command line
206 #endif 206 #endif
207 207
208 /* Some parameters for dialog boxes. All in pixels. */ 208 // Some parameters for dialog boxes. All in pixels.
209 #define DLG_PADDING_X 10 209 #define DLG_PADDING_X 10
210 #define DLG_PADDING_Y 10 210 #define DLG_PADDING_Y 10
211 #define DLG_OLD_STYLE_PADDING_X 5 211 #define DLG_OLD_STYLE_PADDING_X 5
212 #define DLG_OLD_STYLE_PADDING_Y 5 212 #define DLG_OLD_STYLE_PADDING_Y 5
213 #define DLG_VERT_PADDING_X 4 /* For vertical buttons */ 213 #define DLG_VERT_PADDING_X 4 // For vertical buttons
214 #define DLG_VERT_PADDING_Y 4 214 #define DLG_VERT_PADDING_Y 4
215 #define DLG_ICON_WIDTH 34 215 #define DLG_ICON_WIDTH 34
216 #define DLG_ICON_HEIGHT 34 216 #define DLG_ICON_HEIGHT 34
217 #define DLG_MIN_WIDTH 150 217 #define DLG_MIN_WIDTH 150
218 #define DLG_FONT_NAME "MS Sans Serif" 218 #define DLG_FONT_NAME "MS Sans Serif"
219 #define DLG_FONT_POINT_SIZE 8 219 #define DLG_FONT_POINT_SIZE 8
220 #define DLG_MIN_MAX_WIDTH 400 220 #define DLG_MIN_MAX_WIDTH 400
221 #define DLG_MIN_MAX_HEIGHT 400 221 #define DLG_MIN_MAX_HEIGHT 400
222 222
223 #define DLG_NONBUTTON_CONTROL 5000 /* First ID of non-button controls */ 223 #define DLG_NONBUTTON_CONTROL 5000 // First ID of non-button controls
224 224
225 #ifndef WM_XBUTTONDOWN /* For Win2K / winME ONLY */ 225 #ifndef WM_XBUTTONDOWN // For Win2K / winME ONLY
226 # define WM_XBUTTONDOWN 0x020B 226 # define WM_XBUTTONDOWN 0x020B
227 # define WM_XBUTTONUP 0x020C 227 # define WM_XBUTTONUP 0x020C
228 # define WM_XBUTTONDBLCLK 0x020D 228 # define WM_XBUTTONDBLCLK 0x020D
229 # define MK_XBUTTON1 0x0020 229 # define MK_XBUTTON1 0x0020
230 # define MK_XBUTTON2 0x0040 230 # define MK_XBUTTON2 0x0040
293 293
294 static void _OnPaint( HWND hwnd); 294 static void _OnPaint( HWND hwnd);
295 static void fill_rect(const RECT *rcp, HBRUSH hbr, COLORREF color); 295 static void fill_rect(const RECT *rcp, HBRUSH hbr, COLORREF color);
296 static void clear_rect(RECT *rcp); 296 static void clear_rect(RECT *rcp);
297 297
298 static WORD s_dlgfntheight; /* height of the dialog font */ 298 static WORD s_dlgfntheight; // height of the dialog font
299 static WORD s_dlgfntwidth; /* width of the dialog font */ 299 static WORD s_dlgfntwidth; // width of the dialog font
300 300
301 #ifdef FEAT_MENU 301 #ifdef FEAT_MENU
302 static HMENU s_menuBar = NULL; 302 static HMENU s_menuBar = NULL;
303 #endif 303 #endif
304 #ifdef FEAT_TEAROFF 304 #ifdef FEAT_TEAROFF
305 static void rebuild_tearoff(vimmenu_T *menu); 305 static void rebuild_tearoff(vimmenu_T *menu);
306 static HBITMAP s_htearbitmap; /* bitmap used to indicate tearoff */ 306 static HBITMAP s_htearbitmap; // bitmap used to indicate tearoff
307 #endif 307 #endif
308 308
309 /* Flag that is set while processing a message that must not be interrupted by 309 // Flag that is set while processing a message that must not be interrupted by
310 * processing another message. */ 310 // processing another message.
311 static int s_busy_processing = FALSE; 311 static int s_busy_processing = FALSE;
312 312
313 static int destroying = FALSE; /* call DestroyWindow() ourselves */ 313 static int destroying = FALSE; // call DestroyWindow() ourselves
314 314
315 #ifdef MSWIN_FIND_REPLACE 315 #ifdef MSWIN_FIND_REPLACE
316 static UINT s_findrep_msg = 0; // set in gui_w[16/32].c 316 static UINT s_findrep_msg = 0; // set in gui_w[16/32].c
317 static FINDREPLACEW s_findrep_struct; 317 static FINDREPLACEW s_findrep_struct;
318 static HWND s_findrep_hwnd = NULL; 318 static HWND s_findrep_hwnd = NULL;
342 static LPARAM s_lParam = 0; 342 static LPARAM s_lParam = 0;
343 343
344 static HWND s_textArea = NULL; 344 static HWND s_textArea = NULL;
345 static UINT s_uMsg = 0; 345 static UINT s_uMsg = 0;
346 346
347 static char_u *s_textfield; /* Used by dialogs to pass back strings */ 347 static char_u *s_textfield; // Used by dialogs to pass back strings
348 348
349 static int s_need_activate = FALSE; 349 static int s_need_activate = FALSE;
350 350
351 /* This variable is set when waiting for an event, which is the only moment 351 // This variable is set when waiting for an event, which is the only moment
352 * scrollbar dragging can be done directly. It's not allowed while commands 352 // scrollbar dragging can be done directly. It's not allowed while commands
353 * are executed, because it may move the cursor and that may cause unexpected 353 // are executed, because it may move the cursor and that may cause unexpected
354 * problems (e.g., while ":s" is working). 354 // problems (e.g., while ":s" is working).
355 */
356 static int allow_scrollbar = FALSE; 355 static int allow_scrollbar = FALSE;
357 356
358 #ifdef GLOBAL_IME 357 #ifdef GLOBAL_IME
359 # define MyTranslateMessage(x) global_ime_TranslateMessage(x) 358 # define MyTranslateMessage(x) global_ime_TranslateMessage(x)
360 #else 359 #else
367 { 366 {
368 if (s_dwc != NULL) 367 if (s_dwc != NULL)
369 return 1; 368 return 1;
370 else if (s_directx_load_attempted) 369 else if (s_directx_load_attempted)
371 return 0; 370 return 0;
372 /* load DirectX */ 371 // load DirectX
373 DWrite_Init(); 372 DWrite_Init();
374 s_directx_load_attempted = 1; 373 s_directx_load_attempted = 1;
375 s_dwc = DWriteContext_Open(); 374 s_dwc = DWriteContext_Open();
376 directx_binddc(); 375 directx_binddc();
377 return s_dwc != NULL ? 1 : 0; 376 return s_dwc != NULL ? 1 : 0;
387 DWriteContext_BindDC(s_dwc, s_hdc, &rect); 386 DWriteContext_BindDC(s_dwc, s_hdc, &rect);
388 } 387 }
389 } 388 }
390 #endif 389 #endif
391 390
392 /* use of WindowProc depends on Global IME */ 391 // use of WindowProc depends on Global IME
393 #define MyWindowProc vim_WindowProc 392 #define MyWindowProc vim_WindowProc
394 393
395 extern int current_font_height; /* this is in os_mswin.c */ 394 extern int current_font_height; // this is in os_mswin.c
396 395
397 static struct 396 static struct
398 { 397 {
399 UINT key_sym; 398 UINT key_sym;
400 char_u vim_code0; 399 char_u vim_code0;
428 {VK_F19, 'F', '9'}, 427 {VK_F19, 'F', '9'},
429 {VK_F20, 'F', 'A'}, 428 {VK_F20, 'F', 'A'},
430 429
431 {VK_F21, 'F', 'B'}, 430 {VK_F21, 'F', 'B'},
432 #ifdef FEAT_NETBEANS_INTG 431 #ifdef FEAT_NETBEANS_INTG
433 {VK_PAUSE, 'F', 'B'}, /* Pause == F21 (see gui_gtk_x11.c) */ 432 {VK_PAUSE, 'F', 'B'}, // Pause == F21 (see gui_gtk_x11.c)
434 #endif 433 #endif
435 {VK_F22, 'F', 'C'}, 434 {VK_F22, 'F', 'C'},
436 {VK_F23, 'F', 'D'}, 435 {VK_F23, 'F', 'D'},
437 {VK_F24, 'F', 'E'}, /* winuser.h defines up to F24 */ 436 {VK_F24, 'F', 'E'}, // winuser.h defines up to F24
438 437
439 {VK_HELP, '%', '1'}, 438 {VK_HELP, '%', '1'},
440 {VK_BACK, 'k', 'b'}, 439 {VK_BACK, 'k', 'b'},
441 {VK_INSERT, 'k', 'I'}, 440 {VK_INSERT, 'k', 'I'},
442 {VK_DELETE, 'k', 'D'}, 441 {VK_DELETE, 'k', 'D'},
447 {VK_PRINT, '%', '9'}, 446 {VK_PRINT, '%', '9'},
448 {VK_ADD, 'K', '6'}, 447 {VK_ADD, 'K', '6'},
449 {VK_SUBTRACT, 'K', '7'}, 448 {VK_SUBTRACT, 'K', '7'},
450 {VK_DIVIDE, 'K', '8'}, 449 {VK_DIVIDE, 'K', '8'},
451 {VK_MULTIPLY, 'K', '9'}, 450 {VK_MULTIPLY, 'K', '9'},
452 {VK_SEPARATOR, 'K', 'A'}, /* Keypad Enter */ 451 {VK_SEPARATOR, 'K', 'A'}, // Keypad Enter
453 {VK_DECIMAL, 'K', 'B'}, 452 {VK_DECIMAL, 'K', 'B'},
454 453
455 {VK_NUMPAD0, 'K', 'C'}, 454 {VK_NUMPAD0, 'K', 'C'},
456 {VK_NUMPAD1, 'K', 'D'}, 455 {VK_NUMPAD1, 'K', 'D'},
457 {VK_NUMPAD2, 'K', 'E'}, 456 {VK_NUMPAD2, 'K', 'E'},
461 {VK_NUMPAD6, 'K', 'I'}, 460 {VK_NUMPAD6, 'K', 'I'},
462 {VK_NUMPAD7, 'K', 'J'}, 461 {VK_NUMPAD7, 'K', 'J'},
463 {VK_NUMPAD8, 'K', 'K'}, 462 {VK_NUMPAD8, 'K', 'K'},
464 {VK_NUMPAD9, 'K', 'L'}, 463 {VK_NUMPAD9, 'K', 'L'},
465 464
466 /* Keys that we want to be able to use any modifier with: */ 465 // Keys that we want to be able to use any modifier with:
467 {VK_SPACE, ' ', NUL}, 466 {VK_SPACE, ' ', NUL},
468 {VK_TAB, TAB, NUL}, 467 {VK_TAB, TAB, NUL},
469 {VK_ESCAPE, ESC, NUL}, 468 {VK_ESCAPE, ESC, NUL},
470 {NL, NL, NUL}, 469 {NL, NL, NUL},
471 {CAR, CAR, NUL}, 470 {CAR, CAR, NUL},
472 471
473 /* End of list marker: */ 472 // End of list marker:
474 {0, 0, 0} 473 {0, 0, 0}
475 }; 474 };
476 475
477 /* Local variables */ 476 // Local variables
478 static int s_button_pending = -1; 477 static int s_button_pending = -1;
479 478
480 /* s_getting_focus is set when we got focus but didn't see mouse-up event yet, 479 // s_getting_focus is set when we got focus but didn't see mouse-up event yet,
481 * so don't reset s_button_pending. */ 480 // so don't reset s_button_pending.
482 static int s_getting_focus = FALSE; 481 static int s_getting_focus = FALSE;
483 482
484 static int s_x_pending; 483 static int s_x_pending;
485 static int s_y_pending; 484 static int s_y_pending;
486 static UINT s_kFlags_pending; 485 static UINT s_kFlags_pending;
489 static int dead_key = 0; // 0: no dead key, 1: dead key pressed 488 static int dead_key = 0; // 0: no dead key, 1: dead key pressed
490 static UINT surrogate_pending_ch = 0; // 0: no surrogate pending, 489 static UINT surrogate_pending_ch = 0; // 0: no surrogate pending,
491 // else a high surrogate 490 // else a high surrogate
492 491
493 #ifdef FEAT_BEVAL_GUI 492 #ifdef FEAT_BEVAL_GUI
494 /* balloon-eval WM_NOTIFY_HANDLER */ 493 // balloon-eval WM_NOTIFY_HANDLER
495 static void Handle_WM_Notify(HWND hwnd, LPNMHDR pnmh); 494 static void Handle_WM_Notify(HWND hwnd, LPNMHDR pnmh);
496 static void TrackUserActivity(UINT uMsg); 495 static void TrackUserActivity(UINT uMsg);
497 #endif 496 #endif
498 497
499 /* 498 /*
500 * For control IME. 499 * For control IME.
501 * 500 *
502 * These LOGFONTW used for IME. 501 * These LOGFONTW used for IME.
503 */ 502 */
504 #if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME) 503 #if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME)
505 /* holds LOGFONTW for 'guifontwide' if available, otherwise 'guifont' */ 504 // holds LOGFONTW for 'guifontwide' if available, otherwise 'guifont'
506 static LOGFONTW norm_logfont; 505 static LOGFONTW norm_logfont;
507 #endif 506 #endif
508 #ifdef FEAT_MBYTE_IME 507 #ifdef FEAT_MBYTE_IME
509 /* holds LOGFONTW for 'guifont' always. */ 508 // holds LOGFONTW for 'guifont' always.
510 static LOGFONTW sub_logfont; 509 static LOGFONTW sub_logfont;
511 #endif 510 #endif
512 511
513 #ifdef FEAT_MBYTE_IME 512 #ifdef FEAT_MBYTE_IME
514 static LRESULT _OnImeNotify(HWND hWnd, DWORD dwCommand, DWORD dwData); 513 static LRESULT _OnImeNotify(HWND hWnd, DWORD dwCommand, DWORD dwData);
588 TRACE2("Got timer event, id %d, blink_timer %d\n", idEvent, blink_timer); 587 TRACE2("Got timer event, id %d, blink_timer %d\n", idEvent, blink_timer);
589 */ 588 */
590 589
591 KillTimer(NULL, idEvent); 590 KillTimer(NULL, idEvent);
592 591
593 /* Eat spurious WM_TIMER messages */ 592 // Eat spurious WM_TIMER messages
594 while (pPeekMessage(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) 593 while (pPeekMessage(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
595 ; 594 ;
596 595
597 if (blink_state == BLINK_ON) 596 if (blink_state == BLINK_ON)
598 { 597 {
617 MSG msg; 616 MSG msg;
618 617
619 if (blink_timer != 0) 618 if (blink_timer != 0)
620 { 619 {
621 KillTimer(NULL, blink_timer); 620 KillTimer(NULL, blink_timer);
622 /* Eat spurious WM_TIMER messages */ 621 // Eat spurious WM_TIMER messages
623 while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) 622 while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
624 ; 623 ;
625 blink_timer = 0; 624 blink_timer = 0;
626 } 625 }
627 } 626 }
648 void 647 void
649 gui_mch_start_blink(void) 648 gui_mch_start_blink(void)
650 { 649 {
651 gui_mswin_rm_blink_timer(); 650 gui_mswin_rm_blink_timer();
652 651
653 /* Only switch blinking on if none of the times is zero */ 652 // Only switch blinking on if none of the times is zero
654 if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) 653 if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus)
655 { 654 {
656 blink_timer = (UINT)SetTimer(NULL, 0, (UINT)blink_waittime, 655 blink_timer = (UINT)SetTimer(NULL, 0, (UINT)blink_waittime,
657 (TIMERPROC)_OnBlinkTimer); 656 (TIMERPROC)_OnBlinkTimer);
658 blink_state = BLINK_ON; 657 blink_state = BLINK_ON;
678 TRACE2("Got timer event, id %d, s_wait_timer %d\n", idEvent, s_wait_timer); 677 TRACE2("Got timer event, id %d, s_wait_timer %d\n", idEvent, s_wait_timer);
679 */ 678 */
680 KillTimer(NULL, idEvent); 679 KillTimer(NULL, idEvent);
681 s_timed_out = TRUE; 680 s_timed_out = TRUE;
682 681
683 /* Eat spurious WM_TIMER messages */ 682 // Eat spurious WM_TIMER messages
684 while (pPeekMessage(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) 683 while (pPeekMessage(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
685 ; 684 ;
686 if (idEvent == s_wait_timer) 685 if (idEvent == s_wait_timer)
687 s_wait_timer = 0; 686 s_wait_timer = 0;
688 } 687 }
715 WCHAR wstring[2]; 714 WCHAR wstring[2];
716 char_u *ws = NULL; 715 char_u *ws = NULL;
717 716
718 if (surrogate_pending_ch != 0) 717 if (surrogate_pending_ch != 0)
719 { 718 {
720 /* We don't guarantee ch is a low surrogate to match the high surrogate 719 // We don't guarantee ch is a low surrogate to match the high surrogate
721 * we already have; it should be, but if it isn't, tough luck. */ 720 // we already have; it should be, but if it isn't, tough luck.
722 wstring[0] = surrogate_pending_ch; 721 wstring[0] = surrogate_pending_ch;
723 wstring[1] = ch; 722 wstring[1] = ch;
724 surrogate_pending_ch = 0; 723 surrogate_pending_ch = 0;
725 len = 2; 724 len = 2;
726 } 725 }
727 else if (ch >= 0xD800 && ch <= 0xDBFF) /* high surrogate */ 726 else if (ch >= 0xD800 && ch <= 0xDBFF) // high surrogate
728 { 727 {
729 /* We don't have the entire code point yet, only the first UTF-16 code 728 // We don't have the entire code point yet, only the first UTF-16 code
730 * unit; so just remember it and use it in the next call. */ 729 // unit; so just remember it and use it in the next call.
731 surrogate_pending_ch = ch; 730 surrogate_pending_ch = ch;
732 return 0; 731 return 0;
733 } 732 }
734 else 733 else
735 { 734 {
736 wstring[0] = ch; 735 wstring[0] = ch;
737 len = 1; 736 len = 1;
738 } 737 }
739 738
740 /* "ch" is a UTF-16 character. Convert it to a string of bytes. When 739 // "ch" is a UTF-16 character. Convert it to a string of bytes. When
741 * "enc_codepage" is non-zero use the standard Win32 function, 740 // "enc_codepage" is non-zero use the standard Win32 function,
742 * otherwise use our own conversion function (e.g., for UTF-8). */ 741 // otherwise use our own conversion function (e.g., for UTF-8).
743 if (enc_codepage > 0) 742 if (enc_codepage > 0)
744 { 743 {
745 len = WideCharToMultiByte(enc_codepage, 0, wstring, len, 744 len = WideCharToMultiByte(enc_codepage, 0, wstring, len,
746 (LPSTR)string, slen, 0, NULL); 745 (LPSTR)string, slen, 0, NULL);
747 /* If we had included the ALT key into the character but now the 746 // If we had included the ALT key into the character but now the
748 * upper bit is no longer set, that probably means the conversion 747 // upper bit is no longer set, that probably means the conversion
749 * failed. Convert the original character and set the upper bit 748 // failed. Convert the original character and set the upper bit
750 * afterwards. */ 749 // afterwards.
751 if (had_alt && len == 1 && ch >= 0x80 && string[0] < 0x80) 750 if (had_alt && len == 1 && ch >= 0x80 && string[0] < 0x80)
752 { 751 {
753 wstring[0] = ch & 0x7f; 752 wstring[0] = ch & 0x7f;
754 len = WideCharToMultiByte(enc_codepage, 0, wstring, len, 753 len = WideCharToMultiByte(enc_codepage, 0, wstring, len,
755 (LPSTR)string, slen, 0, NULL); 754 (LPSTR)string, slen, 0, NULL);
756 if (len == 1) /* safety check */ 755 if (len == 1) // safety check
757 string[0] |= 0x80; 756 string[0] |= 0x80;
758 } 757 }
759 } 758 }
760 else 759 else
761 { 760 {
762 ws = utf16_to_enc(wstring, &len); 761 ws = utf16_to_enc(wstring, &len);
763 if (ws == NULL) 762 if (ws == NULL)
764 len = 0; 763 len = 0;
765 else 764 else
766 { 765 {
767 if (len > slen) /* just in case */ 766 if (len > slen) // just in case
768 len = slen; 767 len = slen;
769 mch_memmove(string, ws, len); 768 mch_memmove(string, ws, len);
770 vim_free(ws); 769 vim_free(ws);
771 } 770 }
772 } 771 }
778 } 777 }
779 778
780 for (i = 0; i < len; ++i) 779 for (i = 0; i < len; ++i)
781 if (string[i] == CSI && len <= slen - 2) 780 if (string[i] == CSI && len <= slen - 2)
782 { 781 {
783 /* Insert CSI as K_CSI. */ 782 // Insert CSI as K_CSI.
784 mch_memmove(string + i + 3, string + i + 1, len - i - 1); 783 mch_memmove(string + i + 3, string + i + 1, len - i - 1);
785 string[++i] = KS_EXTRA; 784 string[++i] = KS_EXTRA;
786 string[++i] = (int)KE_CSI; 785 string[++i] = (int)KE_CSI;
787 len += 2; 786 len += 2;
788 } 787 }
821 _OnSysChar( 820 _OnSysChar(
822 HWND hwnd UNUSED, 821 HWND hwnd UNUSED,
823 UINT cch, 822 UINT cch,
824 int cRepeat UNUSED) 823 int cRepeat UNUSED)
825 { 824 {
826 char_u string[40]; /* Enough for multibyte character */ 825 char_u string[40]; // Enough for multibyte character
827 int len; 826 int len;
828 int modifiers; 827 int modifiers;
829 int ch = cch; /* special keys are negative */ 828 int ch = cch; // special keys are negative
830 829
831 dead_key = 0; 830 dead_key = 0;
832 831
833 /* TRACE("OnSysChar(%d, %c)\n", ch, ch); */ 832 // TRACE("OnSysChar(%d, %c)\n", ch, ch);
834 833
835 /* OK, we have a character key (given by ch) which was entered with the 834 // OK, we have a character key (given by ch) which was entered with the
836 * ALT key pressed. Eg, if the user presses Alt-A, then ch == 'A'. Note 835 // ALT key pressed. Eg, if the user presses Alt-A, then ch == 'A'. Note
837 * that the system distinguishes Alt-a and Alt-A (Alt-Shift-a unless 836 // that the system distinguishes Alt-a and Alt-A (Alt-Shift-a unless
838 * CAPSLOCK is pressed) at this point. 837 // CAPSLOCK is pressed) at this point.
839 */
840 modifiers = MOD_MASK_ALT; 838 modifiers = MOD_MASK_ALT;
841 if (GetKeyState(VK_SHIFT) & 0x8000) 839 if (GetKeyState(VK_SHIFT) & 0x8000)
842 modifiers |= MOD_MASK_SHIFT; 840 modifiers |= MOD_MASK_SHIFT;
843 if (GetKeyState(VK_CONTROL) & 0x8000) 841 if (GetKeyState(VK_CONTROL) & 0x8000)
844 modifiers |= MOD_MASK_CTRL; 842 modifiers |= MOD_MASK_CTRL;
845 843
846 ch = simplify_key(ch, &modifiers); 844 ch = simplify_key(ch, &modifiers);
847 /* remove the SHIFT modifier for keys where it's already included, e.g., 845 // remove the SHIFT modifier for keys where it's already included, e.g.,
848 * '(' and '*' */ 846 // '(' and '*'
849 if (ch < 0x100 && !isalpha(ch) && isprint(ch)) 847 if (ch < 0x100 && !isalpha(ch) && isprint(ch))
850 modifiers &= ~MOD_MASK_SHIFT; 848 modifiers &= ~MOD_MASK_SHIFT;
851 849
852 /* Interpret the ALT key as making the key META, include SHIFT, etc. */ 850 // Interpret the ALT key as making the key META, include SHIFT, etc.
853 ch = extract_modifiers(ch, &modifiers, TRUE, NULL); 851 ch = extract_modifiers(ch, &modifiers, TRUE, NULL);
854 if (ch == CSI) 852 if (ch == CSI)
855 ch = K_CSI; 853 ch = K_CSI;
856 854
857 len = 0; 855 len = 0;
868 string[len++] = K_SECOND((int)ch); 866 string[len++] = K_SECOND((int)ch);
869 string[len++] = K_THIRD((int)ch); 867 string[len++] = K_THIRD((int)ch);
870 } 868 }
871 else 869 else
872 { 870 {
873 /* Although the documentation isn't clear about it, we assume "ch" is 871 // Although the documentation isn't clear about it, we assume "ch" is
874 * a Unicode character. */ 872 // a Unicode character.
875 len += char_to_string(ch, string + len, 40 - len, TRUE); 873 len += char_to_string(ch, string + len, 40 - len, TRUE);
876 } 874 }
877 875
878 add_to_input_buf(string, len); 876 add_to_input_buf(string, len);
879 } 877 }
912 910
913 LONG currentTime = GetMessageTime(); 911 LONG currentTime = GetMessageTime();
914 int button = -1; 912 int button = -1;
915 int repeated_click; 913 int repeated_click;
916 914
917 /* Give main window the focus: this is so the cursor isn't hollow. */ 915 // Give main window the focus: this is so the cursor isn't hollow.
918 (void)SetFocus(s_hwnd); 916 (void)SetFocus(s_hwnd);
919 917
920 if (s_uMsg == WM_LBUTTONDOWN || s_uMsg == WM_LBUTTONDBLCLK) 918 if (s_uMsg == WM_LBUTTONDOWN || s_uMsg == WM_LBUTTONDBLCLK)
921 button = MOUSE_LEFT; 919 button = MOUSE_LEFT;
922 else if (s_uMsg == WM_MBUTTONDOWN || s_uMsg == WM_MBUTTONDBLCLK) 920 else if (s_uMsg == WM_MBUTTONDOWN || s_uMsg == WM_MBUTTONDBLCLK)
930 #endif 928 #endif
931 button = ((GET_XBUTTON_WPARAM(s_wParam) == 1) ? MOUSE_X1 : MOUSE_X2); 929 button = ((GET_XBUTTON_WPARAM(s_wParam) == 1) ? MOUSE_X1 : MOUSE_X2);
932 } 930 }
933 else if (s_uMsg == WM_CAPTURECHANGED) 931 else if (s_uMsg == WM_CAPTURECHANGED)
934 { 932 {
935 /* on W95/NT4, somehow you get in here with an odd Msg 933 // on W95/NT4, somehow you get in here with an odd Msg
936 * if you press one button while holding down the other..*/ 934 // if you press one button while holding down the other..
937 if (s_button_pending == MOUSE_LEFT) 935 if (s_button_pending == MOUSE_LEFT)
938 button = MOUSE_RIGHT; 936 button = MOUSE_RIGHT;
939 else 937 else
940 button = MOUSE_LEFT; 938 button = MOUSE_LEFT;
941 } 939 }
968 if (s_button_pending > -1) 966 if (s_button_pending > -1)
969 { 967 {
970 _OnMouseEvent(s_button_pending, x, y, FALSE, keyFlags); 968 _OnMouseEvent(s_button_pending, x, y, FALSE, keyFlags);
971 s_button_pending = -1; 969 s_button_pending = -1;
972 } 970 }
973 /* TRACE("Button down at x %d, y %d\n", x, y); */ 971 // TRACE("Button down at x %d, y %d\n", x, y);
974 _OnMouseEvent(button, x, y, repeated_click, keyFlags); 972 _OnMouseEvent(button, x, y, repeated_click, keyFlags);
975 } 973 }
976 else 974 else
977 { 975 {
978 /* 976 /*
1008 int button; 1006 int button;
1009 1007
1010 s_getting_focus = FALSE; 1008 s_getting_focus = FALSE;
1011 if (s_button_pending > -1) 1009 if (s_button_pending > -1)
1012 { 1010 {
1013 /* Delayed action for mouse down event */ 1011 // Delayed action for mouse down event
1014 _OnMouseEvent(s_button_pending, s_x_pending, 1012 _OnMouseEvent(s_button_pending, s_x_pending,
1015 s_y_pending, FALSE, s_kFlags_pending); 1013 s_y_pending, FALSE, s_kFlags_pending);
1016 s_button_pending = -1; 1014 s_button_pending = -1;
1017 } 1015 }
1018 if (s_uMsg == WM_MOUSEMOVE) 1016 if (s_uMsg == WM_MOUSEMOVE)
1032 * While button is down, keep grabbing mouse move events when 1030 * While button is down, keep grabbing mouse move events when
1033 * the mouse goes outside the window 1031 * the mouse goes outside the window
1034 */ 1032 */
1035 SetCapture(s_textArea); 1033 SetCapture(s_textArea);
1036 button = MOUSE_DRAG; 1034 button = MOUSE_DRAG;
1037 /* TRACE(" move at x %d, y %d\n", x, y); */ 1035 // TRACE(" move at x %d, y %d\n", x, y);
1038 } 1036 }
1039 else 1037 else
1040 { 1038 {
1041 ReleaseCapture(); 1039 ReleaseCapture();
1042 button = MOUSE_RELEASE; 1040 button = MOUSE_RELEASE;
1043 /* TRACE(" up at x %d, y %d\n", x, y); */ 1041 // TRACE(" up at x %d, y %d\n", x, y);
1044 } 1042 }
1045 1043
1046 _OnMouseEvent(button, x, y, FALSE, keyFlags); 1044 _OnMouseEvent(button, x, y, FALSE, keyFlags);
1047 } 1045 }
1048 1046
1112 { 1110 {
1113 int flags = 0; 1111 int flags = 0;
1114 int down; 1112 int down;
1115 1113
1116 if (s_findrep_struct.Flags & FR_DIALOGTERM) 1114 if (s_findrep_struct.Flags & FR_DIALOGTERM)
1117 /* Give main window the focus back. */ 1115 // Give main window the focus back.
1118 (void)SetFocus(s_hwnd); 1116 (void)SetFocus(s_hwnd);
1119 1117
1120 if (s_findrep_struct.Flags & FR_FINDNEXT) 1118 if (s_findrep_struct.Flags & FR_FINDNEXT)
1121 { 1119 {
1122 flags = FRD_FINDNEXT; 1120 flags = FRD_FINDNEXT;
1123 1121
1124 /* Give main window the focus back: this is so the cursor isn't 1122 // Give main window the focus back: this is so the cursor isn't
1125 * hollow. */ 1123 // hollow.
1126 (void)SetFocus(s_hwnd); 1124 (void)SetFocus(s_hwnd);
1127 } 1125 }
1128 else if (s_findrep_struct.Flags & FR_REPLACE) 1126 else if (s_findrep_struct.Flags & FR_REPLACE)
1129 { 1127 {
1130 flags = FRD_REPLACE; 1128 flags = FRD_REPLACE;
1131 1129
1132 /* Give main window the focus back: this is so the cursor isn't 1130 // Give main window the focus back: this is so the cursor isn't
1133 * hollow. */ 1131 // hollow.
1134 (void)SetFocus(s_hwnd); 1132 (void)SetFocus(s_hwnd);
1135 } 1133 }
1136 else if (s_findrep_struct.Flags & FR_REPLACEALL) 1134 else if (s_findrep_struct.Flags & FR_REPLACEALL)
1137 { 1135 {
1138 flags = FRD_REPLACEALL; 1136 flags = FRD_REPLACEALL;
1140 1138
1141 if (flags != 0) 1139 if (flags != 0)
1142 { 1140 {
1143 char_u *p, *q; 1141 char_u *p, *q;
1144 1142
1145 /* Call the generic GUI function to do the actual work. */ 1143 // Call the generic GUI function to do the actual work.
1146 if (s_findrep_struct.Flags & FR_WHOLEWORD) 1144 if (s_findrep_struct.Flags & FR_WHOLEWORD)
1147 flags |= FRD_WHOLE_WORD; 1145 flags |= FRD_WHOLE_WORD;
1148 if (s_findrep_struct.Flags & FR_MATCHCASE) 1146 if (s_findrep_struct.Flags & FR_MATCHCASE)
1149 flags |= FRD_MATCH_CASE; 1147 flags |= FRD_MATCH_CASE;
1150 down = (s_findrep_struct.Flags & FR_DOWN) != 0; 1148 down = (s_findrep_struct.Flags & FR_DOWN) != 0;
1161 static void 1159 static void
1162 HandleMouseHide(UINT uMsg, LPARAM lParam) 1160 HandleMouseHide(UINT uMsg, LPARAM lParam)
1163 { 1161 {
1164 static LPARAM last_lParam = 0L; 1162 static LPARAM last_lParam = 0L;
1165 1163
1166 /* We sometimes get a mousemove when the mouse didn't move... */ 1164 // We sometimes get a mousemove when the mouse didn't move...
1167 if (uMsg == WM_MOUSEMOVE || uMsg == WM_NCMOUSEMOVE) 1165 if (uMsg == WM_MOUSEMOVE || uMsg == WM_NCMOUSEMOVE)
1168 { 1166 {
1169 if (lParam == last_lParam) 1167 if (lParam == last_lParam)
1170 return; 1168 return;
1171 last_lParam = lParam; 1169 last_lParam = lParam;
1172 } 1170 }
1173 1171
1174 /* Handle specially, to centralise coding. We need to be sure we catch all 1172 // Handle specially, to centralise coding. We need to be sure we catch all
1175 * possible events which should cause us to restore the cursor (as it is a 1173 // possible events which should cause us to restore the cursor (as it is a
1176 * shared resource, we take full responsibility for it). 1174 // shared resource, we take full responsibility for it).
1177 */
1178 switch (uMsg) 1175 switch (uMsg)
1179 { 1176 {
1180 case WM_KEYUP: 1177 case WM_KEYUP:
1181 case WM_CHAR: 1178 case WM_CHAR:
1182 /* 1179 /*
1184 */ 1181 */
1185 if (p_mh) 1182 if (p_mh)
1186 gui_mch_mousehide(TRUE); 1183 gui_mch_mousehide(TRUE);
1187 break; 1184 break;
1188 1185
1189 case WM_SYSKEYUP: /* show the pointer when a system-key is pressed */ 1186 case WM_SYSKEYUP: // show the pointer when a system-key is pressed
1190 case WM_SYSCHAR: 1187 case WM_SYSCHAR:
1191 case WM_MOUSEMOVE: /* show the pointer on any mouse action */ 1188 case WM_MOUSEMOVE: // show the pointer on any mouse action
1192 case WM_LBUTTONDOWN: 1189 case WM_LBUTTONDOWN:
1193 case WM_LBUTTONUP: 1190 case WM_LBUTTONUP:
1194 case WM_MBUTTONDOWN: 1191 case WM_MBUTTONDOWN:
1195 case WM_MBUTTONUP: 1192 case WM_MBUTTONUP:
1196 case WM_RBUTTONDOWN: 1193 case WM_RBUTTONDOWN:
1307 * Open the GUI window which was created by a call to gui_mch_init(). 1304 * Open the GUI window which was created by a call to gui_mch_init().
1308 */ 1305 */
1309 int 1306 int
1310 gui_mch_open(void) 1307 gui_mch_open(void)
1311 { 1308 {
1312 /* Actually open the window, if not already visible 1309 // Actually open the window, if not already visible
1313 * (may be done already in gui_mch_set_shellsize) */ 1310 // (may be done already in gui_mch_set_shellsize)
1314 if (!IsWindowVisible(s_hwnd)) 1311 if (!IsWindowVisible(s_hwnd))
1315 ShowWindow(s_hwnd, SW_SHOWDEFAULT); 1312 ShowWindow(s_hwnd, SW_SHOWDEFAULT);
1316 1313
1317 #ifdef MSWIN_FIND_REPLACE 1314 #ifdef MSWIN_FIND_REPLACE
1318 /* Init replace string here, so that we keep it when re-opening the 1315 // Init replace string here, so that we keep it when re-opening the
1319 * dialog. */ 1316 // dialog.
1320 s_findrep_struct.lpstrReplaceWith[0] = NUL; 1317 s_findrep_struct.lpstrReplaceWith[0] = NUL;
1321 #endif 1318 #endif
1322 1319
1323 return OK; 1320 return OK;
1324 } 1321 }
1373 GetClientRect(s_hwnd, &rect); 1370 GetClientRect(s_hwnd, &rect);
1374 MoveWindow(s_tabhwnd, 0, top, rect.right, gui.tabline_height, TRUE); 1371 MoveWindow(s_tabhwnd, 0, top, rect.right, gui.tabline_height, TRUE);
1375 } 1372 }
1376 #endif 1373 #endif
1377 1374
1378 /* When side scroll bar is unshown, the size of window will change. 1375 // When side scroll bar is unshown, the size of window will change.
1379 * then, the text area move left or right. thus client rect should be 1376 // then, the text area move left or right. thus client rect should be
1380 * forcedly redrawn. (Yasuhiro Matsumoto) */ 1377 // forcedly redrawn. (Yasuhiro Matsumoto)
1381 if (oldx != x || oldy != y) 1378 if (oldx != x || oldy != y)
1382 { 1379 {
1383 InvalidateRect(s_hwnd, NULL, FALSE); 1380 InvalidateRect(s_hwnd, NULL, FALSE);
1384 oldx = x; 1381 oldx = x;
1385 oldy = y; 1382 oldy = y;
1396 scrollbar_T *sb, 1393 scrollbar_T *sb,
1397 int flag) 1394 int flag)
1398 { 1395 {
1399 ShowScrollBar(sb->id, SB_CTL, flag); 1396 ShowScrollBar(sb->id, SB_CTL, flag);
1400 1397
1401 /* TODO: When the window is maximized, the size of the window stays the 1398 // TODO: When the window is maximized, the size of the window stays the
1402 * same, thus the size of the text area changes. On Win98 it's OK, on Win 1399 // same, thus the size of the text area changes. On Win98 it's OK, on Win
1403 * NT 4.0 it's not... */ 1400 // NT 4.0 it's not...
1404 } 1401 }
1405 1402
1406 void 1403 void
1407 gui_mch_set_scrollbar_pos( 1404 gui_mch_set_scrollbar_pos(
1408 scrollbar_T *sb, 1405 scrollbar_T *sb,
1416 } 1413 }
1417 1414
1418 void 1415 void
1419 gui_mch_create_scrollbar( 1416 gui_mch_create_scrollbar(
1420 scrollbar_T *sb, 1417 scrollbar_T *sb,
1421 int orient) /* SBAR_VERT or SBAR_HORIZ */ 1418 int orient) // SBAR_VERT or SBAR_HORIZ
1422 { 1419 {
1423 sb->id = CreateWindow( 1420 sb->id = CreateWindow(
1424 "SCROLLBAR", "Scrollbar", 1421 "SCROLLBAR", "Scrollbar",
1425 WS_CHILD | ((orient == SBAR_VERT) ? SBS_VERT : SBS_HORZ), 0, 0, 1422 WS_CHILD | ((orient == SBAR_VERT) ? SBS_VERT : SBS_HORZ), 0, 0,
1426 10, /* Any value will do for now */ 1423 10, // Any value will do for now
1427 10, /* Any value will do for now */ 1424 10, // Any value will do for now
1428 s_hwnd, NULL, 1425 s_hwnd, NULL,
1429 g_hinst, NULL); 1426 g_hinst, NULL);
1430 } 1427 }
1431 1428
1432 /* 1429 /*
1489 static GuiFont 1486 static GuiFont
1490 get_font_handle(LOGFONTW *lf) 1487 get_font_handle(LOGFONTW *lf)
1491 { 1488 {
1492 HFONT font = NULL; 1489 HFONT font = NULL;
1493 1490
1494 /* Load the font */ 1491 // Load the font
1495 font = CreateFontIndirectW(lf); 1492 font = CreateFontIndirectW(lf);
1496 1493
1497 if (font == NULL) 1494 if (font == NULL)
1498 return NOFONT; 1495 return NOFONT;
1499 1496
1720 /* 1717 /*
1721 * Note: FillRect() excludes right and bottom of rectangle. 1718 * Note: FillRect() excludes right and bottom of rectangle.
1722 */ 1719 */
1723 rc.left = 1720 rc.left =
1724 #ifdef FEAT_RIGHTLEFT 1721 #ifdef FEAT_RIGHTLEFT
1725 /* vertical line should be on the right of current point */ 1722 // vertical line should be on the right of current point
1726 CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w : 1723 CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w :
1727 #endif 1724 #endif
1728 FILL_X(gui.col); 1725 FILL_X(gui.col);
1729 rc.top = FILL_Y(gui.row) + gui.char_height - h; 1726 rc.top = FILL_Y(gui.row) + gui.char_height - h;
1730 rc.right = rc.left + w; 1727 rc.right = rc.left + w;
1746 if (!dead_key) 1743 if (!dead_key)
1747 return; 1744 return;
1748 1745
1749 dead_key = 0; 1746 dead_key = 0;
1750 1747
1751 /* Make Windows generate the dead key's character */ 1748 // Make Windows generate the dead key's character
1752 deadCharExpel.message = originalMsg.message; 1749 deadCharExpel.message = originalMsg.message;
1753 deadCharExpel.hwnd = originalMsg.hwnd; 1750 deadCharExpel.hwnd = originalMsg.hwnd;
1754 deadCharExpel.wParam = VK_SPACE; 1751 deadCharExpel.wParam = VK_SPACE;
1755 1752
1756 MyTranslateMessage(&deadCharExpel); 1753 MyTranslateMessage(&deadCharExpel);
1757 1754
1758 /* re-generate the current character free of the dead char influence */ 1755 // re-generate the current character free of the dead char influence
1759 PostMessage(originalMsg.hwnd, originalMsg.message, originalMsg.wParam, 1756 PostMessage(originalMsg.hwnd, originalMsg.message, originalMsg.wParam,
1760 originalMsg.lParam); 1757 originalMsg.lParam);
1761 } 1758 }
1762 1759
1763 1760
1767 */ 1764 */
1768 static void 1765 static void
1769 process_message(void) 1766 process_message(void)
1770 { 1767 {
1771 MSG msg; 1768 MSG msg;
1772 UINT vk = 0; /* Virtual key */ 1769 UINT vk = 0; // Virtual key
1773 char_u string[40]; 1770 char_u string[40];
1774 int i; 1771 int i;
1775 int modifiers = 0; 1772 int modifiers = 0;
1776 int key; 1773 int key;
1777 #ifdef FEAT_MENU 1774 #ifdef FEAT_MENU
1779 #endif 1776 #endif
1780 1777
1781 pGetMessage(&msg, NULL, 0, 0); 1778 pGetMessage(&msg, NULL, 0, 0);
1782 1779
1783 #ifdef FEAT_OLE 1780 #ifdef FEAT_OLE
1784 /* Look after OLE Automation commands */ 1781 // Look after OLE Automation commands
1785 if (msg.message == WM_OLE) 1782 if (msg.message == WM_OLE)
1786 { 1783 {
1787 char_u *str = (char_u *)msg.lParam; 1784 char_u *str = (char_u *)msg.lParam;
1788 if (str == NULL || *str == NUL) 1785 if (str == NULL || *str == NUL)
1789 { 1786 {
1790 /* Message can't be ours, forward it. Fixes problem with Ultramon 1787 // Message can't be ours, forward it. Fixes problem with Ultramon
1791 * 3.0.4 */ 1788 // 3.0.4
1792 pDispatchMessage(&msg); 1789 pDispatchMessage(&msg);
1793 } 1790 }
1794 else 1791 else
1795 { 1792 {
1796 add_to_input_buf(str, (int)STRLEN(str)); 1793 add_to_input_buf(str, (int)STRLEN(str));
1797 vim_free(str); /* was allocated in CVim::SendKeys() */ 1794 vim_free(str); // was allocated in CVim::SendKeys()
1798 } 1795 }
1799 return; 1796 return;
1800 } 1797 }
1801 #endif 1798 #endif
1802 1799
1803 #ifdef MSWIN_FIND_REPLACE 1800 #ifdef MSWIN_FIND_REPLACE
1804 /* Don't process messages used by the dialog */ 1801 // Don't process messages used by the dialog
1805 if (s_findrep_hwnd != NULL && pIsDialogMessage(s_findrep_hwnd, &msg)) 1802 if (s_findrep_hwnd != NULL && pIsDialogMessage(s_findrep_hwnd, &msg))
1806 { 1803 {
1807 HandleMouseHide(msg.message, msg.lParam); 1804 HandleMouseHide(msg.message, msg.lParam);
1808 return; 1805 return;
1809 } 1806 }
1849 { 1846 {
1850 dead_key = 0; 1847 dead_key = 0;
1851 MyTranslateMessage(&msg); 1848 MyTranslateMessage(&msg);
1852 return; 1849 return;
1853 } 1850 }
1854 /* In modes where we are not typing, dead keys should behave 1851 // In modes where we are not typing, dead keys should behave
1855 * normally */ 1852 // normally
1856 else if (!(get_real_state() & (INSERT | CMDLINE | SELECTMODE))) 1853 else if (!(get_real_state() & (INSERT | CMDLINE | SELECTMODE)))
1857 { 1854 {
1858 outputDeadKey_rePost(msg); 1855 outputDeadKey_rePost(msg);
1859 return; 1856 return;
1860 } 1857 }
1861 } 1858 }
1862 1859
1863 /* Check for CTRL-BREAK */ 1860 // Check for CTRL-BREAK
1864 if (vk == VK_CANCEL) 1861 if (vk == VK_CANCEL)
1865 { 1862 {
1866 trash_input_buf(); 1863 trash_input_buf();
1867 got_int = TRUE; 1864 got_int = TRUE;
1868 ctrl_break_was_pressed = TRUE; 1865 ctrl_break_was_pressed = TRUE;
1870 add_to_input_buf(string, 1); 1867 add_to_input_buf(string, 1);
1871 } 1868 }
1872 1869
1873 for (i = 0; special_keys[i].key_sym != 0; i++) 1870 for (i = 0; special_keys[i].key_sym != 0; i++)
1874 { 1871 {
1875 /* ignore VK_SPACE when ALT key pressed: system menu */ 1872 // ignore VK_SPACE when ALT key pressed: system menu
1876 if (special_keys[i].key_sym == vk 1873 if (special_keys[i].key_sym == vk
1877 && (vk != VK_SPACE || !(GetKeyState(VK_MENU) & 0x8000))) 1874 && (vk != VK_SPACE || !(GetKeyState(VK_MENU) & 0x8000)))
1878 { 1875 {
1879 /* 1876 /*
1880 * Behave as expected if we have a dead key and the special key 1877 * Behave as expected if we have a dead key and the special key
1888 outputDeadKey_rePost(msg); 1885 outputDeadKey_rePost(msg);
1889 return; 1886 return;
1890 } 1887 }
1891 1888
1892 #ifdef FEAT_MENU 1889 #ifdef FEAT_MENU
1893 /* Check for <F10>: Windows selects the menu. When <F10> is 1890 // Check for <F10>: Windows selects the menu. When <F10> is
1894 * mapped we want to use the mapping instead. */ 1891 // mapped we want to use the mapping instead.
1895 if (vk == VK_F10 1892 if (vk == VK_F10
1896 && gui.menu_is_active 1893 && gui.menu_is_active
1897 && check_map(k10, State, FALSE, TRUE, FALSE, 1894 && check_map(k10, State, FALSE, TRUE, FALSE,
1898 NULL, NULL) == NULL) 1895 NULL, NULL) == NULL)
1899 break; 1896 break;
1940 } 1937 }
1941 else 1938 else
1942 { 1939 {
1943 int len; 1940 int len;
1944 1941
1945 /* Handle "key" as a Unicode character. */ 1942 // Handle "key" as a Unicode character.
1946 len = char_to_string(key, string, 40, FALSE); 1943 len = char_to_string(key, string, 40, FALSE);
1947 add_to_input_buf(string, len); 1944 add_to_input_buf(string, len);
1948 } 1945 }
1949 break; 1946 break;
1950 } 1947 }
1951 } 1948 }
1952 if (special_keys[i].key_sym == 0) 1949 if (special_keys[i].key_sym == 0)
1953 { 1950 {
1954 /* Some keys need C-S- where they should only need C-. 1951 // Some keys need C-S- where they should only need C-.
1955 * Ignore 0xff, Windows XP sends it when NUMLOCK has changed since 1952 // Ignore 0xff, Windows XP sends it when NUMLOCK has changed since
1956 * system startup (Helmut Stiegler, 2003 Oct 3). */ 1953 // system startup (Helmut Stiegler, 2003 Oct 3).
1957 if (vk != 0xff 1954 if (vk != 0xff
1958 && (GetKeyState(VK_CONTROL) & 0x8000) 1955 && (GetKeyState(VK_CONTROL) & 0x8000)
1959 && !(GetKeyState(VK_SHIFT) & 0x8000) 1956 && !(GetKeyState(VK_SHIFT) & 0x8000)
1960 && !(GetKeyState(VK_MENU) & 0x8000)) 1957 && !(GetKeyState(VK_MENU) & 0x8000))
1961 { 1958 {
1962 /* CTRL-6 is '^'; Japanese keyboard maps '^' to vk == 0xDE */ 1959 // CTRL-6 is '^'; Japanese keyboard maps '^' to vk == 0xDE
1963 if (vk == '6' || MapVirtualKey(vk, 2) == (UINT)'^') 1960 if (vk == '6' || MapVirtualKey(vk, 2) == (UINT)'^')
1964 { 1961 {
1965 string[0] = Ctrl_HAT; 1962 string[0] = Ctrl_HAT;
1966 add_to_input_buf(string, 1); 1963 add_to_input_buf(string, 1);
1967 } 1964 }
1968 /* vk == 0xBD AZERTY for CTRL-'-', but CTRL-[ for * QWERTY! */ 1965 // vk == 0xBD AZERTY for CTRL-'-', but CTRL-[ for * QWERTY!
1969 else if (vk == 0xBD) /* QWERTY for CTRL-'-' */ 1966 else if (vk == 0xBD) // QWERTY for CTRL-'-'
1970 { 1967 {
1971 string[0] = Ctrl__; 1968 string[0] = Ctrl__;
1972 add_to_input_buf(string, 1); 1969 add_to_input_buf(string, 1);
1973 } 1970 }
1974 /* CTRL-2 is '@'; Japanese keyboard maps '@' to vk == 0xC0 */ 1971 // CTRL-2 is '@'; Japanese keyboard maps '@' to vk == 0xC0
1975 else if (vk == '2' || MapVirtualKey(vk, 2) == (UINT)'@') 1972 else if (vk == '2' || MapVirtualKey(vk, 2) == (UINT)'@')
1976 { 1973 {
1977 string[0] = Ctrl_AT; 1974 string[0] = Ctrl_AT;
1978 add_to_input_buf(string, 1); 1975 add_to_input_buf(string, 1);
1979 } 1976 }
1986 } 1983 }
1987 #ifdef FEAT_MBYTE_IME 1984 #ifdef FEAT_MBYTE_IME
1988 else if (msg.message == WM_IME_NOTIFY) 1985 else if (msg.message == WM_IME_NOTIFY)
1989 _OnImeNotify(msg.hwnd, (DWORD)msg.wParam, (DWORD)msg.lParam); 1986 _OnImeNotify(msg.hwnd, (DWORD)msg.wParam, (DWORD)msg.lParam);
1990 else if (msg.message == WM_KEYUP && im_get_status()) 1987 else if (msg.message == WM_KEYUP && im_get_status())
1991 /* added for non-MS IME (Yasuhiro Matsumoto) */ 1988 // added for non-MS IME (Yasuhiro Matsumoto)
1992 MyTranslateMessage(&msg); 1989 MyTranslateMessage(&msg);
1993 #endif 1990 #endif
1994 #if !defined(FEAT_MBYTE_IME) && defined(GLOBAL_IME) 1991 #if !defined(FEAT_MBYTE_IME) && defined(GLOBAL_IME)
1995 /* GIME_TEST */ 1992 // GIME_TEST
1996 else if (msg.message == WM_IME_STARTCOMPOSITION) 1993 else if (msg.message == WM_IME_STARTCOMPOSITION)
1997 { 1994 {
1998 POINT point; 1995 POINT point;
1999 1996
2000 global_ime_set_font(&norm_logfont); 1997 global_ime_set_font(&norm_logfont);
2004 global_ime_set_position(&point); 2001 global_ime_set_position(&point);
2005 } 2002 }
2006 #endif 2003 #endif
2007 2004
2008 #ifdef FEAT_MENU 2005 #ifdef FEAT_MENU
2009 /* Check for <F10>: Default effect is to select the menu. When <F10> is 2006 // Check for <F10>: Default effect is to select the menu. When <F10> is
2010 * mapped we need to stop it here to avoid strange effects (e.g., for the 2007 // mapped we need to stop it here to avoid strange effects (e.g., for the
2011 * key-up event) */ 2008 // key-up event)
2012 if (vk != VK_F10 || check_map(k10, State, FALSE, TRUE, FALSE, 2009 if (vk != VK_F10 || check_map(k10, State, FALSE, TRUE, FALSE,
2013 NULL, NULL) == NULL) 2010 NULL, NULL) == NULL)
2014 #endif 2011 #endif
2015 pDispatchMessage(&msg); 2012 pDispatchMessage(&msg);
2016 } 2013 }
2039 2036
2040 if (s_wait_timer != 0 && !s_timed_out) 2037 if (s_wait_timer != 0 && !s_timed_out)
2041 { 2038 {
2042 KillTimer(NULL, s_wait_timer); 2039 KillTimer(NULL, s_wait_timer);
2043 2040
2044 /* Eat spurious WM_TIMER messages */ 2041 // Eat spurious WM_TIMER messages
2045 while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) 2042 while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
2046 ; 2043 ;
2047 s_wait_timer = 0; 2044 s_wait_timer = 0;
2048 } 2045 }
2049 } 2046 }
2211 int x UNUSED, 2208 int x UNUSED,
2212 int y UNUSED, 2209 int y UNUSED,
2213 int w UNUSED, 2210 int w UNUSED,
2214 int h UNUSED) 2211 int h UNUSED)
2215 { 2212 {
2216 /* It will be in the right place anyway */ 2213 // It will be in the right place anyway
2217 } 2214 }
2218 2215
2219 #if defined(FEAT_MENU) || defined(PROTO) 2216 #if defined(FEAT_MENU) || defined(PROTO)
2220 /* 2217 /*
2221 * Make menu item hidden or not hidden 2218 * Make menu item hidden or not hidden
2243 void 2240 void
2244 gui_mch_draw_menubar(void) 2241 gui_mch_draw_menubar(void)
2245 { 2242 {
2246 DrawMenuBar(s_hwnd); 2243 DrawMenuBar(s_hwnd);
2247 } 2244 }
2248 #endif /*FEAT_MENU*/ 2245 #endif // FEAT_MENU
2249 2246
2250 /* 2247 /*
2251 * Return the RGB value of a pixel as a long. 2248 * Return the RGB value of a pixel as a long.
2252 */ 2249 */
2253 guicolor_T 2250 guicolor_T
2256 return (guicolor_T)((GetRValue(pixel) << 16) + (GetGValue(pixel) << 8) 2253 return (guicolor_T)((GetRValue(pixel) << 16) + (GetGValue(pixel) << 8)
2257 + GetBValue(pixel)); 2254 + GetBValue(pixel));
2258 } 2255 }
2259 2256
2260 #if defined(FEAT_GUI_DIALOG) || defined(PROTO) 2257 #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
2261 /* Convert pixels in X to dialog units */ 2258 /*
2259 * Convert pixels in X to dialog units
2260 */
2262 static WORD 2261 static WORD
2263 PixelToDialogX(int numPixels) 2262 PixelToDialogX(int numPixels)
2264 { 2263 {
2265 return (WORD)((numPixels * 4) / s_dlgfntwidth); 2264 return (WORD)((numPixels * 4) / s_dlgfntwidth);
2266 } 2265 }
2267 2266
2268 /* Convert pixels in Y to dialog units */ 2267 /*
2268 * Convert pixels in Y to dialog units
2269 */
2269 static WORD 2270 static WORD
2270 PixelToDialogY(int numPixels) 2271 PixelToDialogY(int numPixels)
2271 { 2272 {
2272 return (WORD)((numPixels * 8) / s_dlgfntheight); 2273 return (WORD)((numPixels * 8) / s_dlgfntheight);
2273 } 2274 }
2274 2275
2275 /* Return the width in pixels of the given text in the given DC. */ 2276 /*
2277 * Return the width in pixels of the given text in the given DC.
2278 */
2276 static int 2279 static int
2277 GetTextWidth(HDC hdc, char_u *str, int len) 2280 GetTextWidth(HDC hdc, char_u *str, int len)
2278 { 2281 {
2279 SIZE size; 2282 SIZE size;
2280 2283
2326 2329
2327 GetWindowRect(hwndChild, &rChild); 2330 GetWindowRect(hwndChild, &rChild);
2328 wChild = rChild.right - rChild.left; 2331 wChild = rChild.right - rChild.left;
2329 hChild = rChild.bottom - rChild.top; 2332 hChild = rChild.bottom - rChild.top;
2330 2333
2331 /* If Vim is minimized put the window in the middle of the screen. */ 2334 // If Vim is minimized put the window in the middle of the screen.
2332 if (hwndParent == NULL || IsMinimized(hwndParent)) 2335 if (hwndParent == NULL || IsMinimized(hwndParent))
2333 get_work_area(&rParent); 2336 get_work_area(&rParent);
2334 else 2337 else
2335 GetWindowRect(hwndParent, &rParent); 2338 GetWindowRect(hwndParent, &rParent);
2336 wParent = rParent.right - rParent.left; 2339 wParent = rParent.right - rParent.left;
2365 yNew = rScreen.bottom - hChild; 2368 yNew = rScreen.bottom - hChild;
2366 2369
2367 return SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0, 2370 return SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0,
2368 SWP_NOSIZE | SWP_NOZORDER); 2371 SWP_NOSIZE | SWP_NOZORDER);
2369 } 2372 }
2370 #endif /* FEAT_GUI_DIALOG */ 2373 #endif // FEAT_GUI_DIALOG
2371 2374
2372 #if defined(FEAT_TOOLBAR) || defined(PROTO) 2375 #if defined(FEAT_TOOLBAR) || defined(PROTO)
2373 void 2376 void
2374 gui_mch_show_toolbar(int showit) 2377 gui_mch_show_toolbar(int showit)
2375 { 2378 {
2389 } 2392 }
2390 else 2393 else
2391 ShowWindow(s_toolbarhwnd, SW_HIDE); 2394 ShowWindow(s_toolbarhwnd, SW_HIDE);
2392 } 2395 }
2393 2396
2394 /* The number of bitmaps is fixed. Exit is missing! */ 2397 // The number of bitmaps is fixed. Exit is missing!
2395 # define TOOLBAR_BITMAP_COUNT 31 2398 # define TOOLBAR_BITMAP_COUNT 31
2396 2399
2397 #endif 2400 #endif
2398 2401
2399 #if defined(FEAT_GUI_TABLINE) || defined(PROTO) 2402 #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
2422 { 2425 {
2423 HMENU tab_pmenu; 2426 HMENU tab_pmenu;
2424 long rval; 2427 long rval;
2425 POINT pt; 2428 POINT pt;
2426 2429
2427 /* When ignoring events don't show the menu. */ 2430 // When ignoring events don't show the menu.
2428 if (hold_gui_events 2431 if (hold_gui_events
2429 # ifdef FEAT_CMDWIN 2432 # ifdef FEAT_CMDWIN
2430 || cmdwin_type != 0 2433 || cmdwin_type != 0
2431 # endif 2434 # endif
2432 ) 2435 )
2448 rval = TrackPopupMenuEx(tab_pmenu, TPM_RETURNCMD, pt.x, pt.y, s_tabhwnd, 2451 rval = TrackPopupMenuEx(tab_pmenu, TPM_RETURNCMD, pt.x, pt.y, s_tabhwnd,
2449 NULL); 2452 NULL);
2450 2453
2451 DestroyMenu(tab_pmenu); 2454 DestroyMenu(tab_pmenu);
2452 2455
2453 /* Add the string cmd into input buffer */ 2456 // Add the string cmd into input buffer
2454 if (rval > 0) 2457 if (rval > 0)
2455 { 2458 {
2456 TCHITTESTINFO htinfo; 2459 TCHITTESTINFO htinfo;
2457 int idx; 2460 int idx;
2458 2461
2514 2517
2515 if (s_tabhwnd == NULL) 2518 if (s_tabhwnd == NULL)
2516 return; 2519 return;
2517 2520
2518 # ifndef CCM_SETUNICODEFORMAT 2521 # ifndef CCM_SETUNICODEFORMAT
2519 /* For older compilers. We assume this never changes. */ 2522 // For older compilers. We assume this never changes.
2520 # define CCM_SETUNICODEFORMAT 0x2005 2523 # define CCM_SETUNICODEFORMAT 0x2005
2521 # endif 2524 # endif
2522 // Enable unicode support 2525 // Enable unicode support
2523 SendMessage(s_tabhwnd, CCM_SETUNICODEFORMAT, (WPARAM)TRUE, (LPARAM)0); 2526 SendMessage(s_tabhwnd, CCM_SETUNICODEFORMAT, (WPARAM)TRUE, (LPARAM)0);
2524 2527
2525 tie.mask = TCIF_TEXT; 2528 tie.mask = TCIF_TEXT;
2526 tie.iImage = -1; 2529 tie.iImage = -1;
2527 2530
2528 /* Disable redraw for tab updates to eliminate O(N^2) draws. */ 2531 // Disable redraw for tab updates to eliminate O(N^2) draws.
2529 SendMessage(s_tabhwnd, WM_SETREDRAW, (WPARAM)FALSE, 0); 2532 SendMessage(s_tabhwnd, WM_SETREDRAW, (WPARAM)FALSE, 0);
2530 2533
2531 /* Add a label for each tab page. They all contain the same text area. */ 2534 // Add a label for each tab page. They all contain the same text area.
2532 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr) 2535 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr)
2533 { 2536 {
2534 if (tp == curtab) 2537 if (tp == curtab)
2535 curtabidx = nr; 2538 curtabidx = nr;
2536 2539
2537 if (nr >= TabCtrl_GetItemCount(s_tabhwnd)) 2540 if (nr >= TabCtrl_GetItemCount(s_tabhwnd))
2538 { 2541 {
2539 /* Add the tab */ 2542 // Add the tab
2540 tie.pszText = "-Empty-"; 2543 tie.pszText = "-Empty-";
2541 TabCtrl_InsertItem(s_tabhwnd, nr, &tie); 2544 TabCtrl_InsertItem(s_tabhwnd, nr, &tie);
2542 tabadded = 1; 2545 tabadded = 1;
2543 } 2546 }
2544 2547
2556 SendMessage(s_tabhwnd, TCM_SETITEMW, (WPARAM)nr, (LPARAM)&tiw); 2559 SendMessage(s_tabhwnd, TCM_SETITEMW, (WPARAM)nr, (LPARAM)&tiw);
2557 vim_free(wstr); 2560 vim_free(wstr);
2558 } 2561 }
2559 } 2562 }
2560 2563
2561 /* Remove any old labels. */ 2564 // Remove any old labels.
2562 while (nr < TabCtrl_GetItemCount(s_tabhwnd)) 2565 while (nr < TabCtrl_GetItemCount(s_tabhwnd))
2563 TabCtrl_DeleteItem(s_tabhwnd, nr); 2566 TabCtrl_DeleteItem(s_tabhwnd, nr);
2564 2567
2565 if (!tabadded && TabCtrl_GetCurSel(s_tabhwnd) != curtabidx) 2568 if (!tabadded && TabCtrl_GetCurSel(s_tabhwnd) != curtabidx)
2566 TabCtrl_SetCurSel(s_tabhwnd, curtabidx); 2569 TabCtrl_SetCurSel(s_tabhwnd, curtabidx);
2567 2570
2568 /* Re-enable redraw and redraw. */ 2571 // Re-enable redraw and redraw.
2569 SendMessage(s_tabhwnd, WM_SETREDRAW, (WPARAM)TRUE, 0); 2572 SendMessage(s_tabhwnd, WM_SETREDRAW, (WPARAM)TRUE, 0);
2570 RedrawWindow(s_tabhwnd, NULL, NULL, 2573 RedrawWindow(s_tabhwnd, NULL, NULL,
2571 RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); 2574 RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
2572 2575
2573 if (tabadded && TabCtrl_GetCurSel(s_tabhwnd) != curtabidx) 2576 if (tabadded && TabCtrl_GetCurSel(s_tabhwnd) != curtabidx)
2601 2604
2602 PostMessage(s_hwnd, WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)0); 2605 PostMessage(s_hwnd, WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)0);
2603 while (*keys) 2606 while (*keys)
2604 { 2607 {
2605 if (*keys == '~') 2608 if (*keys == '~')
2606 *keys = ' '; /* for showing system menu */ 2609 *keys = ' '; // for showing system menu
2607 PostMessage(s_hwnd, WM_CHAR, (WPARAM)*keys, (LPARAM)0); 2610 PostMessage(s_hwnd, WM_CHAR, (WPARAM)*keys, (LPARAM)0);
2608 keys++; 2611 keys++;
2609 fill_typebuf = TRUE; 2612 fill_typebuf = TRUE;
2610 } 2613 }
2611 if (fill_typebuf) 2614 if (fill_typebuf)
2612 { 2615 {
2613 /* Put a NOP in the typeahead buffer so that the message will get 2616 // Put a NOP in the typeahead buffer so that the message will get
2614 * processed. */ 2617 // processed.
2615 key_name[0] = K_SPECIAL; 2618 key_name[0] = K_SPECIAL;
2616 key_name[1] = KS_EXTRA; 2619 key_name[1] = KS_EXTRA;
2617 key_name[2] = KE_NOP; 2620 key_name[2] = KE_NOP;
2618 key_name[3] = NUL; 2621 key_name[3] = NUL;
2619 #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL) 2622 #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL)
2634 { 2637 {
2635 int wword = FALSE; 2638 int wword = FALSE;
2636 int mcase = !p_ic; 2639 int mcase = !p_ic;
2637 char_u *entry_text; 2640 char_u *entry_text;
2638 2641
2639 /* Get the search string to use. */ 2642 // Get the search string to use.
2640 entry_text = get_find_dialog_text(initial_string, &wword, &mcase); 2643 entry_text = get_find_dialog_text(initial_string, &wword, &mcase);
2641 2644
2642 s_findrep_struct.hwndOwner = s_hwnd; 2645 s_findrep_struct.hwndOwner = s_hwnd;
2643 s_findrep_struct.Flags = FR_DOWN; 2646 s_findrep_struct.Flags = FR_DOWN;
2644 if (mcase) 2647 if (mcase)
2666 { 2669 {
2667 if (title != NULL) 2670 if (title != NULL)
2668 { 2671 {
2669 WCHAR *wbuf; 2672 WCHAR *wbuf;
2670 2673
2671 /* Convert the title from 'encoding' to UTF-16. */ 2674 // Convert the title from 'encoding' to UTF-16.
2672 wbuf = (WCHAR *)enc_to_utf16((char_u *)title, NULL); 2675 wbuf = (WCHAR *)enc_to_utf16((char_u *)title, NULL);
2673 if (wbuf != NULL) 2676 if (wbuf != NULL)
2674 { 2677 {
2675 SetWindowTextW(hwnd, wbuf); 2678 SetWindowTextW(hwnd, wbuf);
2676 vim_free(wbuf); 2679 vim_free(wbuf);
2743 2746
2744 #ifdef FEAT_MENU 2747 #ifdef FEAT_MENU
2745 static void 2748 static void
2746 gui_mch_show_popupmenu_at(vimmenu_T *menu, int x, int y) 2749 gui_mch_show_popupmenu_at(vimmenu_T *menu, int x, int y)
2747 { 2750 {
2748 /* Unhide the mouse, we don't get move events here. */ 2751 // Unhide the mouse, we don't get move events here.
2749 gui_mch_mousehide(FALSE); 2752 gui_mch_mousehide(FALSE);
2750 2753
2751 (void)TrackPopupMenu( 2754 (void)TrackPopupMenu(
2752 (HMENU)menu->submenu_id, 2755 (HMENU)menu->submenu_id,
2753 TPM_LEFTALIGN | TPM_LEFTBUTTON, 2756 TPM_LEFTALIGN | TPM_LEFTBUTTON,
2754 x, y, 2757 x, y,
2755 (int)0, /*reserved param*/ 2758 (int)0, //reserved param
2756 s_hwnd, 2759 s_hwnd,
2757 NULL); 2760 NULL);
2758 /* 2761 /*
2759 * NOTE: The pop-up menu can eat the mouse up event. 2762 * NOTE: The pop-up menu can eat the mouse up event.
2760 * We deal with this in normal.c. 2763 * We deal with this in normal.c.
2797 { 2800 {
2798 if (!IsMinimized(hwnd)) 2801 if (!IsMinimized(hwnd))
2799 { 2802 {
2800 PAINTSTRUCT ps; 2803 PAINTSTRUCT ps;
2801 2804
2802 out_flush(); /* make sure all output has been processed */ 2805 out_flush(); // make sure all output has been processed
2803 (void)BeginPaint(hwnd, &ps); 2806 (void)BeginPaint(hwnd, &ps);
2804 2807
2805 /* prevent multi-byte characters from misprinting on an invalid 2808 // prevent multi-byte characters from misprinting on an invalid
2806 * rectangle */ 2809 // rectangle
2807 if (has_mbyte) 2810 if (has_mbyte)
2808 { 2811 {
2809 RECT rect; 2812 RECT rect;
2810 2813
2811 GetClientRect(hwnd, &rect); 2814 GetClientRect(hwnd, &rect);
2834 if (!IsMinimized(hwnd)) 2837 if (!IsMinimized(hwnd))
2835 { 2838 {
2836 gui_resize_shell(cx, cy); 2839 gui_resize_shell(cx, cy);
2837 2840
2838 #ifdef FEAT_MENU 2841 #ifdef FEAT_MENU
2839 /* Menu bar may wrap differently now */ 2842 // Menu bar may wrap differently now
2840 gui_mswin_get_menu_height(TRUE); 2843 gui_mswin_get_menu_height(TRUE);
2841 #endif 2844 #endif
2842 } 2845 }
2843 } 2846 }
2844 2847
2869 _OnActivateApp( 2872 _OnActivateApp(
2870 HWND hwnd, 2873 HWND hwnd,
2871 BOOL fActivate, 2874 BOOL fActivate,
2872 DWORD dwThreadId) 2875 DWORD dwThreadId)
2873 { 2876 {
2874 /* we call gui_focus_change() in _OnSetFocus() */ 2877 // we call gui_focus_change() in _OnSetFocus()
2875 /* gui_focus_change((int)fActivate); */ 2878 // gui_focus_change((int)fActivate);
2876 return MyWindowProc(hwnd, WM_ACTIVATEAPP, fActivate, (DWORD)dwThreadId); 2879 return MyWindowProc(hwnd, WM_ACTIVATEAPP, fActivate, (DWORD)dwThreadId);
2877 } 2880 }
2878 2881
2879 void 2882 void
2880 gui_mch_destroy_scrollbar(scrollbar_T *sb) 2883 gui_mch_destroy_scrollbar(scrollbar_T *sb)
2952 rc.left = 0; 2955 rc.left = 0;
2953 rc.top = 0; 2956 rc.top = 0;
2954 rc.right = gui.num_cols * gui.char_width; 2957 rc.right = gui.num_cols * gui.char_width;
2955 rc.bottom = gui.num_rows * gui.char_height; 2958 rc.bottom = gui.num_rows * gui.char_height;
2956 InvertRect(s_hdc, &rc); 2959 InvertRect(s_hdc, &rc);
2957 gui_mch_flush(); /* make sure it's displayed */ 2960 gui_mch_flush(); // make sure it's displayed
2958 2961
2959 ui_delay((long)msec, TRUE); /* wait for a few msec */ 2962 ui_delay((long)msec, TRUE); // wait for a few msec
2960 2963
2961 InvertRect(s_hdc, &rc); 2964 InvertRect(s_hdc, &rc);
2962 } 2965 }
2963 2966
2964 /* 2967 /*
2972 HWND hwnd; 2975 HWND hwnd;
2973 RECT rcVim, rcOther, rcDest; 2976 RECT rcVim, rcOther, rcDest;
2974 2977
2975 GetWindowRect(s_hwnd, &rcVim); 2978 GetWindowRect(s_hwnd, &rcVim);
2976 2979
2977 /* Check if the window is partly above or below the screen. We don't care 2980 // Check if the window is partly above or below the screen. We don't care
2978 * about partly left or right of the screen, it is not relevant when 2981 // about partly left or right of the screen, it is not relevant when
2979 * scrolling up or down. */ 2982 // scrolling up or down.
2980 if (rcVim.top < 0 || rcVim.bottom > GetSystemMetrics(SM_CYFULLSCREEN)) 2983 if (rcVim.top < 0 || rcVim.bottom > GetSystemMetrics(SM_CYFULLSCREEN))
2981 return SW_INVALIDATE; 2984 return SW_INVALIDATE;
2982 2985
2983 /* Check if there is an window (partly) on top of us. */ 2986 // Check if there is an window (partly) on top of us.
2984 for (hwnd = s_hwnd; (hwnd = GetWindow(hwnd, GW_HWNDPREV)) != (HWND)0; ) 2987 for (hwnd = s_hwnd; (hwnd = GetWindow(hwnd, GW_HWNDPREV)) != (HWND)0; )
2985 if (IsWindowVisible(hwnd)) 2988 if (IsWindowVisible(hwnd))
2986 { 2989 {
2987 GetWindowRect(hwnd, &rcOther); 2990 GetWindowRect(hwnd, &rcOther);
2988 if (IntersectRect(&rcDest, &rcVim, &rcOther)) 2991 if (IntersectRect(&rcDest, &rcVim, &rcOther))
3034 ScrollWindowEx(s_textArea, 0, -num_lines * gui.char_height, 3037 ScrollWindowEx(s_textArea, 0, -num_lines * gui.char_height,
3035 &rc, &rc, NULL, NULL, get_scroll_flags()); 3038 &rc, &rc, NULL, NULL, get_scroll_flags());
3036 UpdateWindow(s_textArea); 3039 UpdateWindow(s_textArea);
3037 } 3040 }
3038 3041
3039 /* This seems to be required to avoid the cursor disappearing when 3042 // This seems to be required to avoid the cursor disappearing when
3040 * scrolling such that the cursor ends up in the top-left character on 3043 // scrolling such that the cursor ends up in the top-left character on
3041 * the screen... But why? (Webb) */ 3044 // the screen... But why? (Webb)
3042 /* It's probably fixed by disabling drawing the cursor while scrolling. */ 3045 // It's probably fixed by disabling drawing the cursor while scrolling.
3043 /* gui.cursor_is_valid = FALSE; */ 3046 // gui.cursor_is_valid = FALSE;
3044 3047
3045 gui_clear_block(gui.scroll_region_bot - num_lines + 1, 3048 gui_clear_block(gui.scroll_region_bot - num_lines + 1,
3046 gui.scroll_region_left, 3049 gui.scroll_region_left,
3047 gui.scroll_region_bot, gui.scroll_region_right); 3050 gui.scroll_region_bot, gui.scroll_region_right);
3048 } 3051 }
3071 } 3074 }
3072 else 3075 else
3073 #endif 3076 #endif
3074 { 3077 {
3075 intel_gpu_workaround(); 3078 intel_gpu_workaround();
3076 /* The SW_INVALIDATE is required when part of the window is covered or 3079 // The SW_INVALIDATE is required when part of the window is covered or
3077 * off-screen. How do we avoid it when it's not needed? */ 3080 // off-screen. How do we avoid it when it's not needed?
3078 ScrollWindowEx(s_textArea, 0, num_lines * gui.char_height, 3081 ScrollWindowEx(s_textArea, 0, num_lines * gui.char_height,
3079 &rc, &rc, NULL, NULL, get_scroll_flags()); 3082 &rc, &rc, NULL, NULL, get_scroll_flags());
3080 UpdateWindow(s_textArea); 3083 UpdateWindow(s_textArea);
3081 } 3084 }
3082 3085
3096 3099
3097 ReleaseDC(s_textArea, s_hdc); 3100 ReleaseDC(s_textArea, s_hdc);
3098 DeleteObject(s_brush); 3101 DeleteObject(s_brush);
3099 3102
3100 #ifdef FEAT_TEAROFF 3103 #ifdef FEAT_TEAROFF
3101 /* Unload the tearoff bitmap */ 3104 // Unload the tearoff bitmap
3102 (void)DeleteObject((HGDIOBJ)s_htearbitmap); 3105 (void)DeleteObject((HGDIOBJ)s_htearbitmap);
3103 #endif 3106 #endif
3104 3107
3105 /* Destroy our window (if we have one). */ 3108 // Destroy our window (if we have one).
3106 if (s_hwnd != NULL) 3109 if (s_hwnd != NULL)
3107 { 3110 {
3108 destroying = TRUE; /* ignore WM_DESTROY message now */ 3111 destroying = TRUE; // ignore WM_DESTROY message now
3109 DestroyWindow(s_hwnd); 3112 DestroyWindow(s_hwnd);
3110 } 3113 }
3111 3114
3112 #ifdef GLOBAL_IME 3115 #ifdef GLOBAL_IME
3113 global_ime_end(); 3116 global_ime_end();
3244 { 3247 {
3245 LOGFONTW lf; 3248 LOGFONTW lf;
3246 GuiFont font = NOFONT; 3249 GuiFont font = NOFONT;
3247 char_u *p; 3250 char_u *p;
3248 3251
3249 /* Load the font */ 3252 // Load the font
3250 if (get_logfont(&lf, font_name, NULL, TRUE) == OK) 3253 if (get_logfont(&lf, font_name, NULL, TRUE) == OK)
3251 font = get_font_handle(&lf); 3254 font = get_font_handle(&lf);
3252 if (font == NOFONT) 3255 if (font == NOFONT)
3253 return FAIL; 3256 return FAIL;
3254 3257
3271 p = logfont2name(lf); 3274 p = logfont2name(lf);
3272 if (p != NULL) 3275 if (p != NULL)
3273 { 3276 {
3274 hl_set_font_name(p); 3277 hl_set_font_name(p);
3275 3278
3276 /* When setting 'guifont' to "*" replace it with the actual font name. 3279 // When setting 'guifont' to "*" replace it with the actual font name.
3277 * */ 3280 //
3278 if (STRCMP(font_name, "*") == 0 && STRCMP(p_guifont, "*") == 0) 3281 if (STRCMP(font_name, "*") == 0 && STRCMP(p_guifont, "*") == 0)
3279 { 3282 {
3280 vim_free(p_guifont); 3283 vim_free(p_guifont);
3281 p_guifont = p; 3284 p_guifont = p;
3282 } 3285 }
3310 3313
3311 return OK; 3314 return OK;
3312 } 3315 }
3313 3316
3314 #ifndef WPF_RESTORETOMAXIMIZED 3317 #ifndef WPF_RESTORETOMAXIMIZED
3315 # define WPF_RESTORETOMAXIMIZED 2 /* just in case someone doesn't have it */ 3318 # define WPF_RESTORETOMAXIMIZED 2 // just in case someone doesn't have it
3316 #endif 3319 #endif
3317 3320
3318 /* 3321 /*
3319 * Return TRUE if the GUI window is maximized, filling the whole screen. 3322 * Return TRUE if the GUI window is maximized, filling the whole screen.
3320 */ 3323 */
3357 #endif 3360 #endif
3358 ); 3361 );
3359 } 3362 }
3360 else 3363 else
3361 { 3364 {
3362 /* Inside another window, don't use the frame and border. */ 3365 // Inside another window, don't use the frame and border.
3363 gui_resize_shell(rect.right - rect.left, 3366 gui_resize_shell(rect.right - rect.left,
3364 rect.bottom - rect.top 3367 rect.bottom - rect.top
3365 #ifdef FEAT_MENU 3368 #ifdef FEAT_MENU
3366 - gui_mswin_get_menu_height(FALSE) 3369 - gui_mswin_get_menu_height(FALSE)
3367 #endif 3370 #endif
3379 { 3382 {
3380 set_window_title(s_hwnd, (title == NULL ? "VIM" : (char *)title)); 3383 set_window_title(s_hwnd, (title == NULL ? "VIM" : (char *)title));
3381 } 3384 }
3382 3385
3383 #if defined(FEAT_MOUSESHAPE) || defined(PROTO) 3386 #if defined(FEAT_MOUSESHAPE) || defined(PROTO)
3384 /* Table for shape IDCs. Keep in sync with the mshape_names[] table in 3387 // Table for shape IDCs. Keep in sync with the mshape_names[] table in
3385 * misc2.c! */ 3388 // misc2.c!
3386 static LPCSTR mshape_idcs[] = 3389 static LPCSTR mshape_idcs[] =
3387 { 3390 {
3388 IDC_ARROW, /* arrow */ 3391 IDC_ARROW, // arrow
3389 MAKEINTRESOURCE(0), /* blank */ 3392 MAKEINTRESOURCE(0), // blank
3390 IDC_IBEAM, /* beam */ 3393 IDC_IBEAM, // beam
3391 IDC_SIZENS, /* updown */ 3394 IDC_SIZENS, // updown
3392 IDC_SIZENS, /* udsizing */ 3395 IDC_SIZENS, // udsizing
3393 IDC_SIZEWE, /* leftright */ 3396 IDC_SIZEWE, // leftright
3394 IDC_SIZEWE, /* lrsizing */ 3397 IDC_SIZEWE, // lrsizing
3395 IDC_WAIT, /* busy */ 3398 IDC_WAIT, // busy
3396 IDC_NO, /* no */ 3399 IDC_NO, // no
3397 IDC_ARROW, /* crosshair */ 3400 IDC_ARROW, // crosshair
3398 IDC_ARROW, /* hand1 */ 3401 IDC_ARROW, // hand1
3399 IDC_ARROW, /* hand2 */ 3402 IDC_ARROW, // hand2
3400 IDC_ARROW, /* pencil */ 3403 IDC_ARROW, // pencil
3401 IDC_ARROW, /* question */ 3404 IDC_ARROW, // question
3402 IDC_ARROW, /* right-arrow */ 3405 IDC_ARROW, // right-arrow
3403 IDC_UPARROW, /* up-arrow */ 3406 IDC_UPARROW, // up-arrow
3404 IDC_ARROW /* last one */ 3407 IDC_ARROW // last one
3405 }; 3408 };
3406 3409
3407 void 3410 void
3408 mch_set_mouse_shape(int shape) 3411 mch_set_mouse_shape(int shape)
3409 { 3412 {
3420 SetClassLongPtr(s_textArea, GCLP_HCURSOR, (LONG_PTR)LoadCursor(NULL, idc)); 3423 SetClassLongPtr(s_textArea, GCLP_HCURSOR, (LONG_PTR)LoadCursor(NULL, idc));
3421 if (!p_mh) 3424 if (!p_mh)
3422 { 3425 {
3423 POINT mp; 3426 POINT mp;
3424 3427
3425 /* Set the position to make it redrawn with the new shape. */ 3428 // Set the position to make it redrawn with the new shape.
3426 (void)GetCursorPos((LPPOINT)&mp); 3429 (void)GetCursorPos((LPPOINT)&mp);
3427 (void)SetCursorPos(mp.x, mp.y); 3430 (void)SetCursorPos(mp.x, mp.y);
3428 ShowCursor(TRUE); 3431 ShowCursor(TRUE);
3429 } 3432 }
3430 } 3433 }
3468 char_u *dflt, 3471 char_u *dflt,
3469 char_u *ext, 3472 char_u *ext,
3470 char_u *initdir, 3473 char_u *initdir,
3471 char_u *filter) 3474 char_u *filter)
3472 { 3475 {
3473 /* We always use the wide function. This means enc_to_utf16() must work, 3476 // We always use the wide function. This means enc_to_utf16() must work,
3474 * otherwise it fails miserably! */ 3477 // otherwise it fails miserably!
3475 OPENFILENAMEW fileStruct; 3478 OPENFILENAMEW fileStruct;
3476 WCHAR fileBuf[MAXPATHL]; 3479 WCHAR fileBuf[MAXPATHL];
3477 WCHAR *wp; 3480 WCHAR *wp;
3478 int i; 3481 int i;
3479 WCHAR *titlep = NULL; 3482 WCHAR *titlep = NULL;
3496 fileBuf[i] = NUL; 3499 fileBuf[i] = NUL;
3497 vim_free(wp); 3500 vim_free(wp);
3498 } 3501 }
3499 } 3502 }
3500 3503
3501 /* Convert the filter to Windows format. */ 3504 // Convert the filter to Windows format.
3502 filterp = convert_filterW(filter); 3505 filterp = convert_filterW(filter);
3503 3506
3504 vim_memset(&fileStruct, 0, sizeof(OPENFILENAMEW)); 3507 vim_memset(&fileStruct, 0, sizeof(OPENFILENAMEW));
3505 # ifdef OPENFILENAME_SIZE_VERSION_400W 3508 # ifdef OPENFILENAME_SIZE_VERSION_400W
3506 /* be compatible with Windows NT 4.0 */ 3509 // be compatible with Windows NT 4.0
3507 fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400W; 3510 fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400W;
3508 # else 3511 # else
3509 fileStruct.lStructSize = sizeof(fileStruct); 3512 fileStruct.lStructSize = sizeof(fileStruct);
3510 # endif 3513 # endif
3511 3514
3518 fileStruct.lpstrDefExt = extp; 3521 fileStruct.lpstrDefExt = extp;
3519 3522
3520 fileStruct.lpstrFile = fileBuf; 3523 fileStruct.lpstrFile = fileBuf;
3521 fileStruct.nMaxFile = MAXPATHL; 3524 fileStruct.nMaxFile = MAXPATHL;
3522 fileStruct.lpstrFilter = filterp; 3525 fileStruct.lpstrFilter = filterp;
3523 fileStruct.hwndOwner = s_hwnd; /* main Vim window is owner*/ 3526 fileStruct.hwndOwner = s_hwnd; // main Vim window is owner
3524 /* has an initial dir been specified? */ 3527 // has an initial dir been specified?
3525 if (initdir != NULL && *initdir != NUL) 3528 if (initdir != NULL && *initdir != NUL)
3526 { 3529 {
3527 /* Must have backslashes here, no matter what 'shellslash' says */ 3530 // Must have backslashes here, no matter what 'shellslash' says
3528 initdirp = enc_to_utf16(initdir, NULL); 3531 initdirp = enc_to_utf16(initdir, NULL);
3529 if (initdirp != NULL) 3532 if (initdirp != NULL)
3530 { 3533 {
3531 for (wp = initdirp; *wp != NUL; ++wp) 3534 for (wp = initdirp; *wp != NUL; ++wp)
3532 if (*wp == '/') 3535 if (*wp == '/')
3562 vim_free(filterp); 3565 vim_free(filterp);
3563 vim_free(initdirp); 3566 vim_free(initdirp);
3564 vim_free(titlep); 3567 vim_free(titlep);
3565 vim_free(extp); 3568 vim_free(extp);
3566 3569
3567 /* Convert from UCS2 to 'encoding'. */ 3570 // Convert from UCS2 to 'encoding'.
3568 p = utf16_to_enc(fileBuf, NULL); 3571 p = utf16_to_enc(fileBuf, NULL);
3569 if (p == NULL) 3572 if (p == NULL)
3570 return NULL; 3573 return NULL;
3571 3574
3572 /* Give focus back to main window (when using MDI). */ 3575 // Give focus back to main window (when using MDI).
3573 SetFocus(s_hwnd); 3576 SetFocus(s_hwnd);
3574 3577
3575 /* Shorten the file name if possible */ 3578 // Shorten the file name if possible
3576 q = vim_strsave(shorten_fname1(p)); 3579 q = vim_strsave(shorten_fname1(p));
3577 vim_free(p); 3580 vim_free(p);
3578 return q; 3581 return q;
3579 } 3582 }
3580 3583
3600 if (s[i] == '\t' || s[i] == '\n') 3603 if (s[i] == '\t' || s[i] == '\n')
3601 res[i] = '\0'; 3604 res[i] = '\0';
3602 else 3605 else
3603 res[i] = s[i]; 3606 res[i] = s[i];
3604 res[s_len] = NUL; 3607 res[s_len] = NUL;
3605 /* Add two extra NULs to make sure it's properly terminated. */ 3608 // Add two extra NULs to make sure it's properly terminated.
3606 res[s_len + 1] = NUL; 3609 res[s_len + 1] = NUL;
3607 res[s_len + 2] = NUL; 3610 res[s_len + 2] = NUL;
3608 } 3611 }
3609 return res; 3612 return res;
3610 } 3613 }
3613 * Select a directory. 3616 * Select a directory.
3614 */ 3617 */
3615 char_u * 3618 char_u *
3616 gui_mch_browsedir(char_u *title, char_u *initdir) 3619 gui_mch_browsedir(char_u *title, char_u *initdir)
3617 { 3620 {
3618 /* We fake this: Use a filter that doesn't select anything and a default 3621 // We fake this: Use a filter that doesn't select anything and a default
3619 * file name that won't be used. */ 3622 // file name that won't be used.
3620 return gui_mch_browse(0, title, (char_u *)_("Not Used"), NULL, 3623 return gui_mch_browse(0, title, (char_u *)_("Not Used"), NULL,
3621 initdir, (char_u *)_("Directory\t*.nothing\n")); 3624 initdir, (char_u *)_("Directory\t*.nothing\n"));
3622 } 3625 }
3623 #endif /* FEAT_BROWSE */ 3626 #endif // FEAT_BROWSE
3624 3627
3625 static void 3628 static void
3626 _OnDropFiles( 3629 _OnDropFiles(
3627 HWND hwnd UNUSED, 3630 HWND hwnd UNUSED,
3628 HDROP hDrop) 3631 HDROP hDrop)
3635 UINT i; 3638 UINT i;
3636 char_u **fnames; 3639 char_u **fnames;
3637 POINT pt; 3640 POINT pt;
3638 int_u modifiers = 0; 3641 int_u modifiers = 0;
3639 3642
3640 /* TRACE("_OnDropFiles: %d files dropped\n", cFiles); */ 3643 // TRACE("_OnDropFiles: %d files dropped\n", cFiles);
3641 3644
3642 /* Obtain dropped position */ 3645 // Obtain dropped position
3643 DragQueryPoint(hDrop, &pt); 3646 DragQueryPoint(hDrop, &pt);
3644 MapWindowPoints(s_hwnd, s_textArea, &pt, 1); 3647 MapWindowPoints(s_hwnd, s_textArea, &pt, 1);
3645 3648
3646 reset_VIsual(); 3649 reset_VIsual();
3647 3650
3681 HWND hwnd UNUSED, 3684 HWND hwnd UNUSED,
3682 HWND hwndCtl, 3685 HWND hwndCtl,
3683 UINT code, 3686 UINT code,
3684 int pos) 3687 int pos)
3685 { 3688 {
3686 static UINT prev_code = 0; /* code of previous call */ 3689 static UINT prev_code = 0; // code of previous call
3687 scrollbar_T *sb, *sb_info; 3690 scrollbar_T *sb, *sb_info;
3688 long val; 3691 long val;
3689 int dragging = FALSE; 3692 int dragging = FALSE;
3690 int dont_scroll_save = dont_scroll; 3693 int dont_scroll_save = dont_scroll;
3691 SCROLLINFO si; 3694 SCROLLINFO si;
3695 3698
3696 sb = gui_mswin_find_scrollbar(hwndCtl); 3699 sb = gui_mswin_find_scrollbar(hwndCtl);
3697 if (sb == NULL) 3700 if (sb == NULL)
3698 return 0; 3701 return 0;
3699 3702
3700 if (sb->wp != NULL) /* Left or right scrollbar */ 3703 if (sb->wp != NULL) // Left or right scrollbar
3701 { 3704 {
3702 /* 3705 /*
3703 * Careful: need to get scrollbar info out of first (left) scrollbar 3706 * Careful: need to get scrollbar info out of first (left) scrollbar
3704 * for window, but keep real scrollbar too because we must pass it to 3707 * for window, but keep real scrollbar too because we must pass it to
3705 * gui_drag_scrollbar(). 3708 * gui_drag_scrollbar().
3706 */ 3709 */
3707 sb_info = &sb->wp->w_scrollbars[0]; 3710 sb_info = &sb->wp->w_scrollbars[0];
3708 } 3711 }
3709 else /* Bottom scrollbar */ 3712 else // Bottom scrollbar
3710 sb_info = sb; 3713 sb_info = sb;
3711 val = sb_info->value; 3714 val = sb_info->value;
3712 3715
3713 switch (code) 3716 switch (code)
3714 { 3717 {
3749 val <<= sb->scroll_shift; 3752 val <<= sb->scroll_shift;
3750 } 3753 }
3751 break; 3754 break;
3752 3755
3753 default: 3756 default:
3754 /* TRACE("Unknown scrollbar event %d\n", code); */ 3757 // TRACE("Unknown scrollbar event %d\n", code);
3755 return 0; 3758 return 0;
3756 } 3759 }
3757 prev_code = code; 3760 prev_code = code;
3758 3761
3759 si.nPos = (sb->scroll_shift > 0) ? val >> sb->scroll_shift : val; 3762 si.nPos = (sb->scroll_shift > 0) ? val >> sb->scroll_shift : val;
3768 HWND id = sba[ (sb == sba + SBAR_LEFT) ? SBAR_RIGHT : SBAR_LEFT].id; 3771 HWND id = sba[ (sb == sba + SBAR_LEFT) ? SBAR_RIGHT : SBAR_LEFT].id;
3769 3772
3770 SetScrollInfo(id, SB_CTL, &si, TRUE); 3773 SetScrollInfo(id, SB_CTL, &si, TRUE);
3771 } 3774 }
3772 3775
3773 /* Don't let us be interrupted here by another message. */ 3776 // Don't let us be interrupted here by another message.
3774 s_busy_processing = TRUE; 3777 s_busy_processing = TRUE;
3775 3778
3776 /* When "allow_scrollbar" is FALSE still need to remember the new 3779 // When "allow_scrollbar" is FALSE still need to remember the new
3777 * position, but don't actually scroll by setting "dont_scroll". */ 3780 // position, but don't actually scroll by setting "dont_scroll".
3778 dont_scroll = !allow_scrollbar; 3781 dont_scroll = !allow_scrollbar;
3779 3782
3780 mch_disable_flush(); 3783 mch_disable_flush();
3781 gui_drag_scrollbar(sb, val, dragging); 3784 gui_drag_scrollbar(sb, val, dragging);
3782 mch_enable_flush(); 3785 mch_enable_flush();
3900 # endif 3903 # endif
3901 # ifndef HANDLE_WM_DEADCHAR 3904 # ifndef HANDLE_WM_DEADCHAR
3902 # define HANDLE_WM_DEADCHAR(hwnd, wParam, lParam, fn) \ 3905 # define HANDLE_WM_DEADCHAR(hwnd, wParam, lParam, fn) \
3903 ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L) 3906 ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
3904 # endif 3907 # endif
3905 #endif /* __MINGW32__ */ 3908 #endif // __MINGW32__
3906 3909
3907 3910
3908 /* Some parameters for tearoff menus. All in pixels. */ 3911 // Some parameters for tearoff menus. All in pixels.
3909 #define TEAROFF_PADDING_X 2 3912 #define TEAROFF_PADDING_X 2
3910 #define TEAROFF_BUTTON_PAD_X 8 3913 #define TEAROFF_BUTTON_PAD_X 8
3911 #define TEAROFF_MIN_WIDTH 200 3914 #define TEAROFF_MIN_WIDTH 200
3912 #define TEAROFF_SUBMENU_LABEL ">>" 3915 #define TEAROFF_SUBMENU_LABEL ">>"
3913 #define TEAROFF_COLUMN_PADDING 3 // # spaces to pad column with. 3916 #define TEAROFF_COLUMN_PADDING 3 // # spaces to pad column with.
3914 3917
3915 3918
3916 /* For the Intellimouse: */ 3919 // For the Intellimouse:
3917 #ifndef WM_MOUSEWHEEL 3920 #ifndef WM_MOUSEWHEEL
3918 # define WM_MOUSEWHEEL 0x20a 3921 # define WM_MOUSEWHEEL 0x20a
3919 #endif 3922 #endif
3920 3923
3921 3924
3922 #ifdef FEAT_BEVAL_GUI 3925 #ifdef FEAT_BEVAL_GUI
3923 # define ID_BEVAL_TOOLTIP 200 3926 # define ID_BEVAL_TOOLTIP 200
3924 # define BEVAL_TEXT_LEN MAXPATHL 3927 # define BEVAL_TEXT_LEN MAXPATHL
3925 3928
3926 # if (defined(_MSC_VER) && _MSC_VER < 1300) || !defined(MAXULONG_PTR) 3929 # if (defined(_MSC_VER) && _MSC_VER < 1300) || !defined(MAXULONG_PTR)
3927 /* Work around old versions of basetsd.h which wrongly declares 3930 // Work around old versions of basetsd.h which wrongly declares
3928 * UINT_PTR as unsigned long. */ 3931 // UINT_PTR as unsigned long.
3929 # undef UINT_PTR 3932 # undef UINT_PTR
3930 # define UINT_PTR UINT 3933 # define UINT_PTR UINT
3931 # endif 3934 # endif
3932 3935
3933 static BalloonEval *cur_beval = NULL; 3936 static BalloonEval *cur_beval = NULL;
3934 static UINT_PTR BevalTimerId = 0; 3937 static UINT_PTR BevalTimerId = 0;
3935 static DWORD LastActivity = 0; 3938 static DWORD LastActivity = 0;
3936 3939
3937 3940
3938 /* cproto fails on missing include files */ 3941 // cproto fails on missing include files
3939 # ifndef PROTO 3942 # ifndef PROTO
3940 3943
3941 /* 3944 /*
3942 * excerpts from headers since this may not be presented 3945 * excerpts from headers since this may not be presented
3943 * in the extremely old compilers 3946 * in the extremely old compilers
4016 4019
4017 # ifndef TTN_GETDISPINFO 4020 # ifndef TTN_GETDISPINFO
4018 # define TTN_GETDISPINFO (TTN_FIRST - 0) 4021 # define TTN_GETDISPINFO (TTN_FIRST - 0)
4019 # endif 4022 # endif
4020 4023
4021 #endif /* defined(FEAT_BEVAL_GUI) */ 4024 #endif // defined(FEAT_BEVAL_GUI)
4022 4025
4023 #if defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE) 4026 #if defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE)
4024 /* Older MSVC compilers don't have LPNMTTDISPINFO[AW] thus we need to define 4027 // Older MSVC compilers don't have LPNMTTDISPINFO[AW] thus we need to define
4025 * it here if LPNMTTDISPINFO isn't defined. 4028 // it here if LPNMTTDISPINFO isn't defined.
4026 * MingW doesn't define LPNMTTDISPINFO but typedefs it. Thus we need to check 4029 // MingW doesn't define LPNMTTDISPINFO but typedefs it. Thus we need to check
4027 * _MSC_VER. */ 4030 // _MSC_VER.
4028 # if !defined(LPNMTTDISPINFO) && defined(_MSC_VER) 4031 # if !defined(LPNMTTDISPINFO) && defined(_MSC_VER)
4029 typedef struct tagNMTTDISPINFOA { 4032 typedef struct tagNMTTDISPINFOA {
4030 NMHDR hdr; 4033 NMHDR hdr;
4031 LPSTR lpszText; 4034 LPSTR lpszText;
4032 char szText[80]; 4035 char szText[80];
4049 4052
4050 #ifndef TTN_GETDISPINFOW 4053 #ifndef TTN_GETDISPINFOW
4051 # define TTN_GETDISPINFOW (TTN_FIRST - 10) 4054 # define TTN_GETDISPINFOW (TTN_FIRST - 10)
4052 #endif 4055 #endif
4053 4056
4054 /* Local variables: */ 4057 // Local variables:
4055 4058
4056 #ifdef FEAT_MENU 4059 #ifdef FEAT_MENU
4057 static UINT s_menu_id = 100; 4060 static UINT s_menu_id = 100;
4058 #endif 4061 #endif
4059 4062
4064 #define USE_SYSMENU_FONT 4067 #define USE_SYSMENU_FONT
4065 4068
4066 #define VIM_NAME "vim" 4069 #define VIM_NAME "vim"
4067 #define VIM_CLASSW L"Vim" 4070 #define VIM_CLASSW L"Vim"
4068 4071
4069 /* Initial size for the dialog template. For gui_mch_dialog() it's fixed, 4072 // Initial size for the dialog template. For gui_mch_dialog() it's fixed,
4070 * thus there should be room for every dialog. For tearoffs it's made bigger 4073 // thus there should be room for every dialog. For tearoffs it's made bigger
4071 * when needed. */ 4074 // when needed.
4072 #define DLG_ALLOC_SIZE 16 * 1024 4075 #define DLG_ALLOC_SIZE 16 * 1024
4073 4076
4074 /* 4077 /*
4075 * stuff for dialogs, menus, tearoffs etc. 4078 * stuff for dialogs, menus, tearoffs etc.
4076 */ 4079 */
4092 #endif 4095 #endif
4093 static void get_dialog_font_metrics(void); 4096 static void get_dialog_font_metrics(void);
4094 4097
4095 static int dialog_default_button = -1; 4098 static int dialog_default_button = -1;
4096 4099
4097 /* Intellimouse support */ 4100 // Intellimouse support
4098 static int mouse_scroll_lines = 0; 4101 static int mouse_scroll_lines = 0;
4099 4102
4100 static int s_usenewlook; /* emulate W95/NT4 non-bold dialogs */ 4103 static int s_usenewlook; // emulate W95/NT4 non-bold dialogs
4101 #ifdef FEAT_TOOLBAR 4104 #ifdef FEAT_TOOLBAR
4102 static void initialise_toolbar(void); 4105 static void initialise_toolbar(void);
4103 static LRESULT CALLBACK toolbar_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 4106 static LRESULT CALLBACK toolbar_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
4104 static int get_toolbar_bitmap(vimmenu_T *menu); 4107 static int get_toolbar_bitmap(vimmenu_T *menu);
4105 #endif 4108 #endif
4156 /* 4159 /*
4157 * Figure out how high the menu bar is at the moment. 4160 * Figure out how high the menu bar is at the moment.
4158 */ 4161 */
4159 static int 4162 static int
4160 gui_mswin_get_menu_height( 4163 gui_mswin_get_menu_height(
4161 int fix_window) /* If TRUE, resize window if menu height changed */ 4164 int fix_window) // If TRUE, resize window if menu height changed
4162 { 4165 {
4163 static int old_menu_height = -1; 4166 static int old_menu_height = -1;
4164 4167
4165 RECT rc1, rc2; 4168 RECT rc1, rc2;
4166 int num; 4169 int num;
4173 4176
4174 if (num == 0) 4177 if (num == 0)
4175 menu_height = 0; 4178 menu_height = 0;
4176 else if (IsMinimized(s_hwnd)) 4179 else if (IsMinimized(s_hwnd))
4177 { 4180 {
4178 /* The height of the menu cannot be determined while the window is 4181 // The height of the menu cannot be determined while the window is
4179 * minimized. Take the previous height if the menu is changed in that 4182 // minimized. Take the previous height if the menu is changed in that
4180 * state, to avoid that Vim's vertical window size accidentally 4183 // state, to avoid that Vim's vertical window size accidentally
4181 * increases due to the unaccounted-for menu height. */ 4184 // increases due to the unaccounted-for menu height.
4182 menu_height = old_menu_height == -1 ? 0 : old_menu_height; 4185 menu_height = old_menu_height == -1 ? 0 : old_menu_height;
4183 } 4186 }
4184 else 4187 else
4185 { 4188 {
4186 /* 4189 /*
4204 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT); 4207 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
4205 old_menu_height = menu_height; 4208 old_menu_height = menu_height;
4206 4209
4207 return menu_height; 4210 return menu_height;
4208 } 4211 }
4209 #endif /*FEAT_MENU*/ 4212 #endif // FEAT_MENU
4210 4213
4211 4214
4212 /* 4215 /*
4213 * Setup for the Intellimouse 4216 * Setup for the Intellimouse
4214 */ 4217 */
4221 #endif 4224 #endif
4222 #ifndef SPI_SETWHEELSCROLLLINES 4225 #ifndef SPI_SETWHEELSCROLLLINES
4223 # define SPI_SETWHEELSCROLLLINES 105 4226 # define SPI_SETWHEELSCROLLLINES 105
4224 #endif 4227 #endif
4225 4228
4226 #define VMOUSEZ_CLASSNAME "MouseZ" /* hidden wheel window class */ 4229 #define VMOUSEZ_CLASSNAME "MouseZ" // hidden wheel window class
4227 #define VMOUSEZ_TITLE "Magellan MSWHEEL" /* hidden wheel window title */ 4230 #define VMOUSEZ_TITLE "Magellan MSWHEEL" // hidden wheel window title
4228 #define VMSH_MOUSEWHEEL "MSWHEEL_ROLLMSG" 4231 #define VMSH_MOUSEWHEEL "MSWHEEL_ROLLMSG"
4229 #define VMSH_SCROLL_LINES "MSH_SCROLL_LINES_MSG" 4232 #define VMSH_SCROLL_LINES "MSH_SCROLL_LINES_MSG"
4230 4233
4231 mouse_scroll_lines = 3; /* reasonable default */ 4234 mouse_scroll_lines = 3; // reasonable default
4232 4235
4233 /* if NT 4.0+ (or Win98) get scroll lines directly from system */ 4236 // if NT 4.0+ (or Win98) get scroll lines directly from system
4234 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, 4237 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
4235 &mouse_scroll_lines, 0); 4238 &mouse_scroll_lines, 0);
4236 } 4239 }
4237 4240
4238 4241
4397 y = lpwpos->y; 4400 y = lpwpos->y;
4398 cx = lpwpos->cx; 4401 cx = lpwpos->cx;
4399 cy = lpwpos->cy; 4402 cy = lpwpos->cy;
4400 netbeans_frame_moved(x, y); 4403 netbeans_frame_moved(x, y);
4401 } 4404 }
4402 /* Allow to send WM_SIZE and WM_MOVE */ 4405 // Allow to send WM_SIZE and WM_MOVE
4403 FORWARD_WM_WINDOWPOSCHANGED(hwnd, lpwpos, MyWindowProc); 4406 FORWARD_WM_WINDOWPOSCHANGED(hwnd, lpwpos, MyWindowProc);
4404 } 4407 }
4405 #endif 4408 #endif
4406 4409
4407 static int 4410 static int
4457 4460
4458 switch (uMsg) 4461 switch (uMsg)
4459 { 4462 {
4460 HANDLE_MSG(hwnd, WM_DEADCHAR, _OnDeadChar); 4463 HANDLE_MSG(hwnd, WM_DEADCHAR, _OnDeadChar);
4461 HANDLE_MSG(hwnd, WM_SYSDEADCHAR, _OnDeadChar); 4464 HANDLE_MSG(hwnd, WM_SYSDEADCHAR, _OnDeadChar);
4462 /* HANDLE_MSG(hwnd, WM_ACTIVATE, _OnActivate); */ 4465 // HANDLE_MSG(hwnd, WM_ACTIVATE, _OnActivate);
4463 HANDLE_MSG(hwnd, WM_CLOSE, _OnClose); 4466 HANDLE_MSG(hwnd, WM_CLOSE, _OnClose);
4464 /* HANDLE_MSG(hwnd, WM_COMMAND, _OnCommand); */ 4467 // HANDLE_MSG(hwnd, WM_COMMAND, _OnCommand);
4465 HANDLE_MSG(hwnd, WM_DESTROY, _OnDestroy); 4468 HANDLE_MSG(hwnd, WM_DESTROY, _OnDestroy);
4466 HANDLE_MSG(hwnd, WM_DROPFILES, _OnDropFiles); 4469 HANDLE_MSG(hwnd, WM_DROPFILES, _OnDropFiles);
4467 HANDLE_MSG(hwnd, WM_HSCROLL, _OnScroll); 4470 HANDLE_MSG(hwnd, WM_HSCROLL, _OnScroll);
4468 HANDLE_MSG(hwnd, WM_KILLFOCUS, _OnKillFocus); 4471 HANDLE_MSG(hwnd, WM_KILLFOCUS, _OnKillFocus);
4469 #ifdef FEAT_MENU 4472 #ifdef FEAT_MENU
4470 HANDLE_MSG(hwnd, WM_COMMAND, _OnMenu); 4473 HANDLE_MSG(hwnd, WM_COMMAND, _OnMenu);
4471 #endif 4474 #endif
4472 /* HANDLE_MSG(hwnd, WM_MOVE, _OnMove); */ 4475 // HANDLE_MSG(hwnd, WM_MOVE, _OnMove);
4473 /* HANDLE_MSG(hwnd, WM_NCACTIVATE, _OnNCActivate); */ 4476 // HANDLE_MSG(hwnd, WM_NCACTIVATE, _OnNCActivate);
4474 HANDLE_MSG(hwnd, WM_SETFOCUS, _OnSetFocus); 4477 HANDLE_MSG(hwnd, WM_SETFOCUS, _OnSetFocus);
4475 HANDLE_MSG(hwnd, WM_SIZE, _OnSize); 4478 HANDLE_MSG(hwnd, WM_SIZE, _OnSize);
4476 /* HANDLE_MSG(hwnd, WM_SYSCOMMAND, _OnSysCommand); */ 4479 // HANDLE_MSG(hwnd, WM_SYSCOMMAND, _OnSysCommand);
4477 /* HANDLE_MSG(hwnd, WM_SYSKEYDOWN, _OnAltKey); */ 4480 // HANDLE_MSG(hwnd, WM_SYSKEYDOWN, _OnAltKey);
4478 HANDLE_MSG(hwnd, WM_VSCROLL, _OnScroll); 4481 HANDLE_MSG(hwnd, WM_VSCROLL, _OnScroll);
4479 // HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGING, _OnWindowPosChanging); 4482 // HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGING, _OnWindowPosChanging);
4480 HANDLE_MSG(hwnd, WM_ACTIVATEAPP, _OnActivateApp); 4483 HANDLE_MSG(hwnd, WM_ACTIVATEAPP, _OnActivateApp);
4481 #ifdef FEAT_NETBEANS_INTG 4484 #ifdef FEAT_NETBEANS_INTG
4482 HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGED, _OnWindowPosChanged); 4485 HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGED, _OnWindowPosChanged);
4520 } 4523 }
4521 return MyWindowProc(hwnd, uMsg, wParam, lParam); 4524 return MyWindowProc(hwnd, uMsg, wParam, lParam);
4522 } 4525 }
4523 #endif 4526 #endif
4524 4527
4525 case WM_QUERYENDSESSION: /* System wants to go down. */ 4528 case WM_QUERYENDSESSION: // System wants to go down.
4526 gui_shell_closed(); /* Will exit when no changed buffers. */ 4529 gui_shell_closed(); // Will exit when no changed buffers.
4527 return FALSE; /* Do NOT allow system to go down. */ 4530 return FALSE; // Do NOT allow system to go down.
4528 4531
4529 case WM_ENDSESSION: 4532 case WM_ENDSESSION:
4530 if (wParam) /* system only really goes down when wParam is TRUE */ 4533 if (wParam) // system only really goes down when wParam is TRUE
4531 { 4534 {
4532 _OnEndSession(); 4535 _OnEndSession();
4533 return 0L; 4536 return 0L;
4534 } 4537 }
4535 break; 4538 break;
4536 4539
4537 case WM_CHAR: 4540 case WM_CHAR:
4538 /* Don't use HANDLE_MSG() for WM_CHAR, it truncates wParam to a single 4541 // Don't use HANDLE_MSG() for WM_CHAR, it truncates wParam to a single
4539 * byte while we want the UTF-16 character value. */ 4542 // byte while we want the UTF-16 character value.
4540 _OnChar(hwnd, (UINT)wParam, (int)(short)LOWORD(lParam)); 4543 _OnChar(hwnd, (UINT)wParam, (int)(short)LOWORD(lParam));
4541 return 0L; 4544 return 0L;
4542 4545
4543 case WM_SYSCHAR: 4546 case WM_SYSCHAR:
4544 /* 4547 /*
4561 return MyWindowProc(hwnd, uMsg, wParam, lParam); 4564 return MyWindowProc(hwnd, uMsg, wParam, lParam);
4562 #endif 4565 #endif
4563 4566
4564 case WM_SYSKEYUP: 4567 case WM_SYSKEYUP:
4565 #ifdef FEAT_MENU 4568 #ifdef FEAT_MENU
4566 /* This used to be done only when menu is active: ALT key is used for 4569 // This used to be done only when menu is active: ALT key is used for
4567 * that. But that caused problems when menu is disabled and using 4570 // that. But that caused problems when menu is disabled and using
4568 * Alt-Tab-Esc: get into a strange state where no mouse-moved events 4571 // Alt-Tab-Esc: get into a strange state where no mouse-moved events
4569 * are received, mouse pointer remains hidden. */ 4572 // are received, mouse pointer remains hidden.
4570 return MyWindowProc(hwnd, uMsg, wParam, lParam); 4573 return MyWindowProc(hwnd, uMsg, wParam, lParam);
4571 #else 4574 #else
4572 return 0L; 4575 return 0L;
4573 #endif 4576 #endif
4574 4577
4575 case WM_SIZING: /* HANDLE_MSG doesn't seem to handle this one */ 4578 case WM_SIZING: // HANDLE_MSG doesn't seem to handle this one
4576 return _DuringSizing((UINT)wParam, (LPRECT)lParam); 4579 return _DuringSizing((UINT)wParam, (LPRECT)lParam);
4577 4580
4578 case WM_MOUSEWHEEL: 4581 case WM_MOUSEWHEEL:
4579 _OnMouseWheel(hwnd, HIWORD(wParam)); 4582 _OnMouseWheel(hwnd, HIWORD(wParam));
4580 return 0L; 4583 return 0L;
4581 4584
4582 /* Notification for change in SystemParametersInfo() */ 4585 // Notification for change in SystemParametersInfo()
4583 case WM_SETTINGCHANGE: 4586 case WM_SETTINGCHANGE:
4584 return _OnSettingChange((UINT)wParam); 4587 return _OnSettingChange((UINT)wParam);
4585 4588
4586 #if defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE) 4589 #if defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE)
4587 case WM_NOTIFY: 4590 case WM_NOTIFY:
4651 { 4654 {
4652 if (hdr->code == TTN_GETDISPINFOW) 4655 if (hdr->code == TTN_GETDISPINFOW)
4653 { 4656 {
4654 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam; 4657 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
4655 4658
4656 /* Set the maximum width, this also enables using 4659 // Set the maximum width, this also enables using
4657 * \n for line break. */ 4660 // \n for line break.
4658 SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 4661 SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH,
4659 0, 500); 4662 0, 500);
4660 4663
4661 tt_text = enc_to_utf16(str, NULL); 4664 tt_text = enc_to_utf16(str, NULL);
4662 lpdi->lpszText = tt_text; 4665 lpdi->lpszText = tt_text;
4663 /* can't show tooltip if failed */ 4666 // can't show tooltip if failed
4664 } 4667 }
4665 else 4668 else
4666 { 4669 {
4667 LPNMTTDISPINFO lpdi = (LPNMTTDISPINFO)lParam; 4670 LPNMTTDISPINFO lpdi = (LPNMTTDISPINFO)lParam;
4668 4671
4669 /* Set the maximum width, this also enables using 4672 // Set the maximum width, this also enables using
4670 * \n for line break. */ 4673 // \n for line break.
4671 SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 4674 SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH,
4672 0, 500); 4675 0, 500);
4673 4676
4674 if (STRLEN(str) < sizeof(lpdi->szText) 4677 if (STRLEN(str) < sizeof(lpdi->szText)
4675 || ((tt_text = vim_strsave(str)) == NULL)) 4678 || ((tt_text = vim_strsave(str)) == NULL))
4758 if (gui_mch_showing_tabline()) 4761 if (gui_mch_showing_tabline())
4759 { 4762 {
4760 int yPos = GET_Y_LPARAM(lParam); 4763 int yPos = GET_Y_LPARAM(lParam);
4761 RECT rct; 4764 RECT rct;
4762 4765
4763 /* If the cursor is on the GUI tabline, don't process this 4766 // If the cursor is on the GUI tabline, don't process this
4764 * event */ 4767 // event
4765 GetWindowRect(s_textArea, &rct); 4768 GetWindowRect(s_textArea, &rct);
4766 if (yPos < rct.top) 4769 if (yPos < rct.top)
4767 return result; 4770 return result;
4768 } 4771 }
4769 #endif 4772 #endif
4770 (void)gui_mch_get_winpos(&x, &y); 4773 (void)gui_mch_get_winpos(&x, &y);
4771 xPos -= x; 4774 xPos -= x;
4772 4775
4773 if (xPos < 48) /* <VN> TODO should use system metric? */ 4776 if (xPos < 48) // <VN> TODO should use system metric?
4774 return HTBOTTOMLEFT; 4777 return HTBOTTOMLEFT;
4775 else 4778 else
4776 return HTBOTTOMRIGHT; 4779 return HTBOTTOMRIGHT;
4777 } 4780 }
4778 else 4781 else
4779 return result; 4782 return result;
4780 } 4783 }
4781 /* break; notreached */ 4784 // break; notreached
4782 4785
4783 #ifdef FEAT_MBYTE_IME 4786 #ifdef FEAT_MBYTE_IME
4784 case WM_IME_NOTIFY: 4787 case WM_IME_NOTIFY:
4785 if (!_OnImeNotify(hwnd, (DWORD)wParam, (DWORD)lParam)) 4788 if (!_OnImeNotify(hwnd, (DWORD)wParam, (DWORD)lParam))
4786 return MyWindowProc(hwnd, uMsg, wParam, lParam); 4789 return MyWindowProc(hwnd, uMsg, wParam, lParam);
4805 4808
4806 /* 4809 /*
4807 * End of call-back routines 4810 * End of call-back routines
4808 */ 4811 */
4809 4812
4810 /* parent window, if specified with -P */ 4813 // parent window, if specified with -P
4811 HWND vim_parent_hwnd = NULL; 4814 HWND vim_parent_hwnd = NULL;
4812 4815
4813 static BOOL CALLBACK 4816 static BOOL CALLBACK
4814 FindWindowTitle(HWND hwnd, LPARAM lParam) 4817 FindWindowTitle(HWND hwnd, LPARAM lParam)
4815 { 4818 {
4818 4821
4819 if (GetWindowText(hwnd, buf, sizeof(buf))) 4822 if (GetWindowText(hwnd, buf, sizeof(buf)))
4820 { 4823 {
4821 if (strstr(buf, title) != NULL) 4824 if (strstr(buf, title) != NULL)
4822 { 4825 {
4823 /* Found it. Store the window ref. and quit searching if MDI 4826 // Found it. Store the window ref. and quit searching if MDI
4824 * works. */ 4827 // works.
4825 vim_parent_hwnd = FindWindowEx(hwnd, NULL, "MDIClient", NULL); 4828 vim_parent_hwnd = FindWindowEx(hwnd, NULL, "MDIClient", NULL);
4826 if (vim_parent_hwnd != NULL) 4829 if (vim_parent_hwnd != NULL)
4827 return FALSE; 4830 return FALSE;
4828 } 4831 }
4829 } 4832 }
4830 return TRUE; /* continue searching */ 4833 return TRUE; // continue searching
4831 } 4834 }
4832 4835
4833 /* 4836 /*
4834 * Invoked for '-P "title"' argument: search for parent application to open 4837 * Invoked for '-P "title"' argument: search for parent application to open
4835 * our window in. 4838 * our window in.
4853 4856
4854 # ifdef VIMDLL 4857 # ifdef VIMDLL
4855 gui.in_use = mch_is_gui_executable(); 4858 gui.in_use = mch_is_gui_executable();
4856 # endif 4859 # endif
4857 4860
4858 /* Can't use emsg() here, we have not finished initialisation yet. */ 4861 // Can't use emsg() here, we have not finished initialisation yet.
4859 vim_snprintf(buf, IOSIZE, 4862 vim_snprintf(buf, IOSIZE,
4860 _("E243: Argument not supported: \"-%s\"; Use the OLE version."), 4863 _("E243: Argument not supported: \"-%s\"; Use the OLE version."),
4861 arg); 4864 arg);
4862 mch_errmsg(buf); 4865 mch_errmsg(buf);
4863 } 4866 }
5007 gui_mch_prepare(int *argc, char **argv) 5010 gui_mch_prepare(int *argc, char **argv)
5008 { 5011 {
5009 int silent = FALSE; 5012 int silent = FALSE;
5010 int idx; 5013 int idx;
5011 5014
5012 /* Check for special OLE command line parameters */ 5015 // Check for special OLE command line parameters
5013 if ((*argc == 2 || *argc == 3) && (argv[1][0] == '-' || argv[1][0] == '/')) 5016 if ((*argc == 2 || *argc == 3) && (argv[1][0] == '-' || argv[1][0] == '/'))
5014 { 5017 {
5015 /* Check for a "-silent" argument first. */ 5018 // Check for a "-silent" argument first.
5016 if (*argc == 3 && STRICMP(argv[1] + 1, "silent") == 0 5019 if (*argc == 3 && STRICMP(argv[1] + 1, "silent") == 0
5017 && (argv[2][0] == '-' || argv[2][0] == '/')) 5020 && (argv[2][0] == '-' || argv[2][0] == '/'))
5018 { 5021 {
5019 silent = TRUE; 5022 silent = TRUE;
5020 idx = 2; 5023 idx = 2;
5021 } 5024 }
5022 else 5025 else
5023 idx = 1; 5026 idx = 1;
5024 5027
5025 /* Register Vim as an OLE Automation server */ 5028 // Register Vim as an OLE Automation server
5026 if (STRICMP(argv[idx] + 1, "register") == 0) 5029 if (STRICMP(argv[idx] + 1, "register") == 0)
5027 { 5030 {
5028 #ifdef FEAT_OLE 5031 #ifdef FEAT_OLE
5029 RegisterMe(silent); 5032 RegisterMe(silent);
5030 mch_exit(0); 5033 mch_exit(0);
5033 ole_error("register"); 5036 ole_error("register");
5034 mch_exit(2); 5037 mch_exit(2);
5035 #endif 5038 #endif
5036 } 5039 }
5037 5040
5038 /* Unregister Vim as an OLE Automation server */ 5041 // Unregister Vim as an OLE Automation server
5039 if (STRICMP(argv[idx] + 1, "unregister") == 0) 5042 if (STRICMP(argv[idx] + 1, "unregister") == 0)
5040 { 5043 {
5041 #ifdef FEAT_OLE 5044 #ifdef FEAT_OLE
5042 UnregisterMe(!silent); 5045 UnregisterMe(!silent);
5043 mch_exit(0); 5046 mch_exit(0);
5046 ole_error("unregister"); 5049 ole_error("unregister");
5047 mch_exit(2); 5050 mch_exit(2);
5048 #endif 5051 #endif
5049 } 5052 }
5050 5053
5051 /* Ignore an -embedding argument. It is only relevant if the 5054 // Ignore an -embedding argument. It is only relevant if the
5052 * application wants to treat the case when it is started manually 5055 // application wants to treat the case when it is started manually
5053 * differently from the case where it is started via automation (and 5056 // differently from the case where it is started via automation (and
5054 * we don't). 5057 // we don't).
5055 */
5056 if (STRICMP(argv[idx] + 1, "embedding") == 0) 5058 if (STRICMP(argv[idx] + 1, "embedding") == 0)
5057 { 5059 {
5058 #ifdef FEAT_OLE 5060 #ifdef FEAT_OLE
5059 *argc = 1; 5061 *argc = 1;
5060 #else 5062 #else
5067 #ifdef FEAT_OLE 5069 #ifdef FEAT_OLE
5068 { 5070 {
5069 int bDoRestart = FALSE; 5071 int bDoRestart = FALSE;
5070 5072
5071 InitOLE(&bDoRestart); 5073 InitOLE(&bDoRestart);
5072 /* automatically exit after registering */ 5074 // automatically exit after registering
5073 if (bDoRestart) 5075 if (bDoRestart)
5074 mch_exit(0); 5076 mch_exit(0);
5075 } 5077 }
5076 #endif 5078 #endif
5077 5079
5078 #ifdef FEAT_NETBEANS_INTG 5080 #ifdef FEAT_NETBEANS_INTG
5079 { 5081 {
5080 /* stolen from gui_x11.c */ 5082 // stolen from gui_x11.c
5081 int arg; 5083 int arg;
5082 5084
5083 for (arg = 1; arg < *argc; arg++) 5085 for (arg = 1; arg < *argc; arg++)
5084 if (strncmp("-nb", argv[arg], 3) == 0) 5086 if (strncmp("-nb", argv[arg], 3) == 0)
5085 { 5087 {
5086 netbeansArg = argv[arg]; 5088 netbeansArg = argv[arg];
5087 mch_memmove(&argv[arg], &argv[arg + 1], 5089 mch_memmove(&argv[arg], &argv[arg + 1],
5088 (--*argc - arg) * sizeof(char *)); 5090 (--*argc - arg) * sizeof(char *));
5089 argv[*argc] = NULL; 5091 argv[*argc] = NULL;
5090 break; /* enough? */ 5092 break; // enough?
5091 } 5093 }
5092 } 5094 }
5093 #endif 5095 #endif
5094 } 5096 }
5095 5097
5105 WNDCLASSW wndclassw; 5107 WNDCLASSW wndclassw;
5106 #ifdef GLOBAL_IME 5108 #ifdef GLOBAL_IME
5107 ATOM atom; 5109 ATOM atom;
5108 #endif 5110 #endif
5109 5111
5110 /* Return here if the window was already opened (happens when 5112 // Return here if the window was already opened (happens when
5111 * gui_mch_dialog() is called early). */ 5113 // gui_mch_dialog() is called early).
5112 if (s_hwnd != NULL) 5114 if (s_hwnd != NULL)
5113 goto theend; 5115 goto theend;
5114 5116
5115 /* 5117 /*
5116 * Load the tearoff bitmap 5118 * Load the tearoff bitmap
5120 #endif 5122 #endif
5121 5123
5122 gui.scrollbar_width = GetSystemMetrics(SM_CXVSCROLL); 5124 gui.scrollbar_width = GetSystemMetrics(SM_CXVSCROLL);
5123 gui.scrollbar_height = GetSystemMetrics(SM_CYHSCROLL); 5125 gui.scrollbar_height = GetSystemMetrics(SM_CYHSCROLL);
5124 #ifdef FEAT_MENU 5126 #ifdef FEAT_MENU
5125 gui.menu_height = 0; /* Windows takes care of this */ 5127 gui.menu_height = 0; // Windows takes care of this
5126 #endif 5128 #endif
5127 gui.border_width = 0; 5129 gui.border_width = 0;
5128 5130
5129 s_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); 5131 s_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
5130 5132
5131 /* First try using the wide version, so that we can use any title. 5133 // First try using the wide version, so that we can use any title.
5132 * Otherwise only characters in the active codepage will work. */ 5134 // Otherwise only characters in the active codepage will work.
5133 if (GetClassInfoW(g_hinst, szVimWndClassW, &wndclassw) == 0) 5135 if (GetClassInfoW(g_hinst, szVimWndClassW, &wndclassw) == 0)
5134 { 5136 {
5135 wndclassw.style = CS_DBLCLKS; 5137 wndclassw.style = CS_DBLCLKS;
5136 wndclassw.lpfnWndProc = _WndProc; 5138 wndclassw.lpfnWndProc = _WndProc;
5137 wndclassw.cbClsExtra = 0; 5139 wndclassw.cbClsExtra = 0;
5173 g_hinst, NULL); 5175 g_hinst, NULL);
5174 #ifdef HAVE_TRY_EXCEPT 5176 #ifdef HAVE_TRY_EXCEPT
5175 } 5177 }
5176 __except(EXCEPTION_EXECUTE_HANDLER) 5178 __except(EXCEPTION_EXECUTE_HANDLER)
5177 { 5179 {
5178 /* NOP */ 5180 // NOP
5179 } 5181 }
5180 #endif 5182 #endif
5181 if (s_hwnd == NULL) 5183 if (s_hwnd == NULL)
5182 { 5184 {
5183 emsg(_("E672: Unable to open window inside MDI application")); 5185 emsg(_("E672: Unable to open window inside MDI application"));
5184 mch_exit(2); 5186 mch_exit(2);
5185 } 5187 }
5186 } 5188 }
5187 else 5189 else
5188 { 5190 {
5189 /* If the provided windowid is not valid reset it to zero, so that it 5191 // If the provided windowid is not valid reset it to zero, so that it
5190 * is ignored and we open our own window. */ 5192 // is ignored and we open our own window.
5191 if (IsWindow((HWND)win_socket_id) <= 0) 5193 if (IsWindow((HWND)win_socket_id) <= 0)
5192 win_socket_id = 0; 5194 win_socket_id = 0;
5193 5195
5194 /* Create a window. If win_socket_id is not zero without border and 5196 // Create a window. If win_socket_id is not zero without border and
5195 * titlebar, it will be reparented below. */ 5197 // titlebar, it will be reparented below.
5196 s_hwnd = CreateWindowW( 5198 s_hwnd = CreateWindowW(
5197 szVimWndClassW, L"Vim MSWindows GUI", 5199 szVimWndClassW, L"Vim MSWindows GUI",
5198 (win_socket_id == 0 ? WS_OVERLAPPEDWINDOW : WS_POPUP) 5200 (win_socket_id == 0 ? WS_OVERLAPPEDWINDOW : WS_POPUP)
5199 | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 5201 | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
5200 gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x, 5202 gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
5201 gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y, 5203 gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y,
5202 100, /* Any value will do */ 5204 100, // Any value will do
5203 100, /* Any value will do */ 5205 100, // Any value will do
5204 NULL, NULL, 5206 NULL, NULL,
5205 g_hinst, NULL); 5207 g_hinst, NULL);
5206 if (s_hwnd != NULL && win_socket_id != 0) 5208 if (s_hwnd != NULL && win_socket_id != 0)
5207 { 5209 {
5208 SetParent(s_hwnd, (HWND)win_socket_id); 5210 SetParent(s_hwnd, (HWND)win_socket_id);
5218 #endif 5220 #endif
5219 #if defined(FEAT_MBYTE_IME) && defined(DYNAMIC_IME) 5221 #if defined(FEAT_MBYTE_IME) && defined(DYNAMIC_IME)
5220 dyn_imm_load(); 5222 dyn_imm_load();
5221 #endif 5223 #endif
5222 5224
5223 /* Create the text area window */ 5225 // Create the text area window
5224 if (GetClassInfoW(g_hinst, szTextAreaClassW, &wndclassw) == 0) 5226 if (GetClassInfoW(g_hinst, szTextAreaClassW, &wndclassw) == 0)
5225 { 5227 {
5226 wndclassw.style = CS_OWNDC; 5228 wndclassw.style = CS_OWNDC;
5227 wndclassw.lpfnWndProc = _TextAreaWndProc; 5229 wndclassw.lpfnWndProc = _TextAreaWndProc;
5228 wndclassw.cbClsExtra = 0; 5230 wndclassw.cbClsExtra = 0;
5249 5251
5250 if (s_textArea == NULL) 5252 if (s_textArea == NULL)
5251 return FAIL; 5253 return FAIL;
5252 5254
5253 #ifdef FEAT_LIBCALL 5255 #ifdef FEAT_LIBCALL
5254 /* Try loading an icon from $RUNTIMEPATH/bitmaps/vim.ico. */ 5256 // Try loading an icon from $RUNTIMEPATH/bitmaps/vim.ico.
5255 { 5257 {
5256 HANDLE hIcon = NULL; 5258 HANDLE hIcon = NULL;
5257 5259
5258 if (mch_icon_load(&hIcon) == OK && hIcon != NULL) 5260 if (mch_icon_load(&hIcon) == OK && hIcon != NULL)
5259 SendMessage(s_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); 5261 SendMessage(s_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
5265 #endif 5267 #endif
5266 s_hdc = GetDC(s_textArea); 5268 s_hdc = GetDC(s_textArea);
5267 5269
5268 DragAcceptFiles(s_hwnd, TRUE); 5270 DragAcceptFiles(s_hwnd, TRUE);
5269 5271
5270 /* Do we need to bother with this? */ 5272 // Do we need to bother with this?
5271 /* m_fMouseAvail = GetSystemMetrics(SM_MOUSEPRESENT); */ 5273 // m_fMouseAvail = GetSystemMetrics(SM_MOUSEPRESENT);
5272 5274
5273 /* Get background/foreground colors from the system */ 5275 // Get background/foreground colors from the system
5274 gui_mch_def_colors(); 5276 gui_mch_def_colors();
5275 5277
5276 /* Get the colors from the "Normal" group (set in syntax.c or in a vimrc 5278 // Get the colors from the "Normal" group (set in syntax.c or in a vimrc
5277 * file) */ 5279 // file)
5278 set_normal_colors(); 5280 set_normal_colors();
5279 5281
5280 /* 5282 /*
5281 * Check that none of the colors are the same as the background color. 5283 * Check that none of the colors are the same as the background color.
5282 * Then store the current values as the defaults. 5284 * Then store the current values as the defaults.
5283 */ 5285 */
5284 gui_check_colors(); 5286 gui_check_colors();
5285 gui.def_norm_pixel = gui.norm_pixel; 5287 gui.def_norm_pixel = gui.norm_pixel;
5286 gui.def_back_pixel = gui.back_pixel; 5288 gui.def_back_pixel = gui.back_pixel;
5287 5289
5288 /* Get the colors for the highlight groups (gui_check_colors() might have 5290 // Get the colors for the highlight groups (gui_check_colors() might have
5289 * changed them) */ 5291 // changed them)
5290 highlight_gui_started(); 5292 highlight_gui_started();
5291 5293
5292 /* 5294 /*
5293 * Start out by adding the configured border width into the border offset. 5295 * Start out by adding the configured border width into the border offset.
5294 */ 5296 */
5319 /* 5321 /*
5320 * Initialise the dialog box stuff 5322 * Initialise the dialog box stuff
5321 */ 5323 */
5322 s_findrep_msg = RegisterWindowMessage(FINDMSGSTRING); 5324 s_findrep_msg = RegisterWindowMessage(FINDMSGSTRING);
5323 5325
5324 /* Initialise the struct */ 5326 // Initialise the struct
5325 s_findrep_struct.lStructSize = sizeof(s_findrep_struct); 5327 s_findrep_struct.lStructSize = sizeof(s_findrep_struct);
5326 s_findrep_struct.lpstrFindWhat = ALLOC_MULT(WCHAR, MSWIN_FR_BUFSIZE); 5328 s_findrep_struct.lpstrFindWhat = ALLOC_MULT(WCHAR, MSWIN_FR_BUFSIZE);
5327 s_findrep_struct.lpstrFindWhat[0] = NUL; 5329 s_findrep_struct.lpstrFindWhat[0] = NUL;
5328 s_findrep_struct.lpstrReplaceWith = ALLOC_MULT(WCHAR, MSWIN_FR_BUFSIZE); 5330 s_findrep_struct.lpstrReplaceWith = ALLOC_MULT(WCHAR, MSWIN_FR_BUFSIZE);
5329 s_findrep_struct.lpstrReplaceWith[0] = NUL; 5331 s_findrep_struct.lpstrReplaceWith[0] = NUL;
5331 s_findrep_struct.wReplaceWithLen = MSWIN_FR_BUFSIZE; 5333 s_findrep_struct.wReplaceWithLen = MSWIN_FR_BUFSIZE;
5332 #endif 5334 #endif
5333 5335
5334 #ifdef FEAT_EVAL 5336 #ifdef FEAT_EVAL
5335 # if !defined(_MSC_VER) || (_MSC_VER < 1400) 5337 # if !defined(_MSC_VER) || (_MSC_VER < 1400)
5336 /* Define HandleToLong for old MS and non-MS compilers if not defined. */ 5338 // Define HandleToLong for old MS and non-MS compilers if not defined.
5337 # ifndef HandleToLong 5339 # ifndef HandleToLong
5338 # define HandleToLong(h) ((long)(intptr_t)(h)) 5340 # define HandleToLong(h) ((long)(intptr_t)(h))
5339 # endif 5341 # endif
5340 # endif 5342 # endif
5341 /* set the v:windowid variable */ 5343 // set the v:windowid variable
5342 set_vim_var_nr(VV_WINDOWID, HandleToLong(s_hwnd)); 5344 set_vim_var_nr(VV_WINDOWID, HandleToLong(s_hwnd));
5343 #endif 5345 #endif
5344 5346
5345 #ifdef FEAT_RENDER_OPTIONS 5347 #ifdef FEAT_RENDER_OPTIONS
5346 if (p_rop) 5348 if (p_rop)
5347 (void)gui_mch_set_rendering_options(p_rop); 5349 (void)gui_mch_set_rendering_options(p_rop);
5348 #endif 5350 #endif
5349 5351
5350 theend: 5352 theend:
5351 /* Display any pending error messages */ 5353 // Display any pending error messages
5352 display_errors(); 5354 display_errors();
5353 5355
5354 return OK; 5356 return OK;
5355 } 5357 }
5356 5358
5362 get_work_area(RECT *spi_rect) 5364 get_work_area(RECT *spi_rect)
5363 { 5365 {
5364 HMONITOR mon; 5366 HMONITOR mon;
5365 MONITORINFO moninfo; 5367 MONITORINFO moninfo;
5366 5368
5367 /* work out which monitor the window is on, and get *its* work area */ 5369 // work out which monitor the window is on, and get *its* work area
5368 mon = MonitorFromWindow(s_hwnd, MONITOR_DEFAULTTOPRIMARY); 5370 mon = MonitorFromWindow(s_hwnd, MONITOR_DEFAULTTOPRIMARY);
5369 if (mon != NULL) 5371 if (mon != NULL)
5370 { 5372 {
5371 moninfo.cbSize = sizeof(MONITORINFO); 5373 moninfo.cbSize = sizeof(MONITORINFO);
5372 if (GetMonitorInfo(mon, &moninfo)) 5374 if (GetMonitorInfo(mon, &moninfo))
5373 { 5375 {
5374 *spi_rect = moninfo.rcWork; 5376 *spi_rect = moninfo.rcWork;
5375 return; 5377 return;
5376 } 5378 }
5377 } 5379 }
5378 /* this is the old method... */ 5380 // this is the old method...
5379 SystemParametersInfo(SPI_GETWORKAREA, 0, spi_rect, 0); 5381 SystemParametersInfo(SPI_GETWORKAREA, 0, spi_rect, 0);
5380 } 5382 }
5381 5383
5382 /* 5384 /*
5383 * Set the size of the window to the given width and height in pixels. 5385 * Set the size of the window to the given width and height in pixels.
5394 { 5396 {
5395 RECT workarea_rect; 5397 RECT workarea_rect;
5396 int win_width, win_height; 5398 int win_width, win_height;
5397 WINDOWPLACEMENT wndpl; 5399 WINDOWPLACEMENT wndpl;
5398 5400
5399 /* Try to keep window completely on screen. */ 5401 // Try to keep window completely on screen.
5400 /* Get position of the screen work area. This is the part that is not 5402 // Get position of the screen work area. This is the part that is not
5401 * used by the taskbar or appbars. */ 5403 // used by the taskbar or appbars.
5402 get_work_area(&workarea_rect); 5404 get_work_area(&workarea_rect);
5403 5405
5404 /* Get current position of our window. Note that the .left and .top are 5406 // Get current position of our window. Note that the .left and .top are
5405 * relative to the work area. */ 5407 // relative to the work area.
5406 wndpl.length = sizeof(WINDOWPLACEMENT); 5408 wndpl.length = sizeof(WINDOWPLACEMENT);
5407 GetWindowPlacement(s_hwnd, &wndpl); 5409 GetWindowPlacement(s_hwnd, &wndpl);
5408 5410
5409 /* Resizing a maximized window looks very strange, unzoom it first. 5411 // Resizing a maximized window looks very strange, unzoom it first.
5410 * But don't do it when still starting up, it may have been requested in 5412 // But don't do it when still starting up, it may have been requested in
5411 * the shortcut. */ 5413 // the shortcut.
5412 if (wndpl.showCmd == SW_SHOWMAXIMIZED && starting == 0) 5414 if (wndpl.showCmd == SW_SHOWMAXIMIZED && starting == 0)
5413 { 5415 {
5414 ShowWindow(s_hwnd, SW_SHOWNORMAL); 5416 ShowWindow(s_hwnd, SW_SHOWNORMAL);
5415 /* Need to get the settings of the normal window. */ 5417 // Need to get the settings of the normal window.
5416 GetWindowPlacement(s_hwnd, &wndpl); 5418 GetWindowPlacement(s_hwnd, &wndpl);
5417 } 5419 }
5418 5420
5419 /* compute the size of the outside of the window */ 5421 // compute the size of the outside of the window
5420 win_width = width + (GetSystemMetrics(SM_CXFRAME) + 5422 win_width = width + (GetSystemMetrics(SM_CXFRAME) +
5421 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2; 5423 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2;
5422 win_height = height + (GetSystemMetrics(SM_CYFRAME) + 5424 win_height = height + (GetSystemMetrics(SM_CYFRAME) +
5423 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2 5425 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2
5424 + GetSystemMetrics(SM_CYCAPTION) 5426 + GetSystemMetrics(SM_CYCAPTION)
5425 #ifdef FEAT_MENU 5427 #ifdef FEAT_MENU
5426 + gui_mswin_get_menu_height(FALSE) 5428 + gui_mswin_get_menu_height(FALSE)
5427 #endif 5429 #endif
5428 ; 5430 ;
5429 5431
5430 /* The following should take care of keeping Vim on the same monitor, no 5432 // The following should take care of keeping Vim on the same monitor, no
5431 * matter if the secondary monitor is left or right of the primary 5433 // matter if the secondary monitor is left or right of the primary
5432 * monitor. */ 5434 // monitor.
5433 wndpl.rcNormalPosition.right = wndpl.rcNormalPosition.left + win_width; 5435 wndpl.rcNormalPosition.right = wndpl.rcNormalPosition.left + win_width;
5434 wndpl.rcNormalPosition.bottom = wndpl.rcNormalPosition.top + win_height; 5436 wndpl.rcNormalPosition.bottom = wndpl.rcNormalPosition.top + win_height;
5435 5437
5436 /* If the window is going off the screen, move it on to the screen. */ 5438 // If the window is going off the screen, move it on to the screen.
5437 if ((direction & RESIZE_HOR) 5439 if ((direction & RESIZE_HOR)
5438 && wndpl.rcNormalPosition.right > workarea_rect.right) 5440 && wndpl.rcNormalPosition.right > workarea_rect.right)
5439 OffsetRect(&wndpl.rcNormalPosition, 5441 OffsetRect(&wndpl.rcNormalPosition,
5440 workarea_rect.right - wndpl.rcNormalPosition.right, 0); 5442 workarea_rect.right - wndpl.rcNormalPosition.right, 0);
5441 5443
5452 if ((direction & RESIZE_VERT) 5454 if ((direction & RESIZE_VERT)
5453 && wndpl.rcNormalPosition.top < workarea_rect.top) 5455 && wndpl.rcNormalPosition.top < workarea_rect.top)
5454 OffsetRect(&wndpl.rcNormalPosition, 5456 OffsetRect(&wndpl.rcNormalPosition,
5455 0, workarea_rect.top - wndpl.rcNormalPosition.top); 5457 0, workarea_rect.top - wndpl.rcNormalPosition.top);
5456 5458
5457 /* set window position - we should use SetWindowPlacement rather than 5459 // set window position - we should use SetWindowPlacement rather than
5458 * SetWindowPos as the MSDN docs say the coord systems returned by 5460 // SetWindowPos as the MSDN docs say the coord systems returned by
5459 * these two are not compatible. */ 5461 // these two are not compatible.
5460 SetWindowPlacement(s_hwnd, &wndpl); 5462 SetWindowPlacement(s_hwnd, &wndpl);
5461 5463
5462 SetActiveWindow(s_hwnd); 5464 SetActiveWindow(s_hwnd);
5463 SetFocus(s_hwnd); 5465 SetFocus(s_hwnd);
5464 5466
5465 #ifdef FEAT_MENU 5467 #ifdef FEAT_MENU
5466 /* Menu may wrap differently now */ 5468 // Menu may wrap differently now
5467 gui_mswin_get_menu_height(!gui.starting); 5469 gui_mswin_get_menu_height(!gui.starting);
5468 #endif 5470 #endif
5469 } 5471 }
5470 5472
5471 5473
5541 /* 5543 /*
5542 * Multi-byte handling, originally by Sung-Hoon Baek. 5544 * Multi-byte handling, originally by Sung-Hoon Baek.
5543 * First static functions (no prototypes generated). 5545 * First static functions (no prototypes generated).
5544 */ 5546 */
5545 # ifdef _MSC_VER 5547 # ifdef _MSC_VER
5546 # include <ime.h> /* Apparently not needed for Cygwin or MinGW. */ 5548 # include <ime.h> // Apparently not needed for Cygwin or MinGW.
5547 # endif 5549 # endif
5548 # include <imm.h> 5550 # include <imm.h>
5549 5551
5550 /* 5552 /*
5551 * handle WM_IME_NOTIFY message 5553 * handle WM_IME_NOTIFY message
5564 if (pImmGetOpenStatus(hImc)) 5566 if (pImmGetOpenStatus(hImc))
5565 { 5567 {
5566 pImmSetCompositionFontW(hImc, &norm_logfont); 5568 pImmSetCompositionFontW(hImc, &norm_logfont);
5567 im_set_position(gui.row, gui.col); 5569 im_set_position(gui.row, gui.col);
5568 5570
5569 /* Disable langmap */ 5571 // Disable langmap
5570 State &= ~LANGMAP; 5572 State &= ~LANGMAP;
5571 if (State & INSERT) 5573 if (State & INSERT)
5572 { 5574 {
5573 # if defined(FEAT_KEYMAP) 5575 # if defined(FEAT_KEYMAP)
5574 /* Unshown 'keymap' in status lines */ 5576 // Unshown 'keymap' in status lines
5575 if (curbuf->b_p_iminsert == B_IMODE_LMAP) 5577 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
5576 { 5578 {
5577 /* Save cursor position */ 5579 // Save cursor position
5578 int old_row = gui.row; 5580 int old_row = gui.row;
5579 int old_col = gui.col; 5581 int old_col = gui.col;
5580 5582
5581 // This must be called here before 5583 // This must be called here before
5582 // status_redraw_curbuf(), otherwise the mode 5584 // status_redraw_curbuf(), otherwise the mode
5583 // message may appear in the wrong position. 5585 // message may appear in the wrong position.
5584 showmode(); 5586 showmode();
5585 status_redraw_curbuf(); 5587 status_redraw_curbuf();
5586 update_screen(0); 5588 update_screen(0);
5587 /* Restore cursor position */ 5589 // Restore cursor position
5588 gui.row = old_row; 5590 gui.row = old_row;
5589 gui.col = old_col; 5591 gui.col = old_col;
5590 } 5592 }
5591 # endif 5593 # endif
5592 } 5594 }
5604 _OnImeComposition(HWND hwnd, WPARAM dbcs UNUSED, LPARAM param) 5606 _OnImeComposition(HWND hwnd, WPARAM dbcs UNUSED, LPARAM param)
5605 { 5607 {
5606 char_u *ret; 5608 char_u *ret;
5607 int len; 5609 int len;
5608 5610
5609 if ((param & GCS_RESULTSTR) == 0) /* Composition unfinished. */ 5611 if ((param & GCS_RESULTSTR) == 0) // Composition unfinished.
5610 return 0; 5612 return 0;
5611 5613
5612 ret = GetResultStr(hwnd, GCS_RESULTSTR, &len); 5614 ret = GetResultStr(hwnd, GCS_RESULTSTR, &len);
5613 if (ret != NULL) 5615 if (ret != NULL)
5614 { 5616 {
5629 LONG ret; 5631 LONG ret;
5630 LPWSTR wbuf = NULL; 5632 LPWSTR wbuf = NULL;
5631 char_u *buf; 5633 char_u *buf;
5632 5634
5633 if (!pImmGetContext) 5635 if (!pImmGetContext)
5634 return NULL; /* no imm32.dll */ 5636 return NULL; // no imm32.dll
5635 5637
5636 /* Try Unicode; this'll always work on NT regardless of codepage. */ 5638 // Try Unicode; this'll always work on NT regardless of codepage.
5637 ret = pImmGetCompositionStringW(hIMC, GCS, NULL, 0); 5639 ret = pImmGetCompositionStringW(hIMC, GCS, NULL, 0);
5638 if (ret == 0) 5640 if (ret == 0)
5639 return NULL; /* empty */ 5641 return NULL; // empty
5640 5642
5641 if (ret > 0) 5643 if (ret > 0)
5642 { 5644 {
5643 /* Allocate the requested buffer plus space for the NUL character. */ 5645 // Allocate the requested buffer plus space for the NUL character.
5644 wbuf = alloc(ret + sizeof(WCHAR)); 5646 wbuf = alloc(ret + sizeof(WCHAR));
5645 if (wbuf != NULL) 5647 if (wbuf != NULL)
5646 { 5648 {
5647 pImmGetCompositionStringW(hIMC, GCS, wbuf, ret); 5649 pImmGetCompositionStringW(hIMC, GCS, wbuf, ret);
5648 *lenp = ret / sizeof(WCHAR); 5650 *lenp = ret / sizeof(WCHAR);
5649 } 5651 }
5650 return (short_u *)wbuf; 5652 return (short_u *)wbuf;
5651 } 5653 }
5652 5654
5653 /* ret < 0; we got an error, so try the ANSI version. This'll work 5655 // ret < 0; we got an error, so try the ANSI version. This'll work
5654 * on 9x/ME, but only if the codepage happens to be set to whatever 5656 // on 9x/ME, but only if the codepage happens to be set to whatever
5655 * we're inputting. */ 5657 // we're inputting.
5656 ret = pImmGetCompositionStringA(hIMC, GCS, NULL, 0); 5658 ret = pImmGetCompositionStringA(hIMC, GCS, NULL, 0);
5657 if (ret <= 0) 5659 if (ret <= 0)
5658 return NULL; /* empty or error */ 5660 return NULL; // empty or error
5659 5661
5660 buf = alloc(ret); 5662 buf = alloc(ret);
5661 if (buf == NULL) 5663 if (buf == NULL)
5662 return NULL; 5664 return NULL;
5663 pImmGetCompositionStringA(hIMC, GCS, buf, ret); 5665 pImmGetCompositionStringA(hIMC, GCS, buf, ret);
5664 5666
5665 /* convert from codepage to UCS-2 */ 5667 // convert from codepage to UCS-2
5666 MultiByteToWideChar_alloc(GetACP(), 0, (LPCSTR)buf, ret, &wbuf, lenp); 5668 MultiByteToWideChar_alloc(GetACP(), 0, (LPCSTR)buf, ret, &wbuf, lenp);
5667 vim_free(buf); 5669 vim_free(buf);
5668 5670
5669 return (short_u *)wbuf; 5671 return (short_u *)wbuf;
5670 } 5672 }
5676 * get complete composition string 5678 * get complete composition string
5677 */ 5679 */
5678 static char_u * 5680 static char_u *
5679 GetResultStr(HWND hwnd, int GCS, int *lenp) 5681 GetResultStr(HWND hwnd, int GCS, int *lenp)
5680 { 5682 {
5681 HIMC hIMC; /* Input context handle. */ 5683 HIMC hIMC; // Input context handle.
5682 short_u *buf = NULL; 5684 short_u *buf = NULL;
5683 char_u *convbuf = NULL; 5685 char_u *convbuf = NULL;
5684 5686
5685 if (!pImmGetContext || (hIMC = pImmGetContext(hwnd)) == (HIMC)0) 5687 if (!pImmGetContext || (hIMC = pImmGetContext(hwnd)) == (HIMC)0)
5686 return NULL; 5688 return NULL;
5687 5689
5688 /* Reads in the composition string. */ 5690 // Reads in the composition string.
5689 buf = GetCompositionString_inUCS2(hIMC, GCS, lenp); 5691 buf = GetCompositionString_inUCS2(hIMC, GCS, lenp);
5690 if (buf == NULL) 5692 if (buf == NULL)
5691 return NULL; 5693 return NULL;
5692 5694
5693 convbuf = utf16_to_enc(buf, lenp); 5695 convbuf = utf16_to_enc(buf, lenp);
5695 vim_free(buf); 5697 vim_free(buf);
5696 return convbuf; 5698 return convbuf;
5697 } 5699 }
5698 #endif 5700 #endif
5699 5701
5700 /* For global functions we need prototypes. */ 5702 // For global functions we need prototypes.
5701 #if defined(FEAT_MBYTE_IME) || defined(PROTO) 5703 #if defined(FEAT_MBYTE_IME) || defined(PROTO)
5702 5704
5703 /* 5705 /*
5704 * set font to IM. 5706 * set font to IM.
5705 */ 5707 */
5752 mbyte_im_set_active(active); 5754 mbyte_im_set_active(active);
5753 return; 5755 return;
5754 } 5756 }
5755 # endif 5757 # endif
5756 5758
5757 if (pImmGetContext) /* if NULL imm32.dll wasn't loaded (yet) */ 5759 if (pImmGetContext) // if NULL imm32.dll wasn't loaded (yet)
5758 { 5760 {
5759 if (p_imdisable) 5761 if (p_imdisable)
5760 { 5762 {
5761 if (hImcOld == (HIMC)0) 5763 if (hImcOld == (HIMC)0)
5762 { 5764 {
5785 static DWORD dwConversionSaved = 0, dwSentenceSaved = 0; 5787 static DWORD dwConversionSaved = 0, dwSentenceSaved = 0;
5786 static BOOL bSaved = FALSE; 5788 static BOOL bSaved = FALSE;
5787 5789
5788 if (active) 5790 if (active)
5789 { 5791 {
5790 /* if we have a saved conversion status, restore it */ 5792 // if we have a saved conversion status, restore it
5791 if (bSaved) 5793 if (bSaved)
5792 pImmSetConversionStatus(hImc, dwConversionSaved, 5794 pImmSetConversionStatus(hImc, dwConversionSaved,
5793 dwSentenceSaved); 5795 dwSentenceSaved);
5794 bSaved = FALSE; 5796 bSaved = FALSE;
5795 } 5797 }
5796 else 5798 else
5797 { 5799 {
5798 /* save conversion status and disable korean */ 5800 // save conversion status and disable korean
5799 if (pImmGetConversionStatus(hImc, &dwConversionSaved, 5801 if (pImmGetConversionStatus(hImc, &dwConversionSaved,
5800 &dwSentenceSaved)) 5802 &dwSentenceSaved))
5801 { 5803 {
5802 bSaved = TRUE; 5804 bSaved = TRUE;
5803 pImmSetConversionStatus(hImc, 5805 pImmSetConversionStatus(hImc,
5834 pImmReleaseContext(s_hwnd, hImc); 5836 pImmReleaseContext(s_hwnd, hImc);
5835 } 5837 }
5836 return status; 5838 return status;
5837 } 5839 }
5838 5840
5839 #endif /* FEAT_MBYTE_IME */ 5841 #endif // FEAT_MBYTE_IME
5840 5842
5841 #if !defined(FEAT_MBYTE_IME) && defined(GLOBAL_IME) 5843 #if !defined(FEAT_MBYTE_IME) && defined(GLOBAL_IME)
5842 /* Win32 with GLOBAL IME */ 5844 // Win32 with GLOBAL IME
5843 5845
5844 /* 5846 /*
5845 * Notify cursor position to IM. 5847 * Notify cursor position to IM.
5846 */ 5848 */
5847 void 5849 void
5848 im_set_position(int row, int col) 5850 im_set_position(int row, int col)
5849 { 5851 {
5850 /* Win32 with GLOBAL IME */ 5852 // Win32 with GLOBAL IME
5851 POINT p; 5853 POINT p;
5852 5854
5853 p.x = FILL_X(col); 5855 p.x = FILL_X(col);
5854 p.y = FILL_Y(row); 5856 p.y = FILL_Y(row);
5855 MapWindowPoints(s_textArea, s_hwnd, &p, 1); 5857 MapWindowPoints(s_textArea, s_hwnd, &p, 1);
5886 while (--len >= 0) 5888 while (--len >= 0)
5887 { 5889 {
5888 c = *text++; 5890 c = *text++;
5889 switch (c) 5891 switch (c)
5890 { 5892 {
5891 case 0xa4: c = 0x20ac; break; /* euro */ 5893 case 0xa4: c = 0x20ac; break; // euro
5892 case 0xa6: c = 0x0160; break; /* S hat */ 5894 case 0xa6: c = 0x0160; break; // S hat
5893 case 0xa8: c = 0x0161; break; /* S -hat */ 5895 case 0xa8: c = 0x0161; break; // S -hat
5894 case 0xb4: c = 0x017d; break; /* Z hat */ 5896 case 0xb4: c = 0x017d; break; // Z hat
5895 case 0xb8: c = 0x017e; break; /* Z -hat */ 5897 case 0xb8: c = 0x017e; break; // Z -hat
5896 case 0xbc: c = 0x0152; break; /* OE */ 5898 case 0xbc: c = 0x0152; break; // OE
5897 case 0xbd: c = 0x0153; break; /* oe */ 5899 case 0xbd: c = 0x0153; break; // oe
5898 case 0xbe: c = 0x0178; break; /* Y */ 5900 case 0xbe: c = 0x0178; break; // Y
5899 } 5901 }
5900 *unicodebuf++ = c; 5902 *unicodebuf++ = c;
5901 } 5903 }
5902 } 5904 }
5903 5905
5947 #endif 5949 #endif
5948 { 5950 {
5949 HPEN hpen = CreatePen(PS_SOLID, 1, color); 5951 HPEN hpen = CreatePen(PS_SOLID, 1, color);
5950 HPEN old_pen = SelectObject(s_hdc, hpen); 5952 HPEN old_pen = SelectObject(s_hdc, hpen);
5951 MoveToEx(s_hdc, x1, y1, NULL); 5953 MoveToEx(s_hdc, x1, y1, NULL);
5952 /* Note: LineTo() excludes the last pixel in the line. */ 5954 // Note: LineTo() excludes the last pixel in the line.
5953 LineTo(s_hdc, x2, y2); 5955 LineTo(s_hdc, x2, y2);
5954 DeleteObject(SelectObject(s_hdc, old_pen)); 5956 DeleteObject(SelectObject(s_hdc, old_pen));
5955 } 5957 }
5956 } 5958 }
5957 5959
6039 */ 6041 */
6040 rc.left = FILL_X(col); 6042 rc.left = FILL_X(col);
6041 rc.top = FILL_Y(row); 6043 rc.top = FILL_Y(row);
6042 if (has_mbyte) 6044 if (has_mbyte)
6043 { 6045 {
6044 /* Compute the length in display cells. */ 6046 // Compute the length in display cells.
6045 rc.right = FILL_X(col + mb_string2cells(text, len)); 6047 rc.right = FILL_X(col + mb_string2cells(text, len));
6046 } 6048 }
6047 else 6049 else
6048 rc.right = FILL_X(col + len); 6050 rc.right = FILL_X(col + len);
6049 rc.bottom = FILL_Y(row + 1); 6051 rc.bottom = FILL_Y(row + 1);
6050 6052
6051 /* Cache the created brush, that saves a lot of time. We need two: 6053 // Cache the created brush, that saves a lot of time. We need two:
6052 * one for cursor background and one for the normal background. */ 6054 // one for cursor background and one for the normal background.
6053 if (gui.currBgColor == brush_color[0]) 6055 if (gui.currBgColor == brush_color[0])
6054 { 6056 {
6055 hbr = hbr_cache[0]; 6057 hbr = hbr_cache[0];
6056 brush_lru = 1; 6058 brush_lru = 1;
6057 } 6059 }
6095 if (pad_size != Columns || padding == NULL || padding[0] != gui.char_width) 6097 if (pad_size != Columns || padding == NULL || padding[0] != gui.char_width)
6096 { 6098 {
6097 vim_free(padding); 6099 vim_free(padding);
6098 pad_size = Columns; 6100 pad_size = Columns;
6099 6101
6100 /* Don't give an out-of-memory message here, it would call us 6102 // Don't give an out-of-memory message here, it would call us
6101 * recursively. */ 6103 // recursively.
6102 padding = LALLOC_MULT(int, pad_size); 6104 padding = LALLOC_MULT(int, pad_size);
6103 if (padding != NULL) 6105 if (padding != NULL)
6104 for (i = 0; i < pad_size; i++) 6106 for (i = 0; i < pad_size; i++)
6105 padding[i] = gui.char_width; 6107 padding[i] = gui.char_width;
6106 } 6108 }
6110 * of fixed-width fonts are often one pixel or so wider than their normal 6112 * of fixed-width fonts are often one pixel or so wider than their normal
6111 * versions. 6113 * versions.
6112 * No check for DRAW_BOLD, Windows will have done it already. 6114 * No check for DRAW_BOLD, Windows will have done it already.
6113 */ 6115 */
6114 6116
6115 /* Check if there are any UTF-8 characters. If not, use normal text 6117 // Check if there are any UTF-8 characters. If not, use normal text
6116 * output to speed up output. */ 6118 // output to speed up output.
6117 if (enc_utf8) 6119 if (enc_utf8)
6118 for (n = 0; n < len; ++n) 6120 for (n = 0; n < len; ++n)
6119 if (text[n] >= 0x80) 6121 if (text[n] >= 0x80)
6120 break; 6122 break;
6121 6123
6122 #if defined(FEAT_DIRECTX) 6124 #if defined(FEAT_DIRECTX)
6123 /* Quick hack to enable DirectWrite. To use DirectWrite (antialias), it is 6125 // Quick hack to enable DirectWrite. To use DirectWrite (antialias), it is
6124 * required that unicode drawing routine, currently. So this forces it 6126 // required that unicode drawing routine, currently. So this forces it
6125 * enabled. */ 6127 // enabled.
6126 if (IS_ENABLE_DIRECTX()) 6128 if (IS_ENABLE_DIRECTX())
6127 n = 0; /* Keep n < len, to enter block for unicode. */ 6129 n = 0; // Keep n < len, to enter block for unicode.
6128 #endif 6130 #endif
6129 6131
6130 /* Check if the Unicode buffer exists and is big enough. Create it 6132 // Check if the Unicode buffer exists and is big enough. Create it
6131 * with the same length as the multi-byte string, the number of wide 6133 // with the same length as the multi-byte string, the number of wide
6132 * characters is always equal or smaller. */ 6134 // characters is always equal or smaller.
6133 if ((enc_utf8 6135 if ((enc_utf8
6134 || (enc_codepage > 0 && (int)GetACP() != enc_codepage) 6136 || (enc_codepage > 0 && (int)GetACP() != enc_codepage)
6135 || enc_latin9) 6137 || enc_latin9)
6136 && (unicodebuf == NULL || len > unibuflen)) 6138 && (unicodebuf == NULL || len > unibuflen))
6137 { 6139 {
6144 unibuflen = len; 6146 unibuflen = len;
6145 } 6147 }
6146 6148
6147 if (enc_utf8 && n < len && unicodebuf != NULL) 6149 if (enc_utf8 && n < len && unicodebuf != NULL)
6148 { 6150 {
6149 /* Output UTF-8 characters. Composing characters should be 6151 // Output UTF-8 characters. Composing characters should be
6150 * handled here. */ 6152 // handled here.
6151 int i; 6153 int i;
6152 int wlen; /* string length in words */ 6154 int wlen; // string length in words
6153 int clen; /* string length in characters */ 6155 int clen; // string length in characters
6154 int cells; /* cell width of string up to composing char */ 6156 int cells; // cell width of string up to composing char
6155 int cw; /* width of current cell */ 6157 int cw; // width of current cell
6156 int c; 6158 int c;
6157 6159
6158 wlen = 0; 6160 wlen = 0;
6159 clen = 0; 6161 clen = 0;
6160 cells = 0; 6162 cells = 0;
6161 for (i = 0; i < len; ) 6163 for (i = 0; i < len; )
6162 { 6164 {
6163 c = utf_ptr2char(text + i); 6165 c = utf_ptr2char(text + i);
6164 if (c >= 0x10000) 6166 if (c >= 0x10000)
6165 { 6167 {
6166 /* Turn into UTF-16 encoding. */ 6168 // Turn into UTF-16 encoding.
6167 unicodebuf[wlen++] = ((c - 0x10000) >> 10) + 0xD800; 6169 unicodebuf[wlen++] = ((c - 0x10000) >> 10) + 0xD800;
6168 unicodebuf[wlen++] = ((c - 0x10000) & 0x3ff) + 0xDC00; 6170 unicodebuf[wlen++] = ((c - 0x10000) & 0x3ff) + 0xDC00;
6169 } 6171 }
6170 else 6172 else
6171 { 6173 {
6175 if (utf_iscomposing(c)) 6177 if (utf_iscomposing(c))
6176 cw = 0; 6178 cw = 0;
6177 else 6179 else
6178 { 6180 {
6179 cw = utf_char2cells(c); 6181 cw = utf_char2cells(c);
6180 if (cw > 2) /* don't use 4 for unprintable char */ 6182 if (cw > 2) // don't use 4 for unprintable char
6181 cw = 1; 6183 cw = 1;
6182 } 6184 }
6183 6185
6184 if (unicodepdy != NULL) 6186 if (unicodepdy != NULL)
6185 { 6187 {
6186 /* Use unicodepdy to make characters fit as we expect, even 6188 // Use unicodepdy to make characters fit as we expect, even
6187 * when the font uses different widths (e.g., bold character 6189 // when the font uses different widths (e.g., bold character
6188 * is wider). */ 6190 // is wider).
6189 if (c >= 0x10000) 6191 if (c >= 0x10000)
6190 { 6192 {
6191 unicodepdy[wlen - 2] = cw * gui.char_width; 6193 unicodepdy[wlen - 2] = cw * gui.char_width;
6192 unicodepdy[wlen - 1] = 0; 6194 unicodepdy[wlen - 1] = 0;
6193 } 6195 }
6199 ++clen; 6201 ++clen;
6200 } 6202 }
6201 #if defined(FEAT_DIRECTX) 6203 #if defined(FEAT_DIRECTX)
6202 if (IS_ENABLE_DIRECTX()) 6204 if (IS_ENABLE_DIRECTX())
6203 { 6205 {
6204 /* Add one to "cells" for italics. */ 6206 // Add one to "cells" for italics.
6205 DWriteContext_DrawText(s_dwc, unicodebuf, wlen, 6207 DWriteContext_DrawText(s_dwc, unicodebuf, wlen,
6206 TEXT_X(col), TEXT_Y(row), 6208 TEXT_X(col), TEXT_Y(row),
6207 FILL_X(cells + 1), FILL_Y(1) - p_linespace, 6209 FILL_X(cells + 1), FILL_Y(1) - p_linespace,
6208 gui.char_width, gui.currFgColor, 6210 gui.char_width, gui.currFgColor,
6209 foptions, pcliprect, unicodepdy); 6211 foptions, pcliprect, unicodepdy);
6210 } 6212 }
6211 else 6213 else
6212 #endif 6214 #endif
6213 ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row), 6215 ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row),
6214 foptions, pcliprect, unicodebuf, wlen, unicodepdy); 6216 foptions, pcliprect, unicodebuf, wlen, unicodepdy);
6215 len = cells; /* used for underlining */ 6217 len = cells; // used for underlining
6216 } 6218 }
6217 else if ((enc_codepage > 0 && (int)GetACP() != enc_codepage) || enc_latin9) 6219 else if ((enc_codepage > 0 && (int)GetACP() != enc_codepage) || enc_latin9)
6218 { 6220 {
6219 /* If we want to display codepage data, and the current CP is not the 6221 // If we want to display codepage data, and the current CP is not the
6220 * ANSI one, we need to go via Unicode. */ 6222 // ANSI one, we need to go via Unicode.
6221 if (unicodebuf != NULL) 6223 if (unicodebuf != NULL)
6222 { 6224 {
6223 if (enc_latin9) 6225 if (enc_latin9)
6224 latin9_to_ucs(text, len, unicodebuf); 6226 latin9_to_ucs(text, len, unicodebuf);
6225 else 6227 else
6227 MB_PRECOMPOSED, 6229 MB_PRECOMPOSED,
6228 (char *)text, len, 6230 (char *)text, len,
6229 (LPWSTR)unicodebuf, unibuflen); 6231 (LPWSTR)unicodebuf, unibuflen);
6230 if (len != 0) 6232 if (len != 0)
6231 { 6233 {
6232 /* Use unicodepdy to make characters fit as we expect, even 6234 // Use unicodepdy to make characters fit as we expect, even
6233 * when the font uses different widths (e.g., bold character 6235 // when the font uses different widths (e.g., bold character
6234 * is wider). */ 6236 // is wider).
6235 if (unicodepdy != NULL) 6237 if (unicodepdy != NULL)
6236 { 6238 {
6237 int i; 6239 int i;
6238 int cw; 6240 int cw;
6239 6241
6251 } 6253 }
6252 } 6254 }
6253 else 6255 else
6254 { 6256 {
6255 #ifdef FEAT_RIGHTLEFT 6257 #ifdef FEAT_RIGHTLEFT
6256 /* Windows will mess up RL text, so we have to draw it character by 6258 // Windows will mess up RL text, so we have to draw it character by
6257 * character. Only do this if RL is on, since it's slow. */ 6259 // character. Only do this if RL is on, since it's slow.
6258 if (curwin->w_p_rl) 6260 if (curwin->w_p_rl)
6259 RevOut(s_hdc, TEXT_X(col), TEXT_Y(row), 6261 RevOut(s_hdc, TEXT_X(col), TEXT_Y(row),
6260 foptions, pcliprect, (char *)text, len, padding); 6262 foptions, pcliprect, (char *)text, len, padding);
6261 else 6263 else
6262 #endif 6264 #endif
6263 ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row), 6265 ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row),
6264 foptions, pcliprect, (char *)text, len, padding); 6266 foptions, pcliprect, (char *)text, len, padding);
6265 } 6267 }
6266 6268
6267 /* Underline */ 6269 // Underline
6268 if (flags & DRAW_UNDERL) 6270 if (flags & DRAW_UNDERL)
6269 { 6271 {
6270 /* When p_linespace is 0, overwrite the bottom row of pixels. 6272 // When p_linespace is 0, overwrite the bottom row of pixels.
6271 * Otherwise put the line just below the character. */ 6273 // Otherwise put the line just below the character.
6272 y = FILL_Y(row + 1) - 1; 6274 y = FILL_Y(row + 1) - 1;
6273 if (p_linespace > 1) 6275 if (p_linespace > 1)
6274 y -= p_linespace - 1; 6276 y -= p_linespace - 1;
6275 draw_line(FILL_X(col), y, FILL_X(col + len), y, gui.currFgColor); 6277 draw_line(FILL_X(col), y, FILL_X(col + len), y, gui.currFgColor);
6276 } 6278 }
6277 6279
6278 /* Strikethrough */ 6280 // Strikethrough
6279 if (flags & DRAW_STRIKE) 6281 if (flags & DRAW_STRIKE)
6280 { 6282 {
6281 y = FILL_Y(row + 1) - gui.char_height/2; 6283 y = FILL_Y(row + 1) - gui.char_height/2;
6282 draw_line(FILL_X(col), y, FILL_X(col + len), y, gui.currSpColor); 6284 draw_line(FILL_X(col), y, FILL_X(col + len), y, gui.currSpColor);
6283 } 6285 }
6284 6286
6285 /* Undercurl */ 6287 // Undercurl
6286 if (flags & DRAW_UNDERC) 6288 if (flags & DRAW_UNDERC)
6287 { 6289 {
6288 int x; 6290 int x;
6289 int offset; 6291 int offset;
6290 static const int val[8] = {1, 0, 0, 0, 1, 2, 2, 2 }; 6292 static const int val[8] = {1, 0, 0, 0, 1, 2, 2, 2 };
6301 6303
6302 /* 6304 /*
6303 * Output routines. 6305 * Output routines.
6304 */ 6306 */
6305 6307
6306 /* Flush any output to the screen */ 6308 /*
6309 * Flush any output to the screen
6310 */
6307 void 6311 void
6308 gui_mch_flush(void) 6312 gui_mch_flush(void)
6309 { 6313 {
6310 #if defined(FEAT_DIRECTX) 6314 #if defined(FEAT_DIRECTX)
6311 if (IS_ENABLE_DIRECTX()) 6315 if (IS_ENABLE_DIRECTX())
6331 6335
6332 *screen_w = workarea_rect.right - workarea_rect.left 6336 *screen_w = workarea_rect.right - workarea_rect.left
6333 - (GetSystemMetrics(SM_CXFRAME) + 6337 - (GetSystemMetrics(SM_CXFRAME) +
6334 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2; 6338 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2;
6335 6339
6336 /* FIXME: dirty trick: Because the gui_get_base_height() doesn't include 6340 // FIXME: dirty trick: Because the gui_get_base_height() doesn't include
6337 * the menubar for MSwin, we subtract it from the screen height, so that 6341 // the menubar for MSwin, we subtract it from the screen height, so that
6338 * the window size can be made to fit on the screen. */ 6342 // the window size can be made to fit on the screen.
6339 *screen_h = workarea_rect.bottom - workarea_rect.top 6343 *screen_h = workarea_rect.bottom - workarea_rect.top
6340 - (GetSystemMetrics(SM_CYFRAME) + 6344 - (GetSystemMetrics(SM_CYFRAME) +
6341 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2 6345 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2
6342 - GetSystemMetrics(SM_CYCAPTION) 6346 - GetSystemMetrics(SM_CYCAPTION)
6343 #ifdef FEAT_MENU 6347 #ifdef FEAT_MENU
6383 ? s_menuBar : parent->submenu_id, 6387 ? s_menuBar : parent->submenu_id,
6384 (UINT)pos, TRUE, &infow); 6388 (UINT)pos, TRUE, &infow);
6385 vim_free(wn); 6389 vim_free(wn);
6386 } 6390 }
6387 6391
6388 /* Fix window size if menu may have wrapped */ 6392 // Fix window size if menu may have wrapped
6389 if (parent == NULL) 6393 if (parent == NULL)
6390 gui_mswin_get_menu_height(!gui.starting); 6394 gui_mswin_get_menu_height(!gui.starting);
6391 # ifdef FEAT_TEAROFF 6395 # ifdef FEAT_TEAROFF
6392 else if (IsWindow(parent->tearoff_handle)) 6396 else if (IsWindow(parent->tearoff_handle))
6393 rebuild_tearoff(parent); 6397 rebuild_tearoff(parent);
6410 6414
6411 if (menu != NULL) 6415 if (menu != NULL)
6412 { 6416 {
6413 POINT p; 6417 POINT p;
6414 6418
6415 /* Find the position of the current cursor */ 6419 // Find the position of the current cursor
6416 GetDCOrgEx(s_hdc, &p); 6420 GetDCOrgEx(s_hdc, &p);
6417 if (mouse_pos) 6421 if (mouse_pos)
6418 { 6422 {
6419 int mx, my; 6423 int mx, my;
6420 6424
6440 void 6444 void
6441 gui_make_tearoff(char_u *path_name) 6445 gui_make_tearoff(char_u *path_name)
6442 { 6446 {
6443 vimmenu_T *menu = gui_find_menu(path_name); 6447 vimmenu_T *menu = gui_find_menu(path_name);
6444 6448
6445 /* Found the menu, so tear it off. */ 6449 // Found the menu, so tear it off.
6446 if (menu != NULL) 6450 if (menu != NULL)
6447 gui_mch_tearoff(menu->dname, menu, 0xffffL, 0xffffL); 6451 gui_mch_tearoff(menu->dname, menu, 0xffffL, 0xffffL);
6448 } 6452 }
6449 # endif 6453 # endif
6450 6454
6547 DestroyWindow(menu->tearoff_handle); 6551 DestroyWindow(menu->tearoff_handle);
6548 if (menu->parent != NULL 6552 if (menu->parent != NULL
6549 && menu->parent->children != NULL 6553 && menu->parent->children != NULL
6550 && IsWindow(menu->parent->tearoff_handle)) 6554 && IsWindow(menu->parent->tearoff_handle))
6551 { 6555 {
6552 /* This menu must not show up when rebuilding the tearoff window. */ 6556 // This menu must not show up when rebuilding the tearoff window.
6553 menu->modes = 0; 6557 menu->modes = 0;
6554 rebuild_tearoff(menu->parent); 6558 rebuild_tearoff(menu->parent);
6555 } 6559 }
6556 # endif 6560 # endif
6557 } 6561 }
6559 6563
6560 # ifdef FEAT_TEAROFF 6564 # ifdef FEAT_TEAROFF
6561 static void 6565 static void
6562 rebuild_tearoff(vimmenu_T *menu) 6566 rebuild_tearoff(vimmenu_T *menu)
6563 { 6567 {
6564 /*hackish*/ 6568 //hackish
6565 char_u tbuf[128]; 6569 char_u tbuf[128];
6566 RECT trect; 6570 RECT trect;
6567 RECT rct; 6571 RECT rct;
6568 RECT roct; 6572 RECT roct;
6569 int x, y; 6573 int x, y;
6593 (int)trect.top, 6597 (int)trect.top,
6594 0, 0, 6598 0, 0,
6595 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); 6599 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
6596 } 6600 }
6597 } 6601 }
6598 # endif /* FEAT_TEAROFF */ 6602 # endif // FEAT_TEAROFF
6599 6603
6600 /* 6604 /*
6601 * Make a menu either grey or not grey. 6605 * Make a menu either grey or not grey.
6602 */ 6606 */
6603 void 6607 void
6638 6642
6639 } 6643 }
6640 # endif 6644 # endif
6641 } 6645 }
6642 6646
6643 #endif /* FEAT_MENU */ 6647 #endif // FEAT_MENU
6644 6648
6645 6649
6646 /* define some macros used to make the dialogue creation more readable */ 6650 // define some macros used to make the dialogue creation more readable
6647 6651
6648 #define add_string(s) strcpy((LPSTR)p, s); (LPSTR)p += (strlen((LPSTR)p) + 1) 6652 #define add_string(s) strcpy((LPSTR)p, s); (LPSTR)p += (strlen((LPSTR)p) + 1)
6649 #define add_word(x) *p++ = (x) 6653 #define add_word(x) *p++ = (x)
6650 #define add_long(x) dwp = (DWORD *)p; *dwp++ = (x); p = (WORD *)dwp 6654 #define add_long(x) dwp = (DWORD *)p; *dwp++ = (x); p = (WORD *)dwp
6651 6655
6669 LPARAM lParam UNUSED) 6673 LPARAM lParam UNUSED)
6670 { 6674 {
6671 if (message == WM_INITDIALOG) 6675 if (message == WM_INITDIALOG)
6672 { 6676 {
6673 CenterWindow(hwnd, GetWindow(hwnd, GW_OWNER)); 6677 CenterWindow(hwnd, GetWindow(hwnd, GW_OWNER));
6674 /* Set focus to the dialog. Set the default button, if specified. */ 6678 // Set focus to the dialog. Set the default button, if specified.
6675 (void)SetFocus(hwnd); 6679 (void)SetFocus(hwnd);
6676 if (dialog_default_button > IDCANCEL) 6680 if (dialog_default_button > IDCANCEL)
6677 (void)SetFocus(GetDlgItem(hwnd, dialog_default_button)); 6681 (void)SetFocus(GetDlgItem(hwnd, dialog_default_button));
6678 else 6682 else
6679 /* We don't have a default, set focus on another element of the 6683 // We don't have a default, set focus on another element of the
6680 * dialog window, probably the icon */ 6684 // dialog window, probably the icon
6681 (void)SetFocus(GetDlgItem(hwnd, DLG_NONBUTTON_CONTROL)); 6685 (void)SetFocus(GetDlgItem(hwnd, DLG_NONBUTTON_CONTROL));
6682 return FALSE; 6686 return FALSE;
6683 } 6687 }
6684 6688
6685 if (message == WM_COMMAND) 6689 if (message == WM_COMMAND)
6686 { 6690 {
6687 int button = LOWORD(wParam); 6691 int button = LOWORD(wParam);
6688 6692
6689 /* Don't end the dialog if something was selected that was 6693 // Don't end the dialog if something was selected that was
6690 * not a button. 6694 // not a button.
6691 */
6692 if (button >= DLG_NONBUTTON_CONTROL) 6695 if (button >= DLG_NONBUTTON_CONTROL)
6693 return TRUE; 6696 return TRUE;
6694 6697
6695 /* If the edit box exists, copy the string. */ 6698 // If the edit box exists, copy the string.
6696 if (s_textfield != NULL) 6699 if (s_textfield != NULL)
6697 { 6700 {
6698 WCHAR *wp = ALLOC_MULT(WCHAR, IOSIZE); 6701 WCHAR *wp = ALLOC_MULT(WCHAR, IOSIZE);
6699 char_u *p; 6702 char_u *p;
6700 6703
6742 * -1 for unexpected error 6745 * -1 for unexpected error
6743 * 6746 *
6744 * If stubbing out this fn, return 1. 6747 * If stubbing out this fn, return 1.
6745 */ 6748 */
6746 6749
6747 static const char *dlg_icons[] = /* must match names in resource file */ 6750 static const char *dlg_icons[] = // must match names in resource file
6748 { 6751 {
6749 "IDR_VIM", 6752 "IDR_VIM",
6750 "IDR_VIM_ERROR", 6753 "IDR_VIM_ERROR",
6751 "IDR_VIM_ALERT", 6754 "IDR_VIM_ALERT",
6752 "IDR_VIM_INFO", 6755 "IDR_VIM_INFO",
6798 # endif 6801 # endif
6799 garray_T ga; 6802 garray_T ga;
6800 int l; 6803 int l;
6801 6804
6802 # ifndef NO_CONSOLE 6805 # ifndef NO_CONSOLE
6803 /* Don't output anything in silent mode ("ex -s") */ 6806 // Don't output anything in silent mode ("ex -s")
6804 # ifdef VIMDLL 6807 # ifdef VIMDLL
6805 if (!(gui.in_use || gui.starting)) 6808 if (!(gui.in_use || gui.starting))
6806 # endif 6809 # endif
6807 if (silent_mode) 6810 if (silent_mode)
6808 return dfltbutton; /* return default option */ 6811 return dfltbutton; // return default option
6809 # endif 6812 # endif
6810 6813
6811 if (s_hwnd == NULL) 6814 if (s_hwnd == NULL)
6812 get_dialog_font_metrics(); 6815 get_dialog_font_metrics();
6813 6816
6814 if ((type < 0) || (type > VIM_LAST_TYPE)) 6817 if ((type < 0) || (type > VIM_LAST_TYPE))
6815 type = 0; 6818 type = 0;
6816 6819
6817 /* allocate some memory for dialog template */ 6820 // allocate some memory for dialog template
6818 /* TODO should compute this really */ 6821 // TODO should compute this really
6819 pdlgtemplate = p = (PWORD)LocalAlloc(LPTR, 6822 pdlgtemplate = p = (PWORD)LocalAlloc(LPTR,
6820 DLG_ALLOC_SIZE + STRLEN(message) * 2); 6823 DLG_ALLOC_SIZE + STRLEN(message) * 2);
6821 6824
6822 if (p == NULL) 6825 if (p == NULL)
6823 return -1; 6826 return -1;
6829 */ 6832 */
6830 tbuffer = vim_strsave(buttons); 6833 tbuffer = vim_strsave(buttons);
6831 if (tbuffer == NULL) 6834 if (tbuffer == NULL)
6832 return -1; 6835 return -1;
6833 6836
6834 --dfltbutton; /* Change from one-based to zero-based */ 6837 --dfltbutton; // Change from one-based to zero-based
6835 6838
6836 /* Count buttons */ 6839 // Count buttons
6837 numButtons = 1; 6840 numButtons = 1;
6838 for (i = 0; tbuffer[i] != '\0'; i++) 6841 for (i = 0; tbuffer[i] != '\0'; i++)
6839 { 6842 {
6840 if (tbuffer[i] == DLG_BUTTON_SEP) 6843 if (tbuffer[i] == DLG_BUTTON_SEP)
6841 numButtons++; 6844 numButtons++;
6842 } 6845 }
6843 if (dfltbutton >= numButtons) 6846 if (dfltbutton >= numButtons)
6844 dfltbutton = -1; 6847 dfltbutton = -1;
6845 6848
6846 /* Allocate array to hold the width of each button */ 6849 // Allocate array to hold the width of each button
6847 buttonWidths = ALLOC_MULT(int, numButtons); 6850 buttonWidths = ALLOC_MULT(int, numButtons);
6848 if (buttonWidths == NULL) 6851 if (buttonWidths == NULL)
6849 return -1; 6852 return -1;
6850 6853
6851 /* Allocate array to hold the X position of each button */ 6854 // Allocate array to hold the X position of each button
6852 buttonPositions = ALLOC_MULT(int, numButtons); 6855 buttonPositions = ALLOC_MULT(int, numButtons);
6853 if (buttonPositions == NULL) 6856 if (buttonPositions == NULL)
6854 return -1; 6857 return -1;
6855 6858
6856 /* 6859 /*
6881 dlgPaddingY = DLG_OLD_STYLE_PADDING_Y; 6884 dlgPaddingY = DLG_OLD_STYLE_PADDING_Y;
6882 } 6885 }
6883 GetTextMetrics(hdc, &fontInfo); 6886 GetTextMetrics(hdc, &fontInfo);
6884 fontHeight = fontInfo.tmHeight; 6887 fontHeight = fontInfo.tmHeight;
6885 6888
6886 /* Minimum width for horizontal button */ 6889 // Minimum width for horizontal button
6887 minButtonWidth = GetTextWidth(hdc, (char_u *)"Cancel", 6); 6890 minButtonWidth = GetTextWidth(hdc, (char_u *)"Cancel", 6);
6888 6891
6889 /* Maximum width of a dialog, if possible */ 6892 // Maximum width of a dialog, if possible
6890 if (s_hwnd == NULL) 6893 if (s_hwnd == NULL)
6891 { 6894 {
6892 RECT workarea_rect; 6895 RECT workarea_rect;
6893 6896
6894 /* We don't have a window, use the desktop area. */ 6897 // We don't have a window, use the desktop area.
6895 get_work_area(&workarea_rect); 6898 get_work_area(&workarea_rect);
6896 maxDialogWidth = workarea_rect.right - workarea_rect.left - 100; 6899 maxDialogWidth = workarea_rect.right - workarea_rect.left - 100;
6897 if (maxDialogWidth > 600) 6900 if (maxDialogWidth > 600)
6898 maxDialogWidth = 600; 6901 maxDialogWidth = 600;
6899 /* Leave some room for the taskbar. */ 6902 // Leave some room for the taskbar.
6900 maxDialogHeight = workarea_rect.bottom - workarea_rect.top - 150; 6903 maxDialogHeight = workarea_rect.bottom - workarea_rect.top - 150;
6901 } 6904 }
6902 else 6905 else
6903 { 6906 {
6904 /* Use our own window for the size, unless it's very small. */ 6907 // Use our own window for the size, unless it's very small.
6905 GetWindowRect(s_hwnd, &rect); 6908 GetWindowRect(s_hwnd, &rect);
6906 maxDialogWidth = rect.right - rect.left 6909 maxDialogWidth = rect.right - rect.left
6907 - (GetSystemMetrics(SM_CXFRAME) + 6910 - (GetSystemMetrics(SM_CXFRAME) +
6908 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2; 6911 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2;
6909 if (maxDialogWidth < DLG_MIN_MAX_WIDTH) 6912 if (maxDialogWidth < DLG_MIN_MAX_WIDTH)
6915 - GetSystemMetrics(SM_CYCAPTION); 6918 - GetSystemMetrics(SM_CYCAPTION);
6916 if (maxDialogHeight < DLG_MIN_MAX_HEIGHT) 6919 if (maxDialogHeight < DLG_MIN_MAX_HEIGHT)
6917 maxDialogHeight = DLG_MIN_MAX_HEIGHT; 6920 maxDialogHeight = DLG_MIN_MAX_HEIGHT;
6918 } 6921 }
6919 6922
6920 /* Set dlgwidth to width of message. 6923 // Set dlgwidth to width of message.
6921 * Copy the message into "ga", changing NL to CR-NL and inserting line 6924 // Copy the message into "ga", changing NL to CR-NL and inserting line
6922 * breaks where needed. */ 6925 // breaks where needed.
6923 pstart = message; 6926 pstart = message;
6924 messageWidth = 0; 6927 messageWidth = 0;
6925 msgheight = 0; 6928 msgheight = 0;
6926 ga_init2(&ga, sizeof(char), 500); 6929 ga_init2(&ga, sizeof(char), 500);
6927 do 6930 do
6928 { 6931 {
6929 msgheight += fontHeight; /* at least one line */ 6932 msgheight += fontHeight; // at least one line
6930 6933
6931 /* Need to figure out where to break the string. The system does it 6934 // Need to figure out where to break the string. The system does it
6932 * at a word boundary, which would mean we can't compute the number of 6935 // at a word boundary, which would mean we can't compute the number of
6933 * wrapped lines. */ 6936 // wrapped lines.
6934 textWidth = 0; 6937 textWidth = 0;
6935 last_white = NULL; 6938 last_white = NULL;
6936 for (pend = pstart; *pend != NUL && *pend != '\n'; ) 6939 for (pend = pstart; *pend != NUL && *pend != '\n'; )
6937 { 6940 {
6938 l = (*mb_ptr2len)(pend); 6941 l = (*mb_ptr2len)(pend);
6940 && textWidth > maxDialogWidth * 3 / 4) 6943 && textWidth > maxDialogWidth * 3 / 4)
6941 last_white = pend; 6944 last_white = pend;
6942 textWidth += GetTextWidthEnc(hdc, pend, l); 6945 textWidth += GetTextWidthEnc(hdc, pend, l);
6943 if (textWidth >= maxDialogWidth) 6946 if (textWidth >= maxDialogWidth)
6944 { 6947 {
6945 /* Line will wrap. */ 6948 // Line will wrap.
6946 messageWidth = maxDialogWidth; 6949 messageWidth = maxDialogWidth;
6947 msgheight += fontHeight; 6950 msgheight += fontHeight;
6948 textWidth = 0; 6951 textWidth = 0;
6949 6952
6950 if (last_white != NULL) 6953 if (last_white != NULL)
6951 { 6954 {
6952 /* break the line just after a space */ 6955 // break the line just after a space
6953 ga.ga_len -= (int)(pend - (last_white + 1)); 6956 ga.ga_len -= (int)(pend - (last_white + 1));
6954 pend = last_white + 1; 6957 pend = last_white + 1;
6955 last_white = NULL; 6958 last_white = NULL;
6956 } 6959 }
6957 ga_append(&ga, '\r'); 6960 ga_append(&ga, '\r');
6971 } while (*pend != NUL); 6974 } while (*pend != NUL);
6972 6975
6973 if (ga.ga_data != NULL) 6976 if (ga.ga_data != NULL)
6974 message = ga.ga_data; 6977 message = ga.ga_data;
6975 6978
6976 messageWidth += 10; /* roundoff space */ 6979 messageWidth += 10; // roundoff space
6977 6980
6978 /* Add width of icon to dlgwidth, and some space */ 6981 // Add width of icon to dlgwidth, and some space
6979 dlgwidth = messageWidth + DLG_ICON_WIDTH + 3 * dlgPaddingX 6982 dlgwidth = messageWidth + DLG_ICON_WIDTH + 3 * dlgPaddingX
6980 + GetSystemMetrics(SM_CXVSCROLL); 6983 + GetSystemMetrics(SM_CXVSCROLL);
6981 6984
6982 if (msgheight < DLG_ICON_HEIGHT) 6985 if (msgheight < DLG_ICON_HEIGHT)
6983 msgheight = DLG_ICON_HEIGHT; 6986 msgheight = DLG_ICON_HEIGHT;
6999 if (pend == NULL) 7002 if (pend == NULL)
7000 pend = pstart + STRLEN(pstart); // Last button name. 7003 pend = pstart + STRLEN(pstart); // Last button name.
7001 textWidth = GetTextWidthEnc(hdc, pstart, (int)(pend - pstart)); 7004 textWidth = GetTextWidthEnc(hdc, pstart, (int)(pend - pstart));
7002 if (textWidth < minButtonWidth) 7005 if (textWidth < minButtonWidth)
7003 textWidth = minButtonWidth; 7006 textWidth = minButtonWidth;
7004 textWidth += dlgPaddingX; /* Padding within button */ 7007 textWidth += dlgPaddingX; // Padding within button
7005 buttonWidths[i] = textWidth; 7008 buttonWidths[i] = textWidth;
7006 buttonPositions[i++] = horizWidth; 7009 buttonPositions[i++] = horizWidth;
7007 horizWidth += textWidth + dlgPaddingX; /* Pad between buttons */ 7010 horizWidth += textWidth + dlgPaddingX; // Pad between buttons
7008 pstart = pend + 1; 7011 pstart = pend + 1;
7009 } while (*pend != NUL); 7012 } while (*pend != NUL);
7010 7013
7011 if (horizWidth > maxDialogWidth) 7014 if (horizWidth > maxDialogWidth)
7012 vertical = TRUE; // Too wide to fit on the screen. 7015 vertical = TRUE; // Too wide to fit on the screen.
7022 { 7025 {
7023 pend = vim_strchr(pstart, DLG_BUTTON_SEP); 7026 pend = vim_strchr(pstart, DLG_BUTTON_SEP);
7024 if (pend == NULL) 7027 if (pend == NULL)
7025 pend = pstart + STRLEN(pstart); // Last button name. 7028 pend = pstart + STRLEN(pstart); // Last button name.
7026 textWidth = GetTextWidthEnc(hdc, pstart, (int)(pend - pstart)); 7029 textWidth = GetTextWidthEnc(hdc, pstart, (int)(pend - pstart));
7027 textWidth += dlgPaddingX; /* Padding within button */ 7030 textWidth += dlgPaddingX; // Padding within button
7028 textWidth += DLG_VERT_PADDING_X * 2; /* Padding around button */ 7031 textWidth += DLG_VERT_PADDING_X * 2; // Padding around button
7029 if (textWidth > dlgwidth) 7032 if (textWidth > dlgwidth)
7030 dlgwidth = textWidth; 7033 dlgwidth = textWidth;
7031 pstart = pend + 1; 7034 pstart = pend + 1;
7032 } while (*pend != NUL); 7035 } while (*pend != NUL);
7033 } 7036 }
7034 7037
7035 if (dlgwidth < DLG_MIN_WIDTH) 7038 if (dlgwidth < DLG_MIN_WIDTH)
7036 dlgwidth = DLG_MIN_WIDTH; /* Don't allow a really thin dialog!*/ 7039 dlgwidth = DLG_MIN_WIDTH; // Don't allow a really thin dialog!
7037 7040
7038 /* start to fill in the dlgtemplate information. addressing by WORDs */ 7041 // start to fill in the dlgtemplate information. addressing by WORDs
7039 if (s_usenewlook) 7042 if (s_usenewlook)
7040 lStyle = DS_MODALFRAME | WS_CAPTION |DS_3DLOOK| WS_VISIBLE |DS_SETFONT; 7043 lStyle = DS_MODALFRAME | WS_CAPTION |DS_3DLOOK| WS_VISIBLE |DS_SETFONT;
7041 else 7044 else
7042 lStyle = DS_MODALFRAME | WS_CAPTION |DS_3DLOOK| WS_VISIBLE; 7045 lStyle = DS_MODALFRAME | WS_CAPTION |DS_3DLOOK| WS_VISIBLE;
7043 7046
7044 add_long(lStyle); 7047 add_long(lStyle);
7045 add_long(0); // (lExtendedStyle) 7048 add_long(0); // (lExtendedStyle)
7046 pnumitems = p; /*save where the number of items must be stored*/ 7049 pnumitems = p; //save where the number of items must be stored
7047 add_word(0); // NumberOfItems(will change later) 7050 add_word(0); // NumberOfItems(will change later)
7048 add_word(10); // x 7051 add_word(10); // x
7049 add_word(10); // y 7052 add_word(10); // y
7050 add_word(PixelToDialogX(dlgwidth)); // cx 7053 add_word(PixelToDialogX(dlgwidth)); // cx
7051 7054
7059 // Dialog needs to be taller if contains an edit box. 7062 // Dialog needs to be taller if contains an edit box.
7060 editboxheight = fontHeight + dlgPaddingY + 4 * DLG_VERT_PADDING_Y; 7063 editboxheight = fontHeight + dlgPaddingY + 4 * DLG_VERT_PADDING_Y;
7061 if (textfield != NULL) 7064 if (textfield != NULL)
7062 dlgheight += editboxheight; 7065 dlgheight += editboxheight;
7063 7066
7064 /* Restrict the size to a maximum. Causes a scrollbar to show up. */ 7067 // Restrict the size to a maximum. Causes a scrollbar to show up.
7065 if (dlgheight > maxDialogHeight) 7068 if (dlgheight > maxDialogHeight)
7066 { 7069 {
7067 msgheight = msgheight - (dlgheight - maxDialogHeight); 7070 msgheight = msgheight - (dlgheight - maxDialogHeight);
7068 dlgheight = maxDialogHeight; 7071 dlgheight = maxDialogHeight;
7069 scroll_flag = WS_VSCROLL; 7072 scroll_flag = WS_VSCROLL;
7070 /* Make sure scrollbar doesn't appear in the middle of the dialog */ 7073 // Make sure scrollbar doesn't appear in the middle of the dialog
7071 messageWidth = dlgwidth - DLG_ICON_WIDTH - 3 * dlgPaddingX; 7074 messageWidth = dlgwidth - DLG_ICON_WIDTH - 3 * dlgPaddingX;
7072 } 7075 }
7073 7076
7074 add_word(PixelToDialogY(dlgheight)); 7077 add_word(PixelToDialogY(dlgheight));
7075 7078
7076 add_word(0); // Menu 7079 add_word(0); // Menu
7077 add_word(0); // Class 7080 add_word(0); // Class
7078 7081
7079 /* copy the title of the dialog */ 7082 // copy the title of the dialog
7080 nchar = nCopyAnsiToWideChar(p, (title ? (LPSTR)title 7083 nchar = nCopyAnsiToWideChar(p, (title ? (LPSTR)title
7081 : (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE); 7084 : (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE);
7082 p += nchar; 7085 p += nchar;
7083 7086
7084 if (s_usenewlook) 7087 if (s_usenewlook)
7085 { 7088 {
7086 /* do the font, since DS_3DLOOK doesn't work properly */ 7089 // do the font, since DS_3DLOOK doesn't work properly
7087 # ifdef USE_SYSMENU_FONT 7090 # ifdef USE_SYSMENU_FONT
7088 if (use_lfSysmenu) 7091 if (use_lfSysmenu)
7089 { 7092 {
7090 /* point size */ 7093 // point size
7091 *p++ = -MulDiv(lfSysmenu.lfHeight, 72, 7094 *p++ = -MulDiv(lfSysmenu.lfHeight, 72,
7092 GetDeviceCaps(hdc, LOGPIXELSY)); 7095 GetDeviceCaps(hdc, LOGPIXELSY));
7093 wcscpy(p, lfSysmenu.lfFaceName); 7096 wcscpy(p, lfSysmenu.lfFaceName);
7094 nchar = (int)wcslen(lfSysmenu.lfFaceName) + 1; 7097 nchar = (int)wcslen(lfSysmenu.lfFaceName) + 1;
7095 } 7098 }
7107 if (textfield != NULL) 7110 if (textfield != NULL)
7108 buttonYpos += editboxheight; 7111 buttonYpos += editboxheight;
7109 7112
7110 pstart = tbuffer; 7113 pstart = tbuffer;
7111 if (!vertical) 7114 if (!vertical)
7112 horizWidth = (dlgwidth - horizWidth) / 2; /* Now it's X offset */ 7115 horizWidth = (dlgwidth - horizWidth) / 2; // Now it's X offset
7113 for (i = 0; i < numButtons; i++) 7116 for (i = 0; i < numButtons; i++)
7114 { 7117 {
7115 /* get end of this button. */ 7118 // get end of this button.
7116 for ( pend = pstart; 7119 for ( pend = pstart;
7117 *pend && (*pend != DLG_BUTTON_SEP); 7120 *pend && (*pend != DLG_BUTTON_SEP);
7118 pend++) 7121 pend++)
7119 ; 7122 ;
7120 7123
7138 { 7141 {
7139 p = add_dialog_element(p, 7142 p = add_dialog_element(p,
7140 (i == dfltbutton 7143 (i == dfltbutton
7141 ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP, 7144 ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP,
7142 PixelToDialogX(DLG_VERT_PADDING_X), 7145 PixelToDialogX(DLG_VERT_PADDING_X),
7143 PixelToDialogY(buttonYpos /* TBK */ 7146 PixelToDialogY(buttonYpos // TBK
7144 + 2 * fontHeight * i), 7147 + 2 * fontHeight * i),
7145 PixelToDialogX(dlgwidth - 2 * DLG_VERT_PADDING_X), 7148 PixelToDialogX(dlgwidth - 2 * DLG_VERT_PADDING_X),
7146 (WORD)(PixelToDialogY(2 * fontHeight) - 1), 7149 (WORD)(PixelToDialogY(2 * fontHeight) - 1),
7147 (WORD)(IDCANCEL + 1 + i), (WORD)0x0080, (char *)pstart); 7150 (WORD)(IDCANCEL + 1 + i), (WORD)0x0080, (char *)pstart);
7148 } 7151 }
7150 { 7153 {
7151 p = add_dialog_element(p, 7154 p = add_dialog_element(p,
7152 (i == dfltbutton 7155 (i == dfltbutton
7153 ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP, 7156 ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP,
7154 PixelToDialogX(horizWidth + buttonPositions[i]), 7157 PixelToDialogX(horizWidth + buttonPositions[i]),
7155 PixelToDialogY(buttonYpos), /* TBK */ 7158 PixelToDialogY(buttonYpos), // TBK
7156 PixelToDialogX(buttonWidths[i]), 7159 PixelToDialogX(buttonWidths[i]),
7157 (WORD)(PixelToDialogY(2 * fontHeight) - 1), 7160 (WORD)(PixelToDialogY(2 * fontHeight) - 1),
7158 (WORD)(IDCANCEL + 1 + i), (WORD)0x0080, (char *)pstart); 7161 (WORD)(IDCANCEL + 1 + i), (WORD)0x0080, (char *)pstart);
7159 } 7162 }
7160 pstart = pend + 1; /*next button*/ 7163 pstart = pend + 1; //next button
7161 } 7164 }
7162 *pnumitems += numButtons; 7165 *pnumitems += numButtons;
7163 7166
7164 /* Vim icon */ 7167 // Vim icon
7165 p = add_dialog_element(p, SS_ICON, 7168 p = add_dialog_element(p, SS_ICON,
7166 PixelToDialogX(dlgPaddingX), 7169 PixelToDialogX(dlgPaddingX),
7167 PixelToDialogY(dlgPaddingY), 7170 PixelToDialogY(dlgPaddingY),
7168 PixelToDialogX(DLG_ICON_WIDTH), 7171 PixelToDialogX(DLG_ICON_WIDTH),
7169 PixelToDialogY(DLG_ICON_HEIGHT), 7172 PixelToDialogY(DLG_ICON_HEIGHT),
7170 DLG_NONBUTTON_CONTROL + 0, (WORD)0x0082, 7173 DLG_NONBUTTON_CONTROL + 0, (WORD)0x0082,
7171 dlg_icons[type]); 7174 dlg_icons[type]);
7172 7175
7173 /* Dialog message */ 7176 // Dialog message
7174 p = add_dialog_element(p, ES_LEFT|scroll_flag|ES_MULTILINE|ES_READONLY, 7177 p = add_dialog_element(p, ES_LEFT|scroll_flag|ES_MULTILINE|ES_READONLY,
7175 PixelToDialogX(2 * dlgPaddingX + DLG_ICON_WIDTH), 7178 PixelToDialogX(2 * dlgPaddingX + DLG_ICON_WIDTH),
7176 PixelToDialogY(dlgPaddingY), 7179 PixelToDialogY(dlgPaddingY),
7177 (WORD)(PixelToDialogX(messageWidth) + 1), 7180 (WORD)(PixelToDialogX(messageWidth) + 1),
7178 PixelToDialogY(msgheight), 7181 PixelToDialogY(msgheight),
7179 DLG_NONBUTTON_CONTROL + 1, (WORD)0x0081, (char *)message); 7182 DLG_NONBUTTON_CONTROL + 1, (WORD)0x0081, (char *)message);
7180 7183
7181 /* Edit box */ 7184 // Edit box
7182 if (textfield != NULL) 7185 if (textfield != NULL)
7183 { 7186 {
7184 p = add_dialog_element(p, ES_LEFT|ES_AUTOHSCROLL|WS_TABSTOP|WS_BORDER, 7187 p = add_dialog_element(p, ES_LEFT|ES_AUTOHSCROLL|WS_TABSTOP|WS_BORDER,
7185 PixelToDialogX(2 * dlgPaddingX), 7188 PixelToDialogX(2 * dlgPaddingX),
7186 PixelToDialogY(2 * dlgPaddingY + msgheight), 7189 PixelToDialogY(2 * dlgPaddingY + msgheight),
7194 7197
7195 SelectFont(hdc, oldFont); 7198 SelectFont(hdc, oldFont);
7196 DeleteObject(font); 7199 DeleteObject(font);
7197 ReleaseDC(hwnd, hdc); 7200 ReleaseDC(hwnd, hdc);
7198 7201
7199 /* Let the dialog_callback() function know which button to make default 7202 // Let the dialog_callback() function know which button to make default
7200 * If we have an edit box, make that the default. We also need to tell 7203 // If we have an edit box, make that the default. We also need to tell
7201 * dialog_callback() if this dialog contains an edit box or not. We do 7204 // dialog_callback() if this dialog contains an edit box or not. We do
7202 * this by setting s_textfield if it does. 7205 // this by setting s_textfield if it does.
7203 */
7204 if (textfield != NULL) 7206 if (textfield != NULL)
7205 { 7207 {
7206 dialog_default_button = DLG_NONBUTTON_CONTROL + 2; 7208 dialog_default_button = DLG_NONBUTTON_CONTROL + 2;
7207 s_textfield = textfield; 7209 s_textfield = textfield;
7208 } 7210 }
7210 { 7212 {
7211 dialog_default_button = IDCANCEL + 1 + dfltbutton; 7213 dialog_default_button = IDCANCEL + 1 + dfltbutton;
7212 s_textfield = NULL; 7214 s_textfield = NULL;
7213 } 7215 }
7214 7216
7215 /* show the dialog box modally and get a return value */ 7217 // show the dialog box modally and get a return value
7216 nchar = (int)DialogBoxIndirect( 7218 nchar = (int)DialogBoxIndirect(
7217 g_hinst, 7219 g_hinst,
7218 (LPDLGTEMPLATE)pdlgtemplate, 7220 (LPDLGTEMPLATE)pdlgtemplate,
7219 s_hwnd, 7221 s_hwnd,
7220 (DLGPROC)dialog_callback); 7222 (DLGPROC)dialog_callback);
7223 vim_free(tbuffer); 7225 vim_free(tbuffer);
7224 vim_free(buttonWidths); 7226 vim_free(buttonWidths);
7225 vim_free(buttonPositions); 7227 vim_free(buttonPositions);
7226 vim_free(ga.ga_data); 7228 vim_free(ga.ga_data);
7227 7229
7228 /* Focus back to our window (for when MDI is used). */ 7230 // Focus back to our window (for when MDI is used).
7229 (void)SetFocus(s_hwnd); 7231 (void)SetFocus(s_hwnd);
7230 7232
7231 return nchar; 7233 return nchar;
7232 } 7234 }
7233 7235
7234 #endif /* FEAT_GUI_DIALOG */ 7236 #endif // FEAT_GUI_DIALOG
7235 7237
7236 /* 7238 /*
7237 * Put a simple element (basic class) onto a dialog template in memory. 7239 * Put a simple element (basic class) onto a dialog template in memory.
7238 * return a pointer to where the next item should be added. 7240 * return a pointer to where the next item should be added.
7239 * 7241 *
7261 WORD clss, 7263 WORD clss,
7262 const char *caption) 7264 const char *caption)
7263 { 7265 {
7264 int nchar; 7266 int nchar;
7265 7267
7266 p = lpwAlign(p); /* Align to dword boundary*/ 7268 p = lpwAlign(p); // Align to dword boundary
7267 lStyle = lStyle | WS_VISIBLE | WS_CHILD; 7269 lStyle = lStyle | WS_VISIBLE | WS_CHILD;
7268 *p++ = LOWORD(lStyle); 7270 *p++ = LOWORD(lStyle);
7269 *p++ = HIWORD(lStyle); 7271 *p++ = HIWORD(lStyle);
7270 *p++ = 0; // LOWORD (lExtendedStyle) 7272 *p++ = 0; // LOWORD (lExtendedStyle)
7271 *p++ = 0; // HIWORD (lExtendedStyle) 7273 *p++ = 0; // HIWORD (lExtendedStyle)
7317 LPWORD lpWCStr, 7319 LPWORD lpWCStr,
7318 LPSTR lpAnsiIn, 7320 LPSTR lpAnsiIn,
7319 BOOL use_enc) 7321 BOOL use_enc)
7320 { 7322 {
7321 int nChar = 0; 7323 int nChar = 0;
7322 int len = lstrlen(lpAnsiIn) + 1; /* include NUL character */ 7324 int len = lstrlen(lpAnsiIn) + 1; // include NUL character
7323 int i; 7325 int i;
7324 WCHAR *wn; 7326 WCHAR *wn;
7325 7327
7326 if (use_enc && enc_codepage >= 0 && (int)GetACP() != enc_codepage) 7328 if (use_enc && enc_codepage >= 0 && (int)GetACP() != enc_codepage)
7327 { 7329 {
7328 /* Not a codepage, use our own conversion function. */ 7330 // Not a codepage, use our own conversion function.
7329 wn = enc_to_utf16((char_u *)lpAnsiIn, NULL); 7331 wn = enc_to_utf16((char_u *)lpAnsiIn, NULL);
7330 if (wn != NULL) 7332 if (wn != NULL)
7331 { 7333 {
7332 wcscpy(lpWCStr, wn); 7334 wcscpy(lpWCStr, wn);
7333 nChar = (int)wcslen(wn) + 1; 7335 nChar = (int)wcslen(wn) + 1;
7334 vim_free(wn); 7336 vim_free(wn);
7335 } 7337 }
7336 } 7338 }
7337 if (nChar == 0) 7339 if (nChar == 0)
7338 /* Use Win32 conversion function. */ 7340 // Use Win32 conversion function.
7339 nChar = MultiByteToWideChar( 7341 nChar = MultiByteToWideChar(
7340 enc_codepage > 0 ? enc_codepage : CP_ACP, 7342 enc_codepage > 0 ? enc_codepage : CP_ACP,
7341 MB_PRECOMPOSED, 7343 MB_PRECOMPOSED,
7342 lpAnsiIn, len, 7344 lpAnsiIn, len,
7343 lpWCStr, len); 7345 lpWCStr, len);
7344 for (i = 0; i < nChar; ++i) 7346 for (i = 0; i < nChar; ++i)
7345 if (lpWCStr[i] == (WORD)'\t') /* replace tabs with spaces */ 7347 if (lpWCStr[i] == (WORD)'\t') // replace tabs with spaces
7346 lpWCStr[i] = (WORD)' '; 7348 lpWCStr[i] = (WORD)' ';
7347 7349
7348 return nChar; 7350 return nChar;
7349 } 7351 }
7350 7352
7358 vimmenu_T *menu, 7360 vimmenu_T *menu,
7359 WORD menu_id) 7361 WORD menu_id)
7360 { 7362 {
7361 for ( ; menu != NULL; menu = menu->next) 7363 for ( ; menu != NULL; menu = menu->next)
7362 { 7364 {
7363 if (menu->modes == 0) /* this menu has just been deleted */ 7365 if (menu->modes == 0) // this menu has just been deleted
7364 continue; 7366 continue;
7365 if (menu_is_separator(menu->dname)) 7367 if (menu_is_separator(menu->dname))
7366 continue; 7368 continue;
7367 if ((WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000) == menu_id) 7369 if ((WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000) == menu_id)
7368 return menu->submenu_id; 7370 return menu->submenu_id;
7386 { 7388 {
7387 SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam); 7389 SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
7388 return (TRUE); 7390 return (TRUE);
7389 } 7391 }
7390 7392
7391 /* May show the mouse pointer again. */ 7393 // May show the mouse pointer again.
7392 HandleMouseHide(message, lParam); 7394 HandleMouseHide(message, lParam);
7393 7395
7394 if (message == WM_COMMAND) 7396 if (message == WM_COMMAND)
7395 { 7397 {
7396 if ((WORD)(LOWORD(wParam)) & 0x8000) 7398 if ((WORD)(LOWORD(wParam)) & 0x8000)
7406 (void)TrackPopupMenu( 7408 (void)TrackPopupMenu(
7407 tearoff_lookup_menuhandle(menu, LOWORD(wParam)), 7409 tearoff_lookup_menuhandle(menu, LOWORD(wParam)),
7408 TPM_LEFTALIGN | TPM_LEFTBUTTON, 7410 TPM_LEFTALIGN | TPM_LEFTBUTTON,
7409 (int)rect.right - 8, 7411 (int)rect.right - 8,
7410 (int)mp.y, 7412 (int)mp.y,
7411 (int)0, /*reserved param*/ 7413 (int)0, // reserved param
7412 s_hwnd, 7414 s_hwnd,
7413 NULL); 7415 NULL);
7414 /* 7416 /*
7415 * NOTE: The pop-up menu can eat the mouse up event. 7417 * NOTE: The pop-up menu can eat the mouse up event.
7416 * We deal with this in normal.c. 7418 * We deal with this in normal.c.
7417 */ 7419 */
7418 } 7420 }
7419 } 7421 }
7420 else 7422 else
7421 /* Pass on messages to the main Vim window */ 7423 // Pass on messages to the main Vim window
7422 PostMessage(s_hwnd, WM_COMMAND, LOWORD(wParam), 0); 7424 PostMessage(s_hwnd, WM_COMMAND, LOWORD(wParam), 0);
7423 /* 7425 /*
7424 * Give main window the focus back: this is so after 7426 * Give main window the focus back: this is so after
7425 * choosing a tearoff button you can start typing again 7427 * choosing a tearoff button you can start typing again
7426 * straight away. 7428 * straight away.
7432 { 7434 {
7433 DestroyWindow(hwnd); 7435 DestroyWindow(hwnd);
7434 return TRUE; 7436 return TRUE;
7435 } 7437 }
7436 7438
7437 /* When moved around, give main window the focus back. */ 7439 // When moved around, give main window the focus back.
7438 if (message == WM_EXITSIZEMOVE) 7440 if (message == WM_EXITSIZEMOVE)
7439 (void)SetActiveWindow(s_hwnd); 7441 (void)SetActiveWindow(s_hwnd);
7440 7442
7441 return FALSE; 7443 return FALSE;
7442 } 7444 }
7488 s_usenewlook = TRUE; 7490 s_usenewlook = TRUE;
7489 } 7491 }
7490 7492
7491 if (!s_usenewlook) 7493 if (!s_usenewlook)
7492 { 7494 {
7493 dlgFontSize = GetDialogBaseUnits(); /* fall back to big old system*/ 7495 dlgFontSize = GetDialogBaseUnits(); // fall back to big old system
7494 s_dlgfntwidth = LOWORD(dlgFontSize); 7496 s_dlgfntwidth = LOWORD(dlgFontSize);
7495 s_dlgfntheight = HIWORD(dlgFontSize); 7497 s_dlgfntheight = HIWORD(dlgFontSize);
7496 } 7498 }
7497 } 7499 }
7498 7500
7553 * Create a new tearoff. 7555 * Create a new tearoff.
7554 */ 7556 */
7555 if (*title == MNU_HIDDEN_CHAR) 7557 if (*title == MNU_HIDDEN_CHAR)
7556 title++; 7558 title++;
7557 7559
7558 /* Allocate memory to store the dialog template. It's made bigger when 7560 // Allocate memory to store the dialog template. It's made bigger when
7559 * needed. */ 7561 // needed.
7560 template_len = DLG_ALLOC_SIZE; 7562 template_len = DLG_ALLOC_SIZE;
7561 pdlgtemplate = p = (WORD *)LocalAlloc(LPTR, template_len); 7563 pdlgtemplate = p = (WORD *)LocalAlloc(LPTR, template_len);
7562 if (p == NULL) 7564 if (p == NULL)
7563 return; 7565 return;
7564 7566
7577 if (s_usenewlook) 7579 if (s_usenewlook)
7578 oldFont = SelectFont(hdc, font); 7580 oldFont = SelectFont(hdc, font);
7579 else 7581 else
7580 oldFont = SelectFont(hdc, GetStockObject(SYSTEM_FONT)); 7582 oldFont = SelectFont(hdc, GetStockObject(SYSTEM_FONT));
7581 7583
7582 /* Calculate width of a single space. Used for padding columns to the 7584 // Calculate width of a single space. Used for padding columns to the
7583 * right width. */ 7585 // right width.
7584 spaceWidth = GetTextWidth(hdc, (char_u *)" ", 1); 7586 spaceWidth = GetTextWidth(hdc, (char_u *)" ", 1);
7585 7587
7586 /* Figure out max width of the text column, the accelerator column and the 7588 // Figure out max width of the text column, the accelerator column and the
7587 * optional submenu column. */ 7589 // optional submenu column.
7588 submenuWidth = 0; 7590 submenuWidth = 0;
7589 for (col = 0; col < 2; col++) 7591 for (col = 0; col < 2; col++)
7590 { 7592 {
7591 columnWidths[col] = 0; 7593 columnWidths[col] = 0;
7592 for (pmenu = menu->children; pmenu != NULL; pmenu = pmenu->next) 7594 for (pmenu = menu->children; pmenu != NULL; pmenu = pmenu->next)
7593 { 7595 {
7594 /* Use "dname" here to compute the width of the visible text. */ 7596 // Use "dname" here to compute the width of the visible text.
7595 text = (col == 0) ? pmenu->dname : pmenu->actext; 7597 text = (col == 0) ? pmenu->dname : pmenu->actext;
7596 if (text != NULL && *text != NUL) 7598 if (text != NULL && *text != NUL)
7597 { 7599 {
7598 textWidth = GetTextWidthEnc(hdc, text, (int)STRLEN(text)); 7600 textWidth = GetTextWidthEnc(hdc, text, (int)STRLEN(text));
7599 if (textWidth > columnWidths[col]) 7601 if (textWidth > columnWidths[col])
7603 submenuWidth = TEAROFF_COLUMN_PADDING * spaceWidth; 7605 submenuWidth = TEAROFF_COLUMN_PADDING * spaceWidth;
7604 } 7606 }
7605 } 7607 }
7606 if (columnWidths[1] == 0) 7608 if (columnWidths[1] == 0)
7607 { 7609 {
7608 /* no accelerators */ 7610 // no accelerators
7609 if (submenuWidth != 0) 7611 if (submenuWidth != 0)
7610 columnWidths[0] += submenuWidth; 7612 columnWidths[0] += submenuWidth;
7611 else 7613 else
7612 columnWidths[0] += spaceWidth; 7614 columnWidths[0] += spaceWidth;
7613 } 7615 }
7614 else 7616 else
7615 { 7617 {
7616 /* there is an accelerator column */ 7618 // there is an accelerator column
7617 columnWidths[0] += TEAROFF_COLUMN_PADDING * spaceWidth; 7619 columnWidths[0] += TEAROFF_COLUMN_PADDING * spaceWidth;
7618 columnWidths[1] += submenuWidth; 7620 columnWidths[1] += submenuWidth;
7619 } 7621 }
7620 7622
7621 /* 7623 /*
7631 dlgwidth = GetTextWidthEnc(hdc, title, (int)STRLEN(title)); 7633 dlgwidth = GetTextWidthEnc(hdc, title, (int)STRLEN(title));
7632 if (textWidth > dlgwidth) 7634 if (textWidth > dlgwidth)
7633 dlgwidth = textWidth; 7635 dlgwidth = textWidth;
7634 dlgwidth += 2 * TEAROFF_PADDING_X + TEAROFF_BUTTON_PAD_X; 7636 dlgwidth += 2 * TEAROFF_PADDING_X + TEAROFF_BUTTON_PAD_X;
7635 7637
7636 /* start to fill in the dlgtemplate information. addressing by WORDs */ 7638 // start to fill in the dlgtemplate information. addressing by WORDs
7637 if (s_usenewlook) 7639 if (s_usenewlook)
7638 lStyle = DS_MODALFRAME | WS_CAPTION| WS_SYSMENU |DS_SETFONT| WS_VISIBLE; 7640 lStyle = DS_MODALFRAME | WS_CAPTION| WS_SYSMENU |DS_SETFONT| WS_VISIBLE;
7639 else 7641 else
7640 lStyle = DS_MODALFRAME | WS_CAPTION| WS_SYSMENU | WS_VISIBLE; 7642 lStyle = DS_MODALFRAME | WS_CAPTION| WS_SYSMENU | WS_VISIBLE;
7641 7643
7642 lExtendedStyle = WS_EX_TOOLWINDOW|WS_EX_STATICEDGE; 7644 lExtendedStyle = WS_EX_TOOLWINDOW|WS_EX_STATICEDGE;
7643 *p++ = LOWORD(lStyle); 7645 *p++ = LOWORD(lStyle);
7644 *p++ = HIWORD(lStyle); 7646 *p++ = HIWORD(lStyle);
7645 *p++ = LOWORD(lExtendedStyle); 7647 *p++ = LOWORD(lExtendedStyle);
7646 *p++ = HIWORD(lExtendedStyle); 7648 *p++ = HIWORD(lExtendedStyle);
7647 pnumitems = p; /* save where the number of items must be stored */ 7649 pnumitems = p; // save where the number of items must be stored
7648 *p++ = 0; // NumberOfItems(will change later) 7650 *p++ = 0; // NumberOfItems(will change later)
7649 gui_mch_getmouse(&x, &y); 7651 gui_mch_getmouse(&x, &y);
7650 if (initX == 0xffffL) 7652 if (initX == 0xffffL)
7651 *p++ = PixelToDialogX(x); // x 7653 *p++ = PixelToDialogX(x); // x
7652 else 7654 else
7659 ptrueheight = p; 7661 ptrueheight = p;
7660 *p++ = 0; // dialog height: changed later anyway 7662 *p++ = 0; // dialog height: changed later anyway
7661 *p++ = 0; // Menu 7663 *p++ = 0; // Menu
7662 *p++ = 0; // Class 7664 *p++ = 0; // Class
7663 7665
7664 /* copy the title of the dialog */ 7666 // copy the title of the dialog
7665 nchar = nCopyAnsiToWideChar(p, ((*title) 7667 nchar = nCopyAnsiToWideChar(p, ((*title)
7666 ? (LPSTR)title 7668 ? (LPSTR)title
7667 : (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE); 7669 : (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE);
7668 p += nchar; 7670 p += nchar;
7669 7671
7670 if (s_usenewlook) 7672 if (s_usenewlook)
7671 { 7673 {
7672 /* do the font, since DS_3DLOOK doesn't work properly */ 7674 // do the font, since DS_3DLOOK doesn't work properly
7673 # ifdef USE_SYSMENU_FONT 7675 # ifdef USE_SYSMENU_FONT
7674 if (use_lfSysmenu) 7676 if (use_lfSysmenu)
7675 { 7677 {
7676 /* point size */ 7678 // point size
7677 *p++ = -MulDiv(lfSysmenu.lfHeight, 72, 7679 *p++ = -MulDiv(lfSysmenu.lfHeight, 72,
7678 GetDeviceCaps(hdc, LOGPIXELSY)); 7680 GetDeviceCaps(hdc, LOGPIXELSY));
7679 wcscpy(p, lfSysmenu.lfFaceName); 7681 wcscpy(p, lfSysmenu.lfFaceName);
7680 nchar = (int)wcslen(lfSysmenu.lfFaceName) + 1; 7682 nchar = (int)wcslen(lfSysmenu.lfFaceName) + 1;
7681 } 7683 }
7697 else 7699 else
7698 menu = menu->children; 7700 menu = menu->children;
7699 top_menu = menu; 7701 top_menu = menu;
7700 for ( ; menu != NULL; menu = menu->next) 7702 for ( ; menu != NULL; menu = menu->next)
7701 { 7703 {
7702 if (menu->modes == 0) /* this menu has just been deleted */ 7704 if (menu->modes == 0) // this menu has just been deleted
7703 continue; 7705 continue;
7704 if (menu_is_separator(menu->dname)) 7706 if (menu_is_separator(menu->dname))
7705 { 7707 {
7706 sepPadding += 3; 7708 sepPadding += 3;
7707 continue; 7709 continue;
7708 } 7710 }
7709 7711
7710 /* Check if there still is plenty of room in the template. Make it 7712 // Check if there still is plenty of room in the template. Make it
7711 * larger when needed. */ 7713 // larger when needed.
7712 if (((char *)p - (char *)pdlgtemplate) + 1000 > template_len) 7714 if (((char *)p - (char *)pdlgtemplate) + 1000 > template_len)
7713 { 7715 {
7714 WORD *newp; 7716 WORD *newp;
7715 7717
7716 newp = (WORD *)LocalAlloc(LPTR, template_len + 4096); 7718 newp = (WORD *)LocalAlloc(LPTR, template_len + 4096);
7725 LocalFree(LocalHandle(pdlgtemplate)); 7727 LocalFree(LocalHandle(pdlgtemplate));
7726 pdlgtemplate = newp; 7728 pdlgtemplate = newp;
7727 } 7729 }
7728 } 7730 }
7729 7731
7730 /* Figure out minimal length of this menu label. Use "name" for the 7732 // Figure out minimal length of this menu label. Use "name" for the
7731 * actual text, "dname" for estimating the displayed size. "name" 7733 // actual text, "dname" for estimating the displayed size. "name"
7732 * has "&a" for mnemonic and includes the accelerator. */ 7734 // has "&a" for mnemonic and includes the accelerator.
7733 len = nameLen = (int)STRLEN(menu->name); 7735 len = nameLen = (int)STRLEN(menu->name);
7734 padding0 = (columnWidths[0] - GetTextWidthEnc(hdc, menu->dname, 7736 padding0 = (columnWidths[0] - GetTextWidthEnc(hdc, menu->dname,
7735 (int)STRLEN(menu->dname))) / spaceWidth; 7737 (int)STRLEN(menu->dname))) / spaceWidth;
7736 len += padding0; 7738 len += padding0;
7737 7739
7756 { 7758 {
7757 len += (int)STRLEN(TEAROFF_SUBMENU_LABEL); 7759 len += (int)STRLEN(TEAROFF_SUBMENU_LABEL);
7758 menuID = (WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000); 7760 menuID = (WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000);
7759 } 7761 }
7760 7762
7761 /* Allocate menu label and fill it in */ 7763 // Allocate menu label and fill it in
7762 text = label = alloc(len + 1); 7764 text = label = alloc(len + 1);
7763 if (label == NULL) 7765 if (label == NULL)
7764 break; 7766 break;
7765 7767
7766 vim_strncpy(text, menu->name, nameLen); 7768 vim_strncpy(text, menu->name, nameLen);
7767 text = vim_strchr(text, TAB); /* stop at TAB before actext */ 7769 text = vim_strchr(text, TAB); // stop at TAB before actext
7768 if (text == NULL) 7770 if (text == NULL)
7769 text = label + nameLen; /* no actext, use whole name */ 7771 text = label + nameLen; // no actext, use whole name
7770 while (padding0-- > 0) 7772 while (padding0-- > 0)
7771 *text++ = ' '; 7773 *text++ = ' ';
7772 if (menu->actext != NULL) 7774 if (menu->actext != NULL)
7773 { 7775 {
7774 STRNCPY(text, menu->actext, acLen); 7776 STRNCPY(text, menu->actext, acLen);
7804 } 7806 }
7805 7807
7806 *ptrueheight = (WORD)(sepPadding + 1 + 13 * (*pnumitems)); 7808 *ptrueheight = (WORD)(sepPadding + 1 + 13 * (*pnumitems));
7807 7809
7808 7810
7809 /* show modelessly */ 7811 // show modelessly
7810 the_menu->tearoff_handle = CreateDialogIndirectParam( 7812 the_menu->tearoff_handle = CreateDialogIndirectParam(
7811 g_hinst, 7813 g_hinst,
7812 (LPDLGTEMPLATE)pdlgtemplate, 7814 (LPDLGTEMPLATE)pdlgtemplate,
7813 s_hwnd, 7815 s_hwnd,
7814 (DLGPROC)tearoff_callback, 7816 (DLGPROC)tearoff_callback,
7824 * a tearoff, the user doesn't have to click with the mouse just to start 7826 * a tearoff, the user doesn't have to click with the mouse just to start
7825 * typing again! 7827 * typing again!
7826 */ 7828 */
7827 (void)SetActiveWindow(s_hwnd); 7829 (void)SetActiveWindow(s_hwnd);
7828 7830
7829 /* make sure the right buttons are enabled */ 7831 // make sure the right buttons are enabled
7830 force_menu_update = TRUE; 7832 force_menu_update = TRUE;
7831 } 7833 }
7832 #endif 7834 #endif
7833 7835
7834 #if defined(FEAT_TOOLBAR) || defined(PROTO) 7836 #if defined(FEAT_TOOLBAR) || defined(PROTO)
7835 # include "gui_w32_rc.h" 7837 # include "gui_w32_rc.h"
7836 7838
7837 /* This not defined in older SDKs */ 7839 // This not defined in older SDKs
7838 # ifndef TBSTYLE_FLAT 7840 # ifndef TBSTYLE_FLAT
7839 # define TBSTYLE_FLAT 0x0800 7841 # define TBSTYLE_FLAT 0x0800
7840 # endif 7842 # endif
7841 7843
7842 /* 7844 /*
7939 tbAddBitmap.hInst = NULL; 7941 tbAddBitmap.hInst = NULL;
7940 tbAddBitmap.nID = (long_u)hbitmap; 7942 tbAddBitmap.nID = (long_u)hbitmap;
7941 7943
7942 i = (int)SendMessage(s_toolbarhwnd, TB_ADDBITMAP, 7944 i = (int)SendMessage(s_toolbarhwnd, TB_ADDBITMAP,
7943 (WPARAM)1, (LPARAM)&tbAddBitmap); 7945 (WPARAM)1, (LPARAM)&tbAddBitmap);
7944 /* i will be set to -1 if it fails */ 7946 // i will be set to -1 if it fails
7945 } 7947 }
7946 } 7948 }
7947 if (i == -1 && menu->iconidx >= 0 && menu->iconidx < TOOLBAR_BITMAP_COUNT) 7949 if (i == -1 && menu->iconidx >= 0 && menu->iconidx < TOOLBAR_BITMAP_COUNT)
7948 i = menu->iconidx; 7950 i = menu->iconidx;
7949 7951
7982 7984
7983 if (gui_mch_showing_tabline()) 7985 if (gui_mch_showing_tabline())
7984 { 7986 {
7985 TCHITTESTINFO htinfo; 7987 TCHITTESTINFO htinfo;
7986 htinfo.pt = pt; 7988 htinfo.pt = pt;
7987 /* ignore if a window under cusor is not tabcontrol. */ 7989 // ignore if a window under cusor is not tabcontrol.
7988 if (s_tabhwnd == hWnd) 7990 if (s_tabhwnd == hWnd)
7989 { 7991 {
7990 int idx = TabCtrl_HitTest(s_tabhwnd, &htinfo); 7992 int idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
7991 if (idx != -1) 7993 if (idx != -1)
7992 ptp = find_tabpage(idx + 1); 7994 ptp = find_tabpage(idx + 1);
8019 case WM_LBUTTONDOWN: 8021 case WM_LBUTTONDOWN:
8020 { 8022 {
8021 s_pt.x = GET_X_LPARAM(lParam); 8023 s_pt.x = GET_X_LPARAM(lParam);
8022 s_pt.y = GET_Y_LPARAM(lParam); 8024 s_pt.y = GET_Y_LPARAM(lParam);
8023 SetCapture(hwnd); 8025 SetCapture(hwnd);
8024 s_hCursor = GetCursor(); /* backup default cursor */ 8026 s_hCursor = GetCursor(); // backup default cursor
8025 break; 8027 break;
8026 } 8028 }
8027 case WM_MOUSEMOVE: 8029 case WM_MOUSEMOVE:
8028 if (GetCapture() == hwnd 8030 if (GetCapture() == hwnd
8029 && ((wParam & MK_LBUTTON)) != 0) 8031 && ((wParam & MK_LBUTTON)) != 0)
8041 idx1 = tabpage_index(tp) - 1; 8043 idx1 = tabpage_index(tp) - 1;
8042 8044
8043 TabCtrl_GetItemRect(hwnd, idx1, &rect); 8045 TabCtrl_GetItemRect(hwnd, idx1, &rect);
8044 nCenter = rect.left + (rect.right - rect.left) / 2; 8046 nCenter = rect.left + (rect.right - rect.left) / 2;
8045 8047
8046 /* Check if the mouse cursor goes over the center of 8048 // Check if the mouse cursor goes over the center of
8047 * the next tab to prevent "flickering". */ 8049 // the next tab to prevent "flickering".
8048 if ((idx0 < idx1) && (nCenter < pt.x)) 8050 if ((idx0 < idx1) && (nCenter < pt.x))
8049 { 8051 {
8050 tabpage_move(idx1 + 1); 8052 tabpage_move(idx1 + 1);
8051 update_screen(0); 8053 update_screen(0);
8052 } 8054 }
8155 typedef struct _signicon_t 8157 typedef struct _signicon_t
8156 { 8158 {
8157 HANDLE hImage; 8159 HANDLE hImage;
8158 UINT uType; 8160 UINT uType;
8159 # ifdef FEAT_XPM_W32 8161 # ifdef FEAT_XPM_W32
8160 HANDLE hShape; /* Mask bitmap handle */ 8162 HANDLE hShape; // Mask bitmap handle
8161 # endif 8163 # endif
8162 } signicon_t; 8164 } signicon_t;
8163 8165
8164 void 8166 void
8165 gui_mch_drawsign(int row, int col, int typenr) 8167 gui_mch_drawsign(int row, int col, int typenr)
8203 HDC hdcMem; 8205 HDC hdcMem;
8204 HBITMAP hbmpOld; 8206 HBITMAP hbmpOld;
8205 8207
8206 hdcMem = CreateCompatibleDC(s_hdc); 8208 hdcMem = CreateCompatibleDC(s_hdc);
8207 hbmpOld = (HBITMAP)SelectObject(hdcMem, sign->hShape); 8209 hbmpOld = (HBITMAP)SelectObject(hdcMem, sign->hShape);
8208 /* Make hole */ 8210 // Make hole
8209 BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCAND); 8211 BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCAND);
8210 8212
8211 SelectObject(hdcMem, sign->hImage); 8213 SelectObject(hdcMem, sign->hImage);
8212 /* Paint sign */ 8214 // Paint sign
8213 BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCPAINT); 8215 BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCPAINT);
8214 SelectObject(hdcMem, hbmpOld); 8216 SelectObject(hdcMem, hbmpOld);
8215 DeleteDC(hdcMem); 8217 DeleteDC(hdcMem);
8216 } 8218 }
8217 break; 8219 break;
8248 { 8250 {
8249 signicon_t sign, *psign; 8251 signicon_t sign, *psign;
8250 char_u *ext; 8252 char_u *ext;
8251 8253
8252 sign.hImage = NULL; 8254 sign.hImage = NULL;
8253 ext = signfile + STRLEN(signfile) - 4; /* get extension */ 8255 ext = signfile + STRLEN(signfile) - 4; // get extension
8254 if (ext > signfile) 8256 if (ext > signfile)
8255 { 8257 {
8256 int do_load = 1; 8258 int do_load = 1;
8257 8259
8258 if (!STRICMP(ext, ".bmp")) 8260 if (!STRICMP(ext, ".bmp"))
8303 } 8305 }
8304 #endif 8306 #endif
8305 8307
8306 #if defined(FEAT_BEVAL_GUI) || defined(PROTO) 8308 #if defined(FEAT_BEVAL_GUI) || defined(PROTO)
8307 8309
8308 /* BALLOON-EVAL IMPLEMENTATION FOR WINDOWS. 8310 /*
8311 * BALLOON-EVAL IMPLEMENTATION FOR WINDOWS.
8309 * Added by Sergey Khorev <sergey.khorev@gmail.com> 8312 * Added by Sergey Khorev <sergey.khorev@gmail.com>
8310 * 8313 *
8311 * The only reused thing is beval.h and get_beval_info() 8314 * The only reused thing is beval.h and get_beval_info()
8312 * from gui_beval.c (note it uses x and y of the BalloonEval struct 8315 * from gui_beval.c (note it uses x and y of the BalloonEval struct
8313 * to get current mouse position). 8316 * to get current mouse position).
8364 return multiline_tip; 8367 return multiline_tip;
8365 } 8368 }
8366 } 8369 }
8367 else 8370 else
8368 { 8371 {
8369 /* there is chance we have ancient CommCtl 4.70 8372 // there is chance we have ancient CommCtl 4.70
8370 which doesn't export DllGetVersion */ 8373 // which doesn't export DllGetVersion
8371 DWORD dwHandle = 0; 8374 DWORD dwHandle = 0;
8372 DWORD len = GetFileVersionInfoSize(comctl_dll, &dwHandle); 8375 DWORD len = GetFileVersionInfoSize(comctl_dll, &dwHandle);
8373 if (len > 0) 8376 if (len > 0)
8374 { 8377 {
8375 VS_FIXEDFILEINFO *ver; 8378 VS_FIXEDFILEINFO *ver;
8498 && (dwTime - LastActivity) >= (DWORD)p_bdlay 8501 && (dwTime - LastActivity) >= (DWORD)p_bdlay
8499 && (cur_beval->showState != ShS_PENDING 8502 && (cur_beval->showState != ShS_PENDING
8500 || abs(cur_beval->x - pt.x) > 3 8503 || abs(cur_beval->x - pt.x) > 3
8501 || abs(cur_beval->y - pt.y) > 3)) 8504 || abs(cur_beval->y - pt.y) > 3))
8502 { 8505 {
8503 /* Pointer resting in one place long enough, it's time to show 8506 // Pointer resting in one place long enough, it's time to show
8504 * the tooltip. */ 8507 // the tooltip.
8505 cur_beval->showState = ShS_PENDING; 8508 cur_beval->showState = ShS_PENDING;
8506 cur_beval->x = pt.x; 8509 cur_beval->x = pt.x;
8507 cur_beval->y = pt.y; 8510 cur_beval->y = pt.y;
8508 8511
8509 // TRACE0("BevalTimerProc: sending request"); 8512 // TRACE0("BevalTimerProc: sending request");
8552 GetCursorPos(&pt); 8555 GetCursorPos(&pt);
8553 ScreenToClient(s_textArea, &pt); 8556 ScreenToClient(s_textArea, &pt);
8554 8557
8555 if (abs(beval->x - pt.x) < 3 && abs(beval->y - pt.y) < 3) 8558 if (abs(beval->x - pt.x) < 3 && abs(beval->y - pt.y) < 3)
8556 { 8559 {
8557 /* cursor is still here */ 8560 // cursor is still here
8558 gui_mch_disable_beval_area(cur_beval); 8561 gui_mch_disable_beval_area(cur_beval);
8559 beval->showState = ShS_SHOWING; 8562 beval->showState = ShS_SHOWING;
8560 make_tooltip(beval, (char *)mesg, pt); 8563 make_tooltip(beval, (char *)mesg, pt);
8561 } 8564 }
8562 // TRACE0("gui_mch_post_balloon }}}"); 8565 // TRACE0("gui_mch_post_balloon }}}");
8563 } 8566 }
8564 8567
8565 BalloonEval * 8568 BalloonEval *
8566 gui_mch_create_beval_area( 8569 gui_mch_create_beval_area(
8567 void *target UNUSED, /* ignored, always use s_textArea */ 8570 void *target UNUSED, // ignored, always use s_textArea
8568 char_u *mesg, 8571 char_u *mesg,
8569 void (*mesgCB)(BalloonEval *, int), 8572 void (*mesgCB)(BalloonEval *, int),
8570 void *clientData) 8573 void *clientData)
8571 { 8574 {
8572 /* partially stolen from gui_beval.c */ 8575 // partially stolen from gui_beval.c
8573 BalloonEval *beval; 8576 BalloonEval *beval;
8574 8577
8575 if (mesg != NULL && mesgCB != NULL) 8578 if (mesg != NULL && mesgCB != NULL)
8576 { 8579 {
8577 iemsg(_("E232: Cannot create BalloonEval with both message and callback")); 8580 iemsg(_("E232: Cannot create BalloonEval with both message and callback"));
8598 } 8601 }
8599 8602
8600 static void 8603 static void
8601 Handle_WM_Notify(HWND hwnd UNUSED, LPNMHDR pnmh) 8604 Handle_WM_Notify(HWND hwnd UNUSED, LPNMHDR pnmh)
8602 { 8605 {
8603 if (pnmh->idFrom != ID_BEVAL_TOOLTIP) /* it is not our tooltip */ 8606 if (pnmh->idFrom != ID_BEVAL_TOOLTIP) // it is not our tooltip
8604 return; 8607 return;
8605 8608
8606 if (cur_beval != NULL) 8609 if (cur_beval != NULL)
8607 { 8610 {
8608 switch (pnmh->code) 8611 switch (pnmh->code)
8609 { 8612 {
8610 case TTN_SHOW: 8613 case TTN_SHOW:
8611 // TRACE0("TTN_SHOW {{{"); 8614 // TRACE0("TTN_SHOW {{{");
8612 // TRACE0("TTN_SHOW }}}"); 8615 // TRACE0("TTN_SHOW }}}");
8613 break; 8616 break;
8614 case TTN_POP: /* Before tooltip disappear */ 8617 case TTN_POP: // Before tooltip disappear
8615 // TRACE0("TTN_POP {{{"); 8618 // TRACE0("TTN_POP {{{");
8616 delete_tooltip(cur_beval); 8619 delete_tooltip(cur_beval);
8617 gui_mch_enable_beval_area(cur_beval); 8620 gui_mch_enable_beval_area(cur_beval);
8618 // TRACE0("TTN_POP }}}"); 8621 // TRACE0("TTN_POP }}}");
8619 8622
8620 cur_beval->showState = ShS_NEUTRAL; 8623 cur_beval->showState = ShS_NEUTRAL;
8621 break; 8624 break;
8622 case TTN_GETDISPINFO: 8625 case TTN_GETDISPINFO:
8623 { 8626 {
8624 /* if you get there then we have new common controls */ 8627 // if you get there then we have new common controls
8625 NMTTDISPINFO_NEW *info = (NMTTDISPINFO_NEW *)pnmh; 8628 NMTTDISPINFO_NEW *info = (NMTTDISPINFO_NEW *)pnmh;
8626 info->lpszText = (LPSTR)info->lParam; 8629 info->lpszText = (LPSTR)info->lParam;
8627 info->uFlags |= TTF_DI_SETITEM; 8630 info->uFlags |= TTF_DI_SETITEM;
8628 } 8631 }
8629 break; 8632 break;
8654 vim_free(beval->vts); 8657 vim_free(beval->vts);
8655 # endif 8658 # endif
8656 vim_free(beval->tofree); 8659 vim_free(beval->tofree);
8657 vim_free(beval); 8660 vim_free(beval);
8658 } 8661 }
8659 #endif /* FEAT_BEVAL_GUI */ 8662 #endif // FEAT_BEVAL_GUI
8660 8663
8661 #if defined(FEAT_NETBEANS_INTG) || defined(PROTO) 8664 #if defined(FEAT_NETBEANS_INTG) || defined(PROTO)
8662 /* 8665 /*
8663 * We have multiple signs to draw at the same location. Draw the 8666 * We have multiple signs to draw at the same location. Draw the
8664 * multi-sign indicator (down-arrow) instead. This is the Win32 version. 8667 * multi-sign indicator (down-arrow) instead. This is the Win32 version.