[Ttssh2-commit] [3898] IMEのon / off状態を見て、カーソルの色を変更する。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 5月 20日 (木) 01:26:50 JST


Revision: 3898
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3898
Author:   yutakapon
Date:     2010-05-20 01:26:50 +0900 (Thu, 20 May 2010)

Log Message:
-----------
IMEのon/off状態を見て、カーソルの色を変更する。
WM_INPUTLANGCHANGE, WM_IME_NOTIFY ではカーソルの再描画のみ行う。

注:
Cursor control sequenceが有効の場合、vimの入力モードでは下線カーソルに
なるため、あまり変化が分かりにくい。

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


-------------- next part --------------
Modified: trunk/teraterm/teraterm/vtdisp.c
===================================================================
--- trunk/teraterm/teraterm/vtdisp.c	2010-05-19 15:04:50 UTC (rev 3897)
+++ trunk/teraterm/teraterm/vtdisp.c	2010-05-19 16:26:50 UTC (rev 3898)
@@ -2104,10 +2104,26 @@
 // Turn on the cursor
 {
 	int CaretX, CaretY, H;
+    HIMC hImc;
+	HBITMAP color;
+	int ime_on;
 
 	if (ts.KillFocusCursor == 0 && !Active)
 		return;
 
+	/* IME‚Ìon/offó‘Ô‚ðŒ©‚ÄAƒJ[ƒ\ƒ‹‚̐F‚ð•ÏX‚·‚éB
+	 * WM_INPUTLANGCHANGE, WM_IME_NOTIFY ‚ł̓J[ƒ\ƒ‹‚̍ĕ`‰æ‚̂ݍs‚¤B
+	 * (2010.5.20 yutaka)
+	 */
+	hImc = ImmGetContext(HVTWin);
+    ime_on = ImmGetOpenStatus(hImc);
+    ImmReleaseContext(HVTWin, hImc);
+	if (ime_on) {
+		color = (HBITMAP)1;
+	} else {
+		color = NULL;
+	}
+
 	CaretX = (CursorX-WinOrgX)*FontWidth;
 	CaretY = (CursorY-WinOrgY)*FontHeight;
 
@@ -2133,11 +2149,11 @@
 			DestroyCaret();
 			if (CursorOnDBCS) {
 				/* double width caret */
-				CreateCaret(HVTWin, 0, FontWidth*2, H);
+				CreateCaret(HVTWin, color, FontWidth*2, H);
 			}
 			else {
 				/* single width caret */
-				CreateCaret(HVTWin, 0, FontWidth, H);
+				CreateCaret(HVTWin, color, FontWidth, H);
 			}
 			CaretStatus = 1;
 		}

Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2010-05-19 15:04:50 UTC (rev 3897)
+++ trunk/teraterm/teraterm/vtwin.cpp	2010-05-19 16:26:50 UTC (rev 3898)
@@ -48,6 +48,7 @@
 #include <imagehlp.h>
 
 #include <windowsx.h>
+#include <imm.h>
 
 #include "tt_res.h"
 #include "vtwin.h"
@@ -125,6 +126,8 @@
 	ON_WM_TIMER()
 	ON_WM_VSCROLL()
 	ON_MESSAGE(WM_IME_COMPOSITION,OnIMEComposition)
+	ON_MESSAGE(WM_INPUTLANGCHANGE,OnIMEInputChange)
+	ON_MESSAGE(WM_IME_NOTIFY,OnIMENotify)
 //<!--by AKASI
 	ON_MESSAGE(WM_WINDOWPOSCHANGING,OnWindowPosChanging)
 	ON_MESSAGE(WM_SETTINGCHANGE,OnSettingChange)
@@ -2898,6 +2901,22 @@
 	return CFrameWnd::DefWindowProc(WM_IME_COMPOSITION,wParam,lParam);
 }
 
+LONG CVTWindow::OnIMEInputChange(UINT wParam, LONG lParam)
+{
+	ChangeCaret();
+
+	return CFrameWnd::DefWindowProc(WM_INPUTLANGCHANGE,wParam,lParam);
+}
+
+LONG CVTWindow::OnIMENotify(UINT wParam, LONG lParam)
+{
+	if (wParam == IMN_SETOPENSTATUS) {
+		ChangeCaret();
+	}
+
+	return CFrameWnd::DefWindowProc(WM_IME_NOTIFY,wParam,lParam);
+}
+
 LONG CVTWindow::OnAccelCommand(UINT wParam, LONG lParam)
 {
 	switch (wParam) {

Modified: trunk/teraterm/teraterm/vtwin.h
===================================================================
--- trunk/teraterm/teraterm/vtwin.h	2010-05-19 15:04:50 UTC (rev 3897)
+++ trunk/teraterm/teraterm/vtwin.h	2010-05-19 16:26:50 UTC (rev 3898)
@@ -97,6 +97,8 @@
 	afx_msg LONG  OnExitSizeMove(UINT wParam, LONG lParam);
 //-->
 	afx_msg LONG OnIMEComposition(UINT wParam, LONG lParam);
+	afx_msg LONG OnIMEInputChange(UINT wParam, LONG lParam);
+	afx_msg LONG OnIMENotify(UINT wParam, LONG lParam);
 	afx_msg LONG OnAccelCommand(UINT wParam, LONG lParam);
 	afx_msg LONG OnChangeMenu(UINT wParam, LONG lParam);
 	afx_msg LONG OnChangeTBar(UINT wParam, LONG lParam);



Ttssh2-commit メーリングリストの案内
Back to archive index