OSDN Git Service

add support for 2-byte-char input on win/win32
authorSHIRAKATA Kentaro <argrath@ub32.org>
Tue, 16 Feb 2016 14:18:08 +0000 (23:18 +0900)
committerSHIRAKATA Kentaro <argrath@ub32.org>
Tue, 16 Feb 2016 15:29:58 +0000 (00:29 +0900)
win/win32/mhmain.c
win/win32/mswproc.c

index 044ec7f..707ac3d 100644 (file)
@@ -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 <commdlg.h>
 #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*//*\91S\8ap\95\8e\9a\91Î\89\9e*/
+    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 */
     {
         /*
index 57ca516..03e58a5 100644 (file)
@@ -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\83o\83C\83g\95\8e\9a\82È\82ç\82à\82¤1\83o\83C\83g\8fÁ\82·*/
+                    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\83o\83C\83g\95\8e\9a\82È\82ç\82»\82Ì\8fê\82Å\82à\82¤1\83o\83C\83g\93Ç\82Ý\8d\9e\82Þ*/
+                    if (is_kanji(c)){
+                        c = mswin_nhgetch();
+                        input[len++] = c;
+                    }
+#endif
                     input[len] = '\0';
                 }
                 mswin_putstr_ex(WIN_MESSAGE, ATR_NONE, input, 1);