[Ttssh2-commit] [3904] ファイル送信も Bracketed Paste Mode の適用対象に。

svnno****@sourc***** svnno****@sourc*****
2010年 5月 22日 (土) 15:57:02 JST


Revision: 3904
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3904
Author:   doda
Date:     2010-05-22 15:57:02 +0900 (Sat, 22 May 2010)

Log Message:
-----------
ファイル送信も Bracketed Paste Mode の適用対象に。

Modified Paths:
--------------
    trunk/teraterm/teraterm/filesys.cpp
    trunk/teraterm/teraterm/vtterm.c
    trunk/teraterm/teraterm/vtterm.h
    trunk/teraterm/teraterm/vtwin.cpp


-------------- next part --------------
Modified: trunk/teraterm/teraterm/filesys.cpp
===================================================================
--- trunk/teraterm/teraterm/filesys.cpp	2010-05-21 14:51:24 UTC (rev 3903)
+++ trunk/teraterm/teraterm/filesys.cpp	2010-05-22 06:57:02 UTC (rev 3904)
@@ -17,10 +17,15 @@
 #include "ttlib.h"
 #include "helpid.h"
 #include "dlglib.h"
+#include "vtterm.h"
 
 #include "filesys.h"
 #include "ftlib.h"
 
+#define FS_BRACKET_NONE  0
+#define FS_BRACKET_START 1
+#define FS_BRACKET_END   2
+
 PFileVar LogVar = NULL;
 PFileVar SendVar = NULL;
 PFileVar FileVar = NULL;
@@ -31,9 +36,14 @@
 BOOL FileLog = FALSE;
 BOOL BinLog = FALSE;
 BOOL DDELog = FALSE;
-static BOOL FileRetrySend, FileRetryEcho, FileCRSend;
+static BOOL FileRetrySend, FileRetryEcho, FileCRSend, FileReadEOF, BinaryMode;
 static BYTE FileByte;
 
+static int FileBracketMode = FS_BRACKET_NONE;
+static int FileBracketPtr = 0;
+static char BracketStartStr[] = "\033[200~";
+static char BracketEndStr[] = "\033[201~";
+
 static BOOL FSend = FALSE;
 
 HWND HWndLog = NULL; //steven add 
@@ -833,7 +843,18 @@
 	FileRetrySend = FALSE;
 	FileRetryEcho = FALSE;
 	FileCRSend = FALSE;
+	FileReadEOF = FALSE;
 
+	if (BracketedPasteMode()) {
+		FileBracketMode = FS_BRACKET_START;
+		FileBracketPtr = 0;
+		BinaryMode = TRUE;
+	}
+	else {
+		FileBracketMode = FS_BRACKET_NONE;
+		BinaryMode = ts.TransBin;
+	}
+
 	if (! OpenFTDlg(SendVar))
 		FileTransEnd(OpSendFile);
 	}
@@ -878,7 +899,7 @@
 
 int FSOut1(BYTE b)
 {
-	if (ts.TransBin > 0)
+	if (BinaryMode)
 		return CommBinaryOut(&cv,(PCHAR)&b,1);
 	else if ((b>=0x20) || (b==0x09) || (b==0x0A) || (b==0x0D))
 		return CommTextOut(&cv,(PCHAR)&b,1);
@@ -888,7 +909,7 @@
 
 int FSEcho1(BYTE b)
 {
-	if (ts.TransBin > 0)
+	if (BinaryMode)
 		return CommBinaryEcho(&cv,(PCHAR)&b,1);
 	else
 		return CommTextEcho(&cv,(PCHAR)&b,1);
@@ -924,15 +945,42 @@
 	}
 
 	do {
-		fc = _lread(SendVar->FileHandle,&FileByte,1);
-		SendVar->ByteCount = SendVar->ByteCount + fc;
+		if (FileBracketMode == FS_BRACKET_START) {
+			FileByte = BracketStartStr[FileBracketPtr++];
+			fc = 1;
 
-		if (FileCRSend && (fc==1) && (FileByte==0x0A))
-		{
+			if (FileBracketPtr >= sizeof(BracketStartStr) - 1) {
+				FileBracketMode = FS_BRACKET_END;
+				FileBracketPtr = 0;
+				BinaryMode = ts.TransBin;
+			}
+		}
+		else if (! FileReadEOF) {
 			fc = _lread(SendVar->FileHandle,&FileByte,1);
 			SendVar->ByteCount = SendVar->ByteCount + fc;
+
+			if (FileCRSend && (fc==1) && (FileByte==0x0A)) {
+				fc = _lread(SendVar->FileHandle,&FileByte,1);
+				SendVar->ByteCount = SendVar->ByteCount + fc;
+			}
 		}
+		else {
+			fc = 0;
+		}
 
+		if (fc == 0 && FileBracketMode == FS_BRACKET_END) {
+			FileReadEOF = TRUE;
+			FileByte = BracketEndStr[FileBracketPtr++];
+			fc = 1;
+			BinaryMode = TRUE;
+
+			if (FileBracketPtr >= sizeof(BracketEndStr) - 1) {
+				FileBracketMode = FS_BRACKET_NONE;
+				FileBracketPtr = 0;
+			}
+		}
+
+
 		if (fc!=0)
 		{
 			c = FSOut1(FileByte);
@@ -952,8 +1000,7 @@
 					return;
 			}
 		}
-		if ((fc==0) || (SendVar->ByteCount % 100 == 0))
-		{
+		if ((fc==0) || ((SendVar->ByteCount % 100 == 0) && (FileBracketPtr == 0))) {
 			SendDlg->RefreshNum();
 			BCOld = SendVar->ByteCount;
 			if (fc!=0)

Modified: trunk/teraterm/teraterm/vtterm.c
===================================================================
--- trunk/teraterm/teraterm/vtterm.c	2010-05-21 14:51:24 UTC (rev 3903)
+++ trunk/teraterm/teraterm/vtterm.c	2010-05-22 06:57:02 UTC (rev 3904)
@@ -3769,3 +3769,7 @@
 	}
 	CLocale = NULL;
 }
+
+BOOL BracketedPasteMode() {
+	return BracketedPaste;
+}

Modified: trunk/teraterm/teraterm/vtterm.h
===================================================================
--- trunk/teraterm/teraterm/vtterm.h	2010-05-21 14:51:24 UTC (rev 3903)
+++ trunk/teraterm/teraterm/vtterm.h	2010-05-22 06:57:02 UTC (rev 3904)
@@ -17,10 +17,9 @@
 int VTParse();
 void FocusReport(BOOL Focus);
 BOOL MouseReport(int Event, int Button, int Xpos, int Ypos);
+BOOL BracketedPasteMode();
 void EndTerm();
 
-extern BOOL BracketedPaste;
-
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2010-05-21 14:51:24 UTC (rev 3903)
+++ trunk/teraterm/teraterm/vtwin.cpp	2010-05-22 06:57:02 UTC (rev 3904)
@@ -783,7 +783,7 @@
 	// added ConfirmPasteMouseRButton (2007.3.17 maya)
 	if (pasteRButton && !ts.ConfirmPasteMouseRButton) {
 		if (CBStartPasteConfirmChange(HVTWin)) {
-			CBStartPaste(HVTWin, FALSE, BracketedPaste, 0, NULL, 0);
+			CBStartPaste(HVTWin, FALSE, BracketedPasteMode(), 0, NULL, 0);
 			/* Å‰ºs‚Å‚¾‚¯Ž©“®ƒXƒNƒ[ƒ‹‚·‚éÝ’è‚̏ꍇ
 			   ƒy[ƒXƒgˆ—‚ŃXƒNƒ[ƒ‹‚³‚¹‚é */
 			if (ts.AutoScrollOnlyInBottomLine != 0 && WinOrgY != 0) {
@@ -793,7 +793,7 @@
 	}
 	else if (pasteMButton) {
 		if (CBStartPasteConfirmChange(HVTWin)) {
-			CBStartPaste(HVTWin, FALSE, BracketedPaste, 0, NULL, 0);
+			CBStartPaste(HVTWin, FALSE, BracketedPasteMode(), 0, NULL, 0);
 			/* Å‰ºs‚Å‚¾‚¯Ž©“®ƒXƒNƒ[ƒ‹‚·‚éÝ’è‚̏ꍇ
 			   ƒy[ƒXƒgˆ—‚ŃXƒNƒ[ƒ‹‚³‚¹‚é */
 			if (ts.AutoScrollOnlyInBottomLine != 0 && WinOrgY != 0) {
@@ -3932,7 +3932,7 @@
 {
 	// add confirm (2008.2.4 yutaka)
 	if (CBStartPasteConfirmChange(HVTWin)) {
-		CBStartPaste(HVTWin, FALSE, BracketedPaste, 0, NULL, 0);
+		CBStartPaste(HVTWin, FALSE, BracketedPasteMode(), 0, NULL, 0);
 		/* Å‰ºs‚Å‚¾‚¯Ž©“®ƒXƒNƒ[ƒ‹‚·‚éÝ’è‚̏ꍇ
 		   ƒy[ƒXƒgˆ—‚ŃXƒNƒ[ƒ‹‚³‚¹‚é */
 		if (ts.AutoScrollOnlyInBottomLine != 0 && WinOrgY != 0) {
@@ -3945,7 +3945,7 @@
 {
 	// add confirm (2008.3.11 maya)
 	if (CBStartPasteConfirmChange(HVTWin)) {
-		CBStartPaste(HVTWin, TRUE, BracketedPaste, 0, NULL, 0);
+		CBStartPaste(HVTWin, TRUE, BracketedPasteMode(), 0, NULL, 0);
 		/* Å‰ºs‚Å‚¾‚¯Ž©“®ƒXƒNƒ[ƒ‹‚·‚éÝ’è‚̏ꍇ
 		   ƒy[ƒXƒgˆ—‚ŃXƒNƒ[ƒ‹‚³‚¹‚é */
 		if (ts.AutoScrollOnlyInBottomLine != 0 && WinOrgY != 0) {
@@ -5053,7 +5053,7 @@
 	if (sending) {
 		// ’[––‚Ö•¶Žš—ñ‚𑗂荞‚Þ
 		// DDE’ʐM‚ÉŽg‚¤ŠÖ”‚ɕύXB(2006.2.7 yutaka)
-		CBStartPaste(HVTWin, FALSE, BracketedPaste, TermWidthMax/*CBBufSize*/, buf, buflen);
+		CBStartPaste(HVTWin, FALSE, BracketedPasteMode(), TermWidthMax/*CBBufSize*/, buf, buflen);
 		// ‘—Mƒf[ƒ^‚ª‚ ‚éê‡‚Í‘—M‚·‚é
 		if (TalkStatus == IdTalkCB) {
 			CBSend();



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