[Ttssh2-commit] [6913] SI/ SO 以外のシフトも無効化できるようにした。

svnno****@sourc***** svnno****@sourc*****
2017年 8月 25日 (金) 23:48:35 JST


Revision: 6913
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6913
Author:   doda
Date:     2017-08-25 23:48:35 +0900 (Fri, 25 Aug 2017)
Log Message:
-----------
SI/SO 以外のシフトも無効化できるようにした。

Modified Paths:
--------------
    trunk/teraterm/common/tttypes.h
    trunk/teraterm/teraterm/vtterm.c
    trunk/teraterm/ttpset/ttset.c

-------------- next part --------------
Modified: trunk/teraterm/common/tttypes.h
===================================================================
--- trunk/teraterm/common/tttypes.h	2017-08-25 14:48:32 UTC (rev 6912)
+++ trunk/teraterm/common/tttypes.h	2017-08-25 14:48:35 UTC (rev 6913)
@@ -302,6 +302,22 @@
 #define TABF_TBC        (TABF_TBC0 | TABF_TBC3)
 #define TABF_ALL        (TABF_HTS | TABF_TBC)
 
+// ISO 2022 Shift flags (used in ts.ISO2022Flag)
+#define ISO2022_SHIFT_NONE   0x0000
+#define ISO2022_SI           0x0001
+#define ISO2022_SO           0x0002
+#define ISO2022_LS2          0x0004
+#define ISO2022_LS3          0x0008
+#define ISO2022_LS1R         0x0010
+#define ISO2022_LS2R         0x0020
+#define ISO2022_LS3R         0x0040
+#define ISO2022_SS2          0x0100
+#define ISO2022_SS3          0x0200
+#define ISO2022_LS           (ISO2022_SI | ISO2022_SO | ISO2022_LS2 | ISO2022_LS3)
+#define ISO2022_LSR          (ISO2022_LS1R | ISO2022_LS2R | ISO2022_LS3R)
+#define ISO2022_SS           (ISO2022_SS2 | ISO2022_SS3)
+#define ISO2022_SHIFT_ALL    (ISO2022_LS | ISO2022_LSR | ISO2022_SS)
+
 // Control Sequence flags (used in ts.CtrlFlag)
 #define CSF_CBWRITE     1
 #define CSF_CBREAD      2
@@ -589,7 +605,7 @@
 	WORD DisableMenuDuplicateSession;
 	WORD DisableMenuNewConnection;
 	char TerminalUID[9];
-	WORD EnableSOSI;
+	WORD ISO2022Flag;
 	WORD JumpList;
 	WORD TabStopFlag;
 	DWORD CtrlFlag;

Modified: trunk/teraterm/teraterm/vtterm.c
===================================================================
--- trunk/teraterm/teraterm/vtterm.c	2017-08-25 14:48:32 UTC (rev 6912)
+++ trunk/teraterm/teraterm/vtterm.c	2017-08-25 14:48:35 UTC (rev 6913)
@@ -827,7 +827,7 @@
 	case NUL:
 		return;
 	case SO:
-		if (ts.EnableSOSI && ! DirectPrn) {
+		if ((ts.ISO2022Flag & ISO2022_SO) && ! DirectPrn) {
 			if ((ts.Language==IdJapanese) &&
 			    (ts.KanjiCode==IdJIS) &&
 			    (ts.JIS7Katakana==1) &&
@@ -840,7 +840,7 @@
 		}
 		break;
 	case SI:
-		if (ts.EnableSOSI && ! DirectPrn) {
+		if ((ts.ISO2022Flag & ISO2022_SI) && ! DirectPrn) {
 			Glr[0] = 0; /* LS0 */
 			return;
 		}
@@ -967,7 +967,7 @@
 		}
 		break;
 	case SO: /* LS1 */
-		if (ts.EnableSOSI) {
+		if (ts.ISO2022Flag & ISO2022_SO) {
 			if ((ts.Language==IdJapanese) &&
 			    (ts.KanjiCode==IdJIS) &&
 			    (ts.JIS7Katakana==1) &&
@@ -980,7 +980,7 @@
 		}
 		break;
 	case SI: /* LS0 */
-		if (ts.EnableSOSI) {
+		if (ts.ISO2022Flag & ISO2022_SI) {
 			Glr[0] = 0;
 		}
 		break;
@@ -1030,12 +1030,16 @@
 		CursorUpWithScroll();
 		break;
 	case SS2:
-		GLtmp = 2;
-		SSflag = TRUE;
+		if (ts.ISO2022Flag & ISO2022_SS2) {
+			GLtmp = 2;
+			SSflag = TRUE;
+		}
 		break;
 	case SS3:
-		GLtmp = 3;
-		SSflag = TRUE;
+		if (ts.ISO2022Flag & ISO2022_SS3) {
+			GLtmp = 3;
+			SSflag = TRUE;
+		}
 		break;
 	case DCS:
 		ClearParams();
@@ -1374,12 +1378,16 @@
 			CursorUpWithScroll();
 			break;
 		case 'N': /* SS2 */
-			GLtmp = 2;
-			SSflag = TRUE;
+			if (ts.ISO2022Flag & ISO2022_SS2) {
+				GLtmp = 2;
+				SSflag = TRUE;
+			}
 			break;
 		case 'O': /* SS3 */
-			GLtmp = 3;
-			SSflag = TRUE;
+			if (ts.ISO2022Flag & ISO2022_SS3) {
+				GLtmp = 3;
+				SSflag = TRUE;
+			}
 			break;
 		case 'P': /* DCS */
 			ClearParams();
@@ -1416,11 +1424,31 @@
 		case 'g': /* Visual Bell (screen original?) */
 			RingBell(IdBeepVisual);
 			break;
-		case 'n': Glr[0] = 2; break; /* LS2 */
-		case 'o': Glr[0] = 3; break; /* LS3 */
-		case '|': Glr[1] = 3; break; /* LS3R */
-		case '}': Glr[1] = 2; break; /* LS2R */
-		case '~': Glr[1] = 1; break; /* LS1R */
+		case 'n': /* LS2 */
+			if (ts.ISO2022Flag & ISO2022_LS2) {
+				Glr[0] = 2;
+			}
+			break;
+		case 'o': /* LS3 */
+			if (ts.ISO2022Flag & ISO2022_LS3) {
+				Glr[0] = 3;
+			}
+			break;
+		case '|': /* LS3R */
+			if (ts.ISO2022Flag & ISO2022_LS3R) {
+				Glr[1] = 3;
+			}
+			break;
+		case '}': /* LS2R */
+			if (ts.ISO2022Flag & ISO2022_LS2R) {
+				Glr[1] = 2;
+			}
+			break;
+		case '~': /* LS1R */
+			if (ts.ISO2022Flag & ISO2022_LS1R) {
+				Glr[1] = 1;
+			}
+			break;
 		}
 		break;
 		/* end of case Icount=0 */
@@ -5096,7 +5124,9 @@
 	else if (b==0x8E) { // SS2
 		switch (ts.KanjiCode) {
 		case IdEUC:
-			EUCkanaIn = TRUE;
+			if (ts.ISO2022Flag & ISO2022_SS2) {
+				EUCkanaIn = TRUE;
+			}
 			break;
 		case IdUTF8:
 		case IdUTF8m:
@@ -5109,8 +5139,10 @@
 	else if (b==0x8F) { // SS3
 		switch (ts.KanjiCode) {
 		case IdEUC:
-			EUCcount = 2;
-			EUCsupIn = TRUE;
+			if (ts.ISO2022Flag & ISO2022_SS3) {
+				EUCcount = 2;
+				EUCsupIn = TRUE;
+			}
 			break;
 		case IdUTF8:
 		case IdUTF8m:

Modified: trunk/teraterm/ttpset/ttset.c
===================================================================
--- trunk/teraterm/ttpset/ttset.c	2017-08-25 14:48:32 UTC (rev 6912)
+++ trunk/teraterm/ttpset/ttset.c	2017-08-25 14:48:35 UTC (rev 6913)
@@ -1965,12 +1965,39 @@
 	if (GetOnOff(Section, "NormalizeLineBreakOnPaste", FName, FALSE))
 		ts->PasteFlag |= CPF_NORMALIZE_LINEBREAK;
 
-	// Disable SO/SI.
-	ts->EnableSOSI = GetOnOff(Section, "EnableSOSI", FName, TRUE);
-
 	// List Inactive Font
 	ts->ListHiddenFonts = GetOnOff(Section, "ListHiddenFonts", FName, FALSE);
 
+	// ISO2022ShiftCharacter
+	GetPrivateProfileString(Section, "ISO2022ShiftCharacter", "on", Temp, sizeof(Temp), FName);
+	if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
+		ts->ISO2022Flag = ISO2022_SHIFT_ALL;
+	else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0)
+		ts->ISO2022Flag = ISO2022_SHIFT_NONE;
+	else {
+		ts->ISO2022Flag = ISO2022_SHIFT_NONE;
+		for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
+			if (_stricmp(Temp2, "SI") == 0 || _stricmp(Temp2, "LS0") == 0)
+				ts->ISO2022Flag |= ISO2022_SI;
+			else if (_stricmp(Temp2, "SO") == 0 || _stricmp(Temp2, "LS1") == 0)
+				ts->ISO2022Flag |= ISO2022_SO;
+			else if (_stricmp(Temp2, "LS2") == 0)
+				ts->ISO2022Flag |= ISO2022_LS2;
+			else if (_stricmp(Temp2, "LS3") == 0)
+				ts->ISO2022Flag |= ISO2022_LS3;
+			else if (_stricmp(Temp2, "LS1R") == 0)
+				ts->ISO2022Flag |= ISO2022_LS1R;
+			else if (_stricmp(Temp2, "LS2R") == 0)
+				ts->ISO2022Flag |= ISO2022_LS2R;
+			else if (_stricmp(Temp2, "LS3R") == 0)
+				ts->ISO2022Flag |= ISO2022_LS3R;
+			else if (_stricmp(Temp2, "SS2") == 0)
+				ts->ISO2022Flag |= ISO2022_SS2;
+			else if (_stricmp(Temp2, "SS3") == 0)
+				ts->ISO2022Flag |= ISO2022_SS3;
+		}
+	}
+
 	// Fallback to CP932 (Experimental)
 	ts->FallbackToCP932 = GetOnOff(Section, "FallbackToCP932", FName, FALSE);
 
@@ -3242,12 +3269,57 @@
 	WriteOnOff(Section, "NormalizeLineBreakOnPaste", FName,
 		(WORD) (ts->PasteFlag & CPF_NORMALIZE_LINEBREAK));
 
-	// Disable SO/SI.
-	WriteOnOff(Section, "EnableSOSI", FName, ts->EnableSOSI);
-
 	// List Inactive Font
 	WriteOnOff(Section, "ListHiddenFonts", FName, ts->ListHiddenFonts);
 
+	// ISO2022ShiftCharacter
+	switch (ts->TabStopFlag) {
+	case ISO2022_SHIFT_ALL:
+		strncpy_s(Temp, sizeof(Temp), "on", _TRUNCATE);
+		break;
+	case ISO2022_SHIFT_NONE:
+		strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
+		break;
+	default:
+		if (ts->ISO2022Flag & ISO2022_SI) {
+			strncpy_s(Temp, sizeof(Temp), "SI,", _TRUNCATE);
+		}
+		if (ts->ISO2022Flag & ISO2022_SO) {
+			strncat_s(Temp, sizeof(Temp), "SO,", _TRUNCATE);
+		}
+		if (ts->ISO2022Flag & ISO2022_LS2) {
+			strncat_s(Temp, sizeof(Temp), "LS2,", _TRUNCATE);
+		}
+		if (ts->ISO2022Flag & ISO2022_LS3) {
+			strncat_s(Temp, sizeof(Temp), "LS3,", _TRUNCATE);
+		}
+		if (ts->ISO2022Flag & ISO2022_LS1R) {
+			strncat_s(Temp, sizeof(Temp), "LS1R,", _TRUNCATE);
+		}
+		if (ts->ISO2022Flag & ISO2022_LS2R) {
+			strncat_s(Temp, sizeof(Temp), "LS2R,", _TRUNCATE);
+		}
+		if (ts->ISO2022Flag & ISO2022_LS3R) {
+			strncat_s(Temp, sizeof(Temp), "LS3R,", _TRUNCATE);
+		}
+		if (ts->ISO2022Flag & ISO2022_SS2) {
+			strncat_s(Temp, sizeof(Temp), "SS2,", _TRUNCATE);
+		}
+		if (ts->ISO2022Flag & ISO2022_SS3) {
+			strncat_s(Temp, sizeof(Temp), "SS3,", _TRUNCATE);
+		}
+
+		i = strlen(Temp);
+		if (i == 0) { // \x96\xB3\x82\xA2\x82͂\xB8\x82\xBE\x82\xAF\x82\xEA\x82ǔO\x82̂\xBD\x82\xDF
+			strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
+		}
+		else if (Temp[i-1] == ',') {
+			Temp[i-1] = 0;
+		}
+		break;
+	}
+	WritePrivateProfileString(Section, "ISO2022ShiftCharacter", Temp, FName);
+
 	// CygTerm Configuration File
 	WriteCygtermConfFile(ts);
 }



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