[Ttssh2-commit] [6455] 行末の改行削除を CBStartPaste () に移動

svnno****@sourc***** svnno****@sourc*****
2016年 8月 1日 (月) 18:01:28 JST


Revision: 6455
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6455
Author:   doda
Date:     2016-08-01 18:01:28 +0900 (Mon, 01 Aug 2016)
Log Message:
-----------
行末の改行削除を CBStartPaste() に移動

Modified Paths:
--------------
    trunk/teraterm/teraterm/clipboar.c

-------------- next part --------------
Modified: trunk/teraterm/teraterm/clipboar.c
===================================================================
--- trunk/teraterm/teraterm/clipboar.c	2016-08-01 09:01:24 UTC (rev 6454)
+++ trunk/teraterm/teraterm/clipboar.c	2016-08-01 09:01:28 UTC (rev 6455)
@@ -139,6 +139,21 @@
 	}
 }
 
+// \x83N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x83o\x83b\x83t\x83@\x82̖\x96\x94\xF6\x82ɂ\xA0\x82\xE9 CR / LF \x82\xF0\x82\xB7\x82ׂč폜\x82\xB7\x82\xE9
+BOOL TrimTrailingNL(BOOL AddCR, BOOL Bracketed) {
+	PCHAR tail;
+	if (ts.TrimTrailingNLonPaste) {
+		for (tail = CBMemPtr+strlen(CBMemPtr)-1; tail >= CBMemPtr; tail--) {
+			if (*tail != '\r' && *tail != '\n') {
+				break;
+			}
+			*tail = '\0';
+		}
+	}
+
+	return TRUE;
+}
+
 #define BracketStartLen	(sizeof(BracketStart)-1)
 #define BracketEndLen	(sizeof(BracketEnd)-1)
 void CBStartPaste(HWND HWin, BOOL AddCR, BOOL Bracketed)
@@ -237,6 +252,11 @@
 
 	// \x93\\x82\xE8\x95t\x82\xAF\x91O\x82ɃN\x83\x8A\x83b\x83v\x83{\x81[\x83h\x82̓\xE0\x97e\x82\xF0\x8Am\x94F/\x89\xC1\x8DH\x93\x99\x82\xB7\x82\xE9\x8Fꍇ\x82͂\xB1\x82\xB1\x82ōs\x82\xA4
 
+	if (!TrimTrailingNL(AddCR, Bracketed)) {
+		CBEndPaste();
+		return;
+	}
+
 	// AddCR / Bracket \x97p\x82̗̈悪\x82\xA0\x82邩\x82̊m\x94F\x81A\x96\xB3\x82\xAF\x82\xEA\x82Βlj\xC1\x8Am\x95\xDB
 	StrLen = strlen(CBMemPtr);
 	BuffLen = StrLen + 1; // strlen + NUL
@@ -901,15 +921,15 @@
 {
 	UINT Cf;
 	HANDLE hText;
-	char *pText, *tail;
+	char *pText;
 	int pos;
 	int ret = 0;
-	BOOL confirm = FALSE, need_writeback = FALSE;
+	BOOL confirm = FALSE;
 	HANDLE wide_hText;
 	LPWSTR wide_buf;
 	int mb_len;
 
-	if (!ts.ConfirmChangePaste && !ts.TrimTrailingNLonPaste)
+	if (!ts.ConfirmChangePaste)
 		return 1;
 
 	if (! cv.Ready)
@@ -958,18 +978,6 @@
 	}
 	CloseClipboard();
 
-	if (ts.TrimTrailingNLonPaste) {
-		for (tail=ClipboardPtr+strlen(ClipboardPtr)-1; tail >= ClipboardPtr; tail--) {
-			if (*tail == '\r' || *tail == '\n') {
-				*tail = '\0';
-				need_writeback = TRUE;
-			}
-			else {
-				break;
-			}
-		}
-	}
-
 	if (AddCR) {
 		if (ts.ConfirmChangePasteCR) {
 			confirm = TRUE;
@@ -1000,17 +1008,6 @@
 			goto error;
 		}
 	}
-	else if (need_writeback) {
-		HGLOBAL hMem;
-		hMem = CBAllocClipboardMem(ClipboardPtr);
-		if (hMem) {
-			if (! CBSetClipboard(NULL, hMem)) {
-				// \x83N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x82ւ̃Z\x83b\x83g\x82\xAA\x8E\xB8\x94s\x82\xB5\x82\xBD\x8E\x9E\x82\xCD hMem \x82\xF0\x94j\x8A\xFC\x82\xB7\x82\xE9
-				// \x90\xAC\x8C\x{1C2D42}\xBD\x8Fꍇ\x82̓N\x83\x8A\x83b\x83v\x83{\x81[\x83h\x82\xAA\x8F\x8A\x8E\x9D\x82\xB5\x82Ă\xA2\x82\xE9\x82̂ŁA\x94j\x8A\xFC\x82\xB5\x82Ă͂\xA2\x82\xAF\x82Ȃ\xA2
-				GlobalFree(hMem);
-			}
-		}
-	}
 
 	ret = 1;
 



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