• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

patch投げ用


Commit MetaInfo

Revision9b994f92a90b8bda2dea3cf2f0e89ed6340c59ec (tree)
Zeit2016-02-17 00:29:58
AutorSHIRAKATA Kentaro <argrath@ub32...>
CommiterSHIRAKATA Kentaro

Log Message

add support for 2-byte-char input on win/win32

Ändern Zusammenfassung

Diff

--- a/win/win32/mhmain.c
+++ b/win/win32/mhmain.c
@@ -2,6 +2,11 @@
22 /* Copyright (C) 2001 by Alex Kompel */
33 /* NetHack may be freely redistributed. See license for details. */
44
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+
510 #include "winMS.h"
611 #include <commdlg.h>
712 #include "date.h"
@@ -193,6 +198,9 @@ LRESULT CALLBACK
193198 MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
194199 {
195200 PNHMainWindow data;
201+#if 1 /*JP*/
202+ static int doublebyte = 0;
203+#endif
196204
197205 switch (message) {
198206 case WM_CREATE:
@@ -380,6 +388,21 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
380388 } /* end switch */
381389 } break;
382390
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
383406 case WM_SYSCHAR: /* Alt-char pressed */
384407 {
385408 /*
--- a/win/win32/mswproc.c
+++ b/win/win32/mswproc.c
@@ -2,6 +2,10 @@
22 /* Copyright (C) 2001 by Alex Kompel */
33 /* NetHack may be freely redistributed. See license for details. */
44
5+/* JNetHack Copyright */
6+/* For 3.6-, Copyright (c) SHIRAKATA Kentaro, 2016 */
7+/* JNetHack may be freely redistributed. See license for details. */
8+
59 /*
610 * This file implements the interface between the window port specific
711 * code in the mswin port and the rest of the nethack game engine.
@@ -1606,7 +1610,11 @@ mswin_getlin(const char *question, char *input)
16061610 logDebug("mswin_getlin(%s, %p)\n", question, input);
16071611
16081612 if (!iflags.wc_popup_dialog) {
1613+#if 0 /*JP*/
16091614 char c;
1615+#else
1616+ int c;
1617+#endif
16101618 int len;
16111619 int done;
16121620 int createcaret;
@@ -1640,11 +1648,21 @@ mswin_getlin(const char *question, char *input)
16401648 if (c == VK_BACK) {
16411649 if (len > 0)
16421650 len--;
1651+#if 1 /*JP*//*2バイト文字ならもう1バイト消す*/
1652+ if (len > 0 && is_kanji2(input, len))
1653+ len--;
1654+#endif
16431655 input[len] = '\0';
16441656 } else if (len>=(BUFSZ-1)) {
16451657 PlaySound((LPCSTR)SND_ALIAS_SYSTEMEXCLAMATION, NULL, SND_ALIAS_ID|SND_ASYNC);
16461658 } else {
16471659 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
16481666 input[len] = '\0';
16491667 }
16501668 mswin_putstr_ex(WIN_MESSAGE, ATR_NONE, input, 1);