svnno****@sourc*****
svnno****@sourc*****
2012年 4月 12日 (木) 17:42:21 JST
Revision: 4893 http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4893 Author: maya Date: 2012-04-12 17:42:20 +0900 (Thu, 12 Apr 2012) Log Message: ----------- 受信改行コードに「自動」を追加 http://sourceforge.jp/ticket/browse.php?group_id=1412&tid=27837 tentner 氏のパッチを適用 Modified Paths: -------------- trunk/teraterm/common/tttypes.h trunk/teraterm/teraterm/vtterm.c trunk/teraterm/ttpdlg/ttdlg.c trunk/teraterm/ttpset/ttset.c -------------- next part -------------- Modified: trunk/teraterm/common/tttypes.h =================================================================== --- trunk/teraterm/common/tttypes.h 2012-04-11 22:47:15 UTC (rev 4892) +++ trunk/teraterm/common/tttypes.h 2012-04-12 08:42:20 UTC (rev 4893) @@ -565,6 +565,7 @@ #define IdCR 1 #define IdCRLF 2 #define IdLF 3 +#define IdAUTO 4 /* Terminal ID */ #define IdVT100 1 Modified: trunk/teraterm/teraterm/vtterm.c =================================================================== --- trunk/teraterm/teraterm/vtterm.c 2012-04-11 22:47:15 UTC (rev 4892) +++ trunk/teraterm/teraterm/vtterm.c 2012-04-12 08:42:20 UTC (rev 4893) @@ -83,6 +83,10 @@ } TStatusBuff; typedef TStatusBuff *PStatusBuff; +// currently only used for AUTO CR/LF receive mode +BYTE PrevCharacter; +BOOL PrevCRorLFGeneratedCRLF; // indicates that previous CR or LF really generated a CR+LF + // status buffer for main screen & status line static TStatusBuff SBuff1, SBuff2, SBuff3; @@ -267,6 +271,10 @@ // Saved IME Status IMEstat = FALSE; + + // previous received character + PrevCharacter = -1; // none + PrevCRorLFGeneratedCRLF = FALSE; } void ResetCharSet() @@ -864,15 +872,28 @@ case HT: Tab(); break; case LF: - // \x8E\xF3\x90M\x8E\x9E\x82̉\xFC\x8Ds\x83R\x81[\x83h\x82\xAA LF \x82̏ꍇ\x82́A\x83T\x81[\x83o\x82\xA9\x82\xE7 LF \x82݂̂\xAA\x91\x97\x82\xE7\x82\xEA\x82Ă\xAD\x82\xE9\x82Ɖ\xBC\x92肵\x81A - // CR+LF\x82Ƃ\xB5\x82Ĉ\xB5\x82\xA4\x82悤\x82ɂ\xB7\x82\xE9\x81B - // cf. http://www.neocom.ca/forum/viewtopic.php?t=216 - // (2007.1.21 yutaka) if (ts.CRReceive == IdLF) { + // \x8E\xF3\x90M\x8E\x9E\x82̉\xFC\x8Ds\x83R\x81[\x83h\x82\xAA LF \x82̏ꍇ\x82́A\x83T\x81[\x83o\x82\xA9\x82\xE7 LF \x82݂̂\xAA\x91\x97\x82\xE7\x82\xEA\x82Ă\xAD\x82\xE9\x82Ɖ\xBC\x92肵\x81A + // CR+LF\x82Ƃ\xB5\x82Ĉ\xB5\x82\xA4\x82悤\x82ɂ\xB7\x82\xE9\x81B + // cf. http://www.neocom.ca/forum/viewtopic.php?t=216 + // (2007.1.21 yutaka) CarriageReturn(TRUE); LineFeed(b, TRUE); break; } + else if (ts.CRReceive == IdAUTO) { + // 9th Apr 2012: AUTO CR/LF mode (tentner) + // a CR or LF will generated a CR+LF, if the next character is the opposite, it will be ignored + if(PrevCharacter != CR || !PrevCRorLFGeneratedCRLF) { + CarriageReturn(TRUE); + LineFeed(b, TRUE); + PrevCRorLFGeneratedCRLF = TRUE; + } + else { + PrevCRorLFGeneratedCRLF = FALSE; + } + break; + } case VT: LineFeed(b,TRUE); break; @@ -887,9 +908,24 @@ LineFeed(b,TRUE); break; case CR: - CarriageReturn(TRUE); - if (ts.CRReceive==IdCRLF) - CommInsert1Byte(&cv,LF); + if (ts.CRReceive == IdAUTO) { + // 9th Apr 2012: AUTO CR/LF mode (tentner) + // a CR or LF will generated a CR+LF, if the next character is the opposite, it will be ignored + if(PrevCharacter != LF || !PrevCRorLFGeneratedCRLF) { + CarriageReturn(TRUE); + LineFeed(b, TRUE); + PrevCRorLFGeneratedCRLF = TRUE; + } + else { + PrevCRorLFGeneratedCRLF = FALSE; + } + } + else { + CarriageReturn(TRUE); + if (ts.CRReceive==IdCRLF) { + CommInsert1Byte(&cv,LF); + } + } break; case SO: if ((ts.Language==IdJapanese) && @@ -4487,6 +4523,8 @@ } } + PrevCharacter = b; // memorize previous character for AUTO CR/LF-receive mode + if (ChangeEmu==0) c = CommRead1Byte(&cv,&b); } Modified: trunk/teraterm/ttpdlg/ttdlg.c =================================================================== --- trunk/teraterm/ttpdlg/ttdlg.c 2012-04-11 22:47:15 UTC (rev 4892) +++ trunk/teraterm/ttpdlg/ttdlg.c 2012-04-12 08:42:20 UTC (rev 4893) @@ -49,7 +49,7 @@ char UILanguageFile[MAX_PATH]; -static PCHAR far NLListRcv[] = {"CR","CR+LF", "LF", NULL}; +static PCHAR far NLListRcv[] = {"CR","CR+LF", "LF", "AUTO", NULL}; static PCHAR far NLList[] = {"CR","CR+LF", NULL}; static PCHAR far TermList[] = {"VT100", "VT101", "VT102", "VT282", "VT320", "VT382", @@ -267,7 +267,7 @@ if ( ts->TermIsWin>0 ) DisableDlgItem(Dialog,IDC_TERMRESIZE,IDC_TERMRESIZE); - SetDropDownList(Dialog, IDC_TERMCRRCV, NLListRcv, ts->CRReceive); // add 'LF' (2007.1.21 yutaka) + SetDropDownList(Dialog, IDC_TERMCRRCV, NLListRcv, ts->CRReceive); // add 'LF' (2007.1.21 yutaka), added "AUTO" (9th Apr 2012, tentner) SetDropDownList(Dialog, IDC_TERMCRSEND, NLList, ts->CRSend); if ( ts->Language!=IdJapanese ) { /* non-Japanese mode */ Modified: trunk/teraterm/ttpset/ttset.c =================================================================== --- trunk/teraterm/ttpset/ttset.c 2012-04-11 22:47:15 UTC (rev 4892) +++ trunk/teraterm/ttpset/ttset.c 2012-04-12 08:42:20 UTC (rev 4893) @@ -306,6 +306,9 @@ else if (_stricmp(Temp, "LF") == 0) { ts->CRReceive = IdLF; } + else if (_stricmp(Temp, "AUTO") == 0) { + ts->CRReceive = IdAUTO; + } else { ts->CRReceive = IdCR; } @@ -1561,6 +1564,9 @@ else if (ts->CRReceive == IdLF) { strncpy_s(Temp, sizeof(Temp), "LF", _TRUNCATE); } + else if (ts->CRReceive == IdAUTO) { + strncpy_s(Temp, sizeof(Temp), "AUTO", _TRUNCATE); + } else { strncpy_s(Temp, sizeof(Temp), "CR", _TRUNCATE); }