[Ttssh2-commit] [3614] クリッカブルURLのプレフィックスをポインタ配列に定義し直した。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 8月 29日 (土) 01:19:17 JST


Revision: 3614
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3614
Author:   yutakapon
Date:     2009-08-29 01:19:17 +0900 (Sat, 29 Aug 2009)

Log Message:
-----------
クリッカブルURLのプレフィックスをポインタ配列に定義し直した。

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


-------------- next part --------------
Modified: trunk/teraterm/teraterm/buffer.c
===================================================================
--- trunk/teraterm/teraterm/buffer.c	2009-08-28 05:00:15 UTC (rev 3613)
+++ trunk/teraterm/teraterm/buffer.c	2009-08-28 16:19:17 UTC (rev 3614)
@@ -1355,6 +1355,16 @@
 		 * other: url head char --> url_table array number + 1
 		 */
 	};
+	static char *prefix[] = {
+		"https://",
+		"http://",
+		"sftp://",
+		"tftp://",
+		"news://",
+		"ftp://",
+		"mms://",
+		NULL
+	};
 	unsigned char ch = CodeLine[x];
 
 	if (ts.EnableClickableUrl == FALSE)
@@ -1383,33 +1393,18 @@
 		int i, len = -1;
 		RECT rc;
 		int CaretX, CaretY;
+		char **p = prefix;
 
-		if ((x-6>=0) && !strncmp(&CodeLine[x-6], "http", 4)) {
-			len = 6;
+		while (*p) {
+			len = strlen(*p) - 1;
+			if ((x-len>=0) && !strncmp(&CodeLine[x-len], *p, len)) {
+				for (i = 0; i <= len; i++) {
+					AttrLine[x-i] |= (AttrURL | AttrUnder); 
+				}
+				break;
+			}
+			p++;
 		}
-		else if ((x-7>=0) && !strncmp(&CodeLine[x-7], "https", 5)) {
-			len = 7;
-		}
-		else if ((x-6>=0) && !strncmp(&CodeLine[x-6], "news", 4)) {
-			len = 6;
-		}
-		else if ((x-6>=0) && !strncmp(&CodeLine[x-6], "sftp", 4)) {
-			len = 6;
-		}
-		else if ((x-5>=0) && !strncmp(&CodeLine[x-5], "ftp", 3)) {
-			len = 5;
-		}
-		else if ((x-5>=0) && !strncmp(&CodeLine[x-5], "mms", 3)) {
-			len = 5;
-		}
-#if 0
-		if ((x-5>=0) && !strncmp(&CodeLine[x-5], "ttp", 3)) {
-			len = 5;
-		}
-#endif
-		for (i = 0; i <= len; i++) {
-			AttrLine[x-i] |= (AttrURL | AttrUnder); 
-		}
 
 		/* ƒnƒCƒp[ƒŠƒ“ƒN‚̐F‘®«•ÏX‚́A‚·‚łɉæ–ʂ֏o—ÍŒã‚ɁAƒoƒbƒtƒ@‚ð‘k‚Á‚Ä URL ‘®«‚ð
 		 * •t‚¯’¼‚·‚Æ‚¢‚¤ƒƒWƒbƒN‚Å‚ ‚邽‚߁AF‚ª³‚µ‚­•`‰æ‚³‚ê‚È‚¢ê‡‚ª‚ ‚éB



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