svnno****@sourc*****
svnno****@sourc*****
2010年 8月 31日 (火) 18:18:28 JST
Revision: 4070 http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4070 Author: doda Date: 2010-08-31 18:18:28 +0900 (Tue, 31 Aug 2010) Log Message: ----------- Selective Erase に対応。 Modified Paths: -------------- trunk/teraterm/common/tttypes.h trunk/teraterm/teraterm/buffer.c trunk/teraterm/teraterm/buffer.h trunk/teraterm/teraterm/vtterm.c -------------- next part -------------- Modified: trunk/teraterm/common/tttypes.h =================================================================== --- trunk/teraterm/common/tttypes.h 2010-08-31 05:20:43 UTC (rev 4069) +++ trunk/teraterm/common/tttypes.h 2010-08-31 09:18:28 UTC (rev 4070) @@ -56,6 +56,8 @@ #define AttrColorMask (AttrBold | AttrBlink | AttrReverse) #define Attr2ColorMask (Attr2Fore | Attr2Back) +#define Attr2Protect 0x04 + typedef struct { BYTE Attr; BYTE Attr2; Modified: trunk/teraterm/teraterm/buffer.c =================================================================== --- trunk/teraterm/teraterm/buffer.c 2010-08-31 05:20:43 UTC (rev 4069) +++ trunk/teraterm/teraterm/buffer.c 2010-08-31 09:18:28 UTC (rev 4070) @@ -464,7 +464,7 @@ memcpy(&(AttrBuffBG[DestPtr]),&(AttrBuffBG[SrcPtr]),NumOfColumns); memset(&(CodeBuff[SrcPtr]),0x20,NumOfColumns); memset(&(AttrBuff[SrcPtr]),AttrDefault,NumOfColumns); - memset(&(AttrBuff2[SrcPtr]),CurCharAttr.Attr2,NumOfColumns); + memset(&(AttrBuff2[SrcPtr]),CurCharAttr.Attr2 & Attr2ColorMask, NumOfColumns); memset(&(AttrBuffFG[SrcPtr]),CurCharAttr.Fore,NumOfColumns); memset(&(AttrBuffBG[SrcPtr]),CurCharAttr.Back,NumOfColumns); SrcPtr = PrevLinePtr(SrcPtr); @@ -475,7 +475,7 @@ for (i = 1 ; i <= n ; i++) { memset(&CodeBuff[DestPtr],0x20,NumOfColumns); memset(&AttrBuff[DestPtr],AttrDefault,NumOfColumns); - memset(&AttrBuff2[DestPtr],CurCharAttr.Attr2,NumOfColumns); + memset(&AttrBuff2[DestPtr],CurCharAttr.Attr2 & Attr2ColorMask, NumOfColumns); memset(&AttrBuffFG[DestPtr],CurCharAttr.Fore,NumOfColumns); memset(&AttrBuffBG[DestPtr],CurCharAttr.Back,NumOfColumns); DestPtr = PrevLinePtr(DestPtr); @@ -580,7 +580,7 @@ NumOfColumns-Count-CursorX); memset(&(CodeLine[CursorX]),0x20,Count); memset(&(AttrLine[CursorX]),AttrDefault,Count); - memset(&(AttrLine2[CursorX]),CurCharAttr.Attr2,Count); + memset(&(AttrLine2[CursorX]),CurCharAttr.Attr2 & Attr2ColorMask, Count); memset(&(AttrLineFG[CursorX]),CurCharAttr.Fore,Count); memset(&(AttrLineBG[CursorX]),CurCharAttr.Back,Count); /* last char in current line is kanji first? */ @@ -616,7 +616,7 @@ for (i = CursorY ; i <= YEnd ; i++) { memset(&(CodeBuff[TmpPtr+offset]),0x20,NumOfColumns-offset); memset(&(AttrBuff[TmpPtr+offset]),AttrDefault,NumOfColumns-offset); - memset(&(AttrBuff2[TmpPtr+offset]),CurCharAttr.Attr2,NumOfColumns-offset); + memset(&(AttrBuff2[TmpPtr+offset]),CurCharAttr.Attr2 & Attr2ColorMask, NumOfColumns-offset); memset(&(AttrBuffFG[TmpPtr+offset]),CurCharAttr.Fore,NumOfColumns-offset); memset(&(AttrBuffBG[TmpPtr+offset]),CurCharAttr.Back,NumOfColumns-offset); offset = 0; @@ -651,7 +651,7 @@ } memset(&(CodeBuff[TmpPtr]),0x20,offset); memset(&(AttrBuff[TmpPtr]),AttrDefault,offset); - memset(&(AttrBuff2[TmpPtr]),CurCharAttr.Attr2,offset); + memset(&(AttrBuff2[TmpPtr]),CurCharAttr.Attr2 & Attr2ColorMask, offset); memset(&(AttrBuffFG[TmpPtr]),CurCharAttr.Fore,offset); memset(&(AttrBuffBG[TmpPtr]),CurCharAttr.Back,offset); TmpPtr = NextLinePtr(TmpPtr); @@ -685,7 +685,7 @@ for (i = 1 ; i <= Count ; i++) { memset(&(CodeBuff[DestPtr]),0x20,NumOfColumns); memset(&(AttrBuff[DestPtr]),AttrDefault,NumOfColumns); - memset(&(AttrBuff2[DestPtr]),CurCharAttr.Attr2,NumOfColumns); + memset(&(AttrBuff2[DestPtr]),CurCharAttr.Attr2 & Attr2ColorMask, NumOfColumns); memset(&(AttrBuffFG[DestPtr]),CurCharAttr.Fore,NumOfColumns); memset(&(AttrBuffBG[DestPtr]),CurCharAttr.Back,NumOfColumns); DestPtr = PrevLinePtr(DestPtr); @@ -716,7 +716,7 @@ NewLine(PageStart+CursorY); memset(&(CodeLine[XStart]),0x20,Count); memset(&(AttrLine[XStart]),AttrDefault,Count); - memset(&(AttrLine2[XStart]),CurCharAttr.Attr2,Count); + memset(&(AttrLine2[XStart]),CurCharAttr.Attr2 & Attr2ColorMask, Count); memset(&(AttrLineFG[XStart]),CurCharAttr.Fore,Count); memset(&(AttrLineBG[XStart]),CurCharAttr.Back,Count); @@ -759,7 +759,7 @@ for (i = YEnd+1-Count ; i<=YEnd ; i++) { memset(&(CodeBuff[DestPtr]),0x20,NumOfColumns); memset(&(AttrBuff[DestPtr]),AttrDefault,NumOfColumns); - memset(&(AttrBuff2[DestPtr]),CurCharAttr.Attr2,NumOfColumns); + memset(&(AttrBuff2[DestPtr]),CurCharAttr.Attr2 & Attr2ColorMask, NumOfColumns); memset(&(AttrBuffFG[DestPtr]),CurCharAttr.Fore,NumOfColumns); memset(&(AttrBuffBG[DestPtr]),CurCharAttr.Back,NumOfColumns); DestPtr = NextLinePtr(DestPtr); @@ -796,7 +796,7 @@ NumOfColumns-Count-CursorX); memset(&(CodeLine[NumOfColumns-Count]),0x20,Count); memset(&(AttrLine[NumOfColumns-Count]),AttrDefault,Count); - memset(&(AttrLine2[NumOfColumns-Count]),CurCharAttr.Attr2,Count); + memset(&(AttrLine2[NumOfColumns-Count]),CurCharAttr.Attr2 & Attr2ColorMask, Count); memset(&(AttrLineFG[NumOfColumns-Count]),CurCharAttr.Fore,Count); memset(&(AttrLineBG[NumOfColumns-Count]),CurCharAttr.Back,Count); @@ -819,7 +819,7 @@ } memset(&(CodeLine[CursorX]),0x20,Count); memset(&(AttrLine[CursorX]),AttrDefault,Count); - memset(&(AttrLine2[CursorX]),CurCharAttr.Attr2,Count); + memset(&(AttrLine2[CursorX]),CurCharAttr.Attr2 & Attr2ColorMask, Count); memset(&(AttrLineFG[CursorX]),CurCharAttr.Fore,Count); memset(&(AttrLineBG[CursorX]),CurCharAttr.Back,Count); @@ -954,7 +954,7 @@ } memset(&(CodeBuff[Ptr+XStart]),0x20,C); memset(&(AttrBuff[Ptr+XStart]),AttrDefault,C); - memset(&(AttrBuff2[Ptr+XStart]),CurCharAttr.Attr2,C); + memset(&(AttrBuff2[Ptr+XStart]),CurCharAttr.Attr2 & Attr2ColorMask, C); memset(&(AttrBuffFG[Ptr+XStart]),CurCharAttr.Fore,C); memset(&(AttrBuffBG[Ptr+XStart]),CurCharAttr.Back,C); Ptr = NextLinePtr(Ptr); @@ -1812,7 +1812,7 @@ } memset(&(CodeBuff[SrcPtr]),0x20,NumOfColumns); memset(&(AttrBuff[SrcPtr]),AttrDefault,NumOfColumns); - memset(&(AttrBuff2[SrcPtr]),CurCharAttr.Attr2,NumOfColumns); + memset(&(AttrBuff2[SrcPtr]),CurCharAttr.Attr2 & Attr2ColorMask, NumOfColumns); memset(&(AttrBuffFG[SrcPtr]),CurCharAttr.Fore,NumOfColumns); memset(&(AttrBuffBG[SrcPtr]),CurCharAttr.Back,NumOfColumns); @@ -1872,7 +1872,7 @@ for (i = CursorBottom+1-n ; i<=CursorBottom; i++) { memset(&(CodeBuff[DestPtr]),0x20,NumOfColumns); memset(&(AttrBuff[DestPtr]),AttrDefault,NumOfColumns); - memset(&(AttrBuff2[DestPtr]),CurCharAttr.Attr2,NumOfColumns); + memset(&(AttrBuff2[DestPtr]),CurCharAttr.Attr2 & Attr2ColorMask, NumOfColumns); memset(&(AttrBuffFG[DestPtr]),CurCharAttr.Fore,NumOfColumns); memset(&(AttrBuffBG[DestPtr]),CurCharAttr.Back,NumOfColumns); DestPtr = NextLinePtr(DestPtr); @@ -1920,7 +1920,7 @@ for (i = CursorBottom+1-n ; i<=CursorBottom; i++) { memset(&(CodeBuff[DestPtr]),0x20,NumOfColumns); memset(&(AttrBuff[DestPtr]),AttrDefault,NumOfColumns); - memset(&(AttrBuff2[DestPtr]),CurCharAttr.Attr2,NumOfColumns); + memset(&(AttrBuff2[DestPtr]),CurCharAttr.Attr2 & Attr2ColorMask, NumOfColumns); memset(&(AttrBuffFG[DestPtr]),CurCharAttr.Fore,NumOfColumns); memset(&(AttrBuffBG[DestPtr]),CurCharAttr.Back,NumOfColumns); DestPtr = NextLinePtr(DestPtr); @@ -1958,7 +1958,7 @@ for (i = CursorTop+n-1; i>=CursorTop; i--) { memset(&(CodeBuff[DestPtr]),0x20,NumOfColumns); memset(&(AttrBuff[DestPtr]),AttrDefault,NumOfColumns); - memset(&(AttrBuff2[DestPtr]),CurCharAttr.Attr2,NumOfColumns); + memset(&(AttrBuff2[DestPtr]),CurCharAttr.Attr2 & Attr2ColorMask, NumOfColumns); memset(&(AttrBuffFG[DestPtr]),CurCharAttr.Fore,NumOfColumns); memset(&(AttrBuffBG[DestPtr]),CurCharAttr.Back,NumOfColumns); DestPtr = PrevLinePtr(DestPtr); @@ -2971,7 +2971,7 @@ NewLine(0); memset(&CodeBuff[0],0x20,BufferSize); memset(&AttrBuff[0],AttrDefault,BufferSize); - memset(&AttrBuff2[0],CurCharAttr.Attr2,BufferSize); + memset(&AttrBuff2[0],CurCharAttr.Attr2 & Attr2ColorMask, BufferSize); memset(&AttrBuffFG[0],CurCharAttr.Fore,BufferSize); memset(&AttrBuffBG[0],CurCharAttr.Back,BufferSize); @@ -3269,3 +3269,132 @@ SaveBuff = NULL; } } + +void BuffSelectedEraseCurToEnd() +// Erase characters from cursor to the end of screen +{ + LONG TmpPtr; + int offset; + int i, j, YEnd; + + NewLine(PageStart+CursorY); + if (ts.Language==IdJapanese || ts.Language==IdKorean || ts.Language==IdUtf8) { + if (!(AttrLine2[CursorX] & Attr2Protect)) { + EraseKanji(1); /* if cursor is on right half of a kanji, erase the kanji */ + } + } + offset = CursorX; + TmpPtr = GetLinePtr(PageStart+CursorY); + YEnd = NumOfLines-1; + if ((StatusLine>0) && + (CursorY<NumOfLines-1)) { + YEnd--; + } + for (i = CursorY ; i <= YEnd ; i++) { + for (j = TmpPtr + offset; j < TmpPtr + NumOfColumns - offset; j++) { + if (!(AttrBuff2[j] & Attr2Protect)) { + CodeBuff[j] = 0x20; + AttrBuff[j] = AttrDefault; + AttrBuff2[j] = CurCharAttr.Attr2 & Attr2ColorMask; + AttrBuffFG[j] = CurCharAttr.Fore; + AttrBuffBG[j] = CurCharAttr.Back; + } + } + offset = 0; + TmpPtr = NextLinePtr(TmpPtr); + } + /* update window */ + BuffUpdateRect(1, CursorY, NumOfColumns, YEnd); +} + +void BuffSelectedEraseHomeToCur() +// Erase characters from home to cursor +{ + LONG TmpPtr; + int offset; + int i, j, YHome; + + NewLine(PageStart+CursorY); + if (ts.Language==IdJapanese || ts.Language==IdKorean || ts.Language==IdUtf8) { + if (!(AttrLine2[CursorX] & Attr2Protect)) { + EraseKanji(0); /* if cursor is on left half of a kanji, erase the kanji */ + } + } + offset = NumOfColumns; + if ((StatusLine>0) && (CursorY==NumOfLines-1)) { + YHome = CursorY; + } + else { + YHome = 0; + } + TmpPtr = GetLinePtr(PageStart+YHome); + for (i = YHome ; i <= CursorY ; i++) { + if (i==CursorY) { + offset = CursorX+1; + } + for (j = TmpPtr; j < TmpPtr + offset; j++) { + if (!(AttrBuff2[j] & Attr2Protect)) { + CodeBuff[j] = 0x20; + AttrBuff[j] = AttrDefault; + AttrBuff2[j] = CurCharAttr.Attr2 & Attr2ColorMask; + AttrBuffFG[j] = CurCharAttr.Fore; + AttrBuffBG[j] = CurCharAttr.Back; + } + } + TmpPtr = NextLinePtr(TmpPtr); + } + + /* update window */ + BuffUpdateRect(1, YHome, NumOfColumns, CursorY); +} + +void BuffSelectedEraseScreen() { + BuffSelectedEraseHomeToCur(); + BuffSelectedEraseCurToEnd(); +} + +void BuffSelectedEraseCharsInLine(int XStart, int Count) +// erase non-protected characters in the current line +// XStart: start position of erasing +// Count: number of characters to be erased +{ + int i; +#ifndef NO_COPYLINE_FIX + BOOL LineContinued=FALSE; + + if (ts.EnableContinuedLineCopy && XStart == 0 && (AttrLine[0] & AttrLineContinued)) { + LineContinued = TRUE; + } +#endif /* NO_COPYLINE_FIX */ + + if (ts.Language==IdJapanese || ts.Language==IdKorean || ts.Language==IdUtf8) { + if (!(AttrLine2[CursorX] & Attr2Protect)) { + EraseKanji(1); /* if cursor is on right half of a kanji, erase the kanji */ + } + } + + NewLine(PageStart+CursorY); + for (i=XStart; i < XStart + Count; i++) { + if (!(AttrLine2[i] & Attr2Protect)) { + CodeLine[i] = 0x20; + AttrLine[i] = AttrDefault; + AttrLine2[i] = CurCharAttr.Attr2 & Attr2ColorMask; + AttrLineFG[i] = CurCharAttr.Fore; + AttrLineBG[i] = CurCharAttr.Back; + } + } + +#ifndef NO_COPYLINE_FIX + if (ts.EnableContinuedLineCopy) { + if (LineContinued) { + BuffLineContinued(TRUE); + } + + if (XStart + Count >= NumOfColumns) { + AttrBuff[NextLinePtr(LinePtr)] &= ~AttrLineContinued; + } + } +#endif /* NO_COPYLINE_FIX */ + + BuffUpdateRect(XStart, CursorY, XStart+Count, CursorY); +} Modified: trunk/teraterm/teraterm/buffer.h =================================================================== --- trunk/teraterm/teraterm/buffer.h 2010-08-31 05:20:43 UTC (rev 4069) +++ trunk/teraterm/teraterm/buffer.h 2010-08-31 09:18:28 UTC (rev 4070) @@ -71,6 +71,10 @@ void BuffSaveScreen(); void BuffRestoreScreen(); void BuffDiscardSavedScreen(); +void BuffSelectedEraseCharsInLine(int XStart, int Count); +void BuffSelectedEraseCurToEnd(); +void BuffSelectedEraseHomeToCur(); +void BuffSelectedEraseScreen(); extern int StatusLine; extern int CursorTop, CursorBottom; Modified: trunk/teraterm/teraterm/vtterm.c =================================================================== --- trunk/teraterm/teraterm/vtterm.c 2010-08-31 05:20:43 UTC (rev 4069) +++ trunk/teraterm/teraterm/vtterm.c 2010-08-31 09:18:28 UTC (rev 4070) @@ -1404,6 +1404,28 @@ } } +void CSQSelScreenErase() +{ + if (Param[1] == -1) Param[1] = 0; + BuffUpdateScroll(); + switch (Param[1]) { + case 0: + // Erase characters from cursor to end + BuffSelectedEraseCurToEnd(); + break; + + case 1: + // Erase characters from home to cursor + BuffSelectedEraseHomeToCur(); + break; + + case 2: + // Erase entire screen + BuffSelectedEraseScreen(); + break; + } +} + void CSInsertLine() { // Insert lines at current position @@ -1441,6 +1463,26 @@ } } + void CSQSelLineErase() + { + if (Param[1] == -1) Param[1] = 0; + BuffUpdateScroll(); + switch (Param[1]) { + /* erase char from cursor to end of line */ + case 0: + BuffSelectedEraseCharsInLine(CursorX,NumOfColumns-CursorX); + break; + /* erase char from start of line to cursor */ + case 1: + BuffSelectedEraseCharsInLine(0,CursorX+1); + break; + /* erase entire line */ + case 2: + BuffSelectedEraseCharsInLine(0,NumOfColumns); + break; + } + } + void CSDeleteNLines() // Delete lines from current line { @@ -1691,7 +1733,13 @@ if (P<0) P = 0; switch (P) { case 0: /* Clear all */ - CharAttr = DefCharAttr; + if (CharAttr.Attr2 & Attr2Protect) { + CharAttr = DefCharAttr; + CharAttr.Attr2 |= Attr2Protect; + } + else { + CharAttr = DefCharAttr; + } BuffSetCurCharAttr(CharAttr); break; @@ -2369,7 +2417,8 @@ void CSQuest(BYTE b) { switch (b) { - case 'K': CSLineErase(); break; // DECSEL + case 'J': CSQSelScreenErase(); break; // DECSED + case 'K': CSQSelLineErase(); break; // DECSEL case 'h': CSQ_h_Mode(); break; // DECSET case 'i': CSQ_i_Mode(); break; // DECMC case 'l': CSQ_l_Mode(); break; // DECRST @@ -2436,6 +2485,24 @@ } } break; + case 'q': // DECSCA + if (Param[1] < 0) + Param[1] = 0; + switch (Param[1]) { + case 0: + case 2: + CharAttr.Attr2 &= ~Attr2Protect; + BuffSetCurCharAttr(CharAttr); + break; + case 1: + CharAttr.Attr2 |= Attr2Protect; + BuffSetCurCharAttr(CharAttr); + break; + default: + /* nothing to do */ + break; + } + break; } }