• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision7485 (tree)
Time2019-03-15 00:54:13
Authorzmatsuo

Log Message

ttime周りを整理

Change Summary

Incremental Difference

--- trunk/teraterm/teraterm/ttime.c (revision 7484)
+++ trunk/teraterm/teraterm/ttime.c (revision 7485)
@@ -29,9 +29,6 @@
2929 /* Tera Term */
3030 /* TERATERM.EXE, IME interface */
3131
32-#undef UNICODE
33-#undef _UNICODE
34-
3532 #include <windows.h>
3633 #include <stdlib.h>
3734 #include <string.h>
@@ -48,7 +45,7 @@
4845 #include "buffer.h" // for BuffGetCurrentLineData()
4946 #endif
5047
51-#ifndef _IMM_
48+#if 0 // #ifndef _IMM_
5249 #define _IMM_
5350
5451 typedef DWORD HIMC;
@@ -58,9 +55,9 @@
5855 POINT ptCurrentPos;
5956 RECT rcArea;
6057 } COMPOSITIONFORM, *PCOMPOSITIONFORM, NEAR *NPCOMPOSITIONFORM, *LPCOMPOSITIONFORM;
61-#endif //_IMM_
6258
6359 #define GCS_RESULTSTR 0x0800
60+#endif //_IMM_
6461
6562 typedef LONG (WINAPI *TImmGetCompositionStringA)(HIMC, DWORD, LPVOID, DWORD);
6663 typedef LONG (WINAPI *TImmGetCompositionStringW)(HIMC, DWORD, LPVOID, DWORD);
@@ -87,6 +84,9 @@
8784 #if 1
8885 static void show_message()
8986 {
87+#if 0
88+ PTTSet tempts;
89+#endif
9090 char uimsg[MAX_UIMSG];
9191 get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts.UILanguageFile);
9292 get_lang_msg("MSG_USE_IME_ERROR", ts.UIMsg, sizeof(ts.UIMsg), "Can't use IME", ts.UILanguageFile);
@@ -109,9 +109,6 @@
109109 BOOL LoadIME()
110110 {
111111 BOOL Err;
112-#if 0
113- PTTSet tempts;
114-#endif
115112 char imm32_dll[MAX_PATH];
116113
117114 if (HIMEDLL != NULL) return TRUE;
@@ -168,7 +165,7 @@
168165 return TRUE;
169166 }
170167
171-void FreeIME()
168+void FreeIME(HWND hWnd)
172169 {
173170 HANDLE HTemp;
174171
@@ -177,7 +174,7 @@
177174 HIMEDLL = NULL;
178175
179176 /* position of conv. window -> default */
180- SetConversionWindow(HVTWin,-1,0);
177+ SetConversionWindow(hWnd,-1,0);
181178 Sleep(1); // for safety
182179 FreeLibrary(HTemp);
183180 }
@@ -187,7 +184,7 @@
187184 return (HIMEDLL != NULL);
188185 }
189186
190-void SetConversionWindow(HWND HWin, int X, int Y)
187+void SetConversionWindow(HWND HWnd, int X, int Y)
191188 {
192189 HIMC hIMC;
193190 COMPOSITIONFORM cf;
@@ -194,7 +191,7 @@
194191
195192 if (HIMEDLL == NULL) return;
196193 // Adjust the position of conversion window
197- hIMC = (*PImmGetContext)(HVTWin);
194+ hIMC = (*PImmGetContext)(HWnd);
198195 if (X>=0)
199196 {
200197 cf.dwStyle = CFS_POINT;
@@ -204,10 +201,10 @@
204201 else
205202 cf.dwStyle = CFS_DEFAULT;
206203 (*PImmSetCompositionWindow)(hIMC,&cf);
207- (*PImmReleaseContext)(HVTWin,hIMC);
204+ (*PImmReleaseContext)(HWnd,hIMC);
208205 }
209206
210-void SetConversionLogFont(HWND HWin, PLOGFONT lf)
207+void SetConversionLogFont(HWND HWnd, PLOGFONTA lf)
211208 {
212209 HIMC hIMC;
213210 if (HIMEDLL == NULL) return;
@@ -214,10 +211,10 @@
214211
215212 memcpy(&lfIME,lf,sizeof(LOGFONT));
216213
217- hIMC = (*PImmGetContext)(HVTWin);
214+ hIMC = (*PImmGetContext)(HWnd);
218215 // Set font for the conversion window
219216 (*PImmSetCompositionFont)(hIMC,&lfIME);
220- (*PImmReleaseContext)(HVTWin,hIMC);
217+ (*PImmReleaseContext)(HWnd,hIMC);
221218 }
222219
223220 /*
@@ -269,27 +266,27 @@
269266 return lpstr;
270267 }
271268
272-BOOL GetIMEOpenStatus()
269+BOOL GetIMEOpenStatus(HWND hWnd)
273270 {
274271 HIMC hIMC;
275272 BOOL stat;
276273
277274 if (HIMEDLL==NULL) return FALSE;
278- hIMC = (*PImmGetContext)(HVTWin);
275+ hIMC = (*PImmGetContext)(hWnd);
279276 stat = (*PImmGetOpenStatus)(hIMC);
280- (*PImmReleaseContext)(HVTWin, hIMC);
277+ (*PImmReleaseContext)(hWnd, hIMC);
281278
282279 return stat;
283280
284281 }
285282
286-void SetIMEOpenStatus(BOOL stat) {
283+void SetIMEOpenStatus(HWND hWnd, BOOL stat) {
287284 HIMC hIMC;
288285
289286 if (HIMEDLL==NULL) return;
290- hIMC = (*PImmGetContext)(HVTWin);
287+ hIMC = (*PImmGetContext)(hWnd);
291288 (*PImmSetOpenStatus)(hIMC, stat);
292- (*PImmReleaseContext)(HVTWin, hIMC);
289+ (*PImmReleaseContext)(hWnd, hIMC);
293290 }
294291
295292 // IMEの前後参照変換機能への対応
@@ -299,7 +296,7 @@
299296 // http://27213143.at.webry.info/201202/article_2.html
300297 // 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
301298 // (2012.5.9 yutaka)
302-LRESULT ReplyIMERequestDocumentfeed(LPARAM lParam, int NumOfColumns)
299+LRESULT ReplyIMERequestDocumentfeed(HWND hWnd, LPARAM lParam, int NumOfColumns)
303300 {
304301 static int complen, newsize;
305302 static char comp[512];
@@ -306,6 +303,7 @@
306303 int size, ret;
307304 char buf[512], newbuf[1024];
308305 HIMC hIMC;
306+ int cx;
309307
310308 // "IME=off"の場合は、何もしない。
311309 size = NumOfColumns + 1; // カーソルがある行の長さ+null
@@ -315,7 +313,7 @@
315313 // ATOK2012では常に complen=0 となる。
316314 complen = 0;
317315 memset(comp, 0, sizeof(comp));
318- hIMC = PImmGetContext(HVTWin);
316+ hIMC = PImmGetContext(hWnd);
319317 if (hIMC) {
320318 ret = PImmGetCompositionStringA(hIMC, GCS_COMPSTR, comp, sizeof(comp));
321319 if (ret == IMM_ERROR_NODATA || ret == IMM_ERROR_GENERAL) {
@@ -322,7 +320,7 @@
322320 memset(comp, 0, sizeof(comp));
323321 }
324322 complen = strlen(comp); // w/o null
325- PImmReleaseContext(HVTWin, hIMC);
323+ PImmReleaseContext(hWnd, hIMC);
326324 }
327325 newsize = size + complen; // 変換文字も含めた全体の長さ(including null)
328326
@@ -330,7 +328,6 @@
330328 //lParam を RECONVERTSTRING と 文字列格納バッファに使用する
331329 RECONVERTSTRING *pReconv = (RECONVERTSTRING*)lParam;
332330 char* pszParagraph = (char*)pReconv + sizeof(RECONVERTSTRING);
333- int cx;
334331
335332 cx = BuffGetCurrentLineData(buf, sizeof(buf));
336333
@@ -351,7 +348,14 @@
351348 pReconv->dwTargetStrOffset = cx;
352349
353350 memcpy(pszParagraph, newbuf, newsize);
354- //OutputDebugPrintf("cx %d buf [%d:%s] -> [%d:%s]\n", cx, size, buf, newsize, newbuf);
355351 }
352+
353+#if 0
354+ OutputDebugPrintf("WM_IME_REQUEST,IMR_DOCUMENTFEED size %d\n", newsize);
355+ if (lParam == 1) {
356+ OutputDebugPrintf("cx %d buf [%d:%s] -> [%d:%s]\n", cx, size, buf, newsize, newbuf);
357+ }
358+#endif
359+
356360 return (sizeof(RECONVERTSTRING) + newsize);
357361 }
--- trunk/teraterm/teraterm/ttime.h (revision 7484)
+++ trunk/teraterm/teraterm/ttime.h (revision 7485)
@@ -35,20 +35,15 @@
3535
3636 /* proto types */
3737 BOOL LoadIME();
38-void FreeIME();
38+void FreeIME(HWND hWnd);
3939 BOOL CanUseIME();
40-void SetConversionWindow(HWND HWin, int X, int Y);
41-void SetConversionLogFont(HWND HWin, PLOGFONTA lf);
42-BOOL GetIMEOpenStatus(void);
43-void SetIMEOpenStatus(BOOL stat);
44-
40+void SetConversionWindow(HWND HWnd, int X, int Y);
41+void SetConversionLogFont(HWND HWnd, PLOGFONTA lf);
42+BOOL GetIMEOpenStatus(HWND hWnd);
43+void SetIMEOpenStatus(HWND hWnd, BOOL stat);
4544 const wchar_t *GetConvString(HWND hWnd, UINT wParam, LPARAM lParam, size_t *len);
46-LRESULT ReplyIMERequestDocumentfeed(LPARAM lParam, int NumOfColumns);
45+LRESULT ReplyIMERequestDocumentfeed(HWND hWnd, LPARAM lParam, int NumOfColumns);
4746
48-#ifndef WM_IME_COMPOSITION
49-#define WM_IME_COMPOSITION 0x010F
50-#endif
51-
5247 #ifdef __cplusplus
5348 }
5449 #endif
--- trunk/teraterm/teraterm/vtdisp.c (revision 7484)
+++ trunk/teraterm/teraterm/vtdisp.c (revision 7485)
@@ -2057,7 +2057,7 @@
20572057 if ((ts.Language==IdJapanese) || (ts.Language==IdKorean) || (ts.Language==IdUtf8)) //HKS
20582058 {
20592059 if (ts.UseIME==0)
2060- FreeIME();
2060+ FreeIME(HVTWin);
20612061 else if (! LoadIME())
20622062 ts.UseIME = 0;
20632063
@@ -2070,7 +2070,7 @@
20702070 }
20712071 }
20722072 else
2073- FreeIME();
2073+ FreeIME(HVTWin);
20742074
20752075 if (IsCaretOn()) CaretOn();
20762076 }
--- trunk/teraterm/teraterm/vtterm.c (revision 7484)
+++ trunk/teraterm/teraterm/vtterm.c (revision 7485)
@@ -2644,19 +2644,19 @@
26442644 switch (b) {
26452645 case 'r':
26462646 if (CanUseIME()) {
2647- SetIMEOpenStatus(IMEstat);
2647+ SetIMEOpenStatus(HVTWin, IMEstat);
26482648 }
26492649 break;
26502650
26512651 case 's':
26522652 if (CanUseIME()) {
2653- IMEstat = GetIMEOpenStatus();
2653+ IMEstat = GetIMEOpenStatus(HVTWin);
26542654 }
26552655 break;
26562656
26572657 case 't':
26582658 if (CanUseIME()) {
2659- SetIMEOpenStatus(Param[1] == 1);
2659+ SetIMEOpenStatus(HVTWin, Param[1] == 1);
26602660 }
26612661 break;
26622662 }
--- trunk/teraterm/teraterm/vtwin.cpp (revision 7484)
+++ trunk/teraterm/teraterm/vtwin.cpp (revision 7485)
@@ -118,6 +118,10 @@
118118 // 本体は addsetting.cpp
119119 extern mouse_cursor_t MouseCursor[];
120120
121+#ifndef WM_IME_COMPOSITION
122+#define WM_IME_COMPOSITION 0x010F
123+#endif
124+
121125 /////////////////////////////////////////////////////////////////////////////
122126 // CVTWindow
123127
@@ -1984,7 +1988,7 @@
19841988
19851989 OpenHelp(HH_CLOSE_ALL, 0, ts.UILanguageFile);
19861990
1987- FreeIME();
1991+ FreeIME(HVTWin);
19881992 FreeTTSET();
19891993 do { }
19901994 while (FreeTTDLG());
@@ -3259,7 +3263,7 @@
32593263 // 入力コンテキストの開閉状態が更新される(IME On/OFF)
32603264
32613265 // IMEのOn/Offを取得する
3262- IMEstat = GetIMEOpenStatus();
3266+ IMEstat = GetIMEOpenStatus(HVTWin);
32633267
32643268 // 状態を表示するIMEのために位置を通知する
32653269 int CaretX = (CursorX-WinOrgX)*FontWidth;
@@ -3303,7 +3307,7 @@
33033307 if (ts.UseIME > 0) {
33043308 switch(wParam) {
33053309 case IMR_DOCUMENTFEED:
3306- return ReplyIMERequestDocumentfeed(lParam, NumOfColumns);
3310+ return ReplyIMERequestDocumentfeed(HVTWin, lParam, NumOfColumns);
33073311 default:
33083312 break;
33093313 }
Show on old repository browser