[Ttssh2-commit] [4934] IME前後フィードバック機能が、MS-IME2002で動くようにした。

svnno****@sourc***** svnno****@sourc*****
2012年 5月 10日 (木) 01:14:41 JST


Revision: 4934
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4934
Author:   yutakapon
Date:     2012-05-10 01:14:41 +0900 (Thu, 10 May 2012)
Log Message:
-----------
IME前後フィードバック機能が、MS-IME2002で動くようにした。

危機[一髪]
ファイト[一発]

夏は[熱い]
本は[厚い]
お湯は[熱い]
気温は[熱い]
信頼は[厚い]
病は[篤い]

Modified Paths:
--------------
    trunk/teraterm/teraterm/vtwin.cpp

-------------- next part --------------
Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2012-05-09 15:28:47 UTC (rev 4933)
+++ trunk/teraterm/teraterm/vtwin.cpp	2012-05-09 16:14:41 UTC (rev 4934)
@@ -2995,18 +2995,38 @@
 }
 
 // IME\x82̑O\x8C\xE3\x8EQ\x8Fƕϊ\xB7\x8B@\x94\\x82ւ̑Ή\x9E
+// MS\x82\xA9\x82炿\x82\xE1\x82\xF1\x82Ǝd\x97l\x82\xAA\x92񎦂\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2\x82̂ŁA\x83A\x83h\x83z\x83b\x83N\x82ɂ\xE2\x82邵\x82\xA9\x82Ȃ\xA2\x82炵\x82\xA2\x81B
 // cf. http://d.hatena.ne.jp/topiyama/20070703
 //     http://ice.hotmint.com/putty/#DOWNLOAD
+//     http://27213143.at.webry.info/201202/article_2.html
+//     http://webcache.googleusercontent.com/search?q=cache:WzlX3ouMscIJ:anago.2ch.net/test/read.cgi/software/1325573999/82+IMR_DOCUMENTFEED&cd=13&hl=ja&ct=clnk&gl=jp
 // (2012.5.9 yutaka)
 LONG CVTWindow::OnIMERequest(UINT wParam, LONG lParam)
 {
-	int size;
-	char buf[512];
+	static int complen, newsize;
+	static char comp[512];
+	int size, ret;
+	char buf[512], newbuf[1024];
+	HIMC hIMC;
 
 	if (wParam == IMR_DOCUMENTFEED) {
-		size = NumOfColumns + 1;
+		size = NumOfColumns + 1;   // \x83J\x81[\x83\\x83\x8B\x82\xAA\x82\xA0\x82\xE9\x8Ds\x82̒\xB7\x82\xB3+null
+
 		if (lParam == 0) {  // 1\x89\xF1\x96ڂ̌Ăяo\x82\xB5
 			// \x83o\x83b\x83t\x83@\x82̃T\x83C\x83Y\x82\xF0\x95Ԃ\xB7\x82̂݁B
+			// ATOK2012\x82ł͏\xED\x82\xC9 complen=0 \x82ƂȂ\xE9\x81B
+			complen = 0;
+			memset(comp, 0, sizeof(comp));
+			hIMC = ImmGetContext(HVTWin);
+			if (hIMC) {
+				ret = ImmGetCompositionString(hIMC, GCS_COMPSTR, comp, sizeof(comp));
+				if (ret == IMM_ERROR_NODATA || ret == IMM_ERROR_GENERAL) {
+					memset(comp, 0, sizeof(comp));
+				}
+				complen = strlen(comp);  // w/o null
+				ImmReleaseContext(HVTWin, hIMC);
+			}
+			newsize = size + complen;  // \x95ϊ\xB7\x95\xB6\x8E\x9A\x82\xE0\x8A܂߂\xBD\x91S\x91̂̒\xB7\x82\xB3(including null)
 
 		} else {  // 2\x89\xF1\x96ڂ̌Ăяo\x82\xB5
 			//lParam \x82\xF0 RECONVERTSTRING \x82\xC6 \x95\xB6\x8E\x9A\x97\xF1\x8Ai\x94[\x83o\x83b\x83t\x83@\x82Ɏg\x97p\x82\xB7\x82\xE9
@@ -3015,19 +3035,27 @@
 			int cx;
 
 			cx = BuffGetCurrentLineData(buf, sizeof(buf));
+
+			// \x83J\x81[\x83\\x83\x8B\x88ʒu\x82ɕϊ\xB7\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x91}\x93\xFC\x82\xB7\x82\xE9\x81B
+			memset(newbuf, 0, sizeof(newbuf));
+			memcpy(newbuf, buf, cx);
+			memcpy(newbuf + cx, comp, complen);
+			memcpy(newbuf + cx + complen, buf + cx, size - cx);
+			newsize = size + complen;  // \x95ϊ\xB7\x95\xB6\x8E\x9A\x82\xE0\x8A܂߂\xBD\x91S\x91̂̒\xB7\x82\xB3(including null)
 	        
 			pReconv->dwSize            = sizeof(RECONVERTSTRING);
 			pReconv->dwVersion         = 0;
-			pReconv->dwStrLen          = size;
+			pReconv->dwStrLen          = newsize - 1;
 			pReconv->dwStrOffset       = sizeof(RECONVERTSTRING);
-			pReconv->dwCompStrLen      = 0;
-			pReconv->dwCompStrOffset   = 0;
-			pReconv->dwTargetStrLen    = 0;
+			pReconv->dwCompStrLen      = complen;
+			pReconv->dwCompStrOffset   = cx;
+			pReconv->dwTargetStrLen    = complen;
 			pReconv->dwTargetStrOffset = cx;
 	        
-			memcpy(pszParagraph, buf, size);
+			memcpy(pszParagraph, newbuf, newsize);
+			//OutputDebugPrintf("cx %d buf [%d:%s] -> [%d:%s]\n", cx, size, buf, newsize, newbuf);
 		}
-		return (sizeof(RECONVERTSTRING) + size);
+		return (sizeof(RECONVERTSTRING) + newsize);
 	}
 
 	return CFrameWnd::DefWindowProc(WM_IME_REQUEST,wParam,lParam);



Ttssh2-commit メーリングリストの案内