[Ttssh2-commit] [3401] Language に UTF-8 を追加

svnno****@sourc***** svnno****@sourc*****
2009年 5月 16日 (土) 00:33:18 JST


Revision: 3401
          http://svn.sourceforge.jp/view?root=ttssh2&view=rev&rev=3401
Author:   maya
Date:     2009-05-16 00:33:18 +0900 (Sat, 16 May 2009)

Log Message:
-----------
Language に UTF-8 を追加
  Terminal setup ダイアログの動作に UTF-8 を追加(Korean のダイアログを流用)
  コマンドラインオプションの値を追加
  TERATERM.INI の値を追加
Language に対して正しくない KanjiCode/KanjiCodeSend が指定されたとき、正しい(少なくとも存在する)値がが割り当てられるようにした
  General setup ダイアログで Language が変更されたとき
  コマンドラインオプションの解析時
  TERATERM.INI の読み込み時

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


-------------- next part --------------
Modified: trunk/installer/release/TERATERM.INI
===================================================================
--- trunk/installer/release/TERATERM.INI	2009-05-15 12:23:08 UTC (rev 3400)
+++ trunk/installer/release/TERATERM.INI	2009-05-15 15:33:18 UTC (rev 3401)
@@ -26,7 +26,7 @@
 ;	Tera Term version number
 Version=2.3
 
-;	Language (English/Japanese/Russian)
+;	Language (English/Japanese/Russian/Korean/UTF-8)
 Language=
 
 ; User interface language file that includes message strings.

Modified: trunk/teraterm/common/ttlib.c
===================================================================
--- trunk/teraterm/common/ttlib.c	2009-05-15 12:23:08 UTC (rev 3400)
+++ trunk/teraterm/common/ttlib.c	2009-05-15 15:33:18 UTC (rev 3401)
@@ -767,3 +767,55 @@
 	//return OPENFILENAME_SIZE_VERSION_400;
 	return 76;
 }
+
+// convert table for KanjiCodeID and ListID
+// cf. KanjiList,KanjiListSend
+//     KoreanList,KoreanListSend
+//     Utf8List,Utf8ListSend
+//     IdSJIS, IdEUC, IdJIS, IdUTF8, IdUTF8m
+//     IdEnglish, IdJapanese, IdRussian, IdKorean, IdUtf8
+/* KanjiCode2List(Language,KanjiCodeID) returns ListID */
+int KanjiCode2List(int lang, int kcode)
+{
+	int Table[5][5] = {
+		{1, 2, 3, 4, 5}, /* English (dummy) */
+		{1, 2, 3, 4, 5}, /* Japanese(dummy) */
+		{1, 2, 3, 4, 5}, /* Russian (dummy) */
+		{1, 1, 1, 2, 2}, /* Korean */
+		{1, 1, 1, 1, 2}, /* Utf8 */
+	};
+	lang--;
+	kcode--;
+	return Table[lang][kcode];
+}
+/* List2KanjiCode(Language,ListID) returns KanjiCodeID */
+int List2KanjiCode(int lang, int list)
+{
+	int Table[5][5] = {
+		{1, 2, 3, 4, 5}, /* English (dummy) */
+		{1, 2, 3, 4, 5}, /* Japanese(dummy) */
+		{1, 2, 3, 4, 5}, /* Russian (dummy) */
+		{1, 4, 4, 1, 1}, /* Korean */
+		{4, 5, 4, 4, 4}, /* Utf8 */
+	};
+	lang--;
+	list--;
+	if (list < 1) {
+		list = 1;
+	}
+	return Table[lang][list];
+}
+/* KanjiCodeTranslate(Language(dest), KanjiCodeID(source)) returns KanjiCodeID */
+int KanjiCodeTranslate(int lang, int kcode)
+{
+	int Table[5][5] = {
+		{1, 2, 3, 4, 5}, /* to English (dummy) */
+		{1, 2, 3, 4, 5}, /* to Japanese(dummy) */
+		{1, 2, 3, 4, 5}, /* to Russian (dummy) */
+		{1, 1, 1, 4, 5}, /* to Korean */
+		{4, 4, 4, 4, 5}, /* to Utf8 */
+	};
+	lang--;
+	kcode--;
+	return Table[lang][kcode];
+}

Modified: trunk/teraterm/common/ttlib.h
===================================================================
--- trunk/teraterm/common/ttlib.h	2009-05-15 12:23:08 UTC (rev 3400)
+++ trunk/teraterm/common/ttlib.h	2009-05-15 15:33:18 UTC (rev 3401)
@@ -41,6 +41,9 @@
 void OutputDebugPrintf(char *fmt, ...);
 BOOL is_NT4();
 int get_OPENFILENAME_SIZE();
+int KanjiCode2List(int lang, int kcode);
+int List2KanjiCode(int lang, int kcode);
+int KanjiCodeTranslate(int lang, int kcode);
 
 #ifdef __cplusplus
 }

Modified: trunk/teraterm/common/tttypes.h
===================================================================
--- trunk/teraterm/common/tttypes.h	2009-05-15 12:23:08 UTC (rev 3400)
+++ trunk/teraterm/common/tttypes.h	2009-05-15 15:33:18 UTC (rev 3401)
@@ -148,6 +148,7 @@
 #define IdJapanese 2
 #define IdRussian  3
 #define IdKorean   4  //HKS
+#define IdUtf8     5
 
 // log flags (used in ts.LogFlag) 
 #define LOG_TEL 1

Modified: trunk/teraterm/ttpdlg/ttdlg.c
===================================================================
--- trunk/teraterm/ttpdlg/ttdlg.c	2009-05-15 12:23:08 UTC (rev 3400)
+++ trunk/teraterm/ttpdlg/ttdlg.c	2009-05-15 15:33:18 UTC (rev 3401)
@@ -67,6 +67,11 @@
 static PCHAR far KoreanList[] = {"KS5601", "UTF-8", NULL};
 static PCHAR far KoreanListSend[] = {"KS5601", "UTF-8", NULL};
 
+// UTF-8
+static PCHAR far Utf8List[] = {"UTF-8", "UTF-8m", NULL};
+static PCHAR far Utf8ListSend[] = {"UTF-8", NULL};
+
+
 BOOL CALLBACK TermDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 	PTTSet ts;
@@ -121,7 +126,7 @@
 					SendDlgItemMessage(Dialog, IDC_CODEPAGE_LABEL, WM_SETFONT, (WPARAM)DlgTermFont, MAKELPARAM(TRUE,0));
 					SendDlgItemMessage(Dialog, IDC_CODEPAGE_EDIT, WM_SETFONT, (WPARAM)DlgTermFont, MAKELPARAM(TRUE,0));
 				}
-				if (ts->Language==IdRussian) {
+				else if (ts->Language==IdRussian) {
 					SendDlgItemMessage(Dialog, IDC_TERMRUSSCHARSET, WM_SETFONT, (WPARAM)DlgTermFont, MAKELPARAM(TRUE,0));
 					SendDlgItemMessage(Dialog, IDC_TERMRUSSHOSTLABEL, WM_SETFONT, (WPARAM)DlgTermFont, MAKELPARAM(TRUE,0));
 					SendDlgItemMessage(Dialog, IDC_TERMRUSSHOST, WM_SETFONT, (WPARAM)DlgTermFont, MAKELPARAM(TRUE,0));
@@ -130,6 +135,12 @@
 					SendDlgItemMessage(Dialog, IDC_TERMRUSSFONTLABEL, WM_SETFONT, (WPARAM)DlgTermFont, MAKELPARAM(TRUE,0));
 					SendDlgItemMessage(Dialog, IDC_TERMRUSSFONT, WM_SETFONT, (WPARAM)DlgTermFont, MAKELPARAM(TRUE,0));
 				}
+				else if (ts->Language==IdUtf8) {
+					SendDlgItemMessage(Dialog, IDC_LOCALE_LABEL, WM_SETFONT, (WPARAM)DlgTermFont, MAKELPARAM(TRUE,0));
+					SendDlgItemMessage(Dialog, IDC_LOCALE_EDIT, WM_SETFONT, (WPARAM)DlgTermFont, MAKELPARAM(TRUE,0));
+					SendDlgItemMessage(Dialog, IDC_CODEPAGE_LABEL, WM_SETFONT, (WPARAM)DlgTermFont, MAKELPARAM(TRUE,0));
+					SendDlgItemMessage(Dialog, IDC_CODEPAGE_EDIT, WM_SETFONT, (WPARAM)DlgTermFont, MAKELPARAM(TRUE,0));
+				}
 			}
 			else {
 				DlgTermFont = NULL;
@@ -217,6 +228,14 @@
 				get_lang_msg("DLG_TERM_RUSSFONT", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
 				SetDlgItemText(Dialog, IDC_TERMRUSSFONTLABEL, uimsg);
 			}
+			else if (ts->Language==IdUtf8) {
+				GetDlgItemText(Dialog, IDC_LOCALE_LABEL, uimsg2, sizeof(uimsg2));
+				get_lang_msg("DLG_TERM_LOCALE", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
+				SetDlgItemText(Dialog, IDC_LOCALE_LABEL, uimsg);
+				GetDlgItemText(Dialog, IDC_CODEPAGE_LABEL, uimsg2, sizeof(uimsg2));
+				get_lang_msg("DLG_TERM_CODEPAGE", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
+				SetDlgItemText(Dialog, IDC_CODEPAGE_LABEL, uimsg);
+			}
 
 			SetDlgItemInt(Dialog,IDC_TERMWIDTH,ts->TerminalWidth,FALSE);
 			SendDlgItemMessage(Dialog, IDC_TERMWIDTH, EM_LIMITTEXT,3, 0);
@@ -285,8 +304,6 @@
 				SendDlgItemMessage(Dialog, IDC_LOCALE_EDIT, EM_LIMITTEXT, sizeof(ts->Locale), 0);
 
 				SetDlgItemInt(Dialog, IDC_CODEPAGE_EDIT, ts->CodePage, FALSE);
-				//SendDlgItemMessage(Dialog, IDC_CODEPAGE_EDIT, EM_LIMITTEXT, 16, 0);
-
 			}
 			else if (ts->Language==IdRussian) {
 				SetDropDownList(Dialog,IDC_TERMRUSSHOST,RussList,ts->RussHost);
@@ -302,8 +319,16 @@
 				SendDlgItemMessage(Dialog, IDC_LOCALE_EDIT, EM_LIMITTEXT, sizeof(ts->Locale), 0);
 
 				SetDlgItemInt(Dialog, IDC_CODEPAGE_EDIT, ts->CodePage, FALSE);
-				//SendDlgItemMessage(Dialog, IDC_CODEPAGE_EDIT, EM_LIMITTEXT, 16, 0);
+			}
+			else if (ts->Language==IdUtf8) {
+				SetDropDownList(Dialog, IDC_TERMKANJI, Utf8List, KanjiCode2List(ts->Language,ts->KanjiCode));
+				SetDropDownList(Dialog, IDC_TERMKANJISEND, Utf8ListSend, KanjiCode2List(ts->Language,ts->KanjiCode));
 
+				// ƒƒP[ƒ‹—pƒeƒLƒXƒgƒ{ƒbƒNƒX
+				SetDlgItemText(Dialog, IDC_LOCALE_EDIT, ts->Locale);
+				SendDlgItemMessage(Dialog, IDC_LOCALE_EDIT, EM_LIMITTEXT, sizeof(ts->Locale), 0);
+
+				SetDlgItemInt(Dialog, IDC_CODEPAGE_EDIT, ts->CodePage, FALSE);
 			}
 			return TRUE;
 
@@ -391,7 +416,24 @@
 								ts->Language = IdJapanese;
 							}
 						}
+						else if (ts->Language==IdUtf8) {
+							BOOL ret;
+							WORD listId;
 
+							listId = (WORD)GetCurSel(Dialog, IDC_TERMKANJI);
+							ts->KanjiCode = List2KanjiCode(ts->Language,listId);
+							listId = (WORD)GetCurSel(Dialog, IDC_TERMKANJISEND);
+							ts->KanjiCodeSend = List2KanjiCode(ts->Language,listId);
+
+							ts->JIS7KatakanaSend=0;
+							ts->JIS7Katakana=0;
+							ts->KanjiIn = 0;
+							ts->KanjiOut = 0;
+
+							GetDlgItemText(Dialog, IDC_LOCALE_EDIT, ts->Locale, sizeof(ts->Locale));
+							ts->CodePage = GetDlgItemInt(Dialog, IDC_CODEPAGE_EDIT, &ret, FALSE);
+						}
+
 					}
 					EndDialog(Dialog, 1);
 					if (DlgTermFont != NULL) {
@@ -2733,7 +2775,7 @@
 	return FALSE;
 }
 
-static PCHAR far LangList[] = {"English","Japanese","Russian","Korean",NULL};
+static PCHAR far LangList[] = {"English","Japanese","Russian","Korean","UTF-8",NULL};
 
 BOOL CALLBACK GenDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
 {
@@ -2823,7 +2865,18 @@
 							ts->PortType = IdTCPIP;
 						}
 						if ((ts->MenuFlag & MF_NOLANGUAGE)==0) {
-							ts->Language = (WORD)GetCurSel(Dialog, IDC_GENLANG);
+							WORD language = (WORD)GetCurSel(Dialog, IDC_GENLANG);
+
+							// Language ‚ª•ÏX‚³‚ꂽ‚Æ‚«A
+							// KanjiCode/KanjiCodeSend ‚ð•ÏXæ‚Ì Language ‚É‘¶Ý‚·‚é’l‚É’u‚«Š·‚¦‚é
+							if (language != ts->Language) {
+								WORD KanjiCode = ts->KanjiCode;
+								WORD KanjiCodeSend = ts->KanjiCodeSend;
+								ts->KanjiCode = KanjiCodeTranslate(language,KanjiCode);
+								ts->KanjiCodeSend = KanjiCodeTranslate(language,KanjiCodeSend);
+							}
+
+							ts->Language = language;
 						}
 					}
 
@@ -2975,10 +3028,11 @@
 	case IdJapanese: // Japanese mode
 		i = IDD_TERMDLGJ;
 		break;
-	case IdKorean: // Russian mode
+	case IdKorean: // Korean mode //HKS
+	case IdUtf8:   // UTF-8 mode
 		i = IDD_TERMDLGK;
 		break;
-	case IdRussian: // Korean mode //HKS
+	case IdRussian: // Russian mode
 		i = IDD_TERMDLGR;
 		break;
 	default:  // English mode

Modified: trunk/teraterm/ttpset/ttset.c
===================================================================
--- trunk/teraterm/ttpset/ttset.c	2009-05-15 12:23:08 UTC (rev 3400)
+++ trunk/teraterm/ttpset/ttset.c	2009-05-15 15:33:18 UTC (rev 3401)
@@ -225,6 +225,8 @@
 		ts->Language = IdEnglish;
 	else if (_stricmp(Temp,"Korean") == 0) // HKS
 		ts->Language = IdKorean;
+	else if (_stricmp(Temp,"UTF-8") == 0)
+		ts->Language = IdUtf8;
 	else {
 		switch (PRIMARYLANGID(GetSystemDefaultLangID())) {
 		case LANG_JAPANESE:
@@ -325,6 +327,11 @@
 		ts->KanjiCode = IdUTF8m;
 	else
 		ts->KanjiCode = IdSJIS;
+	// KanjiCode/KanjiCodeSend ‚ðŒ»Ý‚Ì Language ‚É‘¶Ý‚·‚é’l‚É’u‚«Š·‚¦‚é
+	{
+		WORD KanjiCode = ts->KanjiCode;
+		ts->KanjiCode = KanjiCodeTranslate(ts->Language,KanjiCode);
+	}
 
 	/* Katakana (receive) */
 	GetPrivateProfileString(Section, "KatakanaReceive", "",
@@ -345,6 +352,11 @@
 		ts->KanjiCodeSend = IdUTF8;
 	else
 		ts->KanjiCodeSend = IdSJIS;
+	// KanjiCode/KanjiCodeSend ‚ðŒ»Ý‚Ì Language ‚É‘¶Ý‚·‚é’l‚É’u‚«Š·‚¦‚é
+	{
+		WORD KanjiCodeSend = ts->KanjiCodeSend;
+		ts->KanjiCodeSend = KanjiCodeTranslate(ts->Language,KanjiCodeSend);
+	}
 
 	/* Katakana (receive) */
 	GetPrivateProfileString(Section, "KatakanaSend", "",
@@ -1297,6 +1309,9 @@
 	case IdRussian:
 	  	strncpy_s(Temp, sizeof(Temp), "Russian",  _TRUNCATE);
 		break;
+	case IdUtf8:
+	  	strncpy_s(Temp, sizeof(Temp), "UTF-8",  _TRUNCATE);
+		break;
 	default:
 	  	strncpy_s(Temp, sizeof(Temp), "English",  _TRUNCATE);
 	}
@@ -2865,6 +2880,9 @@
 			  case 'R':
 			  case 'r':
 				ts->Language = IdRussian; break;
+			  case 'U':
+			  case 'u':
+				ts->Language = IdUtf8; break;
 			}
 		}
 		else if (_strnicmp(Temp, "/M=", 3) == 0) {	/* macro filename */
@@ -2959,6 +2977,15 @@
 		JustAfterHost = FALSE;
 	}
 
+	// Language ‚ª•ÏX‚³‚ꂽ‚©‚à‚µ‚ê‚È‚¢‚̂ŁA
+	// KanjiCode/KanjiCodeSend ‚ðŒ»Ý‚Ì Language ‚É‘¶Ý‚·‚é’l‚É’u‚«Š·‚¦‚é
+	{
+		WORD KanjiCode = ts->KanjiCode;
+		WORD KanjiCodeSend = ts->KanjiCodeSend;
+		ts->KanjiCode = KanjiCodeTranslate(ts->Language,KanjiCode);
+		ts->KanjiCodeSend = KanjiCodeTranslate(ts->Language,KanjiCodeSend);
+	}
+
 	if ((DDETopic != NULL) && (DDETopic[0] != 0))
 		ts->MacroFN[0] = 0;
 



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