[Ttssh2-commit] [8224] URL強調一通り動作するようになる

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2019年 9月 25日 (水) 00:11:32 JST


Revision: 8224
          https://osdn.net/projects/ttssh2/scm/svn/commits/8224
Author:   zmatsuo
Date:     2019-09-25 00:11:32 +0900 (Wed, 25 Sep 2019)
Log Message:
-----------
URL強調一通り動作するようになる

Modified Paths:
--------------
    branches/unicode_buf/teraterm/teraterm/CMakeLists.txt
    branches/unicode_buf/teraterm/teraterm/buffer.c

-------------- next part --------------
Modified: branches/unicode_buf/teraterm/teraterm/CMakeLists.txt
===================================================================
--- branches/unicode_buf/teraterm/teraterm/CMakeLists.txt	2019-09-24 15:11:21 UTC (rev 8223)
+++ branches/unicode_buf/teraterm/teraterm/CMakeLists.txt	2019-09-24 15:11:32 UTC (rev 8224)
@@ -159,7 +159,13 @@
   )
 
 if (MSVC)
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:imagehlp.dll /DELAYLOAD:user32.dll /DELAYLOAD:shell32.dll")
+  set_source_files_properties(buffer.c PROPERTIES COMPILE_FLAGS /W4)
+
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:user32.dll /DELAYLOAD:shell32.dll")
+  if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
+    # 32bit
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:imagehlp.dll")
+  endif()
 endif()
 
 add_executable(

Modified: branches/unicode_buf/teraterm/teraterm/buffer.c
===================================================================
--- branches/unicode_buf/teraterm/teraterm/buffer.c	2019-09-24 15:11:21 UTC (rev 8223)
+++ branches/unicode_buf/teraterm/teraterm/buffer.c	2019-09-24 15:11:32 UTC (rev 8224)
@@ -631,7 +631,7 @@
 	/* Tab stops */
 	NTabStops = (NumOfColumns-1) >> 3;
 	for (i=1 ; i<=NTabStops ; i++) {
-		TabStops[i-1] = i*8;
+		TabStops[i-1] = (WORD)(i*8);
 	}
 
 	/* Initialize text selection region */
@@ -1947,6 +1947,7 @@
 		}
 		TmpPtr = PrevLinePtr(TmpPtr);
 		x += NumOfColumns;
+		y--;
 	}
 	while(x > NumOfColumns) {
 		if (LineContinued && (AttrBuff[TmpPtr+NumOfColumns-1] & AttrLineContinued) == 0) {
@@ -2024,8 +2025,12 @@
 		while (x <= IEnd) {
 			if (MatchString(x, y, str, TRUE)) {
 				// \x83}\x83b\x83`\x82\xB5\x82\xBD
-				*match_x = x;
-				*match_y = y;
+				if (match_x != NULL) {
+					*match_x = x;
+				}
+				if (match_y != NULL) {
+					*match_y = y;
+				}
 				return TRUE;
 			}
 			x++;
@@ -2721,9 +2726,78 @@
 #endif
 
 #if UNICODE_INTERNAL_BUFF
+static const struct schemes_t {
+	const wchar_t *str;
+	int len;
+} schemes[] = {
+	// clang-format off
+	{L"https://", 8},
+	{L"http://", 7},
+	{L"sftp://", 7},
+	{L"tftp://", 7},
+	{L"news://", 7},
+	{L"ftp://", 6},
+	{L"mms://", 6},
+	// clang-format on
+};
+
+static BOOL mark_url_w_sub(int sx_s, int sx_e, int sy_s, int sy_e, int *sx_match_s, int *sx_match_e, int *sy_match_s,
+						   int *sy_match_e)
+{
+	int i;
+	int match_x, match_y;
+	int x;
+	int y;
+	int rx;
+	LONG TmpPtr;
+
+	if (sx_s >= sx_e && sy_s >= sy_e) {
+		return FALSE;
+	}
+
+	for (i = 0; i < _countof(schemes); i++) {
+		const wchar_t *prefix = schemes[i].str;
+		// \x83}\x83b\x83`\x82\xB7\x82邩?
+		if (BuffGetMatchPosFromString(sx_s, PageStart + sy_s, sx_s, PageStart + sy_s, prefix, &match_x, &match_y)) {
+			// \x83}\x83b\x83`\x82\xB5\x82\xBD
+			break;
+		}
+	}
+
+	if (i == _countof(schemes)) {
+		// \x83}\x83b\x83`\x82\xB5\x82Ȃ\xA9\x82\xC1\x82\xBD
+		return FALSE;
+	}
+
+	// \x83}\x83b\x83`\x82\xB5\x82\xBD
+	*sx_match_s = match_x - PageStart;
+	*sy_match_s = match_y;
+	rx = match_x;
+	for (y = match_y; y <= PageStart + sy_e; y++) {
+		int sx_s_i = 0;
+		int sx_e_i = NumOfColumns - 1;  // \x82Ƃɂ\xA9\x82\xAD\x8Ds\x96\x96\x82܂\xC5
+		if (y == PageStart + sy_s) {
+			sx_s_i = match_x;
+		}
+		*sy_match_e = y - PageStart;
+		TmpPtr = GetLinePtr(y);
+		for (x = sx_s_i; x <= sx_e_i; x++) {
+			const buff_char_t *b = &CodeBuffW[TmpPtr + x];
+			if (!isURLchar(b->u32)) {
+				*sx_match_e = rx;
+				return TRUE;
+			}
+			rx = x;
+			AttrBuff[TmpPtr + x] |= AttrURL;
+		}
+	}
+	*sx_match_e = rx;
+	return TRUE;
+}
+
 // cur_x	\x83J\x81[\x83\\x83\x8B\x88ʒu
 // cur_y	\x83J\x81[\x83\\x83\x8B\x88ʒu(!\x83o\x83b\x83t\x83@\x88ʒu)
-static void mark_url_w(int cur_x, int cur_y)
+static void mark_url_line_w(int cur_x, int cur_y)
 {
 	int sx;
 	int sy;
@@ -2733,24 +2807,27 @@
 	const buff_char_t *b;
 
 	// \x8Ds\x93\xAA\x82\xF0\x92T\x82\xB7
-	sx = cur_x;
+	sx = 0;
 	sy = cur_y;
-	TmpPtr = GetLinePtr(PageStart+sy);
+	TmpPtr = GetLinePtr(PageStart + sy);
 	while ((AttrBuff[TmpPtr] & AttrLineContinued) != 0) {
+		if (sy == 0) {
+			break;
+		}
 		sy--;
 		sx = 0;
 		TmpPtr = PrevLinePtr(TmpPtr);
 	}
 	// \x8Ds\x96\x96\x82\xF0\x92T\x82\xB7
-	ex = NumOfColumns-1;
+	ex = NumOfColumns - 1;
 	ey = cur_y;
-	TmpPtr = GetLinePtr(PageStart+ey);
-	while ((AttrBuff[TmpPtr+NumOfColumns-1] & AttrLineContinued) != 0) {
+	TmpPtr = GetLinePtr(PageStart + ey);
+	while ((AttrBuff[TmpPtr + NumOfColumns - 1] & AttrLineContinued) != 0) {
 		ey++;
 		TmpPtr = NextLinePtr(TmpPtr);
 	}
-	b = &CodeBuffW[TmpPtr+ex];
-	for(;;) {
+	b = &CodeBuffW[TmpPtr + ex];
+	for (;;) {
 		if (b->u32 != ' ') {
 			break;
 		}
@@ -2778,83 +2855,192 @@
 		}
 	}
 
+	// \x83}\x81[\x83N\x82\xB7\x82\xE9
+	{
+	int sx_i = sx;
+	int sy_i = sy;
+	for (;;) {
+		int sx_match_s, sx_match_e;
+		int sy_match_s, sy_match_e;
+		BOOL match;
 
-	// \x83v\x83\x8C\x83t\x83B\x83b\x83N\x83X\x82\xF0\x92T\x82\xB7
-	for(;;) {
-		static const struct schemes_t {
-			const wchar_t *str;
-			int len;
-		} schemes[] = {
-			{ L"https://", 8 },
-			{ L"http://", 7},
-			{ L"sftp://", 7},
-			{ L"tftp://", 7},
-			{ L"news://", 7},
-			{ L"ftp://", 6},
-			{ L"mms://", 6},
-		};
-		int i;
-		const wchar_t *prefix;
-		int len;
-		int match_x, match_y;
-
-		if (sx >= ex && sy >= ey) {
+		if (sx_i >= ex && sy_i >= ey) {
 			break;
 		}
 
-		for (i = 0; i < _countof(schemes); i++) {
-			prefix = schemes[i].str;
-			len = schemes[i].len - 1;
-			// \x83}\x83b\x83`\x82\xB7\x82邩?
-			if (BuffGetMatchPosFromString(sx, PageStart+sy, sx, PageStart+sy, prefix, &match_x, &match_y)) {
-				// \x83}\x83b\x83`\x82\xB5\x82\xBD
-				break;
+		match = mark_url_w_sub(sx_i, ex, sy_i, ey, &sx_match_s, &sx_match_e, &sy_match_s, &sy_match_e);
+		if (match) {
+			if (sy_match_s == sy_match_e) {
+				BuffDrawLineI(-1, -1, sy_match_s, sx_match_s, sx_match_e);
 			}
+			else {
+				BuffDrawLineI(-1, -1, sy_match_s, sx_match_s, sx_match_e);
+				BuffDrawLineI(-1, -1, sy_match_s, sx_match_s, sx_match_e);
+			}
+			sx_i = sx_match_e;
+			sy_i = sy_match_e;
 		}
 
-		if (i < _countof(schemes)) {
-			// \x83}\x83b\x83`\x82\xB5\x82\xBD
-			int x;
-			int y;
-			for (y = match_y; y <= PageStart+ey; y++) {
-				int sx_i = 0;
-				int ex_i = NumOfColumns - 1;	// \x82Ƃɂ\xA9\x82\xAD\x8Ds\x96\x96\x82܂\xC5
-				if (y == PageStart+sy) {
-					sx_i = match_x;
-					//ex_i = ex_i - match_x;
-				}
-				TmpPtr = GetLinePtr(y);
-				for (x = sx_i; x <= ex_i; x++) {
-					const buff_char_t *b = &CodeBuffW[TmpPtr + x];
-					if (isURLchar(b->u32)) {
-						AttrBuff[TmpPtr + x] |= AttrURL;
-					} else {
-						// \x92\x86\x92f, \x8E\x9F\x82͂\xB1\x82\xB1\x82\xA9\x82\xE7\x92T\x82\xB5\x8En\x82߂\xE9
-						sx = x;
-						sy = y - PageStart;
-						break;
-					}
-				}
-				if (x <= ex_i) {
-					// \x92\x86\x92f\x82\xB5\x82\xBD
-					sx = x;
-					break;
-				}
+		// \x8E\x9F\x82̃Z\x83\x8B\x82\xD6
+		if (sx_i == NumOfColumns - 1) {
+			sx_i = 0;
+			sy_i++;
+		}
+		else {
+			sx_i++;
+		}
+	}
+	}
+
+	// \x95`\x89悷\x82\xE9
+	{
+		int y;
+		for (y = sy; y <= ey; y++) {
+			int sx_i = 0;
+			int ex_i = NumOfColumns - 1;
+			if (y == sy) {
+				sx_i = sx;
 			}
-			if (y <= PageStart + ey) {
-				// \x92\x86\x92f\x82\xB5\x82\xBD
-				sy = y - PageStart;
+			else if (y == ey) {
+				ex_i = ex;
 			}
+			BuffDrawLineI(-1, -1, y + PageStart, sx_i, ex_i);
 		}
+	}
+}
 
-		sx++;
-		if (sx >= NumOfColumns) {
-			sx = 0;
-			sy++;
+static void mark_url_w(int cur_x, int cur_y)
+{
+	buff_char_t *b = &CodeLineW[cur_x];
+	const char32_t u32 = b->u32;
+	int x = cur_x;
+	BOOL prev = FALSE;
+	BOOL next = FALSE;
+	int i;
+	BOOL match_flag = FALSE;
+	int sx;
+	int sy;
+	int ey;
+	int len;
+
+	// \x83J\x81[\x83\\x83\x8B\x88ʒu\x82\xAAURL
+	if ((AttrLine[x] & AttrURL) != 0) {
+		mark_url_line_w(cur_x, cur_y);
+		return;
+	}
+
+	// 1\x82‘O\x82̃L\x83\x83\x83\x89\x83N\x83^\x82\xAAURL?
+	if (x == 0) {
+		// \x88\xEA\x94ԍ\xB6\x82̎\x9E\x82́A\x91O\x82̍s\x82\xA9\x82\xE7\x8Cp\x91\xB1\x82\xB5\x82Ă\xA2\x82āA\x91O\x82̍s\x82̍ŌオURL\x82\xBE\x82\xC1\x82\xBD\x8E\x9E
+		if ((AttrLine[0] & AttrLineContinued) != 0) {
+			const LONG TmpPtr = GetLinePtr(PageStart + cur_y - 1);
+			if ((AttrBuff[TmpPtr + NumOfColumns - 1] & AttrURL) != 0) {
+				prev = TRUE;
+			}
 		}
 	}
+	else {
+		if (AttrLine[x - 1] & AttrURL) {
+			prev = TRUE;
+		}
+	}
+
+	// 1\x82Œ\xE3\x82\xEB\x82̃Z\x83\x8B\x82\xAAURL?
+	if (x == NumOfColumns - 1) {
+		// \x88\xEA\x94ԉE
+		if ((AttrLine[x] & AttrLineContinued) != 0) {
+			const LONG TmpPtr = GetLinePtr(PageStart + cur_y + 1);
+			if ((AttrBuff[TmpPtr + NumOfColumns - 1] & AttrURL) != 0) {
+				next = TRUE;
+			}
+		}
+	}
+	else {
+		if (AttrLine[x + 1] & AttrURL) {
+			next = TRUE;
+		}
+	}
+
+	if (prev == TRUE) {
+		if (next == TRUE) {
+			// 1line\x8C\x9F\x8D\xB8
+			mark_url_line_w(cur_x, cur_y);
+			return;
+		}
+		if (isURLchar(u32)) {
+			// URL\x82\xF0\x90L\x82΂\xB7
+			AttrLine[x] |= AttrURL;
+			return;
+		}
+	}
+
+	// '/' \x82\xAA\x93\xFC\x97͂\xB3\x82ꂽ\x82璲\x82׎n\x82߂\xE9
+	if (u32 == '/') {
+		if (!MatchString(x - 2, PageStart + CursorY, L"://", TRUE)) {
+			// "://" \x82̈ꕔ\x82ł͂Ȃ\xA2
+			return;
+		}
+	}
+
+	// \x96{\x8Ai\x93I\x82ɒT\x82\xB7
+	for (i = 0; i < _countof(schemes); i++) {
+		const wchar_t *prefix = schemes[i].str;
+		len = schemes[i].len - 1;
+		sx = x - len;
+		sy = PageStart + CursorY;
+		ey = sy;
+		if (x < len) {
+			// \x92Z\x82\xA2
+			if ((AttrLine[0] & AttrLineContinued) == 0) {
+				// \x91O\x82̍s\x82ƘA\x8C\x8B\x82\xB5\x82Ă\xA2\x82Ȃ\xA2
+				continue;
+			}
+			// \x91O\x82̍s\x82\xA9\x82猟\x8D\x{142A42}\xAF\x82\xE9
+			sx = NumOfColumns + sx;
+			sy = PageStart + CursorY - 1;
+		}
+		// \x83}\x83b\x83`\x82\xB7\x82邩?
+		if (BuffGetMatchPosFromString(sx, sy, x, ey, prefix, NULL, NULL)) {
+			match_flag = TRUE;
+			break;
+		}
+	}
+	if (!match_flag) {
+		return;
+	}
+
+	// \x83}\x83b\x83`\x82\xB5\x82\xBD\x82̂\xC5URL\x91\xAE\x90\xAB\x82\xF0\x95t\x82\xAF\x82\xE9
+	if (sy == ey) {
+		for (i = 0; i <= len; i++) {
+			AttrLine[sx + i] |= AttrURL;
+		}
+		if (StrChangeStart > sx) {
+			StrChangeStart = sx;
+			StrChangeCount += len;
+		}
+	}
+	else {
+		LONG TmpPtr = GetLinePtr(sy);
+		int xx = sx;
+		size_t left = len + 1;
+		while (left > 0) {
+			AttrBuff[TmpPtr + xx] |= AttrURL;
+			xx++;
+			if (xx == NumOfColumns) {
+				int draw_x = sx;
+				int draw_y = CursorY - 1;
+				if (IsLineVisible(&draw_x, &draw_y)) {
+					BuffDrawLineI(draw_x, draw_y, PageStart + CursorY - 1, sx, NumOfColumns - 1);
+				}
+				TmpPtr = NextLinePtr(TmpPtr);
+				xx = 0;
+			}
+			left--;
+		}
+		StrChangeStart = 0;
+		StrChangeCount = xx;
+	}
 }
-#endif
 
 static wchar_t *GetWCS(const buff_char_t *b)
 {
@@ -2876,6 +3062,7 @@
 	*p = L'\0';
 	return strW;
 }
+#endif	// #if UNICODE_INTERNAL_BUFF
 
 /**
  *	\x83\x86\x83j\x83R\x81[\x83h\x83L\x83\x83\x83\x89\x83N\x83^\x82\xF01\x95\xB6\x8E\x9A\x83o\x83b\x83t\x83@\x82֓\xFC\x97͂\xB7\x82\xE9
@@ -2898,7 +3085,8 @@
 	if (u32 < 0x80) {
 		b1 = (BYTE)u32;
 		b2 = 0;
-	} else {
+	}
+	else {
 		char mbchar[2];
 		size_t ret = UTF32ToCP932(u32, mbchar, 2);
 		if (ret == 0) {
@@ -2905,10 +3093,12 @@
 			b1 = '?';
 			b2 = 0;
 			ret = 1;
-		} else if (ret == 1) {
+		}
+		else if (ret == 1) {
 			b1 = mbchar[0];
 			b2 = 0;
-		} else {	// ret == 2
+		}
+		else {  // ret == 2
 			b1 = mbchar[0];
 			b2 = mbchar[1];
 			ret = 2;
@@ -2923,25 +3113,23 @@
 		Attr.Attr |= AttrLineContinued;
 	}
 
-	p = NULL;	// NULL\x82̂Ƃ\xAB\x81A\x91O\x82̕\xB6\x8E\x9A\x82͂Ȃ\xA2
+	p = NULL;  // NULL\x82̂Ƃ\xAB\x81A\x91O\x82̕\xB6\x8E\x9A\x82͂Ȃ\xA2
 	// \x91O\x82̕\xB6\x8E\x9A
 	if (CursorX >= 1 && !IsBuffPadding(&CodeLineW[CursorX - 1])) {
 		p = &CodeLineW[CursorX - 1];
-	} else if (CursorX >= 2 && !IsBuffPadding(&CodeLineW[CursorX - 2])) {
+	}
+	else if (CursorX >= 2 && !IsBuffPadding(&CodeLineW[CursorX - 2])) {
 		p = &CodeLineW[CursorX - 2];
 	}
 
-	if (UnicodeIsVariationSelector(u32) ||
-		UnicodeIsCombiningCharacter(u32) ||
-		(u32 == 0x200d) ||
-		(p != NULL && p->u32_last == 0x200d))
-	{
+	if (UnicodeIsVariationSelector(u32) || UnicodeIsCombiningCharacter(u32) || (u32 == 0x200d) ||
+		(p != NULL && p->u32_last == 0x200d)) {
 		// Combining
 		//		VariationSelector or
 		//		CombiningCharacter or
 		//		\x83[\x83\x8D\x95\x9D\x90ڍ\x87\x8Eq,ZERO WIDTH JOINER(ZWJ) (U+200d) or
 		//		1\x82‘O\x82\xAA ZWJ
-		move_x = 0;				// \x83J\x81[\x83\\x83\x8B\x88ړ\xAE\x97\xCA=0
+		move_x = 0;  // \x83J\x81[\x83\\x83\x8B\x88ړ\xAE\x97\xCA=0
 
 		if (p == NULL) {
 			// \x91O\x82\xAA\x82Ȃ\xA2\x82̂ɂ\xAD\x82\xC1\x82‚\xAD\x95\xB6\x8E\x9A\x82\xAA\x8Fo\x82Ă\xAB\x82\xBD\x82Ƃ\xAB
@@ -2958,7 +3146,8 @@
 		AttrLineFG[CursorX] = Attr.Fore;
 		AttrLineBG[CursorX] = Attr.Back;
 #endif
-	} else {
+	}
+	else {
 		char width_property;
 		char emoji;
 		BOOL half_width = BuffIsHalfWidthFromCode(&ts, u32, &width_property, &emoji);
@@ -2967,13 +3156,14 @@
 		// \x8C\xBB\x8D݂̈ʒu\x82\xAA\x91S\x8Ap\x82̉E\x91\xA4?
 		if (IsBuffPadding(p)) {
 			// \x91S\x8Ap\x82̑O\x94\xBC\x82\xF0\x83X\x83y\x81[\x83X\x82ɒu\x82\xAB\x8A\xB7\x82\xA6\x82\xE9
-			assert(CursorX > 0);	// \x8Ds\x93\xAA\x82ɑS\x8Ap\x82̉E\x91\xA4\x82͂Ȃ\xA2
+			assert(CursorX > 0);  // \x8Ds\x93\xAA\x82ɑS\x8Ap\x82̉E\x91\xA4\x82͂Ȃ\xA2
 			BuffSetChar(p - 1, ' ', 'H');
 			BuffSetChar(p, ' ', 'H');
 			if (StrChangeCount == 0) {
 				StrChangeCount = 3;
 				StrChangeStart = CursorX - 1;
-			} else {
+			}
+			else {
 				if (StrChangeStart < CursorX) {
 					StrChangeCount += (CursorX - StrChangeStart) + 1;
 				}
@@ -2986,9 +3176,9 @@
 		// \x8C\xBB\x8D݂̈ʒu\x82\xAA\x91S\x8Ap\x82̍\xB6\x91\xA4 && \x93\xFC\x97͕\xB6\x8E\x9A\x82\xAA\x94\xBC\x8Ap ?
 		if (half_width && IsBuffFullWidth(p)) {
 			// \x91S\x8Ap\x82\xF0\x83X\x83y\x81[\x83X\x82ɒu\x82\xAB\x8A\xB7\x82\xA6\x82\xE9
-			assert(CursorX < NumOfColumns-1);	// \x8Ds\x96\x96\x82ɑS\x8Ap\x82̍\xB6\x82͂\xB1\x82Ȃ\xA2
+			assert(CursorX < NumOfColumns - 1);  // \x8Ds\x96\x96\x82ɑS\x8Ap\x82̍\xB6\x82͂\xB1\x82Ȃ\xA2
 			BuffSetChar(p, ' ', 'H');
-			BuffSetChar(p+1, ' ', 'H');
+			BuffSetChar(p + 1, ' ', 'H');
 			if (StrChangeCount == 0) {
 				StrChangeCount = 3;
 				StrChangeStart = CursorX;
@@ -3003,10 +3193,10 @@
 			}
 		}
 		// \x8E\x9F\x82̕\xB6\x8E\x9A\x82\xAA\x91S\x8Ap && \x93\xFC\x97͕\xB6\x8E\x9A\x82\xAA\x91S\x8Ap ?
-		if (!Insert && !half_width && IsBuffFullWidth(p+1)) {
+		if (!Insert && !half_width && IsBuffFullWidth(p + 1)) {
 			// \x91S\x8Ap\x82\xF0\x92ׂ\xB7
-			BuffSetChar(p+1, ' ', 'H');
-			BuffSetChar(p+2, ' ', 'H');
+			BuffSetChar(p + 1, ' ', 'H');
+			BuffSetChar(p + 2, ' ', 'H');
 		}
 
 		if (Insert) {
@@ -3022,7 +3212,8 @@
 			if (half_width) {
 				// \x94\xBC\x8Ap\x82Ƃ\xB5\x82Ĉ\xB5\x82\xA4
 				move_x = 1;
-			} else {
+			}
+			else {
 				// \x91S\x8Ap\x82Ƃ\xB5\x82Ĉ\xB5\x82\xA4
 				move_x = 2;
 				if (CursorX + 1 > LineEnd) {
@@ -3032,14 +3223,12 @@
 			}
 
 			// \x88\xEA\x94ԍŌ\xE3\x82̕\xB6\x8E\x9A\x82\xAA\x91S\x8Ap\x82̏ꍇ\x81A
-			if (LineEnd <= NumOfColumns - 1 && (AttrLine[LineEnd-1] & AttrKanji)) {
-				CodeLine[LineEnd-1] = 0x20;
-#if UNICODE_INTERNAL_BUFF
-				BuffSetChar(&CodeLineW[LineEnd-1], 0x20, 'H');
-#endif
+			if (LineEnd <= NumOfColumns - 1 && (AttrLine[LineEnd - 1] & AttrKanji)) {
+				CodeLine[LineEnd - 1] = 0x20;
+				BuffSetChar(&CodeLineW[LineEnd - 1], 0x20, 'H');
 				AttrLine[LineEnd] &= ~AttrKanji;
-//				CodeLine[LineEnd+1] = 0x20;
-//				AttrLine[LineEnd+1] &= ~AttrKanji;
+				//				CodeLine[LineEnd+1] = 0x20;
+				//				AttrLine[LineEnd+1] &= ~AttrKanji;
 				extr = 1;
 			}
 
@@ -3046,47 +3235,40 @@
 			if (!half_width) {
 				MoveLen = LineEnd - CursorX - 1;
 				if (MoveLen > 0) {
-					memmove(&CodeLine[CursorX+2], &CodeLine[CursorX], MoveLen);
-#if UNICODE_INTERNAL_BUFF
-					memmoveW(&(CodeLineW[CursorX+2]), &(CodeLineW[CursorX]), MoveLen);
-#endif
-					memmove(&AttrLine[CursorX+2], &AttrLine[CursorX], MoveLen);
-					memmove(&AttrLine2[CursorX+2], &AttrLine2[CursorX], MoveLen);
-					memmove(&AttrLineFG[CursorX+2], &AttrLineFG[CursorX], MoveLen);
-					memmove(&AttrLineBG[CursorX+2], &AttrLineBG[CursorX], MoveLen);
+					memmove(&CodeLine[CursorX + 2], &CodeLine[CursorX], MoveLen);
+					memmoveW(&(CodeLineW[CursorX + 2]), &(CodeLineW[CursorX]), MoveLen);
+					memmove(&AttrLine[CursorX + 2], &AttrLine[CursorX], MoveLen);
+					memmove(&AttrLine2[CursorX + 2], &AttrLine2[CursorX], MoveLen);
+					memmove(&AttrLineFG[CursorX + 2], &AttrLineFG[CursorX], MoveLen);
+					memmove(&AttrLineBG[CursorX + 2], &AttrLineBG[CursorX], MoveLen);
 				}
-			} else {
+			}
+			else {
 				MoveLen = LineEnd - CursorX;
 				if (MoveLen > 0) {
-					memmove(&CodeLine[CursorX+1], &CodeLine[CursorX], MoveLen);
-#if UNICODE_INTERNAL_BUFF
-					memmoveW(&(CodeLineW[CursorX+1]), &(CodeLineW[CursorX]), MoveLen);
-#endif
-					memmove(&AttrLine[CursorX+1], &AttrLine[CursorX], MoveLen);
-					memmove(&AttrLine2[CursorX+1], &AttrLine2[CursorX], MoveLen);
-					memmove(&AttrLineFG[CursorX+1], &AttrLineFG[CursorX], MoveLen);
-					memmove(&AttrLineBG[CursorX+1], &AttrLineBG[CursorX], MoveLen);
+					memmove(&CodeLine[CursorX + 1], &CodeLine[CursorX], MoveLen);
+					memmoveW(&(CodeLineW[CursorX + 1]), &(CodeLineW[CursorX]), MoveLen);
+					memmove(&AttrLine[CursorX + 1], &AttrLine[CursorX], MoveLen);
+					memmove(&AttrLine2[CursorX + 1], &AttrLine2[CursorX], MoveLen);
+					memmove(&AttrLineFG[CursorX + 1], &AttrLineFG[CursorX], MoveLen);
+					memmove(&AttrLineBG[CursorX + 1], &AttrLineBG[CursorX], MoveLen);
 				}
 			}
 
 			CodeLine[CursorX] = b1;
-#if UNICODE_INTERNAL_BUFF
 			BuffSetChar2(&CodeLineW[CursorX], u32, width_property, half_width, emoji);
-#endif
 			AttrLine[CursorX] = Attr.Attr;
 			AttrLine2[CursorX] = Attr.Attr2;
 			AttrLineFG[CursorX] = Attr.Fore;
 			AttrLineBG[CursorX] = Attr.Back;
 			if (!half_width && CursorX < LineEnd) {
-				CodeLine[CursorX+1] = 0;
-#if UNICODE_INTERNAL_BUFF
+				CodeLine[CursorX + 1] = 0;
 				BuffSetChar(&CodeLineW[CursorX + 1], 0, 'H');
 				CodeLineW[CursorX + 1].Padding = TRUE;
-#endif
-				AttrLine[CursorX+1] = Attr.Attr;
-				AttrLine2[CursorX+1] = Attr.Attr2;
-				AttrLineFG[CursorX+1] = Attr.Fore;
-				AttrLineBG[CursorX+1] = Attr.Back;
+				AttrLine[CursorX + 1] = Attr.Attr;
+				AttrLine2[CursorX + 1] = Attr.Attr2;
+				AttrLineFG[CursorX + 1] = Attr.Fore;
+				AttrLineBG[CursorX + 1] = Attr.Back;
 			}
 #if 0
 			/* begin - ishizaki */
@@ -3099,9 +3281,7 @@
 			if ((AttrLine[LineEnd] & AttrKanji) != 0) {
 				/* then delete it */
 				CodeLine[LineEnd] = 0x20;
-#if UNICODE_INTERNAL_BUFF
 				BuffSetChar(&CodeLineW[LineEnd], 0x20, 'H');
-#endif
 				AttrLine[LineEnd] = CurCharAttr.Attr;
 				AttrLine2[LineEnd] = CurCharAttr.Attr2;
 				AttrLineFG[LineEnd] = CurCharAttr.Fore;
@@ -3108,7 +3288,7 @@
 				AttrLineBG[LineEnd] = CurCharAttr.Back;
 			}
 
-			if (StrChangeCount==0) {
+			if (StrChangeCount == 0) {
 				XStart = CursorX;
 			}
 			else {
@@ -3115,8 +3295,9 @@
 				XStart = StrChangeStart;
 			}
 			StrChangeCount = 0;
-			BuffUpdateRect(XStart, CursorY, LineEnd+extr, CursorY);
-		} else {
+			BuffUpdateRect(XStart, CursorY, LineEnd + extr, CursorY);
+		}
+		else {
 			if ((Attr.AttrEx & AttrPadding) != 0) {
 				// \x8Bl\x82ߕ\xA8
 				buff_char_t *p = &CodeLineW[CursorX];
@@ -3127,13 +3308,15 @@
 				AttrLineFG[CursorX] = Attr.Fore;
 				AttrLineBG[CursorX] = Attr.Back;
 				move_x = 1;
-			} else {
+			}
+			else {
 				// \x90V\x82\xB5\x82\xA2\x95\xB6\x8E\x9A\x92lj\xC1
 
 				if (half_width) {
 					// \x94\xBC\x8Ap\x82Ƃ\xB5\x82Ĉ\xB5\x82\xA4
 					move_x = 1;
-				} else {
+				}
+				else {
 					// \x91S\x8Ap\x82Ƃ\xB5\x82Ĉ\xB5\x82\xA4
 					move_x = 2;
 					if (CursorX + 2 > NumOfColumns) {
@@ -3146,7 +3329,8 @@
 				BuffSetChar2(&CodeLineW[CursorX], u32, width_property, half_width, emoji);
 				if (half_width) {
 					AttrLine[CursorX] = Attr.Attr;
-				} else {
+				}
+				else {
 					// \x91S\x8Ap
 					AttrLine[CursorX] = Attr.Attr | AttrKanji;
 				}
@@ -3156,20 +3340,20 @@
 
 				if (!half_width) {
 					// \x91S\x8Ap\x82̎\x9E\x82͎\x9F\x82̃Z\x83\x8B\x82͋l\x82ߕ\xA8
-					if (CursorX < NumOfColumns-1) {
-						buff_char_t *p = &CodeLineW[CursorX+1];
+					if (CursorX < NumOfColumns - 1) {
+						buff_char_t *p = &CodeLineW[CursorX + 1];
 						BuffSetChar(p, 0, 'H');
 						p->Padding = TRUE;
-						CodeLine[CursorX+1] = b2;
-						AttrLine[CursorX+1] = 0;
-						AttrLine2[CursorX+1] = 0;
-						AttrLineFG[CursorX+1] = 0;
-						AttrLineBG[CursorX+1] = 0;
+						CodeLine[CursorX + 1] = b2;
+						AttrLine[CursorX + 1] = 0;
+						AttrLine2[CursorX + 1] = 0;
+						AttrLineFG[CursorX + 1] = 0;
+						AttrLineBG[CursorX + 1] = 0;
 					}
 				}
 			}
 
-			if (StrChangeCount==0) {
+			if (StrChangeCount == 0) {
 				StrChangeStart = CursorX;
 			}
 			if (move_x == 0) {
@@ -3176,144 +3360,21 @@
 				if (StrChangeCount == 0) {
 					StrChangeCount = 1;
 				}
-			} else if (move_x == 1) {
+			}
+			else if (move_x == 1) {
 				// \x94\xBC\x8Ap
 				StrChangeCount = StrChangeCount + 1;
-			} else /*if (move_x == 2)*/ {
+			}
+			else /*if (move_x == 2)*/ {
 				// \x91S\x8Ap
 				StrChangeCount = StrChangeCount + 2;
 			}
 
 			// URL\x82̌\x9F\x8Fo
-			// DEL\x8E\x9E\x82\xC9URL\x82\xBE\x82\xC1\x82\xBD\x82\xE7URL\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x8E\xE6\x82\xC1\x82Ă\xAB\x82Č\x9F\x8D\xB8\x82\xB7\x82\xE9
-#if 0
-			{
-				int x = CursorX;
-				BOOL pass = FALSE;
+			mark_url_w(CursorX, CursorY);
 
-				// TODO 1\x82Œ\xE3\x82\xEB\x82\xE0URL
-				// 1\x82‘O\x82̃L\x83\x83\x83\x89\x83N\x83^\x82\xAAURL?
-				// \x88\xEA\x94ԍ\xB6\x82̎\x9E\x82́A\x91O\x82̍s\x82\xA9\x82\xE7\x8Cp\x91\xB1\x82\xB5\x82Ă\xA2\x82āA\x91O\x82̍s\x82̍ŌオURL\x82\xBE\x82\xC1\x82\xBD\x8E\x9E
-				if ((x == 0 &&
-					 ((AttrLine[0] & AttrLineContinued) != 0) &&
-					 ((AttrBuff[(PageStart + (CursorY-1)) * NumOfColumns + NumOfColumns - 1] & AttrURL) != 0)) ||
-					(x >= 1 && AttrLine[x-1] & AttrURL)) {
-					if (isURLchar(u32)) {
-						// URL\x82\xF0\x90L\x82΂\xB7
-						AttrLine[x] |= AttrURL;
-						pass = TRUE;
-					}
-				}
-
-				// \x83J\x81[\x83\\x83\x8B\x88ʒu\x82\xAAURL
-				if ((AttrLine[x] & AttrURL) != 0) {
-					pass = TRUE;	// \x82\xE2\x82邱\x82ƂȂ\xB5
-				}
-
-				if (!pass) {
-					// '/' \x82\xAA\x93\xFC\x97͂\xB3\x82ꂽ\x82璲\x82׎n\x82߂\xE9
-					if (u32 == '/') {
-						if (MatchString(x-2, PageStart+CursorY, L"://", TRUE)) {
-							pass = FALSE;
-						}
 #if 0
-						if ((CodeLineW[x-2].u32 == ':') && (CodeLineW[x-2].CombinationCharCount16 == 0) &&
-							(CodeLineW[x-1].u32 == '/') && (CodeLineW[x-1].CombinationCharCount16 == 0) &&
-							(CodeLineW[x-0].u32 == '/') && (CodeLineW[x-0].CombinationCharCount16 == 0))
-						{	// "://"\x82\xAA\x93\xFC\x97͂\xB3\x82ꂽ
-							pass = FALSE;
-						} else {
-							pass = TRUE;
-						}
-#endif
-					} else {
-						pass = TRUE;
-					}
-				}
-
-				if (!pass) {
-					// \x96{\x8Ai\x93I\x82ɒT\x82\xB7
-					static const struct schemes_t {
-						const wchar_t *str;
-						int len;
-					} schemes[] = {
-						{ L"https://", 8 },
-						{ L"http://", 7},
-						{ L"sftp://", 7},
-						{ L"tftp://", 7},
-						{ L"news://", 7},
-						{ L"ftp://", 6},
-						{ L"mms://", 6},
-					};
-					int i;
-					for (i = 0; i < _countof(schemes); i++) {
-						const wchar_t *prefix = schemes[i].str;
-						const int len = schemes[i].len - 1;
-						int sx = x - len;
-						int sy = PageStart + CursorY;
-						int ey = sy;
-						if (x < len) {
-							// \x92Z\x82\xA2
-							if ((AttrLine[0] & AttrLineContinued) == 0) {
-								// \x91O\x82̍s\x82ƘA\x8C\x8B\x82\xB5\x82Ă\xA2\x82Ȃ\xA2
-								continue;
-							}
-							// \x91O\x82̍s\x82\xA9\x82猟\x8D\x{142A42}\xAF\x82\xE9
-							sx = NumOfColumns + sx;
-							sy = PageStart + CursorY - 1;
-						}
-						// \x83}\x83b\x83`\x82\xB7\x82邩?
-						int match_x, match_y;
-						if (BuffGetMatchPosFromString(sx, sy, x, ey, prefix, &match_x, &match_y)) {
-							// \x83}\x83b\x83`\x82\xB5\x82\xBD\x82̂\xC5URL\x91\xAE\x90\xAB\x82\xF0\x95t\x82\xAF\x82\xE9
-							if (sy == ey) {
-								int i;
-								for (i = 0; i <= len; i++) {
-									AttrLine[sx + i] |= AttrURL;
-								}
-								if (StrChangeStart > sx) {
-									StrChangeStart = sx;
-									StrChangeCount += len;
-								}
-							}
-							else {
-								LONG TmpPtr = GetLinePtr(sy);
-								int xx = sx;
-								size_t left = len + 1;
-								while (left > 0) {
-									AttrBuff[TmpPtr + xx] |= AttrURL;
-									xx++;
-									if (xx == NumOfColumns) {
-										int draw_x = sx;
-										int draw_y = CursorY - 1;
-										if (IsLineVisible(&draw_x, &draw_y)) {
-											BuffDrawLineI(draw_x, draw_y, PageStart+CursorY-1, sx, NumOfColumns-1);
-										}
-										TmpPtr = NextLinePtr(TmpPtr);
-										xx = 0;
-									}
-									left--;
-								}
-								StrChangeStart = 0;
-								StrChangeCount = xx;
-							}
-							break;
-						}
-					}
-				}
-			}
-#else
 			{
-				mark_url_w(CursorX, CursorY);
-			}
-#endif
-//		markURL(CursorX);
-//		markURL(CursorX+1);
-			/* end - ishizaki */
-
-
-#if 0
-			{
 				char ba[128];
 				memcpy(ba, &CodeLine[0], _countof(ba)-1);
 				ba[127] = 0;
@@ -3320,7 +3381,6 @@
 				OutputDebugPrintf("A '%s'\n", ba);
 			}
 #endif
-
 		}
 	}
 
@@ -3375,7 +3435,7 @@
  *	1\x8Ds\x95`\x89\xE6
  *
  *	@param	DrawX,Y			Clint\x97̈\xE6\x95`\x89\xE6\x88ʒu(pixel)
- *	@param	SY				\x83X\x83N\x83\x8A\x81[\x83\x93\x8F\xE3\x82̈ʒu(Charactor)
+ *	@param	SY				\x83X\x83N\x83\x8A\x81[\x83\x93\x8F\xE3\x82̈ʒu(Charactor)  !\x83o\x83b\x83t\x83@\x8F\xE3\x82̈ʒu
  *							PageStart + YStart \x82Ȃ\xC7
  *	@param	IStart,IEnd		\x83X\x83N\x83\x8A\x81[\x83\x93\x8F\xE3\x82̈ʒu(Charactor)
  *							\x8Ew\x92肵\x82\xBD\x8AԂ\xF0\x95`\x89悷\x82\xE9
@@ -3399,6 +3459,23 @@
 #if 0
 	OutputDebugPrintf("BuffDrawLineI(%d,%d, %d,%d-%d)\n", DrawX, DrawY, SY, IStart, IEnd);
 #endif
+	{
+		// \x83J\x81[\x83\\x83\x8B\x88ʒu\x81A\x95\\x8E\xA6\x8AJ\x8En\x88ʒu\x82\xA9\x82\xE7\x95`\x89\xE6\x88ʒu\x82\xAA\x82킩\x82\xE9\x82͂\xB8
+		int X2 = IStart;
+		int Y2 = SY - PageStart;
+		if (! IsLineVisible(&X2, &Y2)) {
+			// \x95`\x89\xE6\x95s\x97v\x8Ds
+			//assert(FALSE);
+			return;
+		}
+		if (X != -1 && Y != -1) {
+			assert(X == X2 && Y == Y2);
+		}
+		else {
+			X = X2;
+			Y = Y2;
+		}
+	}
 	if (IEnd >= NumOfColumns) {
 		IEnd = NumOfColumns - 1;
 	}
@@ -4082,23 +4159,24 @@
 
 static void invokeBrowserWithUrl(const char *url)
 {
-	if (strncmp(url, "http://", strlen("http://")) == 0 ||
-	    strncmp(url, "https://", strlen("https://")) == 0 ||
-	    strncmp(url, "ftp://", strlen("ftp://")) == 0) {
-		if (strlen(ts.ClickableUrlBrowser) > 0) {
-			char param[1024];
-			_snprintf_s(param, sizeof(param), _TRUNCATE, "%s %s",
-			            ts.ClickableUrlBrowserArg, url);
-			if (ShellExecuteA(NULL, NULL, ts.ClickableUrlBrowser, param, NULL,SW_SHOWNORMAL) >= (HINSTANCE)32) {
-				return;		// \x8E\xC0\x8Ds\x82ł\xAB\x82\xBD
-			}
-			// \x83R\x83}\x83\x93\x83h\x82̎\xC0\x8Ds\x82Ɏ\xB8\x94s\x82\xB5\x82\xBD\x8Fꍇ\x82͒ʏ\xED\x82Ɠ\xAF\x82\xB6\x8F\x88\x97\x9D\x82\xF0\x82\xB7\x82\xE9
+	BOOL use_browser = FALSE;
+	if (strncmp(url, "http://", strlen("http://")) == 0 || strncmp(url, "https://", strlen("https://")) == 0 ||
+		strncmp(url, "ftp://", strlen("ftp://")) == 0) {
+		use_browser = TRUE;
+	}
+
+	if (use_browser && ts.ClickableUrlBrowser[0] != 0) {
+		// \x83u\x83\x89\x83E\x83U\x82\xF0\x8Eg\x97p\x82\xB7\x82\xE9
+		char param[1024];
+		_snprintf_s(param, sizeof(param), _TRUNCATE, "%s %s", ts.ClickableUrlBrowserArg, url);
+		if (ShellExecuteA(NULL, NULL, ts.ClickableUrlBrowser, param, NULL, SW_SHOWNORMAL) >= (HINSTANCE)32) {
+			// \x8E\xC0\x8Ds\x82ł\xAB\x82\xBD
+			return;
 		}
-		ShellExecuteA(NULL, NULL, url, NULL, NULL,SW_SHOWNORMAL);
+		// \x83R\x83}\x83\x93\x83h\x82̎\xC0\x8Ds\x82Ɏ\xB8\x94s\x82\xB5\x82\xBD\x8Fꍇ\x82͒ʏ\xED\x82Ɠ\xAF\x82\xB6\x8F\x88\x97\x9D\x82\xF0\x82\xB7\x82\xE9
 	}
-	else {
-		ShellExecuteA(NULL, NULL, url, NULL, NULL,SW_SHOWNORMAL);
-	}
+
+	ShellExecuteA(NULL, NULL, url, NULL, NULL, SW_SHOWNORMAL);
 }
 
 #if !UNICODE_INTERNAL_BUFF
@@ -6013,7 +6091,6 @@
 #if UNICODE_INTERNAL_BUFF
 	{
 		const buff_char_t *b = &CodeBuffW[TmpPtr+X];
-		const char32_t u32 = b->u32;
 		wchar_t *wcs = GetWCS(b);
 		wchar_t *codes_ptr;
 		wchar_t *str2_ptr;


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