[ttssh2-commit] [9913] Eterm風 背景画像 が設定できなくなっていたので修正

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 5月 8日 (日) 22:25:16 JST


Revision: 9913
          https://osdn.net/projects/ttssh2/scm/svn/commits/9913
Author:   zmatsuo
Date:     2022-05-08 22:25:16 +0900 (Sun, 08 May 2022)
Log Message:
-----------
Eterm風 背景画像 が設定できなくなっていたので修正

- theme/以下の設定ファイル(テーマファイル)が保存できない場合があった
- 保存できるよう修正
  - 起動時に設定ファイルがないとき、
    個人設定フォルダへ設定ファイルをコピーするが、
    そのときにthemeフォルダのファイルもコピーするようにした
  - iniファイル保存時に theme フォルダを作成するようにした
- テーマファイルの書き込み時のファイルパスをUnicode化
- ETERM_SECTION を削除
  - BG_SECTION へ置き換え
- 書き換えを行わないデータに const を追加
- far キーワードを削除

ticket #44377

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

Modified Paths:
--------------
    trunk/teraterm/common/teraterm.h
    trunk/teraterm/teraterm/addsetting.cpp
    trunk/teraterm/ttpcmn/ttcmn.c
    trunk/teraterm/ttpset/ttset.c

-------------- next part --------------
Modified: trunk/teraterm/common/teraterm.h
===================================================================
--- trunk/teraterm/common/teraterm.h	2022-05-08 13:25:03 UTC (rev 9912)
+++ trunk/teraterm/common/teraterm.h	2022-05-08 13:25:16 UTC (rev 9913)
@@ -60,6 +60,7 @@
 // Eterm look-feel
 #define BG_SECTION "BG"
 #define BG_DESTFILE "BGDestFile"
+#define BG_THEME_DIR L"theme"
 #define BG_THEME_IMAGEFILE "theme\\ImageFile.INI"
 #define BG_THEME_IMAGEFILE_DEFAULT "theme\\*.INI"
 #define BG_THEME_IMAGE_BRIGHTNESS_DEFAULT 64
@@ -87,4 +88,3 @@
 		fclose(fp); \
 	} \
 }
-

Modified: trunk/teraterm/teraterm/addsetting.cpp
===================================================================
--- trunk/teraterm/teraterm/addsetting.cpp	2022-05-08 13:25:03 UTC (rev 9912)
+++ trunk/teraterm/teraterm/addsetting.cpp	2022-05-08 13:25:16 UTC (rev 9913)
@@ -643,8 +643,6 @@
 
 void CVisualPropPageDlg::OnInitDialog()
 {
-	char buf[MAXPATHLEN];
-
 	TTCPropertyPage::OnInitDialog();
 
 	static const DlgTextInfo TextInfos[] = {
@@ -702,7 +700,6 @@
 	// Eterm look-feel\x82̔w\x8Ci\x89摜\x8Ew\x92\xE8\x81B
 	SetDlgItemTextA(IDC_BGIMG_EDIT, ts.BGImageFilePath);
 
-	_snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d", ts.BGImgBrightness);
 	SetDlgItemNum(IDC_EDIT_BGIMG_BRIGHTNESS, ts.BGImgBrightness);
 
 	// BGEnable\x8A֌W\x82Ȃ\xAD\x81A\x83`\x83F\x83b\x83N\x83{\x83b\x83N\x83X\x82\xF0\x95t\x82\xAF\x82\xE9\x81B
@@ -776,6 +773,7 @@
 
 	// (5)ANSI color
 	for (int i = 0 ; i < 16 ; i++) {
+		char buf[4];
 		_snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d", i);
 		SendDlgItemMessageA(IDC_ANSI_COLOR, LB_INSERTSTRING, i, (LPARAM)buf);
 	}

Modified: trunk/teraterm/ttpcmn/ttcmn.c
===================================================================
--- trunk/teraterm/ttpcmn/ttcmn.c	2022-05-08 13:25:03 UTC (rev 9912)
+++ trunk/teraterm/ttpcmn/ttcmn.c	2022-05-08 13:25:16 UTC (rev 9913)
@@ -229,7 +229,6 @@
 			L"KEYBOARD.CNF",
 			L"cygterm.cfg",
 			L"ssh_known_hosts",
-#if 0
 			L"theme\\",
 			L"theme\\Advanced.sample",
 			L"theme\\ImageFile.INI",
@@ -241,7 +240,6 @@
 			L"theme\\tile\\03.jpg",
 			L"theme\\tile\\44.jpg",
 			L"theme\\Tile.INI",
-#endif
 			NULL,
 		};
 		CopyFiles(filelist, ts->ExeDirW, ts->HomeDirW);

Modified: trunk/teraterm/ttpset/ttset.c
===================================================================
--- trunk/teraterm/ttpset/ttset.c	2022-05-08 13:25:03 UTC (rev 9912)
+++ trunk/teraterm/ttpset/ttset.c	2022-05-08 13:25:16 UTC (rev 9913)
@@ -49,6 +49,7 @@
 #include "win32helper.h"
 #include "inifile_com.h"
 #include "ttlib_charset.h"
+#include "asprintf.h"
 
 #define DllExport __declspec(dllexport)
 #include "ttset.h"
@@ -58,11 +59,11 @@
 
 #define MaxStrLen (LONG)512
 
-static PCHAR far TermList[] =
+static const PCHAR TermList[] =
 	{ "VT100", "VT100J", "VT101", "VT102", "VT102J", "VT220J", "VT282",
 	"VT320", "VT382", "VT420", "VT520", "VT525", NULL };
 
-static PCHAR far RussList2[] = { "Windows", "KOI8-R", NULL };
+static const PCHAR RussList2[] = { "Windows", "KOI8-R", NULL };
 
 
 /*
@@ -72,16 +73,16 @@
 
 typedef struct id_str_pair {
 	WORD id;
-	char *str;
+	const char *str;
 } id_str_pair_t;
 
-static id_str_pair_t serial_conf_databit[] = {
+static const id_str_pair_t serial_conf_databit[] = {
 	{IdDataBit7, "7"},
 	{IdDataBit8, "8"},
 	{IDENDMARK, NULL},
 };
 
-static id_str_pair_t serial_conf_parity[] = {
+static const id_str_pair_t serial_conf_parity[] = {
 	{IdParityNone, "none"},
 	{IdParityOdd, "odd"},
 	{IdParityEven, "even"},
@@ -90,7 +91,7 @@
 	{IDENDMARK, NULL},
 };
 
-static id_str_pair_t serial_conf_stopbit[] = {
+static const id_str_pair_t serial_conf_stopbit[] = {
 	{IdStopBit1, "1"},
 	{IdStopBit2, "2"},
 	{IDENDMARK, NULL},
@@ -116,7 +117,7 @@
  */
 int WINAPI SerialPortConfconvertId2Str(enum serial_port_conf type, WORD id, PCHAR str, int strlen)
 {
-	id_str_pair_t *conf;
+	const id_str_pair_t *conf;
 	int ret = FALSE;
 	int i;
 
@@ -172,7 +173,7 @@
  */
 static int SerialPortConfconvertStr2Id(enum serial_port_conf type, const wchar_t *str, WORD *id)
 {
-	id_str_pair_t *conf;
+	const id_str_pair_t *conf;
 	int ret = FALSE;
 	int i;
 	char *strA;
@@ -214,7 +215,7 @@
 	return ret;
 }
 
-WORD str2id(PCHAR far * List, PCHAR str, WORD DefId)
+static WORD str2id(const PCHAR *List, PCHAR str, WORD DefId)
 {
 	WORD i;
 	i = 0;
@@ -228,7 +229,7 @@
 	return i;
 }
 
-void id2str(PCHAR far * List, WORD Id, WORD DefId, PCHAR str, int destlen)
+static void id2str(const PCHAR *List, WORD Id, WORD DefId, PCHAR str, int destlen)
 {
 	int i;
 
@@ -3069,29 +3070,41 @@
 	WritePrivateProfileString(NULL, NULL, NULL, FName);
 
 	// Eterm lookfeel alphablend (2005.4.24 yutaka)
-#define ETERM_SECTION BG_SECTION
-	WriteOnOff(ETERM_SECTION, "BGEnable", FName,
+	WriteOnOff(BG_SECTION, "BGEnable", FName,
 	           ts->EtermLookfeel.BGEnable);
-	WriteOnOff(ETERM_SECTION, "BGUseAlphaBlendAPI", FName,
+	WriteOnOff(BG_SECTION, "BGUseAlphaBlendAPI", FName,
 	           ts->EtermLookfeel.BGUseAlphaBlendAPI);
-	WritePrivateProfileString(ETERM_SECTION, "BGSPIPath",
+	WritePrivateProfileString(BG_SECTION, "BGSPIPath",
 	                          ts->EtermLookfeel.BGSPIPath, FName);
-	WriteOnOff(ETERM_SECTION, "BGFastSizeMove", FName,
+	WriteOnOff(BG_SECTION, "BGFastSizeMove", FName,
 	           ts->EtermLookfeel.BGFastSizeMove);
-	WriteOnOff(ETERM_SECTION, "BGFlickerlessMove", FName,
+	WriteOnOff(BG_SECTION, "BGFlickerlessMove", FName,
 	           ts->EtermLookfeel.BGNoCopyBits);
-	WriteOnOff(ETERM_SECTION, "BGNoFrame", FName,
+	WriteOnOff(BG_SECTION, "BGNoFrame", FName,
 	           ts->EtermLookfeel.BGNoFrame);
-	WritePrivateProfileString(ETERM_SECTION, "BGThemeFile",
+	WritePrivateProfileString(BG_SECTION, "BGThemeFile",
 	                          ts->EtermLookfeel.BGThemeFile, FName);
+
+	// theme\x83t\x83H\x83\x8B\x83_\x82\xF0\x8D\xEC\x82\xE9
 	{
-		wchar_t TempW[MAX_PATH];
-		_snwprintf_s(TempW, _countof(TempW), _TRUNCATE, L"%hs\\%hs", ts->HomeDir, BG_THEME_IMAGEFILE);
-		WritePrivateProfileStringA(BG_SECTION, BG_DESTFILE, ts->BGImageFilePath, TempW);
-		WriteInt(BG_SECTION, BG_THEME_IMAGE_BRIGHTNESS1, TempW, ts->BGImgBrightness);
-		WriteInt(BG_SECTION, BG_THEME_IMAGE_BRIGHTNESS2, TempW, ts->BGImgBrightness);
+		wchar_t *theme_folder = NULL;
+		awcscats(&theme_folder, ts->HomeDirW, L"\\", BG_THEME_DIR, NULL);
+		CreateDirectoryW(theme_folder, NULL);
+		free(theme_folder);
 	}
-	WriteOnOff(ETERM_SECTION, "BGIgnoreThemeFile", FName,
+
+	// \x83e\x81[\x83}\x83t\x83@\x83C\x83\x8B\x82ɕۑ\xB6("theme\\ImageFile.INI")
+	//		TODO BGThemeFile\x82̓`\x83F\x83b\x83N\x82\xB5\x82Ȃ\xAD\x82Ă悢?
+	{
+		wchar_t *theme_file = NULL;
+		aswprintf(&theme_file, L"%s\\%hs", ts->HomeDirW, BG_THEME_IMAGEFILE);
+		WritePrivateProfileStringAFileW(BG_SECTION, BG_DESTFILE, ts->BGImageFilePath, theme_file);
+		WriteInt(BG_SECTION, BG_THEME_IMAGE_BRIGHTNESS1, theme_file, ts->BGImgBrightness);
+		WriteInt(BG_SECTION, BG_THEME_IMAGE_BRIGHTNESS2, theme_file, ts->BGImgBrightness);
+		free(theme_file);
+	}
+
+	WriteOnOff(BG_SECTION, "BGIgnoreThemeFile", FName,
 		ts->EtermLookfeel.BGIgnoreThemeFile);
 
 #ifdef USE_NORMAL_BGCOLOR
@@ -4123,6 +4136,8 @@
 BOOL WINAPI DllMain(HANDLE hInst,
                     ULONG ul_reason_for_call, LPVOID lpReserved)
 {
+	(void)hInst;
+	(void)lpReserved;
 	switch (ul_reason_for_call) {
 	case DLL_THREAD_ATTACH:
 		/* do thread initialization */


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