• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision5095 (tree)
Time2012-12-11 06:46:32
Authordoda

Log Message

DECCARA, DECRARA を仮実装。DECSACEをまだ実装していないので、vttestは通りません。

Change Summary

Incremental Difference

--- trunk/teraterm/teraterm/buffer.c (revision 5094)
+++ trunk/teraterm/teraterm/buffer.c (revision 5095)
@@ -1081,6 +1081,67 @@
10811081 BuffUpdateRect(DstX,DstY,DstX+C-1,DstY+L-1);
10821082 }
10831083
1084+void BuffChangeAttrBox(int XStart, int YStart, int XEnd, int YEnd, PCharAttr attr, PCharAttr mask)
1085+{
1086+ int C, i, j;
1087+ LONG Ptr;
1088+
1089+ if (XEnd>NumOfColumns-1) {
1090+ XEnd = NumOfColumns-1;
1091+ }
1092+ if (YEnd>NumOfLines-1-StatusLine) {
1093+ YEnd = NumOfLines-1-StatusLine;
1094+ }
1095+ if (XStart>XEnd || YStart>YEnd) {
1096+ return;
1097+ }
1098+ C = XEnd-XStart+1;
1099+ Ptr = GetLinePtr(PageStart+YStart);
1100+
1101+ if (mask) { // DECCARA
1102+ for (i=YStart; i<=YEnd; i++) {
1103+ j = Ptr+XStart-1;
1104+ if (XStart>0 && (AttrBuff[j] & AttrKanji)) {
1105+ AttrBuff[j] = AttrBuff[j] & ~mask->Attr | attr->Attr;
1106+ AttrBuff[j] = AttrBuff2[j] & ~mask->Attr2 | attr->Attr2;
1107+ AttrBuffFG[j] = attr->Fore;
1108+ AttrBuffBG[j] = attr->Back;
1109+ j++;
1110+ }
1111+ while (j < Ptr+XStart+C) {
1112+ AttrBuff[j] = AttrBuff[j] & ~mask->Attr | attr->Attr;
1113+ AttrBuff2[j] = AttrBuff2[j] & ~mask->Attr2 | attr->Attr2;
1114+ AttrBuffFG[j] = attr->Fore;
1115+ AttrBuffBG[j] = attr->Back;
1116+ j++;
1117+ }
1118+ if (XStart+C<NumOfColumns && (AttrBuff[j-1] & AttrKanji)) {
1119+ AttrBuff[j] = AttrBuff[j] & ~mask->Attr | attr->Attr;
1120+ AttrBuff2[j] = AttrBuff2[j] & ~mask->Attr2 | attr->Attr2;
1121+ AttrBuffFG[j] = attr->Fore;
1122+ AttrBuffBG[j] = attr->Back;
1123+ }
1124+ Ptr = NextLinePtr(Ptr);
1125+ }
1126+ }
1127+ else { // DECRARA
1128+ for (i=YStart; i<=YEnd; i++) {
1129+ j = Ptr+XStart-1;
1130+ if (XStart>0 && (AttrBuff[j] & AttrKanji)) {
1131+ AttrBuff[j++] ^= attr->Attr;
1132+ }
1133+ while (j < Ptr+XStart+C) {
1134+ AttrBuff[j++] ^= attr->Attr;
1135+ }
1136+ if (XStart+C<NumOfColumns && (AttrBuff[j-1] & AttrKanji)) {
1137+ AttrBuff[j] ^= attr->Attr;
1138+ }
1139+ Ptr = NextLinePtr(Ptr);
1140+ }
1141+ }
1142+ BuffUpdateRect(XStart, YStart, XEnd, YEnd);
1143+}
1144+
10841145 int LeftHalfOfDBCS(LONG Line, int CharPtr)
10851146 // If CharPtr is on the right half of a DBCS character,
10861147 // return pointer to the left half
--- trunk/teraterm/teraterm/buffer.h (revision 5094)
+++ trunk/teraterm/teraterm/buffer.h (revision 5095)
@@ -31,6 +31,7 @@
3131 void BuffEraseBox(int XStart, int YStart, int XEnd, int YEnd);
3232 void BuffFillBox(char c, int XStart, int YStart, int XEnd, int YEnd);
3333 void BuffCopyBox(int SrcXStart, int SrcYStart, int SrcXEnd, int SrcYEnd, int SrcPage, int DstX, int DstY, int DstPage);
34+void BuffChangeAttrBox(int XStart, int YStart, int XEnd, int YEnd, PCharAttr attr, PCharAttr mask);
3435 void BuffCBCopy(BOOL Table);
3536 void BuffPrint(BOOL ScrollRegion);
3637 void BuffDumpCurrentLine(BYTE TERM);
--- trunk/teraterm/teraterm/vtterm.c (revision 5094)
+++ trunk/teraterm/teraterm/vtterm.c (revision 5095)
@@ -1835,64 +1835,66 @@
18351835 }
18361836 }
18371837
1838-void CSSetAttr() // SGR
1838+void ParseSGRParams(PCharAttr attr, PCharAttr mask, int start)
18391839 {
18401840 int i, j, P, r, g, b, color;
1841+ TCharAttr dummy;
18411842
1842- UpdateStr();
1843- for (i=1 ; i<=NParam ; i++)
1843+ if (mask == NULL) {
1844+ mask = &dummy;
1845+ }
1846+
1847+ for (i=start ; i<=NParam ; i++)
18441848 {
18451849 P = Param[i];
18461850 switch (P) {
18471851 case 0: /* Clear all */
1848- if (CharAttr.Attr2 & Attr2Protect) {
1849- CharAttr = DefCharAttr;
1850- CharAttr.Attr2 |= Attr2Protect;
1851- }
1852- else {
1853- CharAttr = DefCharAttr;
1854- }
1855- BuffSetCurCharAttr(CharAttr);
1852+ attr->Attr = DefCharAttr.Attr;
1853+ attr->Attr2 = DefCharAttr.Attr2 | (attr->Attr2&Attr2Protect);
1854+ attr->Fore = DefCharAttr.Fore;
1855+ attr->Back = DefCharAttr.Back;
1856+ mask->Attr = AttrSgrMask;
1857+ mask->Attr2 = Attr2ColorMask;
18561858 break;
18571859
18581860 case 1: /* Bold */
1859- CharAttr.Attr |= AttrBold;
1860- BuffSetCurCharAttr(CharAttr);
1861+ attr->Attr |= AttrBold;
1862+ mask->Attr |= AttrBold;
18611863 break;
18621864
18631865 case 4: /* Under line */
1864- CharAttr.Attr |= AttrUnder;
1865- BuffSetCurCharAttr(CharAttr);
1866+ attr->Attr |= AttrUnder;
1867+ mask->Attr |= AttrUnder;
18661868 break;
18671869
18681870 case 5: /* Blink */
1869- CharAttr.Attr |= AttrBlink;
1870- BuffSetCurCharAttr(CharAttr);
1871+ attr->Attr |= AttrBlink;
1872+ mask->Attr |= AttrBlink;
18711873 break;
18721874
18731875 case 7: /* Reverse */
1874- CharAttr.Attr |= AttrReverse;
1875- BuffSetCurCharAttr(CharAttr);
1876+ attr->Attr |= AttrReverse;
1877+ mask->Attr |= AttrReverse;
18761878 break;
18771879
18781880 case 22: /* Bold off */
1879- CharAttr.Attr &= ~ AttrBold;
1880- BuffSetCurCharAttr(CharAttr);
1881+ attr->Attr &= ~ AttrBold;
1882+ mask->Attr |= AttrBold;
18811883 break;
18821884
18831885 case 24: /* Under line off */
1884- CharAttr.Attr &= ~ AttrUnder;
1885- BuffSetCurCharAttr(CharAttr);
1886+ attr->Attr &= ~ AttrUnder;
1887+ mask->Attr |= AttrUnder;
18861888 break;
18871889
18881890 case 25: /* Blink off */
1889- CharAttr.Attr &= ~ AttrBlink;
1890- BuffSetCurCharAttr(CharAttr);
1891+ attr->Attr &= ~ AttrBlink;
1892+ mask->Attr |= AttrBlink;
18911893 break;
18921894
18931895 case 27: /* Reverse off */
1894- CharAttr.Attr &= ~ AttrReverse;
1895- BuffSetCurCharAttr(CharAttr);
1896+ attr->Attr &= ~ AttrReverse;
1897+ mask->Attr |= AttrReverse;
18961898 break;
18971899
18981900 case 30:
@@ -1903,9 +1905,9 @@
19031905 case 35:
19041906 case 36:
19051907 case 37: /* text color */
1906- CharAttr.Attr2 |= Attr2Fore;
1907- CharAttr.Fore = P - 30;
1908- BuffSetCurCharAttr(CharAttr);
1908+ attr->Attr2 |= Attr2Fore;
1909+ mask->Attr2 |= Attr2Fore;
1910+ attr->Fore = P - 30;
19091911 break;
19101912
19111913 case 38: /* text color (256color mode) */
@@ -1975,17 +1977,17 @@
19751977 break;
19761978 }
19771979 if (color >= 0 && color < 256) {
1978- CharAttr.Attr2 |= Attr2Fore;
1979- CharAttr.Fore = color;
1980- BuffSetCurCharAttr(CharAttr);
1980+ attr->Attr2 |= Attr2Fore;
1981+ mask->Attr2 |= Attr2Fore;
1982+ attr->Fore = color;
19811983 }
19821984 }
19831985 break;
19841986
19851987 case 39: /* Reset text color */
1986- CharAttr.Attr2 &= ~ Attr2Fore;
1987- CharAttr.Fore = AttrDefaultFG;
1988- BuffSetCurCharAttr(CharAttr);
1988+ attr->Attr2 &= ~ Attr2Fore;
1989+ mask->Attr2 |= Attr2Fore;
1990+ attr->Fore = AttrDefaultFG;
19891991 break;
19901992
19911993 case 40:
@@ -1996,9 +1998,9 @@
19961998 case 45:
19971999 case 46:
19982000 case 47: /* Back color */
1999- CharAttr.Attr2 |= Attr2Back;
2000- CharAttr.Back = P - 40;
2001- BuffSetCurCharAttr(CharAttr);
2001+ attr->Attr2 |= Attr2Back;
2002+ mask->Attr2 |= Attr2Back;
2003+ attr->Back = P - 40;
20022004 break;
20032005
20042006 case 48: /* Back color (256color mode) */
@@ -2057,17 +2059,17 @@
20572059 break;
20582060 }
20592061 if (color >= 0 && color < 256) {
2060- CharAttr.Attr2 |= Attr2Back;
2061- CharAttr.Back = color;
2062- BuffSetCurCharAttr(CharAttr);
2062+ attr->Attr2 |= Attr2Back;
2063+ mask->Attr2 |= Attr2Back;
2064+ attr->Back = color;
20632065 }
20642066 }
20652067 break;
20662068
20672069 case 49: /* Reset back color */
2068- CharAttr.Attr2 &= ~ Attr2Back;
2069- CharAttr.Back = AttrDefaultBG;
2070- BuffSetCurCharAttr(CharAttr);
2070+ attr->Attr2 &= ~ Attr2Back;
2071+ mask->Attr2 |= Attr2Back;
2072+ attr->Back = AttrDefaultBG;
20712073 break;
20722074
20732075 case 90:
@@ -2079,9 +2081,9 @@
20792081 case 96:
20802082 case 97: /* aixterm style text color */
20812083 if (ts.ColorFlag & CF_AIXTERM16) {
2082- CharAttr.Attr2 |= Attr2Fore;
2083- CharAttr.Fore = P - 90 + 8;
2084- BuffSetCurCharAttr(CharAttr);
2084+ attr->Attr2 |= Attr2Fore;
2085+ mask->Attr2 |= Attr2Fore;
2086+ attr->Fore = P - 90 + 8;
20852087 }
20862088 break;
20872089
@@ -2088,10 +2090,10 @@
20882090 case 100:
20892091 if (! (ts.ColorFlag & CF_AIXTERM16)) {
20902092 /* Reset text and back color */
2091- CharAttr.Attr2 &= ~ (Attr2Fore | Attr2Back);
2092- CharAttr.Fore = AttrDefaultFG;
2093- CharAttr.Back = AttrDefaultBG;
2094- BuffSetCurCharAttr(CharAttr);
2093+ attr->Attr2 &= ~ (Attr2Fore | Attr2Back);
2094+ mask->Attr2 |= Attr2ColorMask;
2095+ attr->Fore = AttrDefaultFG;
2096+ attr->Back = AttrDefaultBG;
20952097 break;
20962098 }
20972099 /* fall through to aixterm style back color */
@@ -2104,9 +2106,9 @@
21042106 case 106:
21052107 case 107: /* aixterm style back color */
21062108 if (ts.ColorFlag & CF_AIXTERM16) {
2107- CharAttr.Attr2 |= Attr2Back;
2108- CharAttr.Back = P - 100 + 8;
2109- BuffSetCurCharAttr(CharAttr);
2109+ attr->Attr2 |= Attr2Back;
2110+ mask->Attr2 |= Attr2Back;
2111+ attr->Back = P - 100 + 8;
21102112 }
21112113 break;
21122114 }
@@ -2113,6 +2115,13 @@
21132115 }
21142116 }
21152117
2118+void CSSetAttr() // SGR
2119+{
2120+ UpdateStr();
2121+ ParseSGRParams(&CharAttr, NULL, 1);
2122+ BuffSetCurCharAttr(CharAttr);
2123+}
2124+
21162125 void CSSetScrollRegion()
21172126 {
21182127 if ((StatusLine>0) &&
@@ -2811,7 +2820,42 @@
28112820
28122821 void CSDol(BYTE b)
28132822 {
2823+ TCharAttr attr, mask;
2824+ attr = DefCharAttr;
2825+ mask = DefCharAttr;
2826+
28142827 switch (b) {
2828+ case 'r': // DECCARA
2829+ case 't': // DECRARA
2830+ if (Param[1] < 1 || NParam < 1) Param[1] = 1;
2831+ if (Param[2] < 1 || NParam < 2) Param[2] = 1;
2832+ if (Param[3] < 1 || NParam < 3) Param[3] = NumOfLines-StatusLine;
2833+ if (Param[4] < 1 || NParam < 4) Param[4] = NumOfColumns;
2834+ if (Param[1] <= Param[3] && Param[2] <= Param[4]) {
2835+ if (RelativeOrgMode) {
2836+ Param[1] += CursorTop;
2837+ if (Param[1] > CursorBottom) {
2838+ Param[1] = CursorBottom + 1;
2839+ }
2840+ Param[3] += CursorTop;
2841+ if (Param[3] > CursorBottom) {
2842+ Param[3] = CursorBottom + 1;
2843+ }
2844+ }
2845+ }
2846+ ParseSGRParams(&attr, &mask, 5);
2847+ if (b == 'r') { // DECCARA
2848+ attr.Attr &= AttrSgrMask;
2849+ mask.Attr &= AttrSgrMask;
2850+ attr.Attr2 &= Attr2ColorMask;
2851+ mask.Attr2 &= Attr2ColorMask;
2852+ BuffChangeAttrBox(Param[2]-1, Param[1]-1, Param[4]-1, Param[3]-1, &attr, &mask);
2853+ }
2854+ else { // DECRARA
2855+ attr.Attr &= AttrSgrMask;
2856+ BuffChangeAttrBox(Param[2]-1, Param[1]-1, Param[4]-1, Param[3]-1, &attr, NULL);
2857+ }
2858+ break;
28152859 case 'v': // DECCRA
28162860 if (Param[1] < 1 || NParam < 1) Param[1] = 1;
28172861 if (Param[2] < 1 || NParam < 2) Param[2] = 1;
Show on old repository browser