[ttssh2-commit] [9958] テーマファイルの読み込み部分を Unicode 化

アーカイブの一覧に戻る
scmno****@osdn***** scmno****@osdn*****
2022年 5月 24日 (火) 23:21:07 JST


Revision: 9958
          https://osdn.net/projects/ttssh2/scm/svn/commits/9958
Author:   zmatsuo
Date:     2022-05-24 23:21:07 +0900 (Tue, 24 May 2022)
Log Message:
-----------
テーマファイルの読み込み部分を Unicode 化

ticket #44048

Ticket Links:
------------
    https://osdn.net/projects/ttssh2/tracker/detail/44048

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

-------------- next part --------------
Modified: trunk/teraterm/teraterm/vtdisp.c
===================================================================
--- trunk/teraterm/teraterm/vtdisp.c	2022-05-23 23:57:59 UTC (rev 9957)
+++ trunk/teraterm/teraterm/vtdisp.c	2022-05-24 14:21:07 UTC (rev 9958)
@@ -42,6 +42,8 @@
 #include "setting.h"
 #include "codeconv.h"
 #include "libsusieplugin.h"
+#include "inifile_com.h"
+#include "win32helper.h"
 
 #include "vtdisp.h"
 
@@ -1193,7 +1195,7 @@
   }
 }
 
-static COLORREF BGGetColor(char *name, COLORREF defcolor, char *file)
+static COLORREF BGGetColor(const char *name, COLORREF defcolor, const wchar_t *file)
 {
 	unsigned int r, g, b;
 	char colorstr[256], defstr[256];
@@ -1201,7 +1203,7 @@
 	_snprintf_s(defstr, sizeof(defstr), _TRUNCATE, "%d,%d,%d", GetRValue(defcolor), GetGValue(defcolor),
 				GetBValue(defcolor));
 
-	GetPrivateProfileString(BG_SECTION, name, defstr, colorstr, 255, file);
+	GetPrivateProfileStringAFileW(BG_SECTION, name, defstr, colorstr, 255, file);
 
 	r = g = b = 0;
 
@@ -1210,7 +1212,7 @@
 	return RGB(r, g, b);
 }
 
-static BG_PATTERN BGGetStrIndex(char *name, BG_PATTERN def, char *file, char **strList, int nList)
+static int BGGetStrIndex(const char *name, int def, const wchar_t *file, const char * const *strList, int nList)
 {
 	char defstr[64], str[64];
 	int i;
@@ -1218,7 +1220,7 @@
 	def %= nList;
 
 	strncpy_s(defstr, sizeof(defstr), strList[def], _TRUNCATE);
-	GetPrivateProfileString(BG_SECTION, name, defstr, str, 64, file);
+	GetPrivateProfileStringAFileW(BG_SECTION, name, defstr, str, 64, file);
 
 	for (i = 0; i < nList; i++)
 		if (!_stricmp(str, strList[i]))
@@ -1227,28 +1229,28 @@
 	return 0;
 }
 
-static BOOL BGGetOnOff(char *name, BOOL def, char *file)
+static BOOL BGGetOnOff(const char *name, BOOL def, const wchar_t *file)
 {
-	char *strList[2] = {"Off", "On"};
+	static const char * const strList[2] = {"Off", "On"};
 
 	return BGGetStrIndex(name, def, file, strList, 2);
 }
 
-static BG_PATTERN BGGetPattern(char *name, BG_PATTERN def, char *file)
+static BG_PATTERN BGGetPattern(const char *name, BG_PATTERN def, const wchar_t *file)
 {
-	char *strList[6] = {"stretch", "tile", "center", "fitwidth", "fitheight", "autofit"};
+	static const char *strList[6] = {"stretch", "tile", "center", "fitwidth", "fitheight", "autofit"};
 
 	return BGGetStrIndex(name, def, file, strList, 6);
 }
 
-static BG_TYPE BGGetType(char *name, BG_TYPE def, char *file)
+static BG_TYPE BGGetType(const char *name, BG_TYPE def, const wchar_t *file)
 {
-	char *strList[3] = {"color", "picture", "wallpaper"};
+	static const char *strList[3] = {"color", "picture", "wallpaper"};
 
 	return BGGetStrIndex(name, def, file, strList, 3);
 }
 
-static void BGReadTextColorConfig(char *file)
+static void BGReadTextColorConfig(const wchar_t *file)
 {
 	ANSIColor[IdFore] = BGGetColor("Fore", ANSIColor[IdFore], file);
 	ANSIColor[IdBack] = BGGetColor("Back", ANSIColor[IdBack], file);
@@ -1286,7 +1288,7 @@
 	/* end - ishizaki */
 }
 
-static void BGReadIniFile(char *file)
+static void BGReadIniFile(const wchar_t *file)
 {
 	char path[MAX_PATH];
 
@@ -1294,27 +1296,27 @@
 	BGDest.pattern = BGGetPattern("BGPicturePattern", BGSrc1.pattern, file);
 	BGDest.color = BGGetColor("BGPictureBaseColor", BGSrc1.color, file);
 
-	GetPrivateProfileString(BG_SECTION, "BGPictureFile", BGSrc1.file, path, MAX_PATH, file);
+	GetPrivateProfileStringAFileW(BG_SECTION, "BGPictureFile", BGSrc1.file, path, MAX_PATH, file);
 	RandomFile(path, BGDest.file, sizeof(BGDest.file));
 
-	BGSrc1.alpha = 255 - GetPrivateProfileInt(BG_SECTION, "BGPictureTone", 255 - BGSrc1.alpha, file);
+	BGSrc1.alpha = 255 - GetPrivateProfileIntAFileW(BG_SECTION, "BGPictureTone", 255 - BGSrc1.alpha, file);
 
 	if (!strcmp(BGDest.file, ""))
 		BGSrc1.alpha = 255;
 
-	BGSrc2.alpha = 255 - GetPrivateProfileInt(BG_SECTION, "BGFadeTone", 255 - BGSrc2.alpha, file);
+	BGSrc2.alpha = 255 - GetPrivateProfileIntAFileW(BG_SECTION, "BGFadeTone", 255 - BGSrc2.alpha, file);
 	BGSrc2.color = BGGetColor("BGFadeColor", BGSrc2.color, file);
 
-	BGReverseTextAlpha = GetPrivateProfileInt(BG_SECTION, "BGReverseTextTone", BGReverseTextAlpha, file);
+	BGReverseTextAlpha = GetPrivateProfileIntAFileW(BG_SECTION, "BGReverseTextTone", BGReverseTextAlpha, file);
 
 	// Src1 \x82̓ǂݏo\x82\xB5
 	BGSrc1.type = BGGetType("BGSrc1Type", BGSrc1.type, file);
 	BGSrc1.pattern = BGGetPattern("BGSrc1Pattern", BGSrc1.pattern, file);
 	BGSrc1.antiAlias = BGGetOnOff("BGSrc1AntiAlias", BGSrc1.antiAlias, file);
-	BGSrc1.alpha = GetPrivateProfileInt(BG_SECTION, "BGSrc1Alpha", BGSrc1.alpha, file);
+	BGSrc1.alpha = GetPrivateProfileIntAFileW(BG_SECTION, "BGSrc1Alpha", BGSrc1.alpha, file);
 	BGSrc1.color = BGGetColor("BGSrc1Color", BGSrc1.color, file);
 
-	GetPrivateProfileString(BG_SECTION, "BGSrc1File", BGSrc1.file, path, MAX_PATH, file);
+	GetPrivateProfileStringAFileW(BG_SECTION, "BGSrc1File", BGSrc1.file, path, MAX_PATH, file);
 	RandomFile(path, BGSrc1.file, sizeof(BGSrc1.file));
 
 	// Src2 \x82̓ǂݏo\x82\xB5
@@ -1321,10 +1323,10 @@
 	BGSrc2.type = BGGetType("BGSrc2Type", BGSrc2.type, file);
 	BGSrc2.pattern = BGGetPattern("BGSrc2Pattern", BGSrc2.pattern, file);
 	BGSrc2.antiAlias = BGGetOnOff("BGSrc2AntiAlias", BGSrc2.antiAlias, file);
-	BGSrc2.alpha = GetPrivateProfileInt(BG_SECTION, "BGSrc2Alpha", BGSrc2.alpha, file);
+	BGSrc2.alpha = GetPrivateProfileIntAFileW(BG_SECTION, "BGSrc2Alpha", BGSrc2.alpha, file);
 	BGSrc2.color = BGGetColor("BGSrc2Color", BGSrc2.color, file);
 
-	GetPrivateProfileString(BG_SECTION, "BGSrc2File", BGSrc2.file, path, MAX_PATH, file);
+	GetPrivateProfileStringAFileW(BG_SECTION, "BGSrc2File", BGSrc2.file, path, MAX_PATH, file);
 	RandomFile(path, BGSrc2.file, sizeof(BGSrc2.file));
 
 	// Dest \x82̓ǂݏo\x82\xB5
@@ -1333,11 +1335,11 @@
 	BGDest.antiAlias = BGGetOnOff("BGDestAntiAlias", BGDest.antiAlias, file);
 	BGDest.color = BGGetColor("BGDestColor", BGDest.color, file);
 
-	GetPrivateProfileString(BG_SECTION, BG_DESTFILE, BGDest.file, path, MAX_PATH, file);
+	GetPrivateProfileStringAFileW(BG_SECTION, BG_DESTFILE, BGDest.file, path, MAX_PATH, file);
 	RandomFile(path, BGDest.file, sizeof(BGDest.file));
 
 	//\x82\xBB\x82̑\xBC\x93ǂݏo\x82\xB5
-	BGReverseTextAlpha = GetPrivateProfileInt(BG_SECTION, "BGReverseTextAlpha", BGReverseTextAlpha, file);
+	BGReverseTextAlpha = GetPrivateProfileIntAFileW(BG_SECTION, "BGReverseTextAlpha", BGReverseTextAlpha, file);
 	BGReadTextColorConfig(file);
 }
 
@@ -1411,10 +1413,10 @@
 	//  \x8B\xF3\x82̏ꍇ\x82̂݁A\x83f\x83B\x83X\x83N\x82\xA9\x82\xE7\x93ǂށBBGInitialize()\x82\xAA Tera Term \x8BN\x93\xAE\x8E\x9E\x88ȊO\x82ɂ\xE0\x81A
 	//  Additional settings \x82\xA9\x82\xE7\x8CĂяo\x82\xB3\x82\xEA\x82邱\x82Ƃ\xAA\x82\xA0\x82邽\x82߁B
 	if (ts.EtermLookfeel.BGThemeFile[0] == '\0') {
-		ts.EtermLookfeel.BGEnable = BGEnable = BGGetOnOff("BGEnable", FALSE, ts.SetupFName);
+		ts.EtermLookfeel.BGEnable = BGEnable = BGGetOnOff("BGEnable", FALSE, ts.SetupFNameW);
 	}
 	else {
-		BGEnable = BGGetOnOff("BGEnable", FALSE, ts.SetupFName);
+		BGEnable = BGGetOnOff("BGEnable", FALSE, ts.SetupFNameW);
 	}
 
 	GetPrivateProfileString(BG_SECTION, "BGSPIPath", "plugin", BGSPIPath, MAX_PATH, ts.SetupFName);
@@ -1439,7 +1441,7 @@
 	// Tera Term\x82̋N\x93\xAE\x8E\x9E\x82݂̂ɏ\x89\x8A\x{227B0B7}\x82\xE9\x81B
 	if (initialize_once) {
 		// Tera Term\x8BN\x93\xAE\x8E\x9E\x82Ɉ\xEA\x93x\x82\xBE\x82\xAF\x93ǂށB
-		ts.EtermLookfeel.BGIgnoreThemeFile = BGGetOnOff("BGIgnoreThemeFile", FALSE, ts.SetupFName);
+		ts.EtermLookfeel.BGIgnoreThemeFile = BGGetOnOff("BGIgnoreThemeFile", FALSE, ts.SetupFNameW);
 	}
 
 	if (!BGEnable)
@@ -1485,10 +1487,10 @@
 	BGReverseTextAlpha = 255;
 
 	//\x90ݒ\xE8\x82̓ǂݏo\x82\xB5
-	BGReadIniFile(ts.SetupFName);
+	BGReadIniFile(ts.SetupFNameW);
 
 	//\x83R\x83\x93\x83t\x83B\x83O\x83t\x83@\x83C\x83\x8B\x82̌\x88\x92\xE8
-	GetPrivateProfileString(BG_SECTION, "BGThemeFile", "", path, MAX_PATH, ts.SetupFName);
+	GetPrivateProfileStringAFileW(BG_SECTION, "BGThemeFile", "", path, MAX_PATH, ts.SetupFNameW);
 	RandomFile(path, config_file, sizeof(config_file));
 
 	// ImageFile.INI\x82ł͂Ȃ\xA2\x8Fꍇ\x82̓\x89\x83\x93\x83_\x83\x80\x82ɑI\x82ԁB
@@ -1501,17 +1503,22 @@
 
 	//\x90ݒ\xE8\x82̃I\x81[\x83o\x81[\x83\x89\x83C\x83h
 	if (strcmp(config_file, "")) {
-		char dir[MAX_PATH], prevDir[MAX_PATH];
+		wchar_t *dir;
+		wchar_t *prevDir;
 
+		hGetCurrentDirectoryW(&prevDir);
+
 		// INI\x83t\x83@\x83C\x83\x8B\x82̂\xA0\x82\xE9\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82Ɉꎞ\x93I\x82Ɉړ\xAE
-		GetCurrentDirectory(MAX_PATH, prevDir);
+		wchar_t *config_fileW = ToWcharA(config_file);
+		dir = ExtractDirNameW(config_fileW);
+		SetCurrentDirectoryW(dir);
+		free(dir);
 
-		ExtractDirName(config_file, dir);
-		SetCurrentDirectory(dir);
+		BGReadIniFile(config_fileW);
 
-		BGReadIniFile(config_file);
-
-		SetCurrentDirectory(prevDir);
+		// \x83J\x83\x8C\x83\x93\x83g\x83t\x83H\x83\x8B\x83_\x82\xF0\x8C\xB3\x82ɖ߂\xB7
+		SetCurrentDirectoryW(prevDir);
+		free(prevDir);
 	}
 
 	//\x95ǎ\x86 or \x94w\x8Ci\x82\xF0\x83v\x83\x8A\x83\x8D\x81[\x83h


ttssh2-commit メーリングリストの案内
アーカイブの一覧に戻る