[Tuxpaint-devel] SDL_im and tuxpaint-0.9.15b for Windows.
An award-winning drawing program for children of all ages
Brought to you by:
wkendrick
From: Shocky H. <sho...@ya...> - 2006-03-30 01:12:13
|
Hi, I and my daughter want to input Korean characters in tuxpaint-0.9.15b for Windows. I finally found the SDL_im project which aims to be an Input Method support in SDL project. <http://sdl-im.csie.net/> I can patch the <http://sdl-im.csie.net/download/SDL_im-1.2.8-20050828.diff. gz> files into the current SDL-1.2.9 branch without difficulties. The major modifications for tuxpaint.c is follows - you will notice you should define the ENABLE_IM_EVENT first. @@ -2777,6 +2793,10 @@ Uint32 last_cursor_blink, cur_cursor_blink, pre_event_time, current_event_time; +#ifdef ENABLE_IM_EVENT + wchar_t wbuf[256]; + int buf_len = 0; +#endif @@ -2838,7 +2858,14 @@ { key = event.key.keysym.sym; mod = event.key.keysym.mod; - + +#ifdef ENABLE_IM_EVENT + SDL_SetIMPosition(cursor_x - 2, cursor_y - 2 + TTF_FontHeight(getfonthandle(cur_font))); + if (buf_len = SDL_FlushIMString(wbuf)) + SDL_FlushIMString(wbuf); + wbuf[buf_len] = 0; +#endif + handle_keymouse(key, SDL_KEYDOWN); if (key == SDLK_ESCAPE && !disable_quit) @@ -2991,6 +3018,10 @@ if (cur_tool == TOOL_TEXT && cursor_x != -1 && cursor_y != -1) { +#ifdef ENABLE_IM_EVENT + if (buf_len > 0) + event.key.keysym.unicode = wbuf[0]; +#endif key_down = key; key_unicode = event.key.keysym.unicode; @@ -3004,8 +3035,13 @@ if (texttool_len > 0) { +#ifdef ENABLE_IM_EVENT + texttool_len = utf8_remove_last_char(texttool_str, texttool_len); + texttool_str[texttool_len] = '\0'; +#else texttool_len--; texttool_str[texttool_len] = '\0'; +#endif playsound(0, SND_KEYCLICK, 0); do_render_cur_text(0); @@ -3040,8 +3076,12 @@ cursor_textwidth = 0; } } +#ifdef ENABLE_IM_EVENT + else //if (isprint(key_unicode)) +#else else if (isprint(key_unicode)) - { +#endif + { if (texttool_len < sizeof(texttool_str) - MAX_UTF8_CHAR_LENGTH) { int old_cursor_textwidth = cursor_textwidth; @@ -3050,9 +3090,18 @@ "unicode = %c (%d)\n\n", key_down, key_unicode, key_unicode); #endif - + +#ifdef ENABLE_IM_EVENT + if (buf_len > 0) { + texttool_len += unicode_to_utf8(&texttool_str[texttool_len], key_unicode); + } else if (key_unicode != 0) { texttool_str[texttool_len++] = key_unicode; - + } +#else + if (key_unicode != 0) { + texttool_str[texttool_len++] = key_unicode; + } +#endif texttool_str[texttool_len] = '\0'; do_render_cur_text(0); Of course, there are unicode_to_utf8() and utf8_remove_last_char() function implementations. And I must fix several tuxpaint-0.9.15b source files to build with Microsoft Visual Studio .Net 2003. You can get results in following URL's: 1. screenshot <http://kldp.org/files/tuxpaint+SDL_im.PNG> 2. diff source <http://kldp.org/files/tuxpaint-0.9.15b+SDL_im-1.2.9- 20060329.diff.txt> 3. Windows XP binary files <http://kldp.org/files/tuxpaint-0.9.15b+SDL_im-1. 2.9-20060329.zip> I hope this could help people who want to use the Windows IME with tuxpaint- 0.9.15b for Windows. Best regards. PS: I use the Korean font downloaded from the tuxpaint website. ________________________________________________________ 야후! 모바일 - 휴대폰에 대한 모든 재미! 유무선 야후!모바일을 즐기세요 http://kr.mobile.yahoo.com |