patch投げ用
Revision | 9b994f92a90b8bda2dea3cf2f0e89ed6340c59ec (tree) |
---|---|
Zeit | 2016-02-17 00:29:58 |
Autor | SHIRAKATA Kentaro <argrath@ub32...> |
Commiter | SHIRAKATA Kentaro |
add support for 2-byte-char input on win/win32
@@ -2,6 +2,11 @@ | ||
2 | 2 | /* Copyright (C) 2001 by Alex Kompel */ |
3 | 3 | /* NetHack may be freely redistributed. See license for details. */ |
4 | 4 | |
5 | +/* JNetHack Copyright */ | |
6 | +/* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000 */ | |
7 | +/* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016 */ | |
8 | +/* JNetHack may be freely redistributed. See license for details. */ | |
9 | + | |
5 | 10 | #include "winMS.h" |
6 | 11 | #include <commdlg.h> |
7 | 12 | #include "date.h" |
@@ -193,6 +198,9 @@ LRESULT CALLBACK | ||
193 | 198 | MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
194 | 199 | { |
195 | 200 | PNHMainWindow data; |
201 | +#if 1 /*JP*/ | |
202 | + static int doublebyte = 0; | |
203 | +#endif | |
196 | 204 | |
197 | 205 | switch (message) { |
198 | 206 | case WM_CREATE: |
@@ -380,6 +388,21 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | ||
380 | 388 | } /* end switch */ |
381 | 389 | } break; |
382 | 390 | |
391 | +#if 1 /*JP*//*全角文字対応*/ | |
392 | + case WM_CHAR: | |
393 | + { | |
394 | + if (doublebyte == 1) { | |
395 | + NHEVENT_KBD(wParam & 0xFF); | |
396 | + doublebyte = 0; | |
397 | + return 0; | |
398 | + } else if (is_kanji(wParam)) { | |
399 | + NHEVENT_KBD(wParam & 0xFF); | |
400 | + doublebyte = 1; | |
401 | + return 0; | |
402 | + } | |
403 | + } break; | |
404 | + | |
405 | +#endif | |
383 | 406 | case WM_SYSCHAR: /* Alt-char pressed */ |
384 | 407 | { |
385 | 408 | /* |
@@ -2,6 +2,10 @@ | ||
2 | 2 | /* Copyright (C) 2001 by Alex Kompel */ |
3 | 3 | /* NetHack may be freely redistributed. See license for details. */ |
4 | 4 | |
5 | +/* JNetHack Copyright */ | |
6 | +/* For 3.6-, Copyright (c) SHIRAKATA Kentaro, 2016 */ | |
7 | +/* JNetHack may be freely redistributed. See license for details. */ | |
8 | + | |
5 | 9 | /* |
6 | 10 | * This file implements the interface between the window port specific |
7 | 11 | * code in the mswin port and the rest of the nethack game engine. |
@@ -1606,7 +1610,11 @@ mswin_getlin(const char *question, char *input) | ||
1606 | 1610 | logDebug("mswin_getlin(%s, %p)\n", question, input); |
1607 | 1611 | |
1608 | 1612 | if (!iflags.wc_popup_dialog) { |
1613 | +#if 0 /*JP*/ | |
1609 | 1614 | char c; |
1615 | +#else | |
1616 | + int c; | |
1617 | +#endif | |
1610 | 1618 | int len; |
1611 | 1619 | int done; |
1612 | 1620 | int createcaret; |
@@ -1640,11 +1648,21 @@ mswin_getlin(const char *question, char *input) | ||
1640 | 1648 | if (c == VK_BACK) { |
1641 | 1649 | if (len > 0) |
1642 | 1650 | len--; |
1651 | +#if 1 /*JP*//*2バイト文字ならもう1バイト消す*/ | |
1652 | + if (len > 0 && is_kanji2(input, len)) | |
1653 | + len--; | |
1654 | +#endif | |
1643 | 1655 | input[len] = '\0'; |
1644 | 1656 | } else if (len>=(BUFSZ-1)) { |
1645 | 1657 | PlaySound((LPCSTR)SND_ALIAS_SYSTEMEXCLAMATION, NULL, SND_ALIAS_ID|SND_ASYNC); |
1646 | 1658 | } else { |
1647 | 1659 | input[len++] = c; |
1660 | +#if 1 /*JP*//*2バイト文字ならその場でもう1バイト読み込む*/ | |
1661 | + if (is_kanji(c)){ | |
1662 | + c = mswin_nhgetch(); | |
1663 | + input[len++] = c; | |
1664 | + } | |
1665 | +#endif | |
1648 | 1666 | input[len] = '\0'; |
1649 | 1667 | } |
1650 | 1668 | mswin_putstr_ex(WIN_MESSAGE, ATR_NONE, input, 1); |