comparison src/gui_w48.c @ 34:e170173ecb68 current-release

before ack base protocol.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 26 Nov 2008 15:02:10 +0900
parents 76efa0be13f1
children c16898406ff2
comparison
equal deleted inserted replaced
33:7d0d8b831f5a 34:e170173ecb68
288 {0, 0, 0} 288 {0, 0, 0}
289 }; 289 };
290 290
291 /* Local variables */ 291 /* Local variables */
292 static int s_button_pending = -1; 292 static int s_button_pending = -1;
293
294 /* s_getting_focus is set when we got focus but didn't see mouse-up event yet,
295 * so don't reset s_button_pending. */
296 static int s_getting_focus = FALSE;
297
293 static int s_x_pending; 298 static int s_x_pending;
294 static int s_y_pending; 299 static int s_y_pending;
295 static UINT s_kFlags_pending; 300 static UINT s_kFlags_pending;
296 static UINT s_wait_timer = 0; /* Timer for get char from user */ 301 static UINT s_wait_timer = 0; /* Timer for get char from user */
297 static int s_timed_out = FALSE; 302 static int s_timed_out = FALSE;
484 dead_key = 1; 489 dead_key = 1;
485 } 490 }
486 491
487 /* 492 /*
488 * Convert Unicode character "ch" to bytes in "string[slen]". 493 * Convert Unicode character "ch" to bytes in "string[slen]".
494 * When "had_alt" is TRUE the ALT key was included in "ch".
489 * Return the length. 495 * Return the length.
490 */ 496 */
491 static int 497 static int
492 char_to_string(int ch, char_u *string, int slen) 498 char_to_string(int ch, char_u *string, int slen, int had_alt)
493 { 499 {
494 int len; 500 int len;
495 int i; 501 int i;
496 #ifdef FEAT_MBYTE 502 #ifdef FEAT_MBYTE
497 WCHAR wstring[2]; 503 WCHAR wstring[2];
520 { 526 {
521 /* "ch" is a UTF-16 character. Convert it to a string of bytes. When 527 /* "ch" is a UTF-16 character. Convert it to a string of bytes. When
522 * "enc_codepage" is non-zero use the standard Win32 function, 528 * "enc_codepage" is non-zero use the standard Win32 function,
523 * otherwise use our own conversion function (e.g., for UTF-8). */ 529 * otherwise use our own conversion function (e.g., for UTF-8). */
524 if (enc_codepage > 0) 530 if (enc_codepage > 0)
531 {
525 len = WideCharToMultiByte(enc_codepage, 0, wstring, len, 532 len = WideCharToMultiByte(enc_codepage, 0, wstring, len,
526 string, slen, 0, NULL); 533 string, slen, 0, NULL);
534 /* If we had included the ALT key into the character but now the
535 * upper bit is no longer set, that probably means the conversion
536 * failed. Convert the original character and set the upper bit
537 * afterwards. */
538 if (had_alt && len == 1 && ch >= 0x80 && string[0] < 0x80)
539 {
540 wstring[0] = ch & 0x7f;
541 len = WideCharToMultiByte(enc_codepage, 0, wstring, len,
542 string, slen, 0, NULL);
543 if (len == 1) /* safety check */
544 string[0] |= 0x80;
545 }
546 }
527 else 547 else
528 { 548 {
529 len = 1; 549 len = 1;
530 ws = ucs2_to_enc(wstring, &len); 550 ws = ucs2_to_enc(wstring, &len);
531 if (ws == NULL) 551 if (ws == NULL)
571 int cRepeat) 591 int cRepeat)
572 { 592 {
573 char_u string[40]; 593 char_u string[40];
574 int len = 0; 594 int len = 0;
575 595
576 len = char_to_string(ch, string, 40); 596 len = char_to_string(ch, string, 40, FALSE);
577 if (len == 1 && string[0] == Ctrl_C && ctrl_c_interrupts) 597 if (len == 1 && string[0] == Ctrl_C && ctrl_c_interrupts)
578 { 598 {
579 trash_input_buf(); 599 trash_input_buf();
580 got_int = TRUE; 600 got_int = TRUE;
581 } 601 }
638 } 658 }
639 else 659 else
640 { 660 {
641 /* Although the documentation isn't clear about it, we assume "ch" is 661 /* Although the documentation isn't clear about it, we assume "ch" is
642 * a Unicode character. */ 662 * a Unicode character. */
643 len += char_to_string(ch, string + len, 40 - len); 663 len += char_to_string(ch, string + len, 40 - len, TRUE);
644 } 664 }
645 665
646 add_to_input_buf(string, len); 666 add_to_input_buf(string, len);
647 } 667 }
648 668
653 int y, 673 int y,
654 int repeated_click, 674 int repeated_click,
655 UINT keyFlags) 675 UINT keyFlags)
656 { 676 {
657 int vim_modifiers = 0x0; 677 int vim_modifiers = 0x0;
678
679 s_getting_focus = FALSE;
658 680
659 if (keyFlags & MK_SHIFT) 681 if (keyFlags & MK_SHIFT)
660 vim_modifiers |= MOUSE_SHIFT; 682 vim_modifiers |= MOUSE_SHIFT;
661 if (keyFlags & MK_CONTROL) 683 if (keyFlags & MK_CONTROL)
662 vim_modifiers |= MOUSE_CTRL; 684 vim_modifiers |= MOUSE_CTRL;
775 int y, 797 int y,
776 UINT keyFlags) 798 UINT keyFlags)
777 { 799 {
778 int button; 800 int button;
779 801
802 s_getting_focus = FALSE;
780 if (s_button_pending > -1) 803 if (s_button_pending > -1)
781 { 804 {
782 /* Delayed action for mouse down event */ 805 /* Delayed action for mouse down event */
783 _OnMouseEvent(s_button_pending, s_x_pending, 806 _OnMouseEvent(s_button_pending, s_x_pending,
784 s_y_pending, FALSE, s_kFlags_pending); 807 s_y_pending, FALSE, s_kFlags_pending);
1773 else 1796 else
1774 { 1797 {
1775 int len; 1798 int len;
1776 1799
1777 /* Handle "key" as a Unicode character. */ 1800 /* Handle "key" as a Unicode character. */
1778 len = char_to_string(key, string, 40); 1801 len = char_to_string(key, string, 40, FALSE);
1779 add_to_input_buf(string, len); 1802 add_to_input_buf(string, len);
1780 } 1803 }
1781 break; 1804 break;
1782 } 1805 }
1783 } 1806 }
1934 s_wait_timer = 0; 1957 s_wait_timer = 0;
1935 } 1958 }
1936 allow_scrollbar = FALSE; 1959 allow_scrollbar = FALSE;
1937 1960
1938 /* Clear pending mouse button, the release event may have been 1961 /* Clear pending mouse button, the release event may have been
1939 * taken by the dialog window. */ 1962 * taken by the dialog window. But don't do this when getting
1940 s_button_pending = -1; 1963 * focus, we need the mouse-up event then. */
1964 if (!s_getting_focus)
1965 s_button_pending = -1;
1941 1966
1942 return OK; 1967 return OK;
1943 } 1968 }
1944 } 1969 }
1945 allow_scrollbar = FALSE; 1970 allow_scrollbar = FALSE;
2685 _OnSetFocus( 2710 _OnSetFocus(
2686 HWND hwnd, 2711 HWND hwnd,
2687 HWND hwndOldFocus) 2712 HWND hwndOldFocus)
2688 { 2713 {
2689 gui_focus_change(TRUE); 2714 gui_focus_change(TRUE);
2715 s_getting_focus = TRUE;
2690 (void)MyWindowProc(hwnd, WM_SETFOCUS, (WPARAM)hwndOldFocus, 0); 2716 (void)MyWindowProc(hwnd, WM_SETFOCUS, (WPARAM)hwndOldFocus, 0);
2691 } 2717 }
2692 2718
2693 static void 2719 static void
2694 _OnKillFocus( 2720 _OnKillFocus(
2695 HWND hwnd, 2721 HWND hwnd,
2696 HWND hwndNewFocus) 2722 HWND hwndNewFocus)
2697 { 2723 {
2698 gui_focus_change(FALSE); 2724 gui_focus_change(FALSE);
2725 s_getting_focus = FALSE;
2699 (void)MyWindowProc(hwnd, WM_KILLFOCUS, (WPARAM)hwndNewFocus, 0); 2726 (void)MyWindowProc(hwnd, WM_KILLFOCUS, (WPARAM)hwndNewFocus, 0);
2700 } 2727 }
2701 2728
2702 /* 2729 /*
2703 * Get a message when the user switches back to vim 2730 * Get a message when the user switches back to vim
3125 { 3152 {
3126 if (shape >= MSHAPE_NUMBERED) 3153 if (shape >= MSHAPE_NUMBERED)
3127 idc = MAKEINTRESOURCE(IDC_ARROW); 3154 idc = MAKEINTRESOURCE(IDC_ARROW);
3128 else 3155 else
3129 idc = mshape_idcs[shape]; 3156 idc = mshape_idcs[shape];
3130 #ifdef _WIN64 3157 #ifdef SetClassLongPtr
3131 SetClassLongPtr(s_textArea, GCLP_HCURSOR, (LONG_PTR)LoadCursor(NULL, idc)); 3158 SetClassLongPtr(s_textArea, GCLP_HCURSOR, (__int3264)(LONG_PTR)LoadCursor(NULL, idc));
3132 #else 3159 #else
3133 # ifdef WIN32 3160 # ifdef WIN32
3134 SetClassLong(s_textArea, GCL_HCURSOR, (LONG)LoadCursor(NULL, idc)); 3161 SetClassLong(s_textArea, GCL_HCURSOR, (long_u)LoadCursor(NULL, idc));
3135 # else 3162 # else /* Win16 */
3136 SetClassWord(s_textArea, GCW_HCURSOR, (WORD)LoadCursor(NULL, idc)); 3163 SetClassWord(s_textArea, GCW_HCURSOR, (WORD)LoadCursor(NULL, idc));
3137 # endif 3164 # endif
3138 #endif 3165 #endif
3139 if (!p_mh) 3166 if (!p_mh)
3140 { 3167 {