[Ttssh2-commit] [7086] DECSACE に対応 #33906

scmno****@osdn***** scmno****@osdn*****
2018年 3月 29日 (木) 23:58:31 JST


Revision: 7086
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7086
Author:   doda
Date:     2018-03-29 23:58:31 +0900 (Thu, 29 Mar 2018)
Log Message:
-----------
DECSACE に対応 #33906

DECCARA / DECRARA を DECSACE の設定に従って適用範囲を変更するようにした。

Ticket Links:
------------
    http://sourceforge.jp/projects/ttssh2/tracker/detail/33906

Modified Paths:
--------------
    trunk/teraterm/teraterm/buffer.c
    trunk/teraterm/teraterm/buffer.h
    trunk/teraterm/teraterm/vtterm.c

Added Paths:
-----------
    trunk/tests/#33906-decsace.sh

-------------- next part --------------
Modified: trunk/teraterm/teraterm/buffer.c
===================================================================
--- trunk/teraterm/teraterm/buffer.c	2018-03-29 14:58:25 UTC (rev 7085)
+++ trunk/teraterm/teraterm/buffer.c	2018-03-29 14:58:31 UTC (rev 7086)
@@ -1241,6 +1241,151 @@
 	BuffUpdateRect(XStart, YStart, XEnd, YEnd);
 }
 
+void BuffChangeAttrStream(int XStart, int YStart, int XEnd, int YEnd, PCharAttr attr, PCharAttr mask)
+{
+	int i, j, endp;
+	LONG Ptr;
+
+	if (XEnd>NumOfColumns-1) {
+		XEnd = NumOfColumns-1;
+	}
+	if (YEnd>NumOfLines-1-StatusLine) {
+		YEnd = NumOfLines-1-StatusLine;
+	}
+	if (XStart>XEnd || YStart>YEnd) {
+		return;
+	}
+
+	Ptr = GetLinePtr(PageStart+YStart);
+
+	if (mask) { // DECCARA
+		if (YStart == YEnd) {
+			i = Ptr + XStart - 1;
+			endp = Ptr + XEnd + 1;
+
+			if (XStart > 0 && (AttrBuff[i] & AttrKanji)) {
+				AttrBuff[i] = AttrBuff[i] & ~mask->Attr | attr->Attr;
+				AttrBuff2[i] = AttrBuff2[i] & ~mask->Attr2 | attr->Attr2;
+				AttrBuffFG[i] = attr->Fore;
+				AttrBuffBG[i] = attr->Back;
+			}
+			while (++i < endp) {
+				AttrBuff[i] = AttrBuff[i] & ~mask->Attr | attr->Attr;
+				AttrBuff2[i] = AttrBuff2[i] & ~mask->Attr2 | attr->Attr2;
+				AttrBuffFG[i] = attr->Fore;
+				AttrBuffBG[i] = attr->Back;
+			}
+			if (XEnd < NumOfColumns-1 && (AttrBuff[i-1] & AttrKanji)) {
+				AttrBuff[i] = AttrBuff[i] & ~mask->Attr | attr->Attr;
+				AttrBuff2[i] = AttrBuff2[i] & ~mask->Attr2 | attr->Attr2;
+				AttrBuffFG[i] = attr->Fore;
+				AttrBuffBG[i] = attr->Back;
+			}
+		}
+		else {
+			i = Ptr + XStart - 1;
+			endp = Ptr + NumOfColumns;
+
+			if (XStart > 0 && (AttrBuff[i] & AttrKanji)) {
+				AttrBuff[i] = AttrBuff[i] & ~mask->Attr | attr->Attr;
+				AttrBuff2[i] = AttrBuff2[i] & ~mask->Attr2 | attr->Attr2;
+				AttrBuffFG[i] = attr->Fore;
+				AttrBuffBG[i] = attr->Back;
+			}
+			while (++i < endp) {
+				AttrBuff[i] = AttrBuff[i] & ~mask->Attr | attr->Attr;
+				AttrBuff2[i] = AttrBuff2[i] & ~mask->Attr2 | attr->Attr2;
+				AttrBuffFG[i] = attr->Fore;
+				AttrBuffBG[i] = attr->Back;
+			}
+
+			for (j=0; j < YEnd-YStart-1; j++) {
+				Ptr = NextLinePtr(Ptr);
+				i = Ptr;
+				endp = Ptr + NumOfColumns;
+
+				while (i < endp) {
+					AttrBuff[i] = AttrBuff[i] & ~mask->Attr | attr->Attr;
+					AttrBuff2[i] = AttrBuff2[i] & ~mask->Attr2 | attr->Attr2;
+					AttrBuffFG[i] = attr->Fore;
+					AttrBuffBG[i] = attr->Back;
+					i++;
+				}
+			}
+
+			Ptr = NextLinePtr(Ptr);
+			i = Ptr;
+			endp = Ptr + XEnd + 1;
+
+			while (i < endp) {
+				AttrBuff[i] = AttrBuff[i] & ~mask->Attr | attr->Attr;
+				AttrBuff2[i] = AttrBuff2[i] & ~mask->Attr2 | attr->Attr2;
+				AttrBuffFG[i] = attr->Fore;
+				AttrBuffBG[i] = attr->Back;
+				i++;
+			}
+			if (XEnd < NumOfColumns-1 && (AttrBuff[i-1] & AttrKanji)) {
+				AttrBuff[i] = AttrBuff[i] & ~mask->Attr | attr->Attr;
+				AttrBuff2[i] = AttrBuff2[i] & ~mask->Attr2 | attr->Attr2;
+				AttrBuffFG[i] = attr->Fore;
+				AttrBuffBG[i] = attr->Back;
+			}
+		}
+	}
+	else { // DECRARA
+		if (YStart == YEnd) {
+			i = Ptr + XStart - 1;
+			endp = Ptr + XEnd + 1;
+
+			if (XStart > 0 && (AttrBuff[i] & AttrKanji)) {
+				AttrBuff[i] ^= attr->Attr;
+			}
+			while (++i < endp) {
+				AttrBuff[i] ^= attr->Attr;
+			}
+			if (XEnd < NumOfColumns-1 && (AttrBuff[i-1] & AttrKanji)) {
+				AttrBuff[i] ^= attr->Attr;
+			}
+		}
+		else {
+			i = Ptr + XStart - 1;
+			endp = Ptr + NumOfColumns;
+
+			if (XStart > 0 && (AttrBuff[i] & AttrKanji)) {
+				AttrBuff[i] ^= attr->Attr;
+			}
+			while (++i < endp) {
+				AttrBuff[i] ^= attr->Attr;
+			}
+
+			for (j=0; j < YEnd-YStart-1; j++) {
+				Ptr = NextLinePtr(Ptr);
+				i = Ptr;
+				endp = Ptr + NumOfColumns;
+
+				while (i < endp) {
+					AttrBuff[i] ^= attr->Attr;
+					i++;
+				}
+			}
+
+			Ptr = NextLinePtr(Ptr);
+			i = Ptr;
+			endp = Ptr + XEnd + 1;
+
+			while (i < endp) {
+				AttrBuff[i] ^= attr->Attr;
+				i++;
+			}
+			if (XEnd < NumOfColumns-1 && (AttrBuff[i-1] & AttrKanji)) {
+				AttrBuff[i] ^= attr->Attr;
+			}
+			Ptr = NextLinePtr(Ptr);
+		}
+	}
+	BuffUpdateRect(0, YStart, NumOfColumns-1, YEnd);
+}
+
 int LeftHalfOfDBCS(LONG Line, int CharPtr)
 // If CharPtr is on the right half of a DBCS character,
 // return pointer to the left half

Modified: trunk/teraterm/teraterm/buffer.h
===================================================================
--- trunk/teraterm/teraterm/buffer.h	2018-03-29 14:58:25 UTC (rev 7085)
+++ trunk/teraterm/teraterm/buffer.h	2018-03-29 14:58:31 UTC (rev 7086)
@@ -57,6 +57,7 @@
 void BuffFillBox(char c, int XStart, int YStart, int XEnd, int YEnd);
 void BuffCopyBox(int SrcXStart, int SrcYStart, int SrcXEnd, int SrcYEnd, int SrcPage, int DstX, int DstY, int DstPage);
 void BuffChangeAttrBox(int XStart, int YStart, int XEnd, int YEnd, PCharAttr attr, PCharAttr mask);
+void BuffChangeAttrStream(int XStart, int YStart, int XEnd, int YEnd, PCharAttr attr, PCharAttr mask);
 void BuffCBCopy(BOOL Table);
 void BuffPrint(BOOL ScrollRegion);
 void BuffDumpCurrentLine(BYTE TERM);

Modified: trunk/teraterm/teraterm/vtterm.c
===================================================================
--- trunk/teraterm/teraterm/vtterm.c	2018-03-29 14:58:25 UTC (rev 7085)
+++ trunk/teraterm/teraterm/vtterm.c	2018-03-29 14:58:31 UTC (rev 7086)
@@ -97,6 +97,7 @@
 static BOOL FocusReportMode;
 static BOOL AltScr;
 static BOOL LRMarginMode;
+static BOOL RectangleMode;
 BOOL BracketedPaste;
 
 static int VTlevel;
@@ -282,6 +283,7 @@
 	MouseReportExtMode = IdMouseTrackExtNone;
 	DecLocatorFlag = 0;
 	ClearThenHome = FALSE;
+	RectangleMode = FALSE;
 
 	ChangeTerminalID();
 
@@ -3446,11 +3448,21 @@
 			mask.Attr &= AttrSgrMask;
 			attr.Attr2 &= Attr2ColorMask;
 			mask.Attr2 &= Attr2ColorMask;
-			BuffChangeAttrBox(Param[2]-1, Param[1]-1, Param[4]-1, Param[3]-1, &attr, &mask);
+			if (RectangleMode) {
+				BuffChangeAttrBox(Param[2]-1, Param[1]-1, Param[4]-1, Param[3]-1, &attr, &mask);
+			}
+			else {
+				BuffChangeAttrStream(Param[2]-1, Param[1]-1, Param[4]-1, Param[3]-1, &attr, &mask);
+			}
 		}
 		else { // DECRARA
 			attr.Attr &= AttrSgrMask;
-			BuffChangeAttrBox(Param[2]-1, Param[1]-1, Param[4]-1, Param[3]-1, &attr, NULL);
+			if (RectangleMode) {
+			    BuffChangeAttrBox(Param[2]-1, Param[1]-1, Param[4]-1, Param[3]-1, &attr, NULL);
+			}
+			else {
+			    BuffChangeAttrStream(Param[2]-1, Param[1]-1, Param[4]-1, Param[3]-1, &attr, NULL);
+			}
 		}
 		break;
 
@@ -3731,6 +3743,23 @@
 	}
 }
 
+void CSAster(BYTE b)
+{
+	switch (b) {
+	  case 'x': // DECSACE
+		switch (Param[1]) {
+		  case 0:
+		  case 1:
+			RectangleMode = FALSE;
+			break;
+		  case 2:
+			RectangleMode = TRUE;
+			break;
+		}
+		break;
+	}
+}
+
 void PrnParseCS(BYTE b) // printer mode
 {
 	ParseMode = ModeFirst;
@@ -3849,6 +3878,7 @@
 			  case '!': CSExc(b); break;    /* intermediate char = '!' */
 			  case '"': CSDouble(b); break; /* intermediate char = '"' */
 			  case '$': CSDol(b); break;    /* intermediate char = '$' */
+			  case '*': CSAster(b); break;  /* intermediate char = '*' */
 			  case '\'': CSQuote(b); break; /* intermediate char = '\'' */
 			}
 			break; /* end of case Prv=0 */

Added: trunk/tests/#33906-decsace.sh
===================================================================
--- trunk/tests/#33906-decsace.sh	                        (rev 0)
+++ trunk/tests/#33906-decsace.sh	2018-03-29 14:58:31 UTC (rev 7086)
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# DECSACE の動作テスト
+# 通常は S と s に色および下線が付く。
+# DECSACE:2 の時のみ S だけに色と下線が付く。
+#
+
+waitkey() {
+	printf "push return"
+	read pause
+}
+
+SetTestingScreen() {
+	printf '\033[2J\033[18H'
+	printf '\033[46;1;1;16;9999$x'
+
+	printf '\033[4;1;4;9999$z'
+	printf '\033[9;1;9;9999$z'
+
+	printf '\033[83;2;11;2;20$x'
+	printf '\033[83;6;11;7;20$x'
+	printf '\033[83;11;11;15;20$x'
+
+	printf '\033[115;6;21;6;9999$x'
+	printf '\033[115;7;1;7;10$x'
+
+	printf '\033[115;11;21;14;9999$x'
+	printf '\033[115;12;1;15;10$x'
+}
+
+TestDECSACE() {
+	SetTestingScreen
+
+	[ $# -gt 0 ] && printf "\033[${1}*x"
+
+	printf '\033[2;11;2;20;1;35$r'
+	printf '\033[2;11;2;20;4$t'
+
+	printf '\033[6;11;7;20;1;35$r'
+	printf '\033[6;11;7;20;4$t'
+
+	printf '\033[11;11;15;20;1;35$r'
+	printf '\033[11;11;15;20;4$t'
+
+	if [ "x$1" = "x" ]; then
+		echo "Default"
+	else
+		echo "DECSACE: ${1}"
+	fi
+
+	sleep 1
+
+	printf "\033[7t"
+}
+
+TestDECSACE
+waitkey
+
+TestDECSACE 0
+waitkey
+
+TestDECSACE 1
+waitkey
+
+TestDECSACE 2
+waitkey
+
+TestDECSACE ""


Property changes on: trunk/tests/#33906-decsace.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property



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