comparison src/gui_w48.c @ 8090:54cfe888c627 v7.4.1339

commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Feb 16 20:12:02 2016 +0100 patch 7.4.1339 Problem: Warnings when building the GUI with MingW. (Cesar Romani) Solution: Add type cats. (Yasuhiro Matsumoto)
author Christian Brabandt <cb@256bit.org>
date Tue, 16 Feb 2016 20:15:05 +0100
parents 7c74cafac0a1
children 441298d72f3c
comparison
equal deleted inserted replaced
8089:e5d330ffb650 8090:54cfe888c627
532 if ((int)GetACP() == enc_codepage) 532 if ((int)GetACP() == enc_codepage)
533 len = 0; /* no conversion required */ 533 len = 0; /* no conversion required */
534 else 534 else
535 { 535 {
536 string[0] = ch; 536 string[0] = ch;
537 len = MultiByteToWideChar(GetACP(), 0, string, 1, wstring, 2); 537 len = MultiByteToWideChar(GetACP(), 0, (LPCSTR)string,
538 1, wstring, 2);
538 } 539 }
539 } 540 }
540 else 541 else
541 { 542 {
542 wstring[0] = ch; 543 wstring[0] = ch;
549 * "enc_codepage" is non-zero use the standard Win32 function, 550 * "enc_codepage" is non-zero use the standard Win32 function,
550 * otherwise use our own conversion function (e.g., for UTF-8). */ 551 * otherwise use our own conversion function (e.g., for UTF-8). */
551 if (enc_codepage > 0) 552 if (enc_codepage > 0)
552 { 553 {
553 len = WideCharToMultiByte(enc_codepage, 0, wstring, len, 554 len = WideCharToMultiByte(enc_codepage, 0, wstring, len,
554 string, slen, 0, NULL); 555 (LPSTR)string, slen, 0, NULL);
555 /* If we had included the ALT key into the character but now the 556 /* If we had included the ALT key into the character but now the
556 * upper bit is no longer set, that probably means the conversion 557 * upper bit is no longer set, that probably means the conversion
557 * failed. Convert the original character and set the upper bit 558 * failed. Convert the original character and set the upper bit
558 * afterwards. */ 559 * afterwards. */
559 if (had_alt && len == 1 && ch >= 0x80 && string[0] < 0x80) 560 if (had_alt && len == 1 && ch >= 0x80 && string[0] < 0x80)
560 { 561 {
561 wstring[0] = ch & 0x7f; 562 wstring[0] = ch & 0x7f;
562 len = WideCharToMultiByte(enc_codepage, 0, wstring, len, 563 len = WideCharToMultiByte(enc_codepage, 0, wstring, len,
563 string, slen, 0, NULL); 564 (LPSTR)string, slen, 0, NULL);
564 if (len == 1) /* safety check */ 565 if (len == 1) /* safety check */
565 string[0] |= 0x80; 566 string[0] |= 0x80;
566 } 567 }
567 } 568 }
568 else 569 else
919 WCHAR *wp; 920 WCHAR *wp;
920 921
921 lpfrw->hwndOwner = lpfr->hwndOwner; 922 lpfrw->hwndOwner = lpfr->hwndOwner;
922 lpfrw->Flags = lpfr->Flags; 923 lpfrw->Flags = lpfr->Flags;
923 924
924 wp = enc_to_utf16(lpfr->lpstrFindWhat, NULL); 925 wp = enc_to_utf16((char_u *)lpfr->lpstrFindWhat, NULL);
925 wcsncpy(lpfrw->lpstrFindWhat, wp, lpfrw->wFindWhatLen - 1); 926 wcsncpy(lpfrw->lpstrFindWhat, wp, lpfrw->wFindWhatLen - 1);
926 vim_free(wp); 927 vim_free(wp);
927 928
928 /* the field "lpstrReplaceWith" doesn't need to be copied */ 929 /* the field "lpstrReplaceWith" doesn't need to be copied */
929 } 930 }
936 { 937 {
937 char_u *p; 938 char_u *p;
938 939
939 lpfr->Flags = lpfrw->Flags; 940 lpfr->Flags = lpfrw->Flags;
940 941
941 p = utf16_to_enc(lpfrw->lpstrFindWhat, NULL); 942 p = utf16_to_enc((short_u*)lpfrw->lpstrFindWhat, NULL);
942 vim_strncpy(lpfr->lpstrFindWhat, p, lpfr->wFindWhatLen - 1); 943 vim_strncpy((char_u *)lpfr->lpstrFindWhat, p, lpfr->wFindWhatLen - 1);
943 vim_free(p); 944 vim_free(p);
944 945
945 p = utf16_to_enc(lpfrw->lpstrReplaceWith, NULL); 946 p = utf16_to_enc((short_u*)lpfrw->lpstrReplaceWith, NULL);
946 vim_strncpy(lpfr->lpstrReplaceWith, p, lpfr->wReplaceWithLen - 1); 947 vim_strncpy((char_u *)lpfr->lpstrReplaceWith, p, lpfr->wReplaceWithLen - 1);
947 vim_free(p); 948 vim_free(p);
948 } 949 }
949 # endif 950 # endif
950 951
951 /* 952 /*
998 if (s_findrep_struct.Flags & FR_WHOLEWORD) 999 if (s_findrep_struct.Flags & FR_WHOLEWORD)
999 flags |= FRD_WHOLE_WORD; 1000 flags |= FRD_WHOLE_WORD;
1000 if (s_findrep_struct.Flags & FR_MATCHCASE) 1001 if (s_findrep_struct.Flags & FR_MATCHCASE)
1001 flags |= FRD_MATCH_CASE; 1002 flags |= FRD_MATCH_CASE;
1002 down = (s_findrep_struct.Flags & FR_DOWN) != 0; 1003 down = (s_findrep_struct.Flags & FR_DOWN) != 0;
1003 gui_do_findrepl(flags, s_findrep_struct.lpstrFindWhat, 1004 gui_do_findrepl(flags, (char_u *)s_findrep_struct.lpstrFindWhat,
1004 s_findrep_struct.lpstrReplaceWith, down); 1005 (char_u *)s_findrep_struct.lpstrReplaceWith, down);
1005 } 1006 }
1006 } 1007 }
1007 #endif 1008 #endif
1008 1009
1009 static void 1010 static void
1528 }; 1529 };
1529 1530
1530 int r, g, b; 1531 int r, g, b;
1531 int i; 1532 int i;
1532 1533
1533 if (name[0] == '#' && strlen(name) == 7) 1534 if (name[0] == '#' && STRLEN(name) == 7)
1534 { 1535 {
1535 /* Name is in "#rrggbb" format */ 1536 /* Name is in "#rrggbb" format */
1536 r = hex_digit(name[1]) * 16 + hex_digit(name[2]); 1537 r = hex_digit(name[1]) * 16 + hex_digit(name[2]);
1537 g = hex_digit(name[3]) * 16 + hex_digit(name[4]); 1538 g = hex_digit(name[3]) * 16 + hex_digit(name[4]);
1538 b = hex_digit(name[5]) * 16 + hex_digit(name[6]); 1539 b = hex_digit(name[5]) * 16 + hex_digit(name[6]);
2266 static int 2267 static int
2267 GetTextWidth(HDC hdc, char_u *str, int len) 2268 GetTextWidth(HDC hdc, char_u *str, int len)
2268 { 2269 {
2269 SIZE size; 2270 SIZE size;
2270 2271
2271 GetTextExtentPoint(hdc, str, len, &size); 2272 GetTextExtentPoint(hdc, (LPCSTR)str, len, &size);
2272 return size.cx; 2273 return size.cx;
2273 } 2274 }
2274 2275
2275 #ifdef FEAT_MBYTE 2276 #ifdef FEAT_MBYTE
2276 /* 2277 /*
2466 if (tab_pmenu == NULL) 2467 if (tab_pmenu == NULL)
2467 return; 2468 return;
2468 2469
2469 if (first_tabpage->tp_next != NULL) 2470 if (first_tabpage->tp_next != NULL)
2470 add_tabline_popup_menu_entry(tab_pmenu, 2471 add_tabline_popup_menu_entry(tab_pmenu,
2471 TABLINE_MENU_CLOSE, _("Close tab")); 2472 TABLINE_MENU_CLOSE, (char_u *)_("Close tab"));
2472 add_tabline_popup_menu_entry(tab_pmenu, TABLINE_MENU_NEW, _("New tab")); 2473 add_tabline_popup_menu_entry(tab_pmenu,
2473 add_tabline_popup_menu_entry(tab_pmenu, TABLINE_MENU_OPEN, 2474 TABLINE_MENU_NEW, (char_u *)_("New tab"));
2474 _("Open tab...")); 2475 add_tabline_popup_menu_entry(tab_pmenu,
2476 TABLINE_MENU_OPEN, (char_u *)_("Open tab..."));
2475 2477
2476 GetCursorPos(&pt); 2478 GetCursorPos(&pt);
2477 rval = TrackPopupMenuEx(tab_pmenu, TPM_RETURNCMD, pt.x, pt.y, s_tabhwnd, 2479 rval = TrackPopupMenuEx(tab_pmenu, TPM_RETURNCMD, pt.x, pt.y, s_tabhwnd,
2478 NULL); 2480 NULL);
2479 2481
2581 TabCtrl_InsertItem(s_tabhwnd, nr, &tie); 2583 TabCtrl_InsertItem(s_tabhwnd, nr, &tie);
2582 tabadded = 1; 2584 tabadded = 1;
2583 } 2585 }
2584 2586
2585 get_tabline_label(tp, FALSE); 2587 get_tabline_label(tp, FALSE);
2586 tie.pszText = NameBuff; 2588 tie.pszText = (LPSTR)NameBuff;
2587 #ifdef FEAT_MBYTE 2589 #ifdef FEAT_MBYTE
2588 wstr = NULL; 2590 wstr = NULL;
2589 if (use_unicode) 2591 if (use_unicode)
2590 { 2592 {
2591 /* Need to go through Unicode. */ 2593 /* Need to go through Unicode. */
2678 if (mcase) 2680 if (mcase)
2679 s_findrep_struct.Flags |= FR_MATCHCASE; 2681 s_findrep_struct.Flags |= FR_MATCHCASE;
2680 if (wword) 2682 if (wword)
2681 s_findrep_struct.Flags |= FR_WHOLEWORD; 2683 s_findrep_struct.Flags |= FR_WHOLEWORD;
2682 if (entry_text != NULL && *entry_text != NUL) 2684 if (entry_text != NULL && *entry_text != NUL)
2683 vim_strncpy(s_findrep_struct.lpstrFindWhat, entry_text, 2685 vim_strncpy((char_u *)s_findrep_struct.lpstrFindWhat, entry_text,
2684 s_findrep_struct.wFindWhatLen - 1); 2686 s_findrep_struct.wFindWhatLen - 1);
2685 vim_free(entry_text); 2687 vim_free(entry_text);
2686 } 2688 }
2687 #endif 2689 #endif
2688 2690
3192 /* Convert a font name from the current codepage to 'encoding'. 3194 /* Convert a font name from the current codepage to 'encoding'.
3193 * TODO: Use Wide APIs (including LOGFONTW) instead of ANSI APIs. */ 3195 * TODO: Use Wide APIs (including LOGFONTW) instead of ANSI APIs. */
3194 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) 3196 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
3195 { 3197 {
3196 int len; 3198 int len;
3197 acp_to_enc(lf.lfFaceName, (int)strlen(lf.lfFaceName), 3199 acp_to_enc((char_u *)lf.lfFaceName, (int)strlen(lf.lfFaceName),
3198 (char_u **)&font_name, &len); 3200 (char_u **)&font_name, &len);
3199 } 3201 }
3200 #endif 3202 #endif
3201 res = alloc((unsigned)(strlen(font_name) + 20 3203 res = (char *)alloc((unsigned)(strlen(font_name) + 20
3202 + (charset_name == NULL ? 0 : strlen(charset_name) + 2))); 3204 + (charset_name == NULL ? 0 : strlen(charset_name) + 2)));
3203 if (res != NULL) 3205 if (res != NULL)
3204 { 3206 {
3205 p = res; 3207 p = res;
3206 /* make a normal font string out of the lf thing:*/ 3208 /* make a normal font string out of the lf thing:*/
3231 3233
3232 #ifdef FEAT_MBYTE 3234 #ifdef FEAT_MBYTE
3233 if (font_name != lf.lfFaceName) 3235 if (font_name != lf.lfFaceName)
3234 vim_free(font_name); 3236 vim_free(font_name);
3235 #endif 3237 #endif
3236 return res; 3238 return (char_u *)res;
3237 } 3239 }
3238 3240
3239 3241
3240 #ifdef FEAT_MBYTE_IME 3242 #ifdef FEAT_MBYTE_IME
3241 /* 3243 /*
3321 font = get_font_handle(&lf); 3323 font = get_font_handle(&lf);
3322 if (font == NOFONT) 3324 if (font == NOFONT)
3323 return FAIL; 3325 return FAIL;
3324 3326
3325 if (font_name == NULL) 3327 if (font_name == NULL)
3326 font_name = lf.lfFaceName; 3328 font_name = (char_u *)lf.lfFaceName;
3327 #if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME) 3329 #if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME)
3328 norm_logfont = lf; 3330 norm_logfont = lf;
3329 sub_logfont = lf; 3331 sub_logfont = lf;
3330 #endif 3332 #endif
3331 #ifdef FEAT_MBYTE_IME 3333 #ifdef FEAT_MBYTE_IME
3751 fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400; 3753 fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400;
3752 #else 3754 #else
3753 fileStruct.lStructSize = sizeof(fileStruct); 3755 fileStruct.lStructSize = sizeof(fileStruct);
3754 #endif 3756 #endif
3755 3757
3756 fileStruct.lpstrTitle = title; 3758 fileStruct.lpstrTitle = (LPSTR)title;
3757 fileStruct.lpstrDefExt = ext; 3759 fileStruct.lpstrDefExt = (LPSTR)ext;
3758 3760
3759 fileStruct.lpstrFile = fileBuf; 3761 fileStruct.lpstrFile = (LPSTR)fileBuf;
3760 fileStruct.nMaxFile = MAXPATHL; 3762 fileStruct.nMaxFile = MAXPATHL;
3761 fileStruct.lpstrFilter = filterp; 3763 fileStruct.lpstrFilter = (LPSTR)filterp;
3762 fileStruct.hwndOwner = s_hwnd; /* main Vim window is owner*/ 3764 fileStruct.hwndOwner = s_hwnd; /* main Vim window is owner*/
3763 /* has an initial dir been specified? */ 3765 /* has an initial dir been specified? */
3764 if (initdir != NULL && *initdir != NUL) 3766 if (initdir != NULL && *initdir != NUL)
3765 { 3767 {
3766 /* Must have backslashes here, no matter what 'shellslash' says */ 3768 /* Must have backslashes here, no matter what 'shellslash' says */
3767 initdirp = vim_strsave(initdir); 3769 initdirp = vim_strsave(initdir);
3768 if (initdirp != NULL) 3770 if (initdirp != NULL)
3769 for (p = initdirp; *p != NUL; ++p) 3771 for (p = initdirp; *p != NUL; ++p)
3770 if (*p == '/') 3772 if (*p == '/')
3771 *p = '\\'; 3773 *p = '\\';
3772 fileStruct.lpstrInitialDir = initdirp; 3774 fileStruct.lpstrInitialDir = (LPSTR)initdirp;
3773 } 3775 }
3774 3776
3775 /* 3777 /*
3776 * TODO: Allow selection of multiple files. Needs another arg to this 3778 * TODO: Allow selection of multiple files. Needs another arg to this
3777 * function to ask for it, and need to use OFN_ALLOWMULTISELECT below. 3779 * function to ask for it, and need to use OFN_ALLOWMULTISELECT below.
3849 fnames[i] = utf16_to_enc(wszFile, NULL); 3851 fnames[i] = utf16_to_enc(wszFile, NULL);
3850 else 3852 else
3851 #endif 3853 #endif
3852 { 3854 {
3853 DragQueryFile(hDrop, i, szFile, BUFPATHLEN); 3855 DragQueryFile(hDrop, i, szFile, BUFPATHLEN);
3854 fnames[i] = vim_strsave(szFile); 3856 fnames[i] = vim_strsave((char_u *)szFile);
3855 } 3857 }
3856 } 3858 }
3857 3859
3858 DragFinish(hDrop); 3860 DragFinish(hDrop);
3859 3861