[Ttssh2-commit] [3416] 韓国語 (KS5601) 対応を改善。

svnno****@sourc***** svnno****@sourc*****
2009年 5月 20日 (水) 22:38:32 JST


Revision: 3416
          http://svn.sourceforge.jp/view?root=ttssh2&view=rev&rev=3416
Author:   doda
Date:     2009-05-20 22:38:32 +0900 (Wed, 20 May 2009)

Log Message:
-----------
韓国語(KS5601)対応を改善。

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


-------------- next part --------------
Modified: trunk/teraterm/teraterm/buffer.c
===================================================================
--- trunk/teraterm/teraterm/buffer.c	2009-05-19 14:21:04 UTC (rev 3415)
+++ trunk/teraterm/teraterm/buffer.c	2009-05-20 13:38:32 UTC (rev 3416)
@@ -587,7 +587,7 @@
 {
 	NewLine(PageStart+CursorY);
 
-	if (ts.Language==IdJapanese || ts.Language==IdUtf8) {
+	if (ts.Language==IdJapanese || ts.Language==IdKorean || ts.Language==IdUtf8) {
 		EraseKanji(1); /* if cursor is on right half of a kanji, erase the kanji */
 	}
 
@@ -630,7 +630,7 @@
 	int i, YEnd;
 
 	NewLine(PageStart+CursorY);
-	if (ts.Language==IdJapanese || ts.Language==IdUtf8) {
+	if (ts.Language==IdJapanese || ts.Language==IdKorean || ts.Language==IdUtf8) {
 		EraseKanji(1); /* if cursor is on right half of a kanji, erase the kanji */
 	}
 	offset = CursorX;
@@ -661,7 +661,7 @@
 	int i, YHome;
 
 	NewLine(PageStart+CursorY);
-	if (ts.Language==IdJapanese || ts.Language==IdUtf8) {
+	if (ts.Language==IdJapanese || ts.Language==IdKorean || ts.Language==IdUtf8) {
 		EraseKanji(0); /* if cursor is on left half of a kanji, erase the kanji */
 	}
 	offset = NumOfColumns;
@@ -736,7 +736,7 @@
 	}
 #endif /* NO_COPYLINE_FIX */
 
-	if (ts.Language==IdJapanese || ts.Language==IdUtf8) {
+	if (ts.Language==IdJapanese || ts.Language==IdKorean || ts.Language==IdUtf8) {
 		EraseKanji(1); /* if cursor is on right half of a kanji, erase the kanji */
 	}
 
@@ -803,7 +803,7 @@
 {
 	NewLine(PageStart+CursorY);
 
-	if (ts.Language==IdJapanese || ts.Language==IdUtf8) {
+	if (ts.Language==IdJapanese || ts.Language==IdKorean || ts.Language==IdUtf8) {
 		EraseKanji(0); /* if cursor is on left harf of a kanji, erase the kanji */
 		EraseKanji(1); /* if cursor on right half... */
 	}
@@ -836,7 +836,7 @@
 {
 	NewLine(PageStart+CursorY);
 
-	if (ts.Language==IdJapanese || ts.Language==IdUtf8) {
+	if (ts.Language==IdJapanese || ts.Language==IdKorean || ts.Language==IdUtf8) {
 		EraseKanji(0); /* if cursor is on left harf of a kanji, erase the kanji */
 		EraseKanji(1); /* if cursor on right half... */
 	}
@@ -1425,7 +1425,7 @@
 	}
 #endif /* NO_COPYLINE_FIX */
 
-	if (ts.Language==IdJapanese || ts.Language==IdUtf8) {
+	if (ts.Language==IdJapanese || ts.Language==IdKorean || ts.Language==IdUtf8) {
 		EraseKanji(1); /* if cursor is on right half of a kanji, erase the kanji */
 		if (! Insert) {
 			EraseKanji(0); /* if cursor on left half... */

Modified: trunk/teraterm/teraterm/vtterm.c
===================================================================
--- trunk/teraterm/teraterm/vtterm.c	2009-05-19 14:21:04 UTC (rev 3415)
+++ trunk/teraterm/teraterm/vtterm.c	2009-05-20 13:38:32 UTC (rev 3416)
@@ -2784,127 +2784,210 @@
   return Check;
 }
 
+BOOL CheckKorean(BYTE b)
+{
+	BOOL Check;
+	if (ts.Language!=IdKorean)
+		return FALSE;
+
+	if (ts.KanjiCode == IdSJIS) {
+		if ((0xA1<=b) && (b<=0xFE)) {
+			Check = TRUE;
+		}
+		else {
+			Check = FALSE;
+		}
+	}
+
+	return Check;
+}
+
 BOOL ParseFirstJP(BYTE b)
 // returns TRUE if b is processed
 //  (actually allways returns TRUE)
 {
-  if (KanjiIn)
-  {
-    if ((! ConvJIS) && (0x3F<b) && (b<0xFD) ||
-	ConvJIS && ( (0x20<b) && (b<0x7f) ||
-		     (0xa0<b) && (b<0xff) ))
-    {
-      PutKanji(b);
-      KanjiIn = FALSE;
-      return TRUE;
-    }
-    else if ((ts.TermFlag & TF_CTRLINKANJI)==0)
-      KanjiIn = FALSE;
-    else if ((b==CR) && Wrap) {
-      CarriageReturn(FALSE);
-      LineFeed(LF,FALSE);
-      Wrap = FALSE;
-    }
-  }
+	if (KanjiIn) {
+		if ((! ConvJIS) && (0x3F<b) && (b<0xFD) ||
+		      ConvJIS && ( (0x20<b) && (b<0x7f) ||
+		                   (0xa0<b) && (b<0xff) ))
+		{
+			PutKanji(b);
+			KanjiIn = FALSE;
+			return TRUE;
+		}
+		else if ((ts.TermFlag & TF_CTRLINKANJI)==0) {
+			KanjiIn = FALSE;
+		}
+		else if ((b==CR) && Wrap) {
+			CarriageReturn(FALSE);
+			LineFeed(LF,FALSE);
+			Wrap = FALSE;
+		}
+	}
 
-  if (SSflag)
-  {
-    if (Gn[GLtmp] == IdKanji)
-    {
-      Kanji = b << 8;
-      KanjiIn = TRUE;
-      SSflag = FALSE;
-      return TRUE;
-    }
-    else if (Gn[GLtmp] == IdKatakana) b = b | 0x80;
+	if (SSflag) {
+		if (Gn[GLtmp] == IdKanji) {
+			Kanji = b << 8;
+			KanjiIn = TRUE;
+			SSflag = FALSE;
+			return TRUE;
+		}
+		else if (Gn[GLtmp] == IdKatakana) {
+			b = b | 0x80;
+		}
 
-    PutChar(b);
-    SSflag = FALSE;
-    return TRUE;
-  }
+		PutChar(b);
+		SSflag = FALSE;
+		return TRUE;
+	}
 
-  if ((! EUCsupIn) && (! EUCkanaIn) &&
-      (! KanjiIn) && CheckKanji(b))
-  {
-    Kanji = b << 8;
-    KanjiIn = TRUE;
-    return TRUE;
-  }
+	if ((!EUCsupIn) && (!EUCkanaIn) && (!KanjiIn) && CheckKanji(b)) {
+		Kanji = b << 8;
+		KanjiIn = TRUE;
+		return TRUE;
+	}
 
-  if (b<=US)
-    ParseControl(b);
-  else if (b==0x20)
-    PutChar(b);
-  else if ((b>=0x21) && (b<=0x7E))
-  {
-    if (EUCsupIn)
-    {
-      EUCcount--;
-      EUCsupIn = (EUCcount==0);
-      return TRUE;
-    }
+	if (b<=US) {
+		ParseControl(b);
+	}
+	else if (b==0x20) {
+		PutChar(b);
+	}
+	else if ((b>=0x21) && (b<=0x7E)) {
+		if (EUCsupIn) {
+			EUCcount--;
+			EUCsupIn = (EUCcount==0);
+			return TRUE;
+		}
 
-    if ((Gn[Glr[0]] == IdKatakana) || EUCkanaIn)
-    {
-      b = b | 0x80;
-      EUCkanaIn = FALSE;
-    }
-    PutChar(b);
-  }
-  else if (b==0x7f)
-    return TRUE;
-  else if ((b>=0x80) && (b<=0x8D))
-    ParseControl(b);
-  else if (b==0x8E)
-  {
-    if (ts.KanjiCode==IdEUC)
-      EUCkanaIn = TRUE;
-    else
-      ParseControl(b);
-  }
-  else if (b==0x8F)
-  {
-    if (ts.KanjiCode==IdEUC)
-    {
-      EUCcount = 2;
-      EUCsupIn = TRUE;
-    } else
-      ParseControl(b);
-  }
-  else if ((b>=0x90) && (b<=0x9F))
-    ParseControl(b);
-  else if (b==0xA0)
-    PutChar(0x20);
-  else if ((b>=0xA1) && (b<=0xFE))
-  {
-    if (EUCsupIn)
-    {
-      EUCcount--;
-      EUCsupIn = (EUCcount==0);
-      return TRUE;
-    }
+		if ((Gn[Glr[0]] == IdKatakana) || EUCkanaIn) {
+			b = b | 0x80;
+			EUCkanaIn = FALSE;
+		}
+		PutChar(b);
+	}
+	else if (b==0x7f) {
+		return TRUE;
+	}
+	else if ((b>=0x80) && (b<=0x8D)) {
+		ParseControl(b);
+	}
+	else if (b==0x8E) { // SS2
+		if (ts.KanjiCode==IdEUC) {
+			EUCkanaIn = TRUE;
+		}
+		else {
+			ParseControl(b);
+		}
+	}
+	else if (b==0x8F) { // SS3
+		if (ts.KanjiCode==IdEUC) {
+			EUCcount = 2;
+			EUCsupIn = TRUE;
+		}
+		else {
+			ParseControl(b);
+		}
+	}
+	else if ((b>=0x90) && (b<=0x9F)) {
+		ParseControl(b);
+	}
+	else if (b==0xA0) {
+		PutChar(0x20);
+	}
+	else if ((b>=0xA1) && (b<=0xFE)) {
+		if (EUCsupIn) {
+			EUCcount--;
+			EUCsupIn = (EUCcount==0);
+			return TRUE;
+		}
 
-    if ((Gn[Glr[1]] != IdASCII) ||
-	(ts.KanjiCode==IdEUC) && EUCkanaIn ||
-	(ts.KanjiCode==IdSJIS) ||
-	(ts.KanjiCode==IdJIS) &&
-	(ts.JIS7Katakana==0) &&
-	((ts.TermFlag & TF_FIXEDJIS)!=0))
-      PutChar(b);  // katakana
-    else {
-      if (Gn[Glr[1]] == IdASCII)
-	b = b & 0x7f;
-      PutChar(b);
-    }
-    EUCkanaIn = FALSE;
-  }
-  else
-    PutChar(b);
+		if ((Gn[Glr[1]] != IdASCII) ||
+		    (ts.KanjiCode==IdEUC) && EUCkanaIn ||
+		    (ts.KanjiCode==IdSJIS) ||
+		    (ts.KanjiCode==IdJIS) &&
+		    (ts.JIS7Katakana==0) &&
+		    ((ts.TermFlag & TF_FIXEDJIS)!=0))
+			PutChar(b);	// katakana
+		else {
+			if (Gn[Glr[1]] == IdASCII) {
+				b = b & 0x7f;
+			}
+			PutChar(b);
+		}
+		EUCkanaIn = FALSE;
+	}
+	else {
+		PutChar(b);
+	}
 
-  return TRUE;
+	return TRUE;
 }
 
+BOOL ParseFirstKR(BYTE b)
+// returns TRUE if b is processed
+//  (actually allways returns TRUE)
+{
+	if (KanjiIn) {
+		if ((0x41<=b) && (b<=0x5A) ||
+		    (0x61<=b) && (b<=0x7A) ||
+		    (0x81<=b) && (b<=0xFE))
+		{
+			PutKanji(b);
+			KanjiIn = FALSE;
+			return TRUE;
+		}
+		else if ((ts.TermFlag & TF_CTRLINKANJI)==0) {
+			KanjiIn = FALSE;
+		}
+		else if ((b==CR) && Wrap) {
+			CarriageReturn(FALSE);
+			LineFeed(LF,FALSE);
+			Wrap = FALSE;
+		}
+	}
 
+	if ((!KanjiIn) && CheckKorean(b)) {
+		Kanji = b << 8;
+		KanjiIn = TRUE;
+		return TRUE;
+	}
+
+	if (b<=US) {
+		ParseControl(b);
+	}
+	else if (b==0x20) {
+		PutChar(b);
+	}
+	else if ((b>=0x21) && (b<=0x7E)) {
+//		if (Gn[Glr[0]] == IdKatakana) {
+//			b = b | 0x80;
+//		}
+		PutChar(b);
+	}
+	else if (b==0x7f) {
+		return TRUE;
+	}
+	else if ((0x80<=b) && (b<=0x9F)) {
+		ParseControl(b);
+	}
+	else if (b==0xA0) {
+		PutChar(0x20);
+	}
+	else if ((b>=0xA1) && (b<=0xFE)) {
+		if (Gn[Glr[1]] == IdASCII) {
+			b = b & 0x7f;
+		}
+		PutChar(b);
+	}
+	else {
+		PutChar(b);
+	}
+
+	return TRUE;
+}
+
+
 static void ParseASCII(BYTE b)
 {
 	if (b<=US) {
@@ -3206,7 +3289,6 @@
 		return;
 
 	  case IdJapanese:
-	  case IdKorean:
 	  	switch (ts.KanjiCode) {
 		  case IdUTF8:
 		  	if (ParseFirstUTF8(b, 0)) {
@@ -3225,6 +3307,26 @@
 		}
 		break;
 
+	  case IdKorean:
+	  	switch (ts.KanjiCode) {
+		  case IdUTF8:
+		  	if (ParseFirstUTF8(b, 0)) {
+				return;
+			}
+			break;
+		  case IdUTF8m:
+		  	if (ParseFirstUTF8(b, 1)) {
+				return;
+			}
+			break;
+		  default:
+			if (ParseFirstKR(b))  {
+				return;
+			}
+		}
+		break;
+
+
 	  case IdRussian:
 		if (ParseFirstRus(b)) {
 			return;



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