[Ttssh2-commit] [4414] MetaKey 設定で、左右の片方だけを指定できるようにした。 [ttssh2-devel 1804 ]

Zurück zum Archiv-Index

svnno****@sourc***** svnno****@sourc*****
2011年 4月 6日 (水) 12:38:07 JST


Revision: 4414
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4414
Author:   doda
Date:     2011-04-06 12:38:07 +0900 (Wed, 06 Apr 2011)

Log Message:
-----------
MetaKey 設定で、左右の片方だけを指定できるようにした。[ttssh2-devel 1804]
http://sourceforge.jp/ticket/browse.php?group_id=1412&tid=23821

Modified Paths:
--------------
    trunk/installer/release/TERATERM.INI
    trunk/installer/release/lang/English.lng
    trunk/installer/release/lang/French.lng
    trunk/installer/release/lang/German.lng
    trunk/installer/release/lang/Japanese.lng
    trunk/teraterm/common/tttypes.h
    trunk/teraterm/teraterm/keyboard.c
    trunk/teraterm/teraterm/keyboard.h
    trunk/teraterm/teraterm/teraterm.cpp
    trunk/teraterm/teraterm/vtwin.cpp
    trunk/teraterm/ttpdlg/dlg_res.h
    trunk/teraterm/ttpdlg/ttdlg.c
    trunk/teraterm/ttpdlg/ttpdlg.rc
    trunk/teraterm/ttpset/ttset.c


-------------- next part --------------
Modified: trunk/installer/release/TERATERM.INI
===================================================================
--- trunk/installer/release/TERATERM.INI	2011-04-04 09:19:19 UTC (rev 4413)
+++ trunk/installer/release/TERATERM.INI	2011-04-06 03:38:07 UTC (rev 4414)
@@ -233,7 +233,7 @@
 ;	Russian code set used in the keyboard driver
 RussKeyb=Windows
 
-;	Meta key (on/off)
+;	Meta key (on/off/left/right)
 MetaKey=off
 
 ;	Meta key sets MSB (off/raw/text)

Modified: trunk/installer/release/lang/English.lng
===================================================================
--- trunk/installer/release/lang/English.lng	2011-04-04 09:19:19 UTC (rev 4413)
+++ trunk/installer/release/lang/English.lng	2011-04-06 03:38:07 UTC (rev 4414)
@@ -267,7 +267,7 @@
 DLG_KEYB_BS=&Backspace key
 DLG_KEYB_DEL=&Delete key
 DLG_KEYB_KEYB=&Keyboard:
-DLG_KEYB_META=&Meta key
+DLG_KEYB_META=&Meta key:
 DLG_KEYB_DISABLE=Disabled mode:
 DLG_KEYB_APPKEY=&Application Keypad
 DLG_KEYB_APPCUR=Application &Cursor

Modified: trunk/installer/release/lang/French.lng
===================================================================
--- trunk/installer/release/lang/French.lng	2011-04-04 09:19:19 UTC (rev 4413)
+++ trunk/installer/release/lang/French.lng	2011-04-06 03:38:07 UTC (rev 4414)
@@ -267,7 +267,7 @@
 DLG_KEYB_BS=Touche &Bkspace
 DLG_KEYB_DEL=Touche &Delete
 DLG_KEYB_KEYB=&Clavier:
-DLG_KEYB_META=Alt = &Meta
+DLG_KEYB_META=Alt = &Meta:
 DLG_KEYB_DISABLE=Dévalider le mode:
 DLG_KEYB_APPKEY=Codes pavé numérique
 DLG_KEYB_APPCUR=Codes Curseur pavé numérique

Modified: trunk/installer/release/lang/German.lng
===================================================================
--- trunk/installer/release/lang/German.lng	2011-04-04 09:19:19 UTC (rev 4413)
+++ trunk/installer/release/lang/German.lng	2011-04-06 03:38:07 UTC (rev 4414)
@@ -267,7 +267,7 @@
 DLG_KEYB_BS=Backspace
 DLG_KEYB_DEL=Entfernen
 DLG_KEYB_KEYB=Keyboard:
-DLG_KEYB_META=Meta-Taste
+DLG_KEYB_META=Meta-Taste:
 DLG_KEYB_DISABLE=Abschalten:
 DLG_KEYB_APPKEY=Anwendungs-Keypad
 DLG_KEYB_APPCUR=Anwendungs-Cursor

Modified: trunk/installer/release/lang/Japanese.lng
===================================================================
--- trunk/installer/release/lang/Japanese.lng	2011-04-04 09:19:19 UTC (rev 4413)
+++ trunk/installer/release/lang/Japanese.lng	2011-04-06 03:38:07 UTC (rev 4414)
@@ -267,7 +267,7 @@
 DLG_KEYB_BS=&Backspace ƒL[
 DLG_KEYB_DEL=&Delete ƒL[
 DLG_KEYB_KEYB=ƒL[ƒ{[ƒh(&K):
-DLG_KEYB_META=&Meta ƒL[
+DLG_KEYB_META=&Meta ƒL[:
 DLG_KEYB_DISABLE=–³Œø‰»‚·‚郂[ƒh
 DLG_KEYB_APPKEY=ƒAƒvƒŠƒP[ƒVƒ‡ƒ“ƒL[ƒpƒbƒh(&A)
 DLG_KEYB_APPCUR=ƒAƒvƒŠƒP[ƒVƒ‡ƒ“ƒJ[ƒ\ƒ‹(&C)

Modified: trunk/teraterm/common/tttypes.h
===================================================================
--- trunk/teraterm/common/tttypes.h	2011-04-04 09:19:19 UTC (rev 4413)
+++ trunk/teraterm/common/tttypes.h	2011-04-06 03:38:07 UTC (rev 4414)
@@ -564,6 +564,11 @@
 #define IdBS  1
 #define IdDEL 2
 
+#define IdMetaOff   0
+#define IdMetaOn    1
+#define IdMetaLeft  2
+#define IdMetaRight 3
+
   /* Mouse tracking mode */
 #define IdMouseTrackNone     0
 #define IdMouseTrackDECELR   1

Modified: trunk/teraterm/teraterm/keyboard.c
===================================================================
--- trunk/teraterm/teraterm/keyboard.c	2011-04-04 09:19:19 UTC (rev 4413)
+++ trunk/teraterm/teraterm/keyboard.c	2011-04-06 03:38:07 UTC (rev 4414)
@@ -596,7 +596,7 @@
 
   if (AltKey()) {
     Scan |= 0x800;
-    if (!ts.MetaKey) {
+    if (!MetaKey(ts.MetaKey)) {
       ModStat |= 16;
     }
   }
@@ -620,7 +620,7 @@
   if (Key==0) {
     CodeLength = VKey2KeyStr(VKey, HWin, Code, sizeof(Code), &CodeType, ModStat);
 
-    if ((ts.MetaKey>0) && (CodeLength==1) && AltKey()) {
+    if (MetaKey(ts.MetaKey) && (CodeLength==1)) {
       switch (ts.Meta8Bit) {
         case IdMeta8BitRaw:
 	  Code[0] |= 0x80;
@@ -639,7 +639,7 @@
     }
   }
   else {
-    if ((ts.MetaKey>0) && AltKey()) {
+    if (MetaKey(ts.MetaKey)) {
       PeekMessage((LPMSG)&M,HWin,WM_SYSCHAR,WM_SYSCHAR,PM_REMOVE);
     }
 
@@ -819,6 +819,20 @@
   return ((GetAsyncKeyState(VK_MENU) & 0xFFFFFF80) != 0);
 }
 
+BOOL MetaKey(int mode)
+{
+  switch (mode) {
+  case IdMetaOn:
+    return ((GetAsyncKeyState(VK_MENU) & 0xFFFFFF80) != 0);
+  case IdMetaLeft:
+    return ((GetAsyncKeyState(VK_LMENU) & 0xFFFFFF80) != 0);
+  case IdMetaRight:
+    return ((GetAsyncKeyState(VK_RMENU) & 0xFFFFFF80) != 0);
+  default:
+    return FALSE;
+  }
+}
+
 void InitKeyboard()
 {
   KeyMap = NULL;

Modified: trunk/teraterm/teraterm/keyboard.h
===================================================================
--- trunk/teraterm/teraterm/keyboard.h	2011-04-04 09:19:19 UTC (rev 4413)
+++ trunk/teraterm/teraterm/keyboard.h	2011-04-06 03:38:07 UTC (rev 4414)
@@ -27,6 +27,7 @@
 BOOL ShiftKey();
 BOOL ControlKey();
 BOOL AltKey();
+BOOL MetaKey(int mode);
 void InitKeyboard();
 void EndKeyboard();
 

Modified: trunk/teraterm/teraterm/teraterm.cpp
===================================================================
--- trunk/teraterm/teraterm/teraterm.cpp	2011-04-04 09:19:19 UTC (rev 4413)
+++ trunk/teraterm/teraterm/teraterm.cpp	2011-04-06 03:38:07 UTC (rev 4414)
@@ -19,6 +19,7 @@
 #include "tektypes.h"
 #include "tekwin.h"
 #include "ttdde.h"
+#include "keyboard.h"
 
 #include "teraapp.h"
 
@@ -189,7 +190,7 @@
 
 BOOL CTeraApp::PreTranslateMessage(MSG* pMsg)
 {
-	if (ts.MetaKey>0) {
+	if (MetaKey(ts.MetaKey)) {
 		return FALSE; /* ignore accelerator keys */
 	}
 	else {

Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2011-04-04 09:19:19 UTC (rev 4413)
+++ trunk/teraterm/teraterm/vtwin.cpp	2011-04-06 03:38:07 UTC (rev 4414)
@@ -1688,7 +1688,7 @@
 		return;
 	}
 
-	if ((ts.MetaKey>0) && AltKey()) {
+	if (MetaKey(ts.MetaKey)) {
 		::PostMessage(HVTWin,WM_SYSCHAR,nChar,MAKELONG(nRepCnt,nFlags));
 		return;
 	}
@@ -2011,8 +2011,10 @@
 		return;
 	}
 
-
-	if ((ts.MetaKey>0) && ((nFlags & 0x2000) != 0)) {
+	// ‰EAlt‚Å‚à‚È‚º‚© nFlags ‚ÌŠg’£ƒL[ƒrƒbƒg(8) ‚ª—§‚½‚È‚¢‚Ì‚Å
+	// nFlags ‚Í“–‚Ä‚É‚¹‚¸ GetAsyncKeyState ‚ðŽg‚Á‚Ä”»’f‚·‚é
+	if (MetaKey(ts.MetaKey))
+	{
 		/* for Ctrl+Alt+Key combination */
 		GetKeyboardState((PBYTE)KeyState);
 		KeyState[VK_MENU] = 0;
@@ -2022,21 +2024,6 @@
 		M.wParam = nChar;
 		M.lParam = MAKELONG(nRepCnt,nFlags & 0xdfff);
 		TranslateMessage(&M);
-
-	} else {
-		// ScrollLockƒL[‚ª“_“”‚µ‚Ä‚¢‚éê‡‚́Aƒ}ƒEƒX‚ðƒNƒŠƒbƒN‚µ‚Á‚Ï‚È‚µó‘Ô‚Å‚ ‚é‚Æ
-		// Œ©‚È‚·B‚·‚È‚í‚¿Aƒp[ƒWƒ“ƒOˆ—‚ªˆêŽž’âŽ~‚·‚éB
-		// “–ŠYƒL[‚ðÁ“”‚³‚¹‚é‚ƁAˆ—‚ªÄŠJ‚³‚ê‚éB(2006.11.14 yutaka)
-#if 0
-		GetKeyboardState((PBYTE)KeyState);
-		if (KeyState[VK_SCROLL] == 0x81) { // on : scroll locked
-			ScrollLock = TRUE;
-		} else if (KeyState[VK_SCROLL] == 0x80) { // off : scroll unlocked
-			ScrollLock = FALSE;
-		} else {
-			// do nothing
-		}
-#endif
 	}
 
 }
@@ -2626,7 +2613,7 @@
 	}
 #endif
 
-	if (ts.MetaKey) {
+	if (MetaKey(ts.MetaKey)) {
 		if (!KeybEnabled || (TalkStatus!=IdTalkKeyb)) return;
 		Code = nChar;
 		for (i=1 ; i<=nRepCnt ; i++) {
@@ -2684,9 +2671,10 @@
 void CVTWindow::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
 {
 	if ((nChar==VK_F10) ||
-	    (ts.MetaKey>0) &&
-	    ((MainMenu==NULL) || (nChar!=VK_MENU)) &&
-		((nFlags & 0x2000) != 0)) {
+	   ((ts.MetaKey == IdMetaOn) && (nFlags & 0x2000) ||
+	    (ts.MetaKey == IdMetaLeft) && (nFlags & 0x2100) == 0x2000 ||
+	    (ts.MetaKey == IdMetaRight) && (nFlags & 0x2100) == 0x2100) &&
+	   ((MainMenu==NULL) || (nChar!=VK_MENU))) {
 		KeyDown(HVTWin,nChar,nRepCnt,nFlags & 0x1ff);
 		// OnKeyDown(nChar,nRepCnt,nFlags);
 	}

Modified: trunk/teraterm/ttpdlg/dlg_res.h
===================================================================
--- trunk/teraterm/ttpdlg/dlg_res.h	2011-04-04 09:19:19 UTC (rev 4413)
+++ trunk/teraterm/ttpdlg/dlg_res.h	2011-04-06 03:38:07 UTC (rev 4414)
@@ -64,6 +64,7 @@
 #define IDC_KEYBMETA                    303
 #define IDC_KEYBKEYBTEXT                304
 #define IDC_KEYBKEYB                    305
+#define IDC_KEYBMETATEXT                306
 #define IDC_KEYBDISABLE                 310
 #define IDC_KEYBAPPKEY                  311
 #define IDC_KEYBAPPCUR                  312

Modified: trunk/teraterm/ttpdlg/ttdlg.c
===================================================================
--- trunk/teraterm/ttpdlg/ttdlg.c	2011-04-04 09:19:19 UTC (rev 4413)
+++ trunk/teraterm/ttpdlg/ttdlg.c	2011-04-06 03:38:07 UTC (rev 4414)
@@ -65,6 +65,8 @@
 static PCHAR far RussList[] = {"Windows","KOI8-R","CP 866","ISO 8859-5",NULL};
 static PCHAR far RussList2[] = {"Windows","KOI8-R",NULL};
 static PCHAR far LocaleList[] = {"japanese","chinese", "chinese-simplified", "chinese-traditional", NULL};
+static PCHAR far MetaList[] = {"off", "on", "left", "right", NULL};
+static PCHAR far MetaList2[] = {"off", "on", NULL};
 
 // HKS
 static PCHAR far KoreanList[] = {"KS5601", "UTF-8", "UTF-8m", NULL};
@@ -1178,6 +1180,7 @@
 	char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG];
 	LOGFONT logfont;
 	HFONT font;
+	OSVERSIONINFO osvi;
 
 	switch (Message) {
 		case WM_INITDIALOG:
@@ -1192,6 +1195,7 @@
 				SendDlgItemMessage(Dialog, IDC_KEYBDEL, WM_SETFONT, (WPARAM)DlgKeybFont, MAKELPARAM(TRUE,0));
 				SendDlgItemMessage(Dialog, IDC_KEYBKEYBTEXT, WM_SETFONT, (WPARAM)DlgKeybFont, MAKELPARAM(TRUE,0));
 				SendDlgItemMessage(Dialog, IDC_KEYBKEYB, WM_SETFONT, (WPARAM)DlgKeybFont, MAKELPARAM(TRUE,0));
+				SendDlgItemMessage(Dialog, IDC_KEYBMETATEXT, WM_SETFONT, (WPARAM)DlgKeybFont, MAKELPARAM(TRUE,0));
 				SendDlgItemMessage(Dialog, IDC_KEYBMETA, WM_SETFONT, (WPARAM)DlgKeybFont, MAKELPARAM(TRUE,0));
 				SendDlgItemMessage(Dialog, IDC_KEYBDISABLE, WM_SETFONT, (WPARAM)DlgKeybFont, MAKELPARAM(TRUE,0));
 				SendDlgItemMessage(Dialog, IDC_KEYBAPPKEY, WM_SETFONT, (WPARAM)DlgKeybFont, MAKELPARAM(TRUE,0));
@@ -1219,9 +1223,9 @@
 			GetDlgItemText(Dialog, IDC_KEYBKEYBTEXT, uimsg2, sizeof(uimsg2));
 			get_lang_msg("DLG_KEYB_KEYB", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
 			SetDlgItemText(Dialog, IDC_KEYBKEYBTEXT, uimsg);
-			GetDlgItemText(Dialog, IDC_KEYBMETA, uimsg2, sizeof(uimsg2));
+			GetDlgItemText(Dialog, IDC_KEYBMETATEXT, uimsg2, sizeof(uimsg2));
 			get_lang_msg("DLG_KEYB_META", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
-			SetDlgItemText(Dialog, IDC_KEYBMETA, uimsg);
+			SetDlgItemText(Dialog, IDC_KEYBMETATEXT, uimsg);
 			GetDlgItemText(Dialog, IDC_KEYBDISABLE, uimsg2, sizeof(uimsg2));
 			get_lang_msg("DLG_KEYB_DISABLE", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
 			SetDlgItemText(Dialog, IDC_KEYBDISABLE, uimsg);
@@ -1246,6 +1250,16 @@
 			SetRB(Dialog,ts->MetaKey,IDC_KEYBMETA,IDC_KEYBMETA);
 			SetRB(Dialog,ts->DisableAppKeypad,IDC_KEYBAPPKEY,IDC_KEYBAPPKEY);
 			SetRB(Dialog,ts->DisableAppCursor,IDC_KEYBAPPCUR,IDC_KEYBAPPCUR);
+
+			osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+                        GetVersionEx(&osvi);
+                        if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
+				SetDropDownList(Dialog, IDC_KEYBMETA, MetaList2, ts->MetaKey + 1);
+                        }
+			else {
+				SetDropDownList(Dialog, IDC_KEYBMETA, MetaList, ts->MetaKey + 1);
+			}
+
 			if (ts->Language==IdRussian) {
 				ShowDlgItem(Dialog,IDC_KEYBKEYBTEXT,IDC_KEYBKEYB);
 				SetDropDownList(Dialog, IDC_KEYBKEYB, RussList2, ts->RussKeyb);
@@ -1263,6 +1277,7 @@
 						GetRB(Dialog,&ts->MetaKey,IDC_KEYBMETA,IDC_KEYBMETA);
 						GetRB(Dialog,&ts->DisableAppKeypad,IDC_KEYBAPPKEY,IDC_KEYBAPPKEY);
 						GetRB(Dialog,&ts->DisableAppCursor,IDC_KEYBAPPCUR,IDC_KEYBAPPCUR);
+						ts->MetaKey = (WORD)GetCurSel(Dialog, IDC_KEYBMETA) - 1;
 						if (ts->Language==IdRussian)
 							ts->RussKeyb = (WORD)GetCurSel(Dialog, IDC_KEYBKEYB);
 					}

Modified: trunk/teraterm/ttpdlg/ttpdlg.rc
===================================================================
--- trunk/teraterm/ttpdlg/ttpdlg.rc	2011-04-04 09:19:19 UTC (rev 4413)
+++ trunk/teraterm/ttpdlg/ttpdlg.rc	2011-04-06 03:38:07 UTC (rev 4414)
@@ -302,7 +302,8 @@
     CONTROL         "&Delete key",IDC_KEYBDEL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,29,63,12
     CONTROL         "&Keyboard:",IDC_KEYBKEYBTEXT,"Static",SS_LEFTNOWORDWRAP | NOT WS_VISIBLE | WS_GROUP,12,49,44,9
     COMBOBOX        IDC_KEYBKEYB,57,47,44,58,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
-    CONTROL         "&Meta key",IDC_KEYBMETA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,59,47,12
+    CONTROL         "&Meta key:",IDC_KEYBMETATEXT,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,12,63,44,9
+    COMBOBOX        IDC_KEYBMETA,57,61,44,58,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
     GROUPBOX        "Disabled mode:",IDC_KEYBDISABLE,10,74,130,35
     CONTROL         "&Application Keypad",IDC_KEYBAPPKEY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,83,115,12
     CONTROL         "Application &Cursor",IDC_KEYBAPPCUR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,96,115,12

Modified: trunk/teraterm/ttpset/ttset.c
===================================================================
--- trunk/teraterm/ttpset/ttset.c	2011-04-04 09:19:19 UTC (rev 4413)
+++ trunk/teraterm/ttpset/ttset.c	2011-04-06 03:38:07 UTC (rev 4414)
@@ -198,6 +198,7 @@
 	int i;
 	HDC TmpDC;
 	char Temp[MAX_PATH];
+	OSVERSIONINFO osvi;
 
 	ts->Minimize = 0;
 	ts->HideWindow = 0;
@@ -213,6 +214,9 @@
 
 	ts->DisableTCPEchoCR = FALSE;
 
+	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+	GetVersionEx(&osvi);
+
 	/* Version number */
 /*  GetPrivateProfileString(Section,"Version","",
 			  Temp,sizeof(Temp),FName); */
@@ -626,8 +630,21 @@
 	ts->DelKey = GetOnOff(Section, "DeleteKey", FName, FALSE);
 
 	/* Meta Key */
-	ts->MetaKey = GetOnOff(Section, "MetaKey", FName, FALSE);
+	GetPrivateProfileString(Section, "MetaKey", "off", Temp, sizeof(Temp), FName);
+	if (_stricmp(Temp, "on") == 0)
+	  ts->MetaKey = IdMetaOn;
+	else if (_stricmp(Temp, "left") == 0)
+	  ts->MetaKey = IdMetaLeft;
+	else if (_stricmp(Temp, "right") == 0)
+	  ts->MetaKey = IdMetaRight;
+	else
+	  ts->MetaKey = IdMetaOff;
 
+	// Windows95 Œn‚͍¶‰E‚Ì Alt ‚Ì”»•Ê‚É”ñ‘Ήž
+	if ((osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && ts->MetaKey != IdMetaOff) {
+	  ts->MetaKey = IdMetaOn;
+	}
+
 	/* Application Keypad */
 	ts->DisableAppKeypad =
 		GetOnOff(Section, "DisableAppKeypad", FName, FALSE);
@@ -1850,7 +1867,20 @@
 	WriteOnOff(Section, "DeleteKey", FName, ts->DelKey);
 
 	/* Meta key */
-	WriteOnOff(Section, "MetaKey", FName, ts->MetaKey);
+	switch (ts->MetaKey) {
+	case 1:
+		strncpy_s(Temp, sizeof(Temp), "on", _TRUNCATE);
+		break;
+	case 2:
+		strncpy_s(Temp, sizeof(Temp), "left", _TRUNCATE);
+		break;
+	case 3:
+		strncpy_s(Temp, sizeof(Temp), "right", _TRUNCATE);
+		break;
+	default:
+		strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
+	}
+	WritePrivateProfileString(Section, "Metakey", Temp, FName);
 
 	/* Application Keypad */
 	WriteOnOff(Section, "DisableAppKeypad", FName, ts->DisableAppKeypad);



Ttssh2-commit メーリングリストの案内
Zurück zum Archiv-Index