src/video/windows/SDL_windowskeyboard.c
changeset 8976 1a5d959d7b32
parent 8732 c62baa0b8827
child 9619 b94b6d0bff0f
equal deleted inserted replaced
8975:180271d72b1e 8976:1a5d959d7b32
   748     if (size) {
   748     if (size) {
   749         cand_list = (LPCANDIDATELIST)SDL_malloc(size);
   749         cand_list = (LPCANDIDATELIST)SDL_malloc(size);
   750         if (cand_list) {
   750         if (cand_list) {
   751             size = ImmGetCandidateListW(himc, 0, cand_list, size);
   751             size = ImmGetCandidateListW(himc, 0, cand_list, size);
   752             if (size) {
   752             if (size) {
   753                 int i = 0;
   753                 UINT i, j;
   754                 int j = 0;
   754                 UINT page_start = 0;
   755                 int page_start = 0;
       
   756                 videodata->ime_candsel = cand_list->dwSelection;
   755                 videodata->ime_candsel = cand_list->dwSelection;
   757                 videodata->ime_candcount = cand_list->dwCount;
   756                 videodata->ime_candcount = cand_list->dwCount;
   758 
   757 
   759                 if (LANG() == LANG_CHS && IME_GetId(videodata, 0)) {
   758                 if (LANG() == LANG_CHS && IME_GetId(videodata, 0)) {
   760                     const UINT maxcandchar = 18;
   759                     const UINT maxcandchar = 18;
   761                     UINT i = 0;
       
   762                     size_t cchars = 0;
   760                     size_t cchars = 0;
   763 
   761 
   764                     for (; i < videodata->ime_candcount; ++i) {
   762                     for (i = 0; i < videodata->ime_candcount; ++i) {
   765                         size_t len = SDL_wcslen((LPWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i])) + 1;
   763                         size_t len = SDL_wcslen((LPWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i])) + 1;
   766                         if (len + cchars > maxcandchar) {
   764                         if (len + cchars > maxcandchar) {
   767                             if (i > cand_list->dwSelection)
   765                             if (i > cand_list->dwSelection)
   768                                 break;
   766                                 break;
   769 
   767 
   773                         else {
   771                         else {
   774                             cchars += len;
   772                             cchars += len;
   775                         }
   773                         }
   776                     }
   774                     }
   777                     videodata->ime_candpgsize = i - page_start;
   775                     videodata->ime_candpgsize = i - page_start;
   778                 }
   776                 } else {
   779                 else {
       
   780                     videodata->ime_candpgsize = SDL_min(cand_list->dwPageSize, MAX_CANDLIST);
   777                     videodata->ime_candpgsize = SDL_min(cand_list->dwPageSize, MAX_CANDLIST);
   781                     page_start = (cand_list->dwSelection / videodata->ime_candpgsize) * videodata->ime_candpgsize;
   778                     page_start = (cand_list->dwSelection / videodata->ime_candpgsize) * videodata->ime_candpgsize;
   782                 }
   779                 }
   783                 SDL_memset(&videodata->ime_candidates, 0, sizeof(videodata->ime_candidates));
   780                 SDL_memset(&videodata->ime_candidates, 0, sizeof(videodata->ime_candidates));
   784                 for (i = page_start, j = 0; (DWORD)i < cand_list->dwCount && j < (int)videodata->ime_candpgsize; i++, j++) {
   781                 for (i = page_start, j = 0; (DWORD)i < cand_list->dwCount && j < (int)videodata->ime_candpgsize; i++, j++) {