Mercurial > vim
comparison src/mbyte.c @ 2205:54605ada811b vim73
"g8" doesn't work properly on a NUL.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 21 May 2010 15:46:35 +0200 |
parents | 7c8c7c95a865 |
children | 1bac28a53fae |
comparison
equal
deleted
inserted
replaced
2204:c493d6bfde09 | 2205:54605ada811b |
---|---|
3174 STRCPY(IObuff + rlen, "+ "); | 3174 STRCPY(IObuff + rlen, "+ "); |
3175 rlen += 2; | 3175 rlen += 2; |
3176 } | 3176 } |
3177 clen = utf_ptr2len(line + i); | 3177 clen = utf_ptr2len(line + i); |
3178 } | 3178 } |
3179 sprintf((char *)IObuff + rlen, "%02x ", line[i]); | 3179 sprintf((char *)IObuff + rlen, "%02x ", |
3180 (line[i] == NL) ? NUL : line[i]); /* NUL is stored as NL */ | |
3180 --clen; | 3181 --clen; |
3181 rlen += (int)STRLEN(IObuff + rlen); | 3182 rlen += (int)STRLEN(IObuff + rlen); |
3182 if (rlen > IOSIZE - 20) | 3183 if (rlen > IOSIZE - 20) |
3183 break; | 3184 break; |
3184 } | 3185 } |
4869 * that for imhangul by sending GDK_Escape, but I don't know if it | 4870 * that for imhangul by sending GDK_Escape, but I don't know if it |
4870 * works with all IM modules that support an activation key :/ | 4871 * works with all IM modules that support an activation key :/ |
4871 * | 4872 * |
4872 * An alternative approach would be to destroy the IM context and | 4873 * An alternative approach would be to destroy the IM context and |
4873 * recreate it. But that means loading/unloading the IM module on | 4874 * recreate it. But that means loading/unloading the IM module on |
4874 * every mode switch, which causes a quite noticable delay even on | 4875 * every mode switch, which causes a quite noticeable delay even on |
4875 * my rather fast box... | 4876 * my rather fast box... |
4876 * * | 4877 * * |
4877 * Moreover, there are some XIM which cannot respond to | 4878 * Moreover, there are some XIM which cannot respond to |
4878 * im_synthesize_keypress(). we hope that they reset by | 4879 * im_synthesize_keypress(). we hope that they reset by |
4879 * xim_shutdown(). | 4880 * xim_shutdown(). |
5177 } | 5178 } |
5178 | 5179 |
5179 static void | 5180 static void |
5180 im_xim_send_event_imactivate() | 5181 im_xim_send_event_imactivate() |
5181 { | 5182 { |
5182 /* Force turn on preedit state by symulate keypress event. | 5183 /* Force turn on preedit state by simulating keypress event. |
5183 * Keycode and state is specified by 'imactivatekey'. | 5184 * Keycode and state is specified by 'imactivatekey'. |
5184 */ | 5185 */ |
5185 XKeyEvent ev; | 5186 XKeyEvent ev; |
5186 | 5187 |
5187 gui_get_x11_windis(&ev.window, &ev.display); | 5188 gui_get_x11_windis(&ev.window, &ev.display); |
5254 { | 5255 { |
5255 if (xim_can_preediting && !active) | 5256 if (xim_can_preediting && !active) |
5256 { | 5257 { |
5257 /* Force turn off preedit state. With some IM | 5258 /* Force turn off preedit state. With some IM |
5258 * implementations, we cannot turn off preedit state by | 5259 * implementations, we cannot turn off preedit state by |
5259 * symulate keypress event. It is why using such a method | 5260 * simulating keypress event. It is why using such a method |
5260 * that destroy old IC (input context), and create new one. | 5261 * that destroy old IC (input context), and create new one. |
5261 * When create new IC, its preedit state is usually off. | 5262 * When create new IC, its preedit state is usually off. |
5262 */ | 5263 */ |
5263 xim_reset(); | 5264 xim_reset(); |
5264 xim_set_focus(FALSE); | 5265 xim_set_focus(FALSE); |
5270 im_xim_send_event_imactivate(); | 5271 im_xim_send_event_imactivate(); |
5271 } | 5272 } |
5272 else | 5273 else |
5273 { | 5274 { |
5274 /* First, force destroy old IC, and create new one. It | 5275 /* First, force destroy old IC, and create new one. It |
5275 * symulates "turning off preedit state". | 5276 * simulates "turning off preedit state". |
5276 */ | 5277 */ |
5277 xim_set_focus(FALSE); | 5278 xim_set_focus(FALSE); |
5278 gdk_ic_destroy(xic); | 5279 gdk_ic_destroy(xic); |
5279 xim_init(); | 5280 xim_init(); |
5280 xim_can_preediting = FALSE; | 5281 xim_can_preediting = FALSE; |
5281 | 5282 |
5282 /* 2nd, when requested to activate IM, symulate this by sending | 5283 /* 2nd, when requested to activate IM, simulate this by sending |
5283 * the event. | 5284 * the event. |
5284 */ | 5285 */ |
5285 if (active) | 5286 if (active) |
5286 { | 5287 { |
5287 im_xim_send_event_imactivate(); | 5288 im_xim_send_event_imactivate(); |
5332 * 'imactivatekey' is "s-space", im_xim_send_event_imactivate() did not | 5333 * 'imactivatekey' is "s-space", im_xim_send_event_imactivate() did not |
5333 * work correctly. It just inserted one space. I don't know why we | 5334 * work correctly. It just inserted one space. I don't know why we |
5334 * couldn't switch state of XIM preediting. This is reason why these | 5335 * couldn't switch state of XIM preediting. This is reason why these |
5335 * codes are commented out. | 5336 * codes are commented out. |
5336 */ | 5337 */ |
5337 /* First, force destroy old IC, and create new one. It symulates | 5338 /* First, force destroy old IC, and create new one. It simulates |
5338 * "turning off preedit state". | 5339 * "turning off preedit state". |
5339 */ | 5340 */ |
5340 xim_set_focus(FALSE); | 5341 xim_set_focus(FALSE); |
5341 XDestroyIC(xic); | 5342 XDestroyIC(xic); |
5342 xic = NULL; | 5343 xic = NULL; |
5343 xim_init(); | 5344 xim_init(); |
5344 | 5345 |
5345 /* 2nd, when requested to activate IM, symulate this by sending the | 5346 /* 2nd, when requested to activate IM, simulate this by sending the |
5346 * event. | 5347 * event. |
5347 */ | 5348 */ |
5348 if (active) | 5349 if (active) |
5349 im_xim_send_event_imactivate(); | 5350 im_xim_send_event_imactivate(); |
5350 # endif | 5351 # endif |