• R/O
  • SSH
  • HTTPS

ttssh2: コミット


コミットメタ情報

リビジョン9958 (tree)
日時2022-05-24 23:21:07
作者zmatsuo

ログメッセージ

テーマファイルの読み込み部分を Unicode 化

ticket #44048

変更サマリ

差分

--- trunk/teraterm/teraterm/vtdisp.c (revision 9957)
+++ trunk/teraterm/teraterm/vtdisp.c (revision 9958)
@@ -42,6 +42,8 @@
4242 #include "setting.h"
4343 #include "codeconv.h"
4444 #include "libsusieplugin.h"
45+#include "inifile_com.h"
46+#include "win32helper.h"
4547
4648 #include "vtdisp.h"
4749
@@ -1193,7 +1195,7 @@
11931195 }
11941196 }
11951197
1196-static COLORREF BGGetColor(char *name, COLORREF defcolor, char *file)
1198+static COLORREF BGGetColor(const char *name, COLORREF defcolor, const wchar_t *file)
11971199 {
11981200 unsigned int r, g, b;
11991201 char colorstr[256], defstr[256];
@@ -1201,7 +1203,7 @@
12011203 _snprintf_s(defstr, sizeof(defstr), _TRUNCATE, "%d,%d,%d", GetRValue(defcolor), GetGValue(defcolor),
12021204 GetBValue(defcolor));
12031205
1204- GetPrivateProfileString(BG_SECTION, name, defstr, colorstr, 255, file);
1206+ GetPrivateProfileStringAFileW(BG_SECTION, name, defstr, colorstr, 255, file);
12051207
12061208 r = g = b = 0;
12071209
@@ -1210,7 +1212,7 @@
12101212 return RGB(r, g, b);
12111213 }
12121214
1213-static BG_PATTERN BGGetStrIndex(char *name, BG_PATTERN def, char *file, char **strList, int nList)
1215+static int BGGetStrIndex(const char *name, int def, const wchar_t *file, const char * const *strList, int nList)
12141216 {
12151217 char defstr[64], str[64];
12161218 int i;
@@ -1218,7 +1220,7 @@
12181220 def %= nList;
12191221
12201222 strncpy_s(defstr, sizeof(defstr), strList[def], _TRUNCATE);
1221- GetPrivateProfileString(BG_SECTION, name, defstr, str, 64, file);
1223+ GetPrivateProfileStringAFileW(BG_SECTION, name, defstr, str, 64, file);
12221224
12231225 for (i = 0; i < nList; i++)
12241226 if (!_stricmp(str, strList[i]))
@@ -1227,28 +1229,28 @@
12271229 return 0;
12281230 }
12291231
1230-static BOOL BGGetOnOff(char *name, BOOL def, char *file)
1232+static BOOL BGGetOnOff(const char *name, BOOL def, const wchar_t *file)
12311233 {
1232- char *strList[2] = {"Off", "On"};
1234+ static const char * const strList[2] = {"Off", "On"};
12331235
12341236 return BGGetStrIndex(name, def, file, strList, 2);
12351237 }
12361238
1237-static BG_PATTERN BGGetPattern(char *name, BG_PATTERN def, char *file)
1239+static BG_PATTERN BGGetPattern(const char *name, BG_PATTERN def, const wchar_t *file)
12381240 {
1239- char *strList[6] = {"stretch", "tile", "center", "fitwidth", "fitheight", "autofit"};
1241+ static const char *strList[6] = {"stretch", "tile", "center", "fitwidth", "fitheight", "autofit"};
12401242
12411243 return BGGetStrIndex(name, def, file, strList, 6);
12421244 }
12431245
1244-static BG_TYPE BGGetType(char *name, BG_TYPE def, char *file)
1246+static BG_TYPE BGGetType(const char *name, BG_TYPE def, const wchar_t *file)
12451247 {
1246- char *strList[3] = {"color", "picture", "wallpaper"};
1248+ static const char *strList[3] = {"color", "picture", "wallpaper"};
12471249
12481250 return BGGetStrIndex(name, def, file, strList, 3);
12491251 }
12501252
1251-static void BGReadTextColorConfig(char *file)
1253+static void BGReadTextColorConfig(const wchar_t *file)
12521254 {
12531255 ANSIColor[IdFore] = BGGetColor("Fore", ANSIColor[IdFore], file);
12541256 ANSIColor[IdBack] = BGGetColor("Back", ANSIColor[IdBack], file);
@@ -1286,7 +1288,7 @@
12861288 /* end - ishizaki */
12871289 }
12881290
1289-static void BGReadIniFile(char *file)
1291+static void BGReadIniFile(const wchar_t *file)
12901292 {
12911293 char path[MAX_PATH];
12921294
@@ -1294,27 +1296,27 @@
12941296 BGDest.pattern = BGGetPattern("BGPicturePattern", BGSrc1.pattern, file);
12951297 BGDest.color = BGGetColor("BGPictureBaseColor", BGSrc1.color, file);
12961298
1297- GetPrivateProfileString(BG_SECTION, "BGPictureFile", BGSrc1.file, path, MAX_PATH, file);
1299+ GetPrivateProfileStringAFileW(BG_SECTION, "BGPictureFile", BGSrc1.file, path, MAX_PATH, file);
12981300 RandomFile(path, BGDest.file, sizeof(BGDest.file));
12991301
1300- BGSrc1.alpha = 255 - GetPrivateProfileInt(BG_SECTION, "BGPictureTone", 255 - BGSrc1.alpha, file);
1302+ BGSrc1.alpha = 255 - GetPrivateProfileIntAFileW(BG_SECTION, "BGPictureTone", 255 - BGSrc1.alpha, file);
13011303
13021304 if (!strcmp(BGDest.file, ""))
13031305 BGSrc1.alpha = 255;
13041306
1305- BGSrc2.alpha = 255 - GetPrivateProfileInt(BG_SECTION, "BGFadeTone", 255 - BGSrc2.alpha, file);
1307+ BGSrc2.alpha = 255 - GetPrivateProfileIntAFileW(BG_SECTION, "BGFadeTone", 255 - BGSrc2.alpha, file);
13061308 BGSrc2.color = BGGetColor("BGFadeColor", BGSrc2.color, file);
13071309
1308- BGReverseTextAlpha = GetPrivateProfileInt(BG_SECTION, "BGReverseTextTone", BGReverseTextAlpha, file);
1310+ BGReverseTextAlpha = GetPrivateProfileIntAFileW(BG_SECTION, "BGReverseTextTone", BGReverseTextAlpha, file);
13091311
13101312 // Src1 の読み出し
13111313 BGSrc1.type = BGGetType("BGSrc1Type", BGSrc1.type, file);
13121314 BGSrc1.pattern = BGGetPattern("BGSrc1Pattern", BGSrc1.pattern, file);
13131315 BGSrc1.antiAlias = BGGetOnOff("BGSrc1AntiAlias", BGSrc1.antiAlias, file);
1314- BGSrc1.alpha = GetPrivateProfileInt(BG_SECTION, "BGSrc1Alpha", BGSrc1.alpha, file);
1316+ BGSrc1.alpha = GetPrivateProfileIntAFileW(BG_SECTION, "BGSrc1Alpha", BGSrc1.alpha, file);
13151317 BGSrc1.color = BGGetColor("BGSrc1Color", BGSrc1.color, file);
13161318
1317- GetPrivateProfileString(BG_SECTION, "BGSrc1File", BGSrc1.file, path, MAX_PATH, file);
1319+ GetPrivateProfileStringAFileW(BG_SECTION, "BGSrc1File", BGSrc1.file, path, MAX_PATH, file);
13181320 RandomFile(path, BGSrc1.file, sizeof(BGSrc1.file));
13191321
13201322 // Src2 の読み出し
@@ -1321,10 +1323,10 @@
13211323 BGSrc2.type = BGGetType("BGSrc2Type", BGSrc2.type, file);
13221324 BGSrc2.pattern = BGGetPattern("BGSrc2Pattern", BGSrc2.pattern, file);
13231325 BGSrc2.antiAlias = BGGetOnOff("BGSrc2AntiAlias", BGSrc2.antiAlias, file);
1324- BGSrc2.alpha = GetPrivateProfileInt(BG_SECTION, "BGSrc2Alpha", BGSrc2.alpha, file);
1326+ BGSrc2.alpha = GetPrivateProfileIntAFileW(BG_SECTION, "BGSrc2Alpha", BGSrc2.alpha, file);
13251327 BGSrc2.color = BGGetColor("BGSrc2Color", BGSrc2.color, file);
13261328
1327- GetPrivateProfileString(BG_SECTION, "BGSrc2File", BGSrc2.file, path, MAX_PATH, file);
1329+ GetPrivateProfileStringAFileW(BG_SECTION, "BGSrc2File", BGSrc2.file, path, MAX_PATH, file);
13281330 RandomFile(path, BGSrc2.file, sizeof(BGSrc2.file));
13291331
13301332 // Dest の読み出し
@@ -1333,11 +1335,11 @@
13331335 BGDest.antiAlias = BGGetOnOff("BGDestAntiAlias", BGDest.antiAlias, file);
13341336 BGDest.color = BGGetColor("BGDestColor", BGDest.color, file);
13351337
1336- GetPrivateProfileString(BG_SECTION, BG_DESTFILE, BGDest.file, path, MAX_PATH, file);
1338+ GetPrivateProfileStringAFileW(BG_SECTION, BG_DESTFILE, BGDest.file, path, MAX_PATH, file);
13371339 RandomFile(path, BGDest.file, sizeof(BGDest.file));
13381340
13391341 //その他読み出し
1340- BGReverseTextAlpha = GetPrivateProfileInt(BG_SECTION, "BGReverseTextAlpha", BGReverseTextAlpha, file);
1342+ BGReverseTextAlpha = GetPrivateProfileIntAFileW(BG_SECTION, "BGReverseTextAlpha", BGReverseTextAlpha, file);
13411343 BGReadTextColorConfig(file);
13421344 }
13431345
@@ -1411,10 +1413,10 @@
14111413 // 空の場合のみ、ディスクから読む。BGInitialize()が Tera Term 起動時以外にも、
14121414 // Additional settings から呼び出されることがあるため。
14131415 if (ts.EtermLookfeel.BGThemeFile[0] == '\0') {
1414- ts.EtermLookfeel.BGEnable = BGEnable = BGGetOnOff("BGEnable", FALSE, ts.SetupFName);
1416+ ts.EtermLookfeel.BGEnable = BGEnable = BGGetOnOff("BGEnable", FALSE, ts.SetupFNameW);
14151417 }
14161418 else {
1417- BGEnable = BGGetOnOff("BGEnable", FALSE, ts.SetupFName);
1419+ BGEnable = BGGetOnOff("BGEnable", FALSE, ts.SetupFNameW);
14181420 }
14191421
14201422 GetPrivateProfileString(BG_SECTION, "BGSPIPath", "plugin", BGSPIPath, MAX_PATH, ts.SetupFName);
@@ -1439,7 +1441,7 @@
14391441 // Tera Termの起動時のみに初期化する。
14401442 if (initialize_once) {
14411443 // Tera Term起動時に一度だけ読む。
1442- ts.EtermLookfeel.BGIgnoreThemeFile = BGGetOnOff("BGIgnoreThemeFile", FALSE, ts.SetupFName);
1444+ ts.EtermLookfeel.BGIgnoreThemeFile = BGGetOnOff("BGIgnoreThemeFile", FALSE, ts.SetupFNameW);
14431445 }
14441446
14451447 if (!BGEnable)
@@ -1485,10 +1487,10 @@
14851487 BGReverseTextAlpha = 255;
14861488
14871489 //設定の読み出し
1488- BGReadIniFile(ts.SetupFName);
1490+ BGReadIniFile(ts.SetupFNameW);
14891491
14901492 //コンフィグファイルの決定
1491- GetPrivateProfileString(BG_SECTION, "BGThemeFile", "", path, MAX_PATH, ts.SetupFName);
1493+ GetPrivateProfileStringAFileW(BG_SECTION, "BGThemeFile", "", path, MAX_PATH, ts.SetupFNameW);
14921494 RandomFile(path, config_file, sizeof(config_file));
14931495
14941496 // ImageFile.INIではない場合はランダムに選ぶ。
@@ -1501,17 +1503,22 @@
15011503
15021504 //設定のオーバーライド
15031505 if (strcmp(config_file, "")) {
1504- char dir[MAX_PATH], prevDir[MAX_PATH];
1506+ wchar_t *dir;
1507+ wchar_t *prevDir;
15051508
1509+ hGetCurrentDirectoryW(&prevDir);
1510+
15061511 // INIファイルのあるディレクトリに一時的に移動
1507- GetCurrentDirectory(MAX_PATH, prevDir);
1512+ wchar_t *config_fileW = ToWcharA(config_file);
1513+ dir = ExtractDirNameW(config_fileW);
1514+ SetCurrentDirectoryW(dir);
1515+ free(dir);
15081516
1509- ExtractDirName(config_file, dir);
1510- SetCurrentDirectory(dir);
1517+ BGReadIniFile(config_fileW);
15111518
1512- BGReadIniFile(config_file);
1513-
1514- SetCurrentDirectory(prevDir);
1519+ // カレントフォルダを元に戻す
1520+ SetCurrentDirectoryW(prevDir);
1521+ free(prevDir);
15151522 }
15161523
15171524 //壁紙 or 背景をプリロード
旧リポジトリブラウザで表示