From: SHIRAKATA Kentaro Date: Tue, 16 Feb 2016 14:18:08 +0000 (+0900) Subject: add support for 2-byte-char input on win/win32 X-Git-Tag: v3.6.0-0.2~7 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9b994f92a90b8bda2dea3cf2f0e89ed6340c59ec;p=jnethack%2Fsource.git add support for 2-byte-char input on win/win32 --- diff --git a/win/win32/mhmain.c b/win/win32/mhmain.c index 044ec7f..707ac3d 100644 --- a/win/win32/mhmain.c +++ b/win/win32/mhmain.c @@ -2,6 +2,11 @@ /* Copyright (C) 2001 by Alex Kompel */ /* NetHack may be freely redistributed. See license for details. */ +/* JNetHack Copyright */ +/* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000 */ +/* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016 */ +/* JNetHack may be freely redistributed. See license for details. */ + #include "winMS.h" #include #include "date.h" @@ -193,6 +198,9 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PNHMainWindow data; +#if 1 /*JP*/ + static int doublebyte = 0; +#endif switch (message) { case WM_CREATE: @@ -380,6 +388,21 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } /* end switch */ } break; +#if 1 /*JP*//*‘SŠp•¶Žš‘Ήž*/ + case WM_CHAR: + { + if (doublebyte == 1) { + NHEVENT_KBD(wParam & 0xFF); + doublebyte = 0; + return 0; + } else if (is_kanji(wParam)) { + NHEVENT_KBD(wParam & 0xFF); + doublebyte = 1; + return 0; + } + } break; + +#endif case WM_SYSCHAR: /* Alt-char pressed */ { /* diff --git a/win/win32/mswproc.c b/win/win32/mswproc.c index 57ca516..03e58a5 100644 --- a/win/win32/mswproc.c +++ b/win/win32/mswproc.c @@ -2,6 +2,10 @@ /* Copyright (C) 2001 by Alex Kompel */ /* NetHack may be freely redistributed. See license for details. */ +/* JNetHack Copyright */ +/* For 3.6-, Copyright (c) SHIRAKATA Kentaro, 2016 */ +/* JNetHack may be freely redistributed. See license for details. */ + /* * This file implements the interface between the window port specific * code in the mswin port and the rest of the nethack game engine. @@ -1606,7 +1610,11 @@ mswin_getlin(const char *question, char *input) logDebug("mswin_getlin(%s, %p)\n", question, input); if (!iflags.wc_popup_dialog) { +#if 0 /*JP*/ char c; +#else + int c; +#endif int len; int done; int createcaret; @@ -1640,11 +1648,21 @@ mswin_getlin(const char *question, char *input) if (c == VK_BACK) { if (len > 0) len--; +#if 1 /*JP*//*2ƒoƒCƒg•¶Žš‚È‚ç‚à‚¤1ƒoƒCƒgÁ‚·*/ + if (len > 0 && is_kanji2(input, len)) + len--; +#endif input[len] = '\0'; } else if (len>=(BUFSZ-1)) { PlaySound((LPCSTR)SND_ALIAS_SYSTEMEXCLAMATION, NULL, SND_ALIAS_ID|SND_ASYNC); } else { input[len++] = c; +#if 1 /*JP*//*2ƒoƒCƒg•¶Žš‚È‚ç‚»‚̏ê‚Å‚à‚¤1ƒoƒCƒg“ǂݍž‚Þ*/ + if (is_kanji(c)){ + c = mswin_nhgetch(); + input[len++] = c; + } +#endif input[len] = '\0'; } mswin_putstr_ex(WIN_MESSAGE, ATR_NONE, input, 1);