[Ttssh2-commit] [3535] ConfirmChangePaste 時に、あらかじめ指定したテキストファイルで定義された文字列群が、

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 6月 26日 (金) 20:20:56 JST


Revision: 3535
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3535
Author:   yutakapon
Date:     2009-06-26 20:20:55 +0900 (Fri, 26 Jun 2009)

Log Message:
-----------
ConfirmChangePaste 時に、あらかじめ指定したテキストファイルで定義された文字列群が、
クリップボードに含まれているかどうかを判断するようにした。
フローは以下のとおり。

  1. ConfirmChangePaste が有効化どうか
  2. クリップボードに改行が含まれているかどうか
  3. クリップボードにファイルに指定された文字列が含まれているかどうか

TERATERM.INI に ConfirmChangePasteStringFile エントリを追加した。

Modified Paths:
--------------
    trunk/installer/release/TERATERM.INI
    trunk/teraterm/common/tttypes.h
    trunk/teraterm/teraterm/clipboar.c
    trunk/teraterm/ttpset/ttset.c


-------------- next part --------------
Modified: trunk/installer/release/TERATERM.INI
===================================================================
--- trunk/installer/release/TERATERM.INI	2009-06-23 16:22:05 UTC (rev 3534)
+++ trunk/installer/release/TERATERM.INI	2009-06-26 11:20:55 UTC (rev 3535)
@@ -50,6 +50,7 @@
 ; confirm changing clipboard string by clicking mouse right button
 ConfirmChangePaste=on
 PasteDialogSize=330,220
+ConfirmChangePasteStringFile=
 
 ; Scroll out the current buffer when the clear screen does.
 ScrollWindowClearScreen=on

Modified: trunk/teraterm/common/tttypes.h
===================================================================
--- trunk/teraterm/common/tttypes.h	2009-06-23 16:22:05 UTC (rev 3534)
+++ trunk/teraterm/common/tttypes.h	2009-06-26 11:20:55 UTC (rev 3535)
@@ -470,6 +470,7 @@
 	WORD Meta8Bit;
 	WORD WindowFlag;
 	WORD EnableLineMode;
+	char ConfirmChangePasteStringFile[MAX_PATH];
 };
 
 typedef struct tttset TTTSet, *PTTSet;
@@ -919,6 +920,7 @@
  *   added tttset.Meta8Bit.
  *   added tttset.WindowFlag.
  *   added tttset.EnableLineMode
+ *   added tttset.ConfirmChangePasteStringFile
  *
  * - At version 4.62, ttset_memfilemap was replaced with ttset_memfilemap_10.
  *   added tttset.DisableMouseTrackingByCtrl.

Modified: trunk/teraterm/teraterm/clipboar.c
===================================================================
--- trunk/teraterm/teraterm/clipboar.c	2009-06-23 16:22:05 UTC (rev 3534)
+++ trunk/teraterm/teraterm/clipboar.c	2009-06-26 11:20:55 UTC (rev 3535)
@@ -488,6 +488,42 @@
 	return TRUE;
 }
 
+// ƒtƒ@ƒCƒ‹‚É’è‹`‚³‚ꂽ•¶Žš—ñ‚ªAtext‚ÉŠÜ‚Ü‚ê‚é‚©‚𒲂ׂéB
+static int search_clipboard(char *filename, char *text)
+{
+	int ret = 0;  // no hit
+	FILE *fp = NULL;
+	char buf[256];
+	int len;
+	
+	if (filename == NULL || filename[0] == '\0')
+		goto error;
+
+	fp = fopen(filename, "r");
+	if (fp == NULL)
+		goto error;
+
+	// TODO: ˆês‚ª256byte‚ð’´‚¦‚Ä‚¢‚éê‡‚̍l—¶
+	while (fgets(buf, sizeof(buf), fp) != NULL) {
+		len = strlen(buf);
+		if (buf[len - 1] == '\n') 
+			buf[len - 1] = '\0';
+		if (buf[0] == '\0')
+			continue;
+		if (strstr(text, buf)) { // hit
+			ret = 1;
+			break;
+		}
+	}
+
+error:
+	if (fp)
+		fclose(fp);
+
+	return (ret);
+}
+
+
 //
 // ƒNƒŠƒbƒvƒ{[ƒh‚ɉüsƒR[ƒh‚ªŠÜ‚Ü‚ê‚Ä‚¢‚½‚çAŠm”Fƒ_ƒCƒAƒƒO‚ð•\Ž¦‚·‚éB
 // ƒNƒŠƒbƒvƒ{[ƒh‚̕ύX‚à‰Â”\B
@@ -504,6 +540,7 @@
 	char *pText;
 	int pos;
 	int ret = 0;
+	int confirm = 0;
 
 	if (ts.ConfirmChangePaste == 0)
 		return 1;
@@ -529,6 +566,17 @@
 		pText = (char *)GlobalLock(hText);
 		pos = strcspn(pText, "\r\n");  // ‰üs‚ªŠÜ‚Ü‚ê‚Ä‚¢‚½‚ç
 		if (pText[pos] != '\0') {
+			confirm = 1;
+
+		} else {
+			// Ž«‘‚ðƒT[ƒ`‚·‚é
+			if (search_clipboard(ts.ConfirmChangePasteStringFile, pText)) {
+				confirm = 1;
+			}
+
+		}
+
+		if (confirm) {
 			ClipboardPtr = pText;
 			PasteCanceled = 0;
 			ret = DialogBox(hInst, MAKEINTRESOURCE(IDD_CLIPBOARD_DIALOG),

Modified: trunk/teraterm/ttpset/ttset.c
===================================================================
--- trunk/teraterm/ttpset/ttset.c	2009-06-23 16:22:05 UTC (rev 3534)
+++ trunk/teraterm/ttpset/ttset.c	2009-06-26 11:20:55 UTC (rev 3535)
@@ -1105,6 +1105,10 @@
 	// added ConfirmChangePaste (2008.2.3 yutaka)
 	ts->ConfirmChangePaste =
 		GetOnOff(Section, "ConfirmChangePaste", FName, TRUE);
+	GetPrivateProfileString(Section, "ConfirmChangePasteStringFile", "",
+	                        Temp, sizeof(Temp), FName);
+	strncpy_s(ts->ConfirmChangePasteStringFile, sizeof(ts->ConfirmChangePasteStringFile), Temp,
+	          _TRUNCATE);
 
 	// added ScrollWindowClearScreen (2008.5.3 yutaka)
 	ts->ScrollWindowClearScreen =
@@ -1511,6 +1515,8 @@
 	// added ConfirmChangePaste
 	WriteOnOff(Section, "ConfirmChangePaste", FName,
 	           ts->ConfirmChangePaste);
+	WritePrivateProfileString(Section, "ConfirmChangePasteStringFile",
+	                          ts->ConfirmChangePasteStringFile, FName);
 
 	// added ScrollWindowClearScreen
 	WriteOnOff(Section, "ScrollWindowClearScreen", FName,



Ttssh2-commit メーリングリストの案内
Back to archive index