[Ttssh2-commit] [4687] タブストップ設定 (HTS)/ 削除 (TBC) 制御シーケンスを受け付けるか設定できるようにした。

svnno****@sourc***** svnno****@sourc*****
2011年 10月 24日 (月) 21:36:52 JST


Revision: 4687
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4687
Author:   doda
Date:     2011-10-24 21:36:52 +0900 (Mon, 24 Oct 2011)

Log Message:
-----------
タブストップ設定(HTS)/削除(TBC)制御シーケンスを受け付けるか設定できるようにした。
主な用途は、TabStopModifySequence=HTS7,TBC として、8ビットの HTS (0x88) を無効にする事。
# SJIS 以外の設定の時に誤って CP932 のテキストを表示した時にタブ位置が崩れないようにするのが目的

Modified Paths:
--------------
    trunk/installer/release/TERATERM.INI
    trunk/teraterm/common/ttlib.c
    trunk/teraterm/common/ttlib.h
    trunk/teraterm/common/tttypes.h
    trunk/teraterm/teraterm/buffer.c
    trunk/teraterm/teraterm/vtterm.c
    trunk/teraterm/ttpset/ttset.c


-------------- next part --------------
Modified: trunk/installer/release/TERATERM.INI
===================================================================
--- trunk/installer/release/TERATERM.INI	2011-10-24 11:46:46 UTC (rev 4686)
+++ trunk/installer/release/TERATERM.INI	2011-10-24 12:36:52 UTC (rev 4687)
@@ -493,6 +493,9 @@
 ; Strict Key Mapping
 StrictKeyMapping=off
 
+; Tab Stop Modify Sequence (on/off/combination of HTS,HTS7,HTS8,TBC,TBC0,TBC3)
+TabStopModifySequence=on
+
 ; TEK mouse code
 TEKGINMouseCode=32
 

Modified: trunk/teraterm/common/ttlib.c
===================================================================
--- trunk/teraterm/common/ttlib.c	2011-10-24 11:46:46 UTC (rev 4686)
+++ trunk/teraterm/common/ttlib.c	2011-10-24 12:36:52 UTC (rev 4687)
@@ -581,27 +581,28 @@
 	memcpy(Text, buf, size);
 }
 
-void GetNthString(PCHAR Source, int Nth, int Size, PCHAR Dest)
+BOOL GetNthString(PCHAR Source, int Nth, int Size, PCHAR Dest)
 {
 	int i, j, k;
-	char c;
 
 	i = 1;
 	j = 0;
 	k = 0;
-	do {
-		c = Source[j];
-		if ( c==',' ) {
+
+	while (i<Nth && Source[j] != 0) {
+		if (Source[j++] == ',') {
 			i++;
 		}
-		j++;
-		if ( (i==Nth) && (c!=',') && (k<Size-1) ) {
-			Dest[k] = c;
-			k++;
+	}
+
+	if (i == Nth) {
+		while (Source[j] != 0 && Source[j] != ',' && k<Size-1) {
+			Dest[k++] = Source[j++];
 		}
 	}
-	while ((i<=Nth) && (c!=0));
+
 	Dest[k] = 0;
+	return (i>=Nth);
 }
 
 void GetNthNum(PCHAR Source, int Nth, int far *Num)
@@ -884,4 +885,4 @@
 	            LocalTime.wYear);
 
 	return strtime;
-}
\ No newline at end of file
+}

Modified: trunk/teraterm/common/ttlib.h
===================================================================
--- trunk/teraterm/common/ttlib.h	2011-10-24 11:46:46 UTC (rev 4686)
+++ trunk/teraterm/common/ttlib.h	2011-10-24 12:36:52 UTC (rev 4687)
@@ -31,7 +31,7 @@
 void ParseStrftimeFileName(PCHAR FName, int destlen);
 void ConvFName(PCHAR HomeDir, PCHAR Temp, int templen, PCHAR DefExt, PCHAR FName, int destlen);
 void RestoreNewLine(PCHAR Text);
-void GetNthString(PCHAR Source, int Nth, int Size, PCHAR Dest);
+BOOL GetNthString(PCHAR Source, int Nth, int Size, PCHAR Dest);
 void GetNthNum(PCHAR Source, int Nth, int far *Num);
 void WINAPI GetDefaultFName(char *home, char *file, char *dest, int destlen);
 void GetDefaultSetupFName(char *home, char *dest, int destlen);

Modified: trunk/teraterm/common/tttypes.h
===================================================================
--- trunk/teraterm/common/tttypes.h	2011-10-24 11:46:46 UTC (rev 4686)
+++ trunk/teraterm/common/tttypes.h	2011-10-24 12:36:52 UTC (rev 4687)
@@ -247,6 +247,16 @@
 #define WF_TITLEREPORT     24 // (8 | 16)
 #define WF_IMECURSORCHANGE 32
 
+// Tab Stop flags (used in ts.TabStopFlag)
+#define TABF_NONE       0
+#define TABF_HTS7       1
+#define TABF_HTS8       2
+#define TABF_TBC0       4
+#define TABF_TBC3       8
+#define TABF_HTS        (TABF_HTS7 | TABF_HTS8)
+#define TABF_TBC        (TABF_TBC0 | TABF_TBC3)
+#define TABF_ALL        (TABF_HTS | TABF_TBC)
+
 // Title Reporting Type
 #define IdTitleReportIgnore 0
 #define IdTitleReportAccept 8
@@ -523,6 +533,7 @@
 	char TerminalUID[9];
 	WORD ConfirmChangePasteCR;
 	WORD JumpList;
+	WORD TabStopFlag;
 };
 
 typedef struct tttset TTTSet, *PTTSet;
@@ -967,6 +978,9 @@
  * Increment the number of this macro value
  * when you change TMap or member of TMap.
  *
+ * - At version 4.72, ttset_memfilemap was replaced with ttset_memfilemap_17.
+ *   added tttset.TabStopFlag.
+ *
  * - At version 4.70, ttset_memfilemap was replaced with ttset_memfilemap_16.
  *   added tttset.JumpList.
  *
@@ -1065,4 +1079,4 @@
  *   added tttset.VTCompatTab.
  */
 
-#define TT_FILEMAPNAME "ttset_memfilemap_16"
+#define TT_FILEMAPNAME "ttset_memfilemap_17"

Modified: trunk/teraterm/teraterm/buffer.c
===================================================================
--- trunk/teraterm/teraterm/buffer.c	2011-10-24 11:46:46 UTC (rev 4686)
+++ trunk/teraterm/teraterm/buffer.c	2011-10-24 12:36:52 UTC (rev 4687)
@@ -3061,7 +3061,8 @@
 
 	if (NTabStops>0) {
 		switch (Ps) {
-			case 0:
+		case 0:
+			if (ts.TabStopFlag & TABF_TBC0) {
 				i = 0;
 				while ((TabStops[i]!=CursorX) && (i<NTabStops-1)) {
 					i++;
@@ -3072,10 +3073,12 @@
 						TabStops[j] = TabStops[j+1];
 					}
 				}
-				break;
-			case 3:
+			}
+			break;
+		case 3:
+			if (ts.TabStopFlag & TABF_TBC3)
 				NTabStops = 0;
-				break;
+			break;
 		}
 	}
 }

Modified: trunk/teraterm/teraterm/vtterm.c
===================================================================
--- trunk/teraterm/teraterm/vtterm.c	2011-10-24 11:46:46 UTC (rev 4686)
+++ trunk/teraterm/teraterm/vtterm.c	2011-10-24 12:36:52 UTC (rev 4687)
@@ -928,7 +928,7 @@
       LineFeed(0,TRUE);
       CarriageReturn(TRUE);
       break;
-    case HTS: SetTabStop(); break;
+    case HTS: if (ts.TabStopFlag & TABF_HTS8) SetTabStop(); break;
     case RI: CursorUpWithScroll(); break;
     case SS2:
       GLtmp = 2;
@@ -1271,7 +1271,7 @@
 	  LineFeed(0,TRUE);
 	  break;
 	case 'H': /* HTS */
-	  SetTabStop();
+	  if (ts.TabStopFlag & TABF_HTS7) SetTabStop();
 	  break;
 	case 'M': /* RI */
 	  CursorUpWithScroll();

Modified: trunk/teraterm/ttpset/ttset.c
===================================================================
--- trunk/teraterm/ttpset/ttset.c	2011-10-24 11:46:46 UTC (rev 4686)
+++ trunk/teraterm/ttpset/ttset.c	2011-10-24 12:36:52 UTC (rev 4687)
@@ -197,7 +197,7 @@
 {
 	int i;
 	HDC TmpDC;
-	char Temp[MAX_PATH];
+	char Temp[MAX_PATH], Temp2[MAX_PATH];
 	OSVERSIONINFO osvi;
 
 	ts->Minimize = 0;
@@ -1418,6 +1418,29 @@
 	// Jump List
 	ts->JumpList = GetOnOff(Section, "JumpList", FName, TRUE);
 
+	GetPrivateProfileString(Section, "TabStopModifySequence", "on", Temp, sizeof(Temp), FName);
+	if (_stricmp(Temp, "on") == 0 || _stricmp(Temp, "all") == 0)
+		ts->TabStopFlag = TABF_ALL;
+	else if (_stricmp(Temp, "off") == 0 || _stricmp(Temp, "none") == 0)
+		ts->TabStopFlag = TABF_NONE;
+	else {
+		ts->TabStopFlag = TABF_NONE;
+		for (i=1; GetNthString(Temp, i, sizeof(Temp2), Temp2); i++) {
+			if (_stricmp(Temp2, "HTS") == 0)
+				ts->TabStopFlag |= TABF_HTS;
+			else if (_stricmp(Temp2, "HTS7") == 0)
+				ts->TabStopFlag |= TABF_HTS7;
+			else if (_stricmp(Temp2, "HTS8") == 0)
+				ts->TabStopFlag |= TABF_HTS8;
+			else if (_stricmp(Temp2, "TBC") == 0)
+				ts->TabStopFlag |= TABF_TBC;
+			else if (_stricmp(Temp2, "TBC0") == 0)
+				ts->TabStopFlag |= TABF_TBC0;
+			else if (_stricmp(Temp2, "TBC3") == 0)
+				ts->TabStopFlag |= TABF_TBC3;
+		}
+	}
+
 	// Use invalid DECRPSS (for testing)
 	if (GetOnOff(Section, "UseInvalidDECRQSSResponse", FName, FALSE))
 		ts->TermFlag |= TF_INVALIDDECRPSS;
@@ -2467,6 +2490,40 @@
 
 	// Confirm PasteCR
 	WriteOnOff(Section, "JumpList", FName, ts->JumpList);
+
+	// TabStopModifySequence
+	switch (ts->TabStopFlag) {
+	case TABF_ALL:
+		strncpy_s(Temp, sizeof(Temp), "on", _TRUNCATE);
+		break;
+	case TABF_NONE:
+		strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
+		break;
+	default:
+		switch (ts->TabStopFlag & TABF_HTS) {
+			case TABF_HTS7: strncpy_s(Temp, sizeof(Temp), "HTS7", _TRUNCATE); break;
+			case TABF_HTS8: strncpy_s(Temp, sizeof(Temp), "HTS8", _TRUNCATE); break;
+			case TABF_HTS:  strncpy_s(Temp, sizeof(Temp), "HTS",  _TRUNCATE); break;
+			default: Temp[0] = 0; break;
+		}
+
+		if (ts->TabStopFlag & TABF_TBC) {
+			if (Temp[0] != 0) {
+				strncat_s(Temp, sizeof(Temp), ",", _TRUNCATE);
+			}
+			switch (ts->TabStopFlag & TABF_TBC) {
+				case TABF_TBC0: strncat_s(Temp, sizeof(Temp), "TBC0", _TRUNCATE); break;
+				case TABF_TBC3: strncat_s(Temp, sizeof(Temp), "TBC3", _TRUNCATE); break;
+				case TABF_TBC:  strncat_s(Temp, sizeof(Temp), "TBC",  _TRUNCATE); break;
+			}
+		}
+
+		if (Temp[0] == 0) { // –³‚¢‚Í‚¸‚¾‚¯‚ê‚Ç”O‚Ì‚½‚ß
+			strncpy_s(Temp, sizeof(Temp), "off", _TRUNCATE);
+		}
+		break;
+	}
+	WritePrivateProfileString(Section, "TabStopModifySequence", Temp, FName);
 }
 
 #define VTEditor "VT editor keypad"



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