[Ttssh2-commit] [7485] ttime周りを整理

scmno****@osdn***** scmno****@osdn*****
2019年 3月 15日 (金) 00:54:14 JST


Revision: 7485
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7485
Author:   zmatsuo
Date:     2019-03-15 00:54:13 +0900 (Fri, 15 Mar 2019)
Log Message:
-----------
ttime周りを整理

Modified Paths:
--------------
    trunk/teraterm/teraterm/ttime.c
    trunk/teraterm/teraterm/ttime.h
    trunk/teraterm/teraterm/vtdisp.c
    trunk/teraterm/teraterm/vtterm.c
    trunk/teraterm/teraterm/vtwin.cpp

-------------- next part --------------
Modified: trunk/teraterm/teraterm/ttime.c
===================================================================
--- trunk/teraterm/teraterm/ttime.c	2019-03-14 15:53:55 UTC (rev 7484)
+++ trunk/teraterm/teraterm/ttime.c	2019-03-14 15:54:13 UTC (rev 7485)
@@ -29,9 +29,6 @@
 /* Tera Term */
 /* TERATERM.EXE, IME interface */
 
-#undef UNICODE
-#undef _UNICODE
-
 #include <windows.h>
 #include <stdlib.h>
 #include <string.h>
@@ -48,7 +45,7 @@
 #include "buffer.h"		// for BuffGetCurrentLineData()
 #endif
 
-#ifndef _IMM_
+#if 0	// #ifndef _IMM_
   #define _IMM_
 
   typedef DWORD HIMC;
@@ -58,9 +55,9 @@
     POINT ptCurrentPos;
     RECT  rcArea;
   } COMPOSITIONFORM, *PCOMPOSITIONFORM, NEAR *NPCOMPOSITIONFORM, *LPCOMPOSITIONFORM;
-#endif //_IMM_
 
 #define GCS_RESULTSTR 0x0800
+#endif //_IMM_
 
 typedef LONG (WINAPI *TImmGetCompositionStringA)(HIMC, DWORD, LPVOID, DWORD);
 typedef LONG (WINAPI *TImmGetCompositionStringW)(HIMC, DWORD, LPVOID, DWORD);
@@ -87,6 +84,9 @@
 #if 1
 static void show_message()
 {
+#if 0
+  PTTSet tempts;
+#endif
   char uimsg[MAX_UIMSG];
     get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg),  "Tera Term: Error", ts.UILanguageFile);
     get_lang_msg("MSG_USE_IME_ERROR", ts.UIMsg, sizeof(ts.UIMsg), "Can't use IME", ts.UILanguageFile);
@@ -109,9 +109,6 @@
 BOOL LoadIME()
 {
   BOOL Err;
-#if 0
-  PTTSet tempts;
-#endif
   char imm32_dll[MAX_PATH];
 
   if (HIMEDLL != NULL) return TRUE;
@@ -168,7 +165,7 @@
     return TRUE;
 }
 
-void FreeIME()
+void FreeIME(HWND hWnd)
 {
   HANDLE HTemp;
 
@@ -177,7 +174,7 @@
   HIMEDLL = NULL;
 
   /* position of conv. window -> default */
-  SetConversionWindow(HVTWin,-1,0);
+  SetConversionWindow(hWnd,-1,0);
   Sleep(1); // for safety
   FreeLibrary(HTemp);
 }
@@ -187,7 +184,7 @@
   return (HIMEDLL != NULL);
 }
 
-void SetConversionWindow(HWND HWin, int X, int Y)
+void SetConversionWindow(HWND HWnd, int X, int Y)
 {
   HIMC	hIMC;
   COMPOSITIONFORM cf;
@@ -194,7 +191,7 @@
 
   if (HIMEDLL == NULL) return;
 // Adjust the position of conversion window
-  hIMC = (*PImmGetContext)(HVTWin);
+  hIMC = (*PImmGetContext)(HWnd);
   if (X>=0)
   {
     cf.dwStyle = CFS_POINT;
@@ -204,10 +201,10 @@
   else
     cf.dwStyle = CFS_DEFAULT;
   (*PImmSetCompositionWindow)(hIMC,&cf);
-  (*PImmReleaseContext)(HVTWin,hIMC);
+  (*PImmReleaseContext)(HWnd,hIMC);
 }
 
-void SetConversionLogFont(HWND HWin, PLOGFONT lf)
+void SetConversionLogFont(HWND HWnd, PLOGFONTA lf)
 {
   HIMC	hIMC;
   if (HIMEDLL == NULL) return;
@@ -214,10 +211,10 @@
 
   memcpy(&lfIME,lf,sizeof(LOGFONT));
 
-  hIMC = (*PImmGetContext)(HVTWin);
+  hIMC = (*PImmGetContext)(HWnd);
   // Set font for the conversion window
   (*PImmSetCompositionFont)(hIMC,&lfIME);
-  (*PImmReleaseContext)(HVTWin,hIMC);
+  (*PImmReleaseContext)(HWnd,hIMC);
 }
 
 /*
@@ -269,27 +266,27 @@
 	return lpstr;
 }
 
-BOOL GetIMEOpenStatus()
+BOOL GetIMEOpenStatus(HWND hWnd)
 {
 	HIMC hIMC;
 	BOOL stat;
 
 	if (HIMEDLL==NULL) return FALSE;
-	hIMC = (*PImmGetContext)(HVTWin);
+	hIMC = (*PImmGetContext)(hWnd);
 	stat = (*PImmGetOpenStatus)(hIMC);
-	(*PImmReleaseContext)(HVTWin, hIMC);
+	(*PImmReleaseContext)(hWnd, hIMC);
 
 	return stat;
 
 }
 
-void SetIMEOpenStatus(BOOL stat) {
+void SetIMEOpenStatus(HWND hWnd, BOOL stat) {
 	HIMC hIMC;
 
 	if (HIMEDLL==NULL) return;
-	hIMC = (*PImmGetContext)(HVTWin);
+	hIMC = (*PImmGetContext)(hWnd);
 	(*PImmSetOpenStatus)(hIMC, stat);
-	(*PImmReleaseContext)(HVTWin, hIMC);
+	(*PImmReleaseContext)(hWnd, hIMC);
 }
 
 // IME\x82̑O\x8C\xE3\x8EQ\x8Fƕϊ\xB7\x8B@\x94\\x82ւ̑Ή\x9E
@@ -299,7 +296,7 @@
 //     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)
-LRESULT ReplyIMERequestDocumentfeed(LPARAM lParam, int NumOfColumns)
+LRESULT ReplyIMERequestDocumentfeed(HWND hWnd, LPARAM lParam, int NumOfColumns)
 {
 	static int complen, newsize;
 	static char comp[512];
@@ -306,6 +303,7 @@
 	int size, ret;
 	char buf[512], newbuf[1024];
 	HIMC hIMC;
+	int cx;
 
 	// "IME=off"\x82̏ꍇ\x82́A\x89\xBD\x82\xE0\x82\xB5\x82Ȃ\xA2\x81B
 	size = NumOfColumns + 1;   // \x83J\x81[\x83\\x83\x8B\x82\xAA\x82\xA0\x82\xE9\x8Ds\x82̒\xB7\x82\xB3+null
@@ -315,7 +313,7 @@
 		// ATOK2012\x82ł͏\xED\x82\xC9 complen=0 \x82ƂȂ\xE9\x81B
 		complen = 0;
 		memset(comp, 0, sizeof(comp));
-		hIMC = PImmGetContext(HVTWin);
+		hIMC = PImmGetContext(hWnd);
 		if (hIMC) {
 			ret = PImmGetCompositionStringA(hIMC, GCS_COMPSTR, comp, sizeof(comp));
 			if (ret == IMM_ERROR_NODATA || ret == IMM_ERROR_GENERAL) {
@@ -322,7 +320,7 @@
 				memset(comp, 0, sizeof(comp));
 			}
 			complen = strlen(comp);  // w/o null
-			PImmReleaseContext(HVTWin, hIMC);
+			PImmReleaseContext(hWnd, hIMC);
 		}
 		newsize = size + complen;  // \x95ϊ\xB7\x95\xB6\x8E\x9A\x82\xE0\x8A܂߂\xBD\x91S\x91̂̒\xB7\x82\xB3(including null)
 
@@ -330,7 +328,6 @@
 		//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
 		RECONVERTSTRING *pReconv   = (RECONVERTSTRING*)lParam;
 		char*  pszParagraph        = (char*)pReconv + sizeof(RECONVERTSTRING);
-		int cx;
 
 		cx = BuffGetCurrentLineData(buf, sizeof(buf));
 
@@ -351,7 +348,14 @@
 		pReconv->dwTargetStrOffset = cx;
 
 		memcpy(pszParagraph, newbuf, newsize);
-		//OutputDebugPrintf("cx %d buf [%d:%s] -> [%d:%s]\n", cx, size, buf, newsize, newbuf);
 	}
+
+#if 0
+	OutputDebugPrintf("WM_IME_REQUEST,IMR_DOCUMENTFEED size %d\n", newsize);
+	if (lParam == 1) {
+		OutputDebugPrintf("cx %d buf [%d:%s] -> [%d:%s]\n", cx, size, buf, newsize, newbuf);
+	}
+#endif
+
 	return (sizeof(RECONVERTSTRING) + newsize);
 }

Modified: trunk/teraterm/teraterm/ttime.h
===================================================================
--- trunk/teraterm/teraterm/ttime.h	2019-03-14 15:53:55 UTC (rev 7484)
+++ trunk/teraterm/teraterm/ttime.h	2019-03-14 15:54:13 UTC (rev 7485)
@@ -35,20 +35,15 @@
 
 /* proto types */
 BOOL LoadIME();
-void FreeIME();
+void FreeIME(HWND hWnd);
 BOOL CanUseIME();
-void SetConversionWindow(HWND HWin, int X, int Y);
-void SetConversionLogFont(HWND HWin, PLOGFONTA lf);
-BOOL GetIMEOpenStatus(void);
-void SetIMEOpenStatus(BOOL stat);
-
+void SetConversionWindow(HWND HWnd, int X, int Y);
+void SetConversionLogFont(HWND HWnd, PLOGFONTA lf);
+BOOL GetIMEOpenStatus(HWND hWnd);
+void SetIMEOpenStatus(HWND hWnd, BOOL stat);
 const wchar_t *GetConvString(HWND hWnd, UINT wParam, LPARAM lParam, size_t *len);
-LRESULT ReplyIMERequestDocumentfeed(LPARAM lParam, int NumOfColumns);
+LRESULT ReplyIMERequestDocumentfeed(HWND hWnd, LPARAM lParam, int NumOfColumns);
 
-#ifndef WM_IME_COMPOSITION
-#define WM_IME_COMPOSITION              0x010F
-#endif
-
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/teraterm/teraterm/vtdisp.c
===================================================================
--- trunk/teraterm/teraterm/vtdisp.c	2019-03-14 15:53:55 UTC (rev 7484)
+++ trunk/teraterm/teraterm/vtdisp.c	2019-03-14 15:54:13 UTC (rev 7485)
@@ -2057,7 +2057,7 @@
 	if ((ts.Language==IdJapanese) || (ts.Language==IdKorean) || (ts.Language==IdUtf8)) //HKS
 	{
 		if (ts.UseIME==0)
-			FreeIME();
+			FreeIME(HVTWin);
 		else if (! LoadIME())
 			ts.UseIME = 0;
 
@@ -2070,7 +2070,7 @@
 		}
 	}
 	else
-		FreeIME();
+		FreeIME(HVTWin);
 
 	if (IsCaretOn()) CaretOn();
 }

Modified: trunk/teraterm/teraterm/vtterm.c
===================================================================
--- trunk/teraterm/teraterm/vtterm.c	2019-03-14 15:53:55 UTC (rev 7484)
+++ trunk/teraterm/teraterm/vtterm.c	2019-03-14 15:54:13 UTC (rev 7485)
@@ -2644,19 +2644,19 @@
 	switch (b) {
 	  case 'r':
 		if (CanUseIME()) {
-			SetIMEOpenStatus(IMEstat);
+			SetIMEOpenStatus(HVTWin, IMEstat);
 		}
 		break;
 
 	  case 's':
 		if (CanUseIME()) {
-			IMEstat = GetIMEOpenStatus();
+			IMEstat = GetIMEOpenStatus(HVTWin);
 		}
 		break;
 
 	  case 't':
 		if (CanUseIME()) {
-			SetIMEOpenStatus(Param[1] == 1);
+			SetIMEOpenStatus(HVTWin, Param[1] == 1);
 		}
 		break;
 	}

Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2019-03-14 15:53:55 UTC (rev 7484)
+++ trunk/teraterm/teraterm/vtwin.cpp	2019-03-14 15:54:13 UTC (rev 7485)
@@ -118,6 +118,10 @@
 // \x96{\x91̂\xCD addsetting.cpp
 extern mouse_cursor_t MouseCursor[];
 
+#ifndef WM_IME_COMPOSITION
+#define WM_IME_COMPOSITION              0x010F
+#endif
+
 /////////////////////////////////////////////////////////////////////////////
 // CVTWindow
 
@@ -1984,7 +1988,7 @@
 
 	OpenHelp(HH_CLOSE_ALL, 0, ts.UILanguageFile);
 
-	FreeIME();
+	FreeIME(HVTWin);
 	FreeTTSET();
 	do { }
 	while (FreeTTDLG());
@@ -3259,7 +3263,7 @@
 		// \x93\xFC\x97̓R\x83\x93\x83e\x83L\x83X\x83g\x82̊J\x95\xF3\x91Ԃ\xAA\x8DX\x90V\x82\xB3\x82\xEA\x82\xE9(IME On/OFF)
 
 		// IME\x82\xCCOn/Off\x82\xF0\x8E擾\x82\xB7\x82\xE9
-		IMEstat = GetIMEOpenStatus();
+		IMEstat = GetIMEOpenStatus(HVTWin);
 
 		// \x8F\xF3\x91Ԃ\xF0\x95\\x8E\xA6\x82\xB7\x82\xE9IME\x82̂\xBD\x82߂Ɉʒu\x82\xF0\x92ʒm\x82\xB7\x82\xE9
 		int CaretX = (CursorX-WinOrgX)*FontWidth;
@@ -3303,7 +3307,7 @@
 	if (ts.UseIME > 0) {
 		switch(wParam) {
 		case IMR_DOCUMENTFEED:
-			return ReplyIMERequestDocumentfeed(lParam, NumOfColumns);
+			return ReplyIMERequestDocumentfeed(HVTWin, lParam, NumOfColumns);
 		default:
 			break;
 		}


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