| 1 |
zmatsuo |
10256 |
/* |
| 2 |
|
|
* Copyright (C) 1994-1998 T. Teranishi |
| 3 |
|
|
* (C) 2005- TeraTerm Project |
| 4 |
|
|
* All rights reserved. |
| 5 |
|
|
* |
| 6 |
|
|
* Redistribution and use in source and binary forms, with or without |
| 7 |
|
|
* modification, are permitted provided that the following conditions |
| 8 |
|
|
* are met: |
| 9 |
|
|
* |
| 10 |
|
|
* 1. Redistributions of source code must retain the above copyright |
| 11 |
|
|
* notice, this list of conditions and the following disclaimer. |
| 12 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
| 13 |
|
|
* notice, this list of conditions and the following disclaimer in the |
| 14 |
|
|
* documentation and/or other materials provided with the distribution. |
| 15 |
|
|
* 3. The name of the author may not be used to endorse or promote products |
| 16 |
|
|
* derived from this software without specific prior written permission. |
| 17 |
|
|
* |
| 18 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR |
| 19 |
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 |
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 21 |
|
|
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 |
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 23 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 |
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 |
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 |
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 |
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 |
|
|
*/ |
| 29 |
|
|
|
| 30 |
|
|
#include <string.h> |
| 31 |
|
|
#include <stdio.h> |
| 32 |
|
|
|
| 33 |
|
|
#include "tttypes.h" |
| 34 |
|
|
#include "compat_win.h" |
| 35 |
|
|
#include "asprintf.h" |
| 36 |
|
|
#include "inifile_com.h" |
| 37 |
|
|
#include "win32helper.h" |
| 38 |
zmatsuo |
10303 |
#include "codeconv.h" |
| 39 |
zmatsuo |
10256 |
|
| 40 |
|
|
#include "theme.h" |
| 41 |
|
|
|
| 42 |
zmatsuo |
10332 |
#define BG_SECTION_OLD L"BG" |
| 43 |
|
|
#define BG_SECTION_NEW L"BG Theme" |
| 44 |
|
|
#define COLOR_THEME_SECTION L"Color Theme" |
| 45 |
zmatsuo |
10256 |
|
| 46 |
zmatsuo |
10332 |
#if !defined(offsetof) |
| 47 |
|
|
#define offsetof(s,m) ((size_t)&(((s*)0)->m)) |
| 48 |
|
|
#endif |
| 49 |
|
|
|
| 50 |
zmatsuo |
10303 |
/** |
| 51 |
|
|
* ANSI256�F��������16�F |
| 52 |
|
|
* INI�t�@�C���������������������L�[���[�h���F�������� |
| 53 |
|
|
*/ |
| 54 |
|
|
static const struct { |
| 55 |
|
|
int index; |
| 56 |
|
|
const wchar_t *key; |
| 57 |
|
|
} ansi_list[] = { |
| 58 |
zmatsuo |
10332 |
{ 7 + 8, L"Fore" }, |
| 59 |
|
|
{ 0, L"Back" }, |
| 60 |
|
|
{ 1 + 8, L"Red" }, |
| 61 |
|
|
{ 2 + 8, L"Green" }, |
| 62 |
|
|
{ 3 + 8, L"Yellow" }, |
| 63 |
|
|
{ 4 + 8, L"Blue" }, |
| 64 |
|
|
{ 5 + 8, L"Magenta" }, |
| 65 |
|
|
{ 6 + 8, L"Cyan" }, |
| 66 |
zmatsuo |
10303 |
|
| 67 |
zmatsuo |
10332 |
{ 7, L"DarkFore" }, |
| 68 |
|
|
{ 0 + 8, L"DarkBack" }, |
| 69 |
|
|
{ 1, L"DarkRed" }, |
| 70 |
|
|
{ 2, L"DarkGreen" }, |
| 71 |
|
|
{ 3, L"DarkYellow" }, |
| 72 |
|
|
{ 4, L"DarkBlue" }, |
| 73 |
|
|
{ 5, L"DarkMagenta" }, |
| 74 |
|
|
{ 6, L"DarkCyan" }, |
| 75 |
zmatsuo |
10303 |
}; |
| 76 |
|
|
|
| 77 |
zmatsuo |
10332 |
/** |
| 78 |
|
|
* INI�t�@�C�����L�[���[�h��TColorTheme�\�����������o�[�������\ |
| 79 |
|
|
*/ |
| 80 |
|
|
static const struct { |
| 81 |
|
|
const wchar_t *key; |
| 82 |
|
|
size_t offset; |
| 83 |
|
|
} color_attr_list[] = { |
| 84 |
|
|
{ L"VTColor", offsetof(TColorTheme, vt) }, |
| 85 |
|
|
{ L"BoldColor", offsetof(TColorTheme, bold) }, |
| 86 |
|
|
{ L"BlinkColor", offsetof(TColorTheme, blink) }, |
| 87 |
|
|
{ L"ReverseColor", offsetof(TColorTheme, reverse) }, |
| 88 |
|
|
{ L"URLColor", offsetof(TColorTheme, url) }, |
| 89 |
|
|
{ L"VTUnderlineColor", offsetof(TColorTheme, underline) }, |
| 90 |
|
|
}; |
| 91 |
|
|
|
| 92 |
zmatsuo |
10256 |
const BG_PATTERN_ST *ThemeBGPatternList(int index) |
| 93 |
|
|
{ |
| 94 |
|
|
static const BG_PATTERN_ST bg_pattern_list[] = { |
| 95 |
zmatsuo |
10332 |
{ BG_STRETCH, L"stretch" }, |
| 96 |
|
|
{ BG_TILE, L"tile" }, |
| 97 |
|
|
{ BG_CENTER, L"center" }, |
| 98 |
|
|
{ BG_FIT_WIDTH, L"fit_width" }, |
| 99 |
|
|
{ BG_FIT_HEIGHT, L"fit_height" }, |
| 100 |
|
|
{ BG_AUTOFIT, L"autofit" }, |
| 101 |
|
|
{ BG_AUTOFILL, L"autofill" }, |
| 102 |
zmatsuo |
10256 |
}; |
| 103 |
|
|
|
| 104 |
|
|
if (index >= _countof(bg_pattern_list)) { |
| 105 |
|
|
return NULL; |
| 106 |
|
|
} |
| 107 |
|
|
return &bg_pattern_list[index]; |
| 108 |
|
|
} |
| 109 |
|
|
|
| 110 |
zmatsuo |
10303 |
static COLORREF LoadColorOneANSI(const wchar_t *section, const wchar_t *key, const wchar_t *file, COLORREF defcolor) |
| 111 |
|
|
{ |
| 112 |
|
|
int r; |
| 113 |
|
|
wchar_t *str; |
| 114 |
|
|
DWORD e = hGetPrivateProfileStringW(section, key, NULL, file, &str); |
| 115 |
|
|
if (e != 0 || *str == 0) { |
| 116 |
|
|
free(str); |
| 117 |
|
|
return defcolor; |
| 118 |
|
|
} |
| 119 |
|
|
if (*str == L'#') { |
| 120 |
|
|
// #RRGGBB �`�� |
| 121 |
|
|
DWORD i32; |
| 122 |
|
|
r = swscanf_s(str, L"#%08x", &i32); |
| 123 |
|
|
if (r == 1) { |
| 124 |
|
|
free(str); |
| 125 |
|
|
return RGB((i32 & 0xff0000) >> 16, (i32 & 0x00ff00) >> 8, (i32 & 0x0000ff)); |
| 126 |
|
|
} |
| 127 |
|
|
} |
| 128 |
|
|
// R, G, B �`�� |
| 129 |
|
|
int red, green, blue; |
| 130 |
|
|
r = swscanf_s(str, L"%d , %d , %d", &red, &green, &blue); |
| 131 |
|
|
free(str); |
| 132 |
|
|
if (r == 3) { |
| 133 |
|
|
return RGB(red, green, blue); |
| 134 |
|
|
} |
| 135 |
|
|
return defcolor; |
| 136 |
|
|
} |
| 137 |
|
|
|
| 138 |
zmatsuo |
10332 |
static COLORREF BGGetColor(const wchar_t *section, const wchar_t *key, COLORREF defcolor, const wchar_t *file) |
| 139 |
zmatsuo |
10256 |
{ |
| 140 |
zmatsuo |
10332 |
COLORREF color = LoadColorOneANSI(section, key, file, defcolor); |
| 141 |
zmatsuo |
10303 |
return color; |
| 142 |
zmatsuo |
10256 |
} |
| 143 |
|
|
|
| 144 |
|
|
/* |
| 145 |
|
|
* color theme�p���[�h |
| 146 |
|
|
*/ |
| 147 |
zmatsuo |
10303 |
static void ThemeLoadColorOld(const wchar_t *file, TColorTheme *theme) |
| 148 |
zmatsuo |
10256 |
{ |
| 149 |
zmatsuo |
10332 |
const wchar_t *section = BG_SECTION_OLD; |
| 150 |
zmatsuo |
10303 |
theme->ansicolor.change = TRUE; |
| 151 |
|
|
|
| 152 |
zmatsuo |
10332 |
theme->ansicolor.color[IdFore] = BGGetColor(section, L"Fore", theme->ansicolor.color[IdFore], file); |
| 153 |
|
|
theme->ansicolor.color[IdBack] = BGGetColor(section, L"Back", theme->ansicolor.color[IdBack], file); |
| 154 |
|
|
theme->ansicolor.color[IdRed] = BGGetColor(section, L"Red", theme->ansicolor.color[IdRed], file); |
| 155 |
|
|
theme->ansicolor.color[IdGreen] = BGGetColor(section, L"Green", theme->ansicolor.color[IdGreen], file); |
| 156 |
|
|
theme->ansicolor.color[IdYellow] = BGGetColor(section, L"Yellow", theme->ansicolor.color[IdYellow], file); |
| 157 |
|
|
theme->ansicolor.color[IdBlue] = BGGetColor(section, L"Blue", theme->ansicolor.color[IdBlue], file); |
| 158 |
|
|
theme->ansicolor.color[IdMagenta] = BGGetColor(section, L"Magenta", theme->ansicolor.color[IdMagenta], file); |
| 159 |
|
|
theme->ansicolor.color[IdCyan] = BGGetColor(section, L"Cyan", theme->ansicolor.color[IdCyan], file); |
| 160 |
zmatsuo |
10256 |
|
| 161 |
zmatsuo |
10332 |
theme->ansicolor.color[IdFore + 8] = BGGetColor(section, L"DarkFore", theme->ansicolor.color[IdFore + 8], file); |
| 162 |
|
|
theme->ansicolor.color[IdBack + 8] = BGGetColor(section, L"DarkBack", theme->ansicolor.color[IdBack + 8], file); |
| 163 |
|
|
theme->ansicolor.color[IdRed + 8] = BGGetColor(section, L"DarkRed", theme->ansicolor.color[IdRed + 8], file); |
| 164 |
|
|
theme->ansicolor.color[IdGreen + 8] = BGGetColor(section, L"DarkGreen", theme->ansicolor.color[IdGreen + 8], file); |
| 165 |
|
|
theme->ansicolor.color[IdYellow + 8] = BGGetColor(section, L"DarkYellow", theme->ansicolor.color[IdYellow + 8], file); |
| 166 |
|
|
theme->ansicolor.color[IdBlue + 8] = BGGetColor(section, L"DarkBlue", theme->ansicolor.color[IdBlue + 8], file); |
| 167 |
|
|
theme->ansicolor.color[IdMagenta + 8] = BGGetColor(section, L"DarkMagenta", theme->ansicolor.color[IdMagenta + 8], file); |
| 168 |
|
|
theme->ansicolor.color[IdCyan + 8] = BGGetColor(section, L"DarkCyan", theme->ansicolor.color[IdCyan + 8], file); |
| 169 |
zmatsuo |
10256 |
|
| 170 |
zmatsuo |
10332 |
theme->vt.fg = BGGetColor(section, L"VTFore", theme->vt.fg, file); |
| 171 |
|
|
theme->vt.bg = BGGetColor(section, L"VTBack", theme->vt.bg, file); |
| 172 |
zmatsuo |
10303 |
theme->vt.change = TRUE; |
| 173 |
|
|
theme->vt.enable = TRUE; |
| 174 |
zmatsuo |
10256 |
|
| 175 |
zmatsuo |
10332 |
theme->blink.fg = BGGetColor(section, L"VTBlinkFore", theme->blink.fg, file); |
| 176 |
|
|
theme->blink.bg = BGGetColor(section, L"VTBlinkBack", theme->blink.bg, file); |
| 177 |
zmatsuo |
10303 |
theme->blink.change = TRUE; |
| 178 |
|
|
theme->blink.enable = TRUE; |
| 179 |
zmatsuo |
10256 |
|
| 180 |
zmatsuo |
10332 |
theme->bold.fg = BGGetColor(section, L"VTBoldFore", theme->bold.fg, file); |
| 181 |
|
|
theme->bold.bg = BGGetColor(section, L"VTBoldBack", theme->bold.bg, file); |
| 182 |
zmatsuo |
10303 |
theme->bold.change = TRUE; |
| 183 |
|
|
theme->bold.enable = TRUE; |
| 184 |
zmatsuo |
10256 |
|
| 185 |
zmatsuo |
10332 |
theme->underline.fg = BGGetColor(section, L"VTUnderlineFore", theme->underline.fg, file); |
| 186 |
|
|
theme->underline.bg = BGGetColor(section, L"VTUnderlineBack", theme->underline.bg, file); |
| 187 |
zmatsuo |
10303 |
theme->underline.change = TRUE; |
| 188 |
|
|
theme->underline.enable = TRUE; |
| 189 |
zmatsuo |
10256 |
|
| 190 |
zmatsuo |
10332 |
theme->reverse.fg = BGGetColor(section, L"VTReverseFore", theme->reverse.fg, file); |
| 191 |
|
|
theme->reverse.bg = BGGetColor(section, L"VTReverseBack", theme->reverse.bg, file); |
| 192 |
zmatsuo |
10303 |
theme->reverse.change = TRUE; |
| 193 |
|
|
theme->reverse.enable = TRUE; |
| 194 |
zmatsuo |
10256 |
|
| 195 |
zmatsuo |
10332 |
theme->url.fg = BGGetColor(section, L"URLFore", theme->url.fg, file); |
| 196 |
|
|
theme->url.bg = BGGetColor(section, L"URLBack", theme->url.bg, file); |
| 197 |
zmatsuo |
10303 |
theme->url.change = TRUE; |
| 198 |
|
|
theme->url.enable = TRUE; |
| 199 |
zmatsuo |
10256 |
} |
| 200 |
|
|
|
| 201 |
|
|
/** |
| 202 |
zmatsuo |
10303 |
* save color one attribute |
| 203 |
zmatsuo |
10256 |
*/ |
| 204 |
zmatsuo |
10332 |
static void BGSaveColorOne(const wchar_t *section, const wchar_t *key, const TColorSetting *color, const wchar_t *fn) |
| 205 |
zmatsuo |
10256 |
{ |
| 206 |
zmatsuo |
10303 |
wchar_t *buf; |
| 207 |
zmatsuo |
10256 |
COLORREF fg = color->fg; |
| 208 |
|
|
COLORREF bg = color->bg; |
| 209 |
zmatsuo |
10303 |
int sp_len = 20 - (int)wcslen(key); |
| 210 |
zmatsuo |
10332 |
aswprintf(&buf, L"%*.*s %d,%d, %3hhu,%3hhu,%3hhu, %3hhu,%3hhu,%3hhu ; #%02x%02x%02x, #%02x%02x%02x", |
| 211 |
zmatsuo |
10303 |
sp_len, sp_len, L" ", |
| 212 |
|
|
color->change, color->enable, |
| 213 |
|
|
GetRValue(fg), GetGValue(fg), GetBValue(fg), |
| 214 |
|
|
GetRValue(bg), GetGValue(bg), GetBValue(bg), |
| 215 |
|
|
GetRValue(fg), GetGValue(fg), GetBValue(fg), |
| 216 |
|
|
GetRValue(bg), GetGValue(bg), GetBValue(bg)); |
| 217 |
|
|
WritePrivateProfileStringW(section, key, buf, fn); |
| 218 |
|
|
free(buf); |
| 219 |
|
|
} |
| 220 |
zmatsuo |
10256 |
|
| 221 |
zmatsuo |
10332 |
#if 1 |
| 222 |
|
|
static void BGSaveColorANSI(const wchar_t *section, const TAnsiColorSetting *color, const wchar_t *fn) |
| 223 |
zmatsuo |
10303 |
{ |
| 224 |
zmatsuo |
10256 |
int i; |
| 225 |
|
|
wchar_t *buff = NULL; |
| 226 |
|
|
awcscat(&buff, L"1, 1, "); |
| 227 |
|
|
|
| 228 |
|
|
for (i = 0; i < 16; i++) { |
| 229 |
|
|
wchar_t color_str[32]; |
| 230 |
|
|
const COLORREF c = color->color[i]; |
| 231 |
zmatsuo |
10303 |
swprintf(color_str, _countof(color_str), L"%hhu,%hhu,%hhu, ", GetRValue(c), GetGValue(c), GetBValue(c)); |
| 232 |
zmatsuo |
10256 |
awcscat(&buff, color_str); |
| 233 |
|
|
} |
| 234 |
|
|
|
| 235 |
zmatsuo |
10332 |
WritePrivateProfileStringW(section, L"ANSIColor", buff, fn); |
| 236 |
zmatsuo |
10256 |
free(buff); |
| 237 |
|
|
} |
| 238 |
zmatsuo |
10332 |
#endif |
| 239 |
zmatsuo |
10256 |
|
| 240 |
zmatsuo |
10303 |
static void SaveColorOneANSI(const wchar_t *section, const wchar_t *key, const wchar_t *file, COLORREF color, int index) |
| 241 |
zmatsuo |
10256 |
{ |
| 242 |
zmatsuo |
10303 |
const BYTE r = GetRValue(color); |
| 243 |
|
|
const BYTE g = GetGValue(color); |
| 244 |
|
|
const BYTE b = GetBValue(color); |
| 245 |
|
|
int sp_len = 20 - (int)wcslen(key); |
| 246 |
|
|
wchar_t *str; |
| 247 |
|
|
aswprintf(&str, L"%*.*s %3hhu, %3hhu, %3hhu ; #%02hhx%02hhx%02hhx ; ANSIColor[%2d]", |
| 248 |
|
|
sp_len, sp_len, L" ", |
| 249 |
|
|
r, g, b, r, g, b, index); |
| 250 |
|
|
WritePrivateProfileStringW(section, key, str, file); |
| 251 |
|
|
free(str); |
| 252 |
|
|
} |
| 253 |
|
|
|
| 254 |
|
|
static void SaveColorANSINew(const wchar_t *section, const TAnsiColorSetting *color, const wchar_t *fname) |
| 255 |
|
|
{ |
| 256 |
|
|
wchar_t *str; |
| 257 |
|
|
aswprintf(&str, L"%d", color->change); |
| 258 |
|
|
WritePrivateProfileStringW(section, L"ANSIColor", str, fname); |
| 259 |
|
|
free(str); |
| 260 |
|
|
|
| 261 |
|
|
for (int i = 0; i < _countof(ansi_list); i++) { |
| 262 |
|
|
const int index = ansi_list[i].index; |
| 263 |
|
|
const wchar_t *key = ansi_list[i].key; |
| 264 |
|
|
SaveColorOneANSI(section, key, fname, color->color[index], index); |
| 265 |
|
|
} |
| 266 |
|
|
} |
| 267 |
|
|
|
| 268 |
|
|
/** |
| 269 |
|
|
* �J���[�e�[�}������ |
| 270 |
zmatsuo |
10332 |
* TODO ���� |
| 271 |
zmatsuo |
10303 |
*/ |
| 272 |
zmatsuo |
10332 |
#if 1 |
| 273 |
zmatsuo |
10303 |
void ThemeSaveColorOld(TColorTheme *color_theme, const wchar_t *fn) |
| 274 |
|
|
{ |
| 275 |
zmatsuo |
10332 |
const wchar_t *section = COLOR_THEME_SECTION; |
| 276 |
zmatsuo |
10256 |
|
| 277 |
zmatsuo |
10332 |
WritePrivateProfileStringW(section, L"Theme", color_theme->name, fn); |
| 278 |
zmatsuo |
10256 |
|
| 279 |
zmatsuo |
10332 |
for (int i = 0; i < _countof(color_attr_list); i++) { |
| 280 |
|
|
const wchar_t *key = color_attr_list[i].key; |
| 281 |
|
|
const TColorSetting *color = (TColorSetting *)((UINT_PTR)color_theme + color_attr_list[i].offset); |
| 282 |
|
|
BGSaveColorOne(section, key, color, fn); |
| 283 |
|
|
} |
| 284 |
|
|
|
| 285 |
|
|
BGSaveColorANSI(section, &(color_theme->ansicolor), fn); |
| 286 |
zmatsuo |
10256 |
} |
| 287 |
zmatsuo |
10332 |
#endif |
| 288 |
zmatsuo |
10256 |
|
| 289 |
zmatsuo |
10332 |
/** |
| 290 |
|
|
* �J���[�e�[�}������ |
| 291 |
|
|
*/ |
| 292 |
zmatsuo |
10303 |
void ThemeSaveColor(TColorTheme *color_theme, const wchar_t *fn) |
| 293 |
|
|
{ |
| 294 |
zmatsuo |
10332 |
const wchar_t *section = COLOR_THEME_SECTION; |
| 295 |
zmatsuo |
10303 |
WritePrivateProfileStringW(section, L"Theme", color_theme->name, fn); |
| 296 |
|
|
|
| 297 |
zmatsuo |
10332 |
for (int i = 0; i < _countof(color_attr_list); i++) { |
| 298 |
|
|
const wchar_t *key = color_attr_list[i].key; |
| 299 |
|
|
const TColorSetting *color = (TColorSetting *)((UINT_PTR)color_theme + color_attr_list[i].offset); |
| 300 |
|
|
BGSaveColorOne(section, key, color, fn); |
| 301 |
|
|
} |
| 302 |
zmatsuo |
10303 |
|
| 303 |
|
|
SaveColorANSINew(section, &(color_theme->ansicolor), fn); |
| 304 |
|
|
} |
| 305 |
|
|
|
| 306 |
zmatsuo |
10332 |
static void WriteInt3(const wchar_t *Sect, const wchar_t *Key, const wchar_t *FName, |
| 307 |
|
|
int i1, int i2, int i3) |
| 308 |
zmatsuo |
10256 |
{ |
| 309 |
zmatsuo |
10332 |
wchar_t Temp[96]; |
| 310 |
|
|
_snwprintf_s(Temp, _countof(Temp), _TRUNCATE, L"%d,%d,%d", |
| 311 |
zmatsuo |
10256 |
i1, i2,i3); |
| 312 |
zmatsuo |
10332 |
WritePrivateProfileStringW(Sect, Key, Temp, FName); |
| 313 |
zmatsuo |
10256 |
} |
| 314 |
|
|
|
| 315 |
zmatsuo |
10332 |
static void WriteCOLORREF(const wchar_t *Sect, const wchar_t *Key, const wchar_t *FName, COLORREF color) |
| 316 |
zmatsuo |
10256 |
{ |
| 317 |
|
|
int red = color & 0xff; |
| 318 |
|
|
int green = (color >> 8) & 0xff; |
| 319 |
|
|
int blue = (color >> 16) & 0xff; |
| 320 |
|
|
|
| 321 |
|
|
WriteInt3(Sect, Key, FName, red, green, blue); |
| 322 |
|
|
} |
| 323 |
|
|
|
| 324 |
zmatsuo |
10332 |
static const wchar_t *GetBGPatternStr(BG_PATTERN id) |
| 325 |
zmatsuo |
10256 |
{ |
| 326 |
|
|
int index; |
| 327 |
|
|
for (index = 0;; index++) { |
| 328 |
|
|
const BG_PATTERN_ST *st = ThemeBGPatternList(index); |
| 329 |
|
|
if (st == NULL) { |
| 330 |
|
|
// ������������ |
| 331 |
|
|
st = ThemeBGPatternList(0); |
| 332 |
|
|
return st->str; |
| 333 |
|
|
} |
| 334 |
|
|
if (st->id == id) { |
| 335 |
|
|
return st->str; |
| 336 |
|
|
} |
| 337 |
|
|
} |
| 338 |
|
|
} |
| 339 |
|
|
|
| 340 |
zmatsuo |
10332 |
static BOOL GetBGPatternID(const wchar_t *str, BG_PATTERN *pattern) |
| 341 |
zmatsuo |
10256 |
{ |
| 342 |
|
|
int index; |
| 343 |
|
|
for (index = 0;; index++) { |
| 344 |
|
|
const BG_PATTERN_ST *st = ThemeBGPatternList(index); |
| 345 |
|
|
if (st == NULL) { |
| 346 |
|
|
// ������������ |
| 347 |
|
|
st = ThemeBGPatternList(0); |
| 348 |
|
|
*pattern = st->id; |
| 349 |
|
|
return FALSE; |
| 350 |
|
|
} |
| 351 |
zmatsuo |
10332 |
if (_wcsicmp(st->str, str) == 0) { |
| 352 |
zmatsuo |
10256 |
*pattern = st->id; |
| 353 |
|
|
return TRUE; |
| 354 |
|
|
} |
| 355 |
|
|
} |
| 356 |
|
|
} |
| 357 |
|
|
|
| 358 |
|
|
void ThemeSaveBG(const BGTheme *bg_theme, const wchar_t *file) |
| 359 |
|
|
{ |
| 360 |
zmatsuo |
10332 |
const wchar_t *section = BG_SECTION_NEW; |
| 361 |
|
|
|
| 362 |
|
|
WritePrivateProfileStringW(section, L"BGDestFile", bg_theme->BGDest.file, file); |
| 363 |
zmatsuo |
10256 |
#if 0 |
| 364 |
zmatsuo |
10332 |
WritePrivateProfileStringW(section, L"BGDestType", |
| 365 |
zmatsuo |
10256 |
bg_theme->BGDest.type == BG_PICTURE ? "picture" : "color", file); |
| 366 |
|
|
#endif |
| 367 |
zmatsuo |
10332 |
WriteCOLORREF(section, L"BGDestColor", file, bg_theme->BGDest.color); |
| 368 |
|
|
WritePrivateProfileStringW(section, L"BGDestPattern", GetBGPatternStr(bg_theme->BGDest.pattern), file); |
| 369 |
zmatsuo |
10256 |
|
| 370 |
zmatsuo |
10332 |
WritePrivateProfileIntW(section, L"BGSrc1Alpha", bg_theme->BGSrc1.alpha, file); |
| 371 |
zmatsuo |
10256 |
|
| 372 |
zmatsuo |
10332 |
WritePrivateProfileIntW(section, L"BGSrc2Alpha", bg_theme->BGSrc2.alpha, file); |
| 373 |
|
|
WriteCOLORREF(section, L"BGSrc2Color", file, bg_theme->BGSrc2.color); |
| 374 |
zmatsuo |
10256 |
|
| 375 |
zmatsuo |
10332 |
WritePrivateProfileIntW(section, L"BGReverseTextAlpha", bg_theme->BGReverseTextAlpha, file); |
| 376 |
zmatsuo |
10256 |
} |
| 377 |
|
|
|
| 378 |
zmatsuo |
10332 |
static int BGGetStrIndex(const wchar_t *section, const wchar_t *name, int def, const wchar_t *file, const wchar_t * const *strList, int nList) |
| 379 |
zmatsuo |
10256 |
{ |
| 380 |
zmatsuo |
10332 |
wchar_t defstr[64]; |
| 381 |
|
|
wchar_t str[64]; |
| 382 |
zmatsuo |
10256 |
int i; |
| 383 |
|
|
|
| 384 |
|
|
def %= nList; |
| 385 |
|
|
|
| 386 |
zmatsuo |
10332 |
wcsncpy_s(defstr, _countof(defstr), strList[def], _TRUNCATE); |
| 387 |
|
|
GetPrivateProfileStringW(section, name, defstr, str, _countof(str), file); |
| 388 |
zmatsuo |
10256 |
|
| 389 |
|
|
for (i = 0; i < nList; i++) |
| 390 |
zmatsuo |
10332 |
if (!_wcsicmp(str, strList[i])) |
| 391 |
zmatsuo |
10256 |
return i; |
| 392 |
|
|
|
| 393 |
|
|
return 0; |
| 394 |
|
|
} |
| 395 |
|
|
|
| 396 |
zmatsuo |
10332 |
static BOOL BGGetOnOff(const wchar_t *section, const wchar_t *name, BOOL def, const wchar_t *file) |
| 397 |
zmatsuo |
10256 |
{ |
| 398 |
zmatsuo |
10332 |
static const wchar_t * const strList[2] = {L"Off", L"On"}; |
| 399 |
zmatsuo |
10256 |
|
| 400 |
zmatsuo |
10332 |
return (BOOL)BGGetStrIndex(section, name, def, file, strList, 2); |
| 401 |
zmatsuo |
10256 |
} |
| 402 |
|
|
|
| 403 |
zmatsuo |
10332 |
static BG_PATTERN BGGetPattern(const wchar_t *section, const wchar_t *name, BG_PATTERN def, const wchar_t *file) |
| 404 |
zmatsuo |
10256 |
{ |
| 405 |
|
|
BG_PATTERN retval; |
| 406 |
zmatsuo |
10332 |
wchar_t str[64]; |
| 407 |
|
|
GetPrivateProfileStringW(section, name, L"", str, _countof(str), file); |
| 408 |
zmatsuo |
10256 |
if (str[0] == 0) { |
| 409 |
|
|
return def; |
| 410 |
|
|
} |
| 411 |
|
|
if (GetBGPatternID(str, &retval) == FALSE) { |
| 412 |
|
|
retval = def; |
| 413 |
|
|
} |
| 414 |
|
|
return retval; |
| 415 |
|
|
} |
| 416 |
|
|
|
| 417 |
zmatsuo |
10332 |
static BG_TYPE BGGetType(const wchar_t *section, const wchar_t *name, BG_TYPE def, const wchar_t *file) |
| 418 |
zmatsuo |
10256 |
{ |
| 419 |
zmatsuo |
10332 |
static const wchar_t *strList[3] = {L"color", L"picture", L"wallpaper"}; |
| 420 |
zmatsuo |
10256 |
|
| 421 |
zmatsuo |
10332 |
return (BG_TYPE)BGGetStrIndex(section, name, def, file, strList, 3); |
| 422 |
zmatsuo |
10256 |
} |
| 423 |
|
|
|
| 424 |
|
|
/** |
| 425 |
|
|
* BG�����[�h |
| 426 |
|
|
*/ |
| 427 |
zmatsuo |
10332 |
void ThemeLoadBGSection(const wchar_t *section, const wchar_t *file, BGTheme *bg_theme) |
| 428 |
zmatsuo |
10256 |
{ |
| 429 |
zmatsuo |
10332 |
wchar_t pathW[MAX_PATH]; |
| 430 |
|
|
wchar_t *p; |
| 431 |
zmatsuo |
10256 |
|
| 432 |
|
|
// Dest �������o�� |
| 433 |
zmatsuo |
10332 |
bg_theme->BGDest.type = BGGetType(section, L"BGDestType", bg_theme->BGDest.type, file); |
| 434 |
|
|
bg_theme->BGDest.pattern = BGGetPattern(section, L"BGPicturePattern", bg_theme->BGDest.pattern, file); |
| 435 |
|
|
bg_theme->BGDest.pattern = BGGetPattern(section, L"BGDestPattern", bg_theme->BGDest.pattern, file); |
| 436 |
|
|
bg_theme->BGDest.antiAlias = BGGetOnOff(section, L"BGDestAntiAlias", bg_theme->BGDest.antiAlias, file); |
| 437 |
|
|
bg_theme->BGDest.color = BGGetColor(section, L"BGPictureBaseColor", bg_theme->BGDest.color, file); |
| 438 |
|
|
bg_theme->BGDest.color = BGGetColor(section, L"BGDestColor", bg_theme->BGDest.color, file); |
| 439 |
|
|
GetPrivateProfileStringW(section, L"BGPictureFile", bg_theme->BGDest.file, pathW, _countof(pathW), file); |
| 440 |
|
|
GetPrivateProfileStringW(section, L"BGDestFile", pathW, pathW, _countof(pathW), file); |
| 441 |
|
|
p = RandomFileW(pathW); |
| 442 |
|
|
if (p != NULL) { |
| 443 |
|
|
wcscpy_s(bg_theme->BGDest.file, _countof(bg_theme->BGDest.file), p); |
| 444 |
|
|
free(p); |
| 445 |
zmatsuo |
10256 |
} |
| 446 |
zmatsuo |
10332 |
else { |
| 447 |
|
|
bg_theme->BGDest.file[0] = 0; |
| 448 |
|
|
} |
| 449 |
zmatsuo |
10256 |
|
| 450 |
|
|
// Src1 �������o�� |
| 451 |
zmatsuo |
10332 |
bg_theme->BGSrc1.type = BGGetType(section, L"BGSrc1Type", bg_theme->BGSrc1.type, file); |
| 452 |
|
|
bg_theme->BGSrc1.pattern = BGGetPattern(section, L"BGSrc1Pattern", bg_theme->BGSrc1.pattern, file); |
| 453 |
|
|
bg_theme->BGSrc1.antiAlias = BGGetOnOff(section, L"BGSrc1AntiAlias", bg_theme->BGSrc1.antiAlias, file); |
| 454 |
|
|
bg_theme->BGSrc1.alpha = 255 - GetPrivateProfileIntW(section, L"BGPictureTone", 255 - bg_theme->BGSrc1.alpha, file); |
| 455 |
|
|
bg_theme->BGSrc1.alpha = GetPrivateProfileIntW(section, L"BGSrc1Alpha", bg_theme->BGSrc1.alpha, file); |
| 456 |
|
|
bg_theme->BGSrc1.color = BGGetColor(section, L"BGSrc1Color", bg_theme->BGSrc1.color, file); |
| 457 |
|
|
GetPrivateProfileStringW(section, L"BGSrc1File", bg_theme->BGSrc1.file, pathW, _countof(pathW), file); |
| 458 |
|
|
p = RandomFileW(pathW); |
| 459 |
|
|
if (p != NULL) { |
| 460 |
|
|
wcscpy_s(bg_theme->BGSrc1.file, _countof(bg_theme->BGSrc1.file), p); |
| 461 |
|
|
free(p); |
| 462 |
|
|
} |
| 463 |
|
|
else { |
| 464 |
|
|
bg_theme->BGSrc1.file[0] = 0; |
| 465 |
|
|
} |
| 466 |
zmatsuo |
10256 |
|
| 467 |
|
|
// Src2 �������o�� |
| 468 |
zmatsuo |
10332 |
bg_theme->BGSrc2.type = BGGetType(section, L"BGSrc2Type", bg_theme->BGSrc2.type, file); |
| 469 |
|
|
bg_theme->BGSrc2.pattern = BGGetPattern(section, L"BGSrc2Pattern", bg_theme->BGSrc2.pattern, file); |
| 470 |
|
|
bg_theme->BGSrc2.antiAlias = BGGetOnOff(section, L"BGSrc2AntiAlias", bg_theme->BGSrc2.antiAlias, file); |
| 471 |
|
|
bg_theme->BGSrc2.alpha = 255 - GetPrivateProfileIntW(section, L"BGFadeTone", 255 - bg_theme->BGSrc2.alpha, file); |
| 472 |
|
|
bg_theme->BGSrc2.alpha = GetPrivateProfileIntW(section, L"BGSrc2Alpha", bg_theme->BGSrc2.alpha, file); |
| 473 |
|
|
bg_theme->BGSrc2.color = BGGetColor(section, L"BGFadeColor", bg_theme->BGSrc2.color, file); |
| 474 |
|
|
bg_theme->BGSrc2.color = BGGetColor(section, L"BGSrc2Color", bg_theme->BGSrc2.color, file); |
| 475 |
|
|
GetPrivateProfileStringW(section, L"BGSrc2File", bg_theme->BGSrc2.file, pathW, _countof(pathW), file); |
| 476 |
|
|
p = RandomFileW(pathW); |
| 477 |
|
|
if (p != NULL) { |
| 478 |
|
|
wcscpy_s(bg_theme->BGSrc2.file, _countof(bg_theme->BGSrc2.file), p); |
| 479 |
|
|
free(p); |
| 480 |
|
|
} |
| 481 |
|
|
else { |
| 482 |
|
|
bg_theme->BGSrc2.file[0] = 0; |
| 483 |
|
|
} |
| 484 |
zmatsuo |
10256 |
|
| 485 |
|
|
//�����������o�� |
| 486 |
zmatsuo |
10332 |
bg_theme->BGReverseTextAlpha = GetPrivateProfileIntW(section, L"BGReverseTextTone", bg_theme->BGReverseTextAlpha, file); |
| 487 |
|
|
bg_theme->BGReverseTextAlpha = GetPrivateProfileIntW(section, L"BGReverseTextAlpha", bg_theme->BGReverseTextAlpha, file); |
| 488 |
zmatsuo |
10256 |
} |
| 489 |
|
|
|
| 490 |
zmatsuo |
10332 |
/** |
| 491 |
|
|
* BG�����[�h |
| 492 |
|
|
*/ |
| 493 |
|
|
void ThemeLoadBG(const wchar_t *file, BGTheme *bg_theme) |
| 494 |
zmatsuo |
10256 |
{ |
| 495 |
zmatsuo |
10332 |
ThemeLoadBGSection(BG_SECTION_OLD, file, bg_theme); |
| 496 |
|
|
ThemeLoadBGSection(BG_SECTION_NEW, file, bg_theme); |
| 497 |
|
|
} |
| 498 |
|
|
|
| 499 |
|
|
static void ReadANSIColorSetting(const wchar_t *section, TAnsiColorSetting *color, const wchar_t *fn) |
| 500 |
|
|
{ |
| 501 |
|
|
wchar_t BuffW[512]; |
| 502 |
zmatsuo |
10256 |
char Buff[512]; |
| 503 |
|
|
int c, r, g, b; |
| 504 |
zmatsuo |
10274 |
// ANSIColor16���A������/�����O���[�v������������������ |
| 505 |
|
|
const static int index256[] = { |
| 506 |
|
|
0, |
| 507 |
zmatsuo |
10303 |
1, 2, 3, 4, 5, 6, 7, |
| 508 |
|
|
8, |
| 509 |
zmatsuo |
10274 |
9, 10, 11, 12, 13, 14, 15, |
| 510 |
|
|
}; |
| 511 |
zmatsuo |
10256 |
|
| 512 |
zmatsuo |
10332 |
GetPrivateProfileStringW(section, L"ANSIColor", L"0", BuffW, sizeof(BuffW), fn); |
| 513 |
|
|
WideCharToACP_t(BuffW, Buff, _countof(Buff)); |
| 514 |
zmatsuo |
10256 |
|
| 515 |
|
|
GetNthNum(Buff, 1, &c); |
| 516 |
|
|
color->change = c; |
| 517 |
|
|
|
| 518 |
|
|
GetNthNum(Buff, 2, &c); |
| 519 |
zmatsuo |
10303 |
//color->enable = c; |
| 520 |
zmatsuo |
10256 |
|
| 521 |
|
|
for (c=0; c<16; c++) { |
| 522 |
zmatsuo |
10274 |
int idx = index256[c]; |
| 523 |
zmatsuo |
10256 |
GetNthNum(Buff, c * 3 + 3, &r); |
| 524 |
|
|
GetNthNum(Buff, c * 3 + 4, &g); |
| 525 |
|
|
GetNthNum(Buff, c * 3 + 5, &b); |
| 526 |
zmatsuo |
10274 |
color->color[idx] = RGB(r, g, b); |
| 527 |
zmatsuo |
10256 |
} |
| 528 |
|
|
} |
| 529 |
|
|
|
| 530 |
zmatsuo |
10332 |
static void ReadColorSetting(const wchar_t *section, TColorSetting *color, const wchar_t *key, const wchar_t *fn) |
| 531 |
zmatsuo |
10256 |
{ |
| 532 |
zmatsuo |
10332 |
wchar_t BuffW[512]; |
| 533 |
zmatsuo |
10256 |
char Buff[512]; |
| 534 |
|
|
int c, r, g, b; |
| 535 |
|
|
|
| 536 |
zmatsuo |
10332 |
GetPrivateProfileStringW(section, key, L"0", BuffW, _countof(BuffW), fn); |
| 537 |
|
|
WideCharToACP_t(BuffW, Buff, _countof(Buff)); |
| 538 |
zmatsuo |
10256 |
|
| 539 |
|
|
GetNthNum(Buff, 1, &c); |
| 540 |
|
|
color->change = c; |
| 541 |
|
|
|
| 542 |
|
|
GetNthNum(Buff, 2, &c); |
| 543 |
|
|
color->enable = c; |
| 544 |
|
|
|
| 545 |
|
|
if (color->change && color->enable) { |
| 546 |
|
|
GetNthNum(Buff, 3, &r); |
| 547 |
|
|
GetNthNum(Buff, 4, &g); |
| 548 |
|
|
GetNthNum(Buff, 5, &b); |
| 549 |
|
|
color->fg = RGB(r, g, b); |
| 550 |
|
|
|
| 551 |
|
|
GetNthNum(Buff, 6, &r); |
| 552 |
|
|
GetNthNum(Buff, 7, &g); |
| 553 |
|
|
GetNthNum(Buff, 8, &b); |
| 554 |
|
|
color->bg = RGB(r, g, b); |
| 555 |
|
|
} |
| 556 |
|
|
} |
| 557 |
|
|
|
| 558 |
zmatsuo |
10303 |
/** |
| 559 |
|
|
* �J���[�e�[�}�v���O�C���� ini �t�@�C���������� |
| 560 |
zmatsuo |
10256 |
*/ |
| 561 |
zmatsuo |
10303 |
static void LoadColorPlugin(const wchar_t *fn, TColorTheme *color_theme) |
| 562 |
zmatsuo |
10256 |
{ |
| 563 |
zmatsuo |
10332 |
const wchar_t *section = COLOR_THEME_SECTION; |
| 564 |
zmatsuo |
10303 |
wchar_t *name; |
| 565 |
|
|
hGetPrivateProfileStringW(section, L"Theme", NULL, fn, &name); |
| 566 |
|
|
wcscpy_s(color_theme->name, _countof(color_theme->name), name); |
| 567 |
|
|
free(name); |
| 568 |
zmatsuo |
10256 |
|
| 569 |
zmatsuo |
10332 |
for (int i = 0; i < _countof(color_attr_list); i++) { |
| 570 |
|
|
const wchar_t *key = color_attr_list[i].key; |
| 571 |
|
|
TColorSetting *color = (TColorSetting *)((UINT_PTR)color_theme + color_attr_list[i].offset); |
| 572 |
|
|
ReadColorSetting(section, color, key, fn); |
| 573 |
|
|
} |
| 574 |
zmatsuo |
10256 |
|
| 575 |
zmatsuo |
10332 |
ReadANSIColorSetting(section, &(color_theme->ansicolor), fn); |
| 576 |
zmatsuo |
10256 |
} |
| 577 |
|
|
|
| 578 |
zmatsuo |
10303 |
/** |
| 579 |
|
|
* �J���[�e�[�}�t�@�C����������,1�A�g���r���[�g�� |
| 580 |
|
|
*/ |
| 581 |
|
|
static void LoadColorAttr(const wchar_t *section, const wchar_t *key, const wchar_t *file, TColorSetting *attr) |
| 582 |
zmatsuo |
10256 |
{ |
| 583 |
zmatsuo |
10303 |
wchar_t *str; |
| 584 |
|
|
DWORD e = hGetPrivateProfileStringW(section, key, NULL, file, &str); |
| 585 |
|
|
if (e != 0 || *str == 0) { |
| 586 |
|
|
free(str); |
| 587 |
|
|
return; |
| 588 |
|
|
} |
| 589 |
zmatsuo |
10256 |
|
| 590 |
zmatsuo |
10303 |
BOOL change = FALSE; |
| 591 |
|
|
BOOL enable = FALSE; |
| 592 |
|
|
int fields; |
| 593 |
zmatsuo |
10256 |
|
| 594 |
zmatsuo |
10303 |
DWORD fore_rgb; |
| 595 |
|
|
DWORD back_rgb; |
| 596 |
|
|
fields = swscanf_s(str, L"%d, %d, #%06x, #%06x", &change, &enable, &fore_rgb, &back_rgb); |
| 597 |
|
|
if (fields == 4) { |
| 598 |
|
|
free(str); |
| 599 |
|
|
attr->change = change; |
| 600 |
|
|
attr->enable = enable; |
| 601 |
|
|
attr->fg = RGB((fore_rgb & 0xff0000) >> 16, (fore_rgb & 0x00ff00) >> 8, (fore_rgb & 0x0000ff)); |
| 602 |
|
|
attr->bg = RGB((back_rgb & 0xff0000) >> 16, (back_rgb & 0x00ff00) >> 8, (back_rgb & 0x0000ff)); |
| 603 |
|
|
return; |
| 604 |
|
|
} |
| 605 |
zmatsuo |
10256 |
|
| 606 |
zmatsuo |
10303 |
BYTE fg_red, fg_green, fg_blue; |
| 607 |
|
|
BYTE bg_red, bg_green, bg_blue; |
| 608 |
|
|
fields = swscanf_s(str, L"%d, %d, %hhu, %hhu, %hhu, %hhu, %hhu, %hhu", &change, &enable, &fg_red, &fg_green, |
| 609 |
|
|
&fg_blue, &bg_red, &bg_green, &bg_blue); |
| 610 |
|
|
if (fields == 8) { |
| 611 |
|
|
free(str); |
| 612 |
|
|
attr->change = change; |
| 613 |
|
|
attr->enable = enable; |
| 614 |
|
|
attr->fg = RGB(fg_red, fg_green, fg_blue); |
| 615 |
|
|
attr->bg = RGB(bg_red, bg_green, bg_blue); |
| 616 |
|
|
return; |
| 617 |
zmatsuo |
10256 |
} |
| 618 |
zmatsuo |
10303 |
fields = swscanf_s(str, L"%d, %d", &change, &enable); |
| 619 |
|
|
if (fields == 2) { |
| 620 |
|
|
free(str); |
| 621 |
|
|
attr->change = change; |
| 622 |
|
|
attr->enable = FALSE; // �F�w���������������������A���������������F������ |
| 623 |
|
|
return; |
| 624 |
|
|
} |
| 625 |
|
|
fields = swscanf_s(str, L"%d", &change); |
| 626 |
|
|
free(str); |
| 627 |
|
|
if (fields == 1) { |
| 628 |
|
|
attr->change = FALSE; // �F���X�������� |
| 629 |
|
|
return; |
| 630 |
|
|
} |
| 631 |
zmatsuo |
10256 |
} |
| 632 |
|
|
|
| 633 |
zmatsuo |
10303 |
/* |
| 634 |
|
|
* color theme�p���[�h |
| 635 |
|
|
*/ |
| 636 |
|
|
static void ThemeLoadColorDraft(const wchar_t *file, TColorTheme *theme) |
| 637 |
zmatsuo |
10256 |
{ |
| 638 |
zmatsuo |
10332 |
const wchar_t *section = COLOR_THEME_SECTION; |
| 639 |
zmatsuo |
10256 |
|
| 640 |
zmatsuo |
10303 |
wchar_t *name; |
| 641 |
|
|
hGetPrivateProfileStringW(section, L"Theme", NULL, file, &name); |
| 642 |
|
|
wcscpy_s(theme->name, _countof(theme->name), name); |
| 643 |
|
|
free(name); |
| 644 |
zmatsuo |
10256 |
|
| 645 |
zmatsuo |
10332 |
for (int i = 0; i < _countof(color_attr_list); i++) { |
| 646 |
|
|
const wchar_t *key = color_attr_list[i].key; |
| 647 |
|
|
TColorSetting *color = (TColorSetting *)((UINT_PTR)theme + color_attr_list[i].offset); |
| 648 |
|
|
LoadColorAttr(section, key, file, color); |
| 649 |
zmatsuo |
10303 |
} |
| 650 |
zmatsuo |
10256 |
|
| 651 |
zmatsuo |
10303 |
theme->ansicolor.change = (BOOL)GetPrivateProfileIntW(section, L"ANSIColor", 1, file); |
| 652 |
|
|
for (int i = 0; i < _countof(ansi_list); i++) { |
| 653 |
|
|
const int index = ansi_list[i].index; |
| 654 |
|
|
const wchar_t *key = ansi_list[i].key; |
| 655 |
|
|
theme->ansicolor.color[index] = LoadColorOneANSI(section, key, file, theme->ansicolor.color[index]); |
| 656 |
|
|
} |
| 657 |
zmatsuo |
10256 |
} |
| 658 |
|
|
|
| 659 |
zmatsuo |
10303 |
/* |
| 660 |
|
|
* �J���[�e�[�}ini�t�@�C�������[�h���� |
| 661 |
zmatsuo |
10256 |
*/ |
| 662 |
zmatsuo |
10303 |
void ThemeLoadColor(const wchar_t *fn, TColorTheme *color_theme) |
| 663 |
zmatsuo |
10256 |
{ |
| 664 |
zmatsuo |
10303 |
ThemeGetColorDefault(color_theme); |
| 665 |
|
|
LoadColorPlugin(fn, color_theme); |
| 666 |
|
|
ThemeLoadColorOld(fn, color_theme); |
| 667 |
|
|
ThemeLoadColorDraft(fn, color_theme); |
| 668 |
zmatsuo |
10256 |
} |
| 669 |
|
|
|
| 670 |
|
|
/** |
| 671 |
|
|
* �e�[�}�t�@�C������������ |
| 672 |
|
|
* |
| 673 |
|
|
* @param file �t�@�C���� |
| 674 |
|
|
* NULL�������\�������f�t�H���g�l������������ |
| 675 |
|
|
* @param bg_theme |
| 676 |
|
|
* @param color_theme |
| 677 |
|
|
*/ |
| 678 |
|
|
void ThemeLoad(const wchar_t *file, BGTheme *bg_theme, TColorTheme *color_theme) |
| 679 |
|
|
{ |
| 680 |
|
|
BOOL bg = FALSE; |
| 681 |
|
|
BOOL color = FALSE; |
| 682 |
|
|
wchar_t *prevDir; |
| 683 |
|
|
|
| 684 |
|
|
// �J�����g�f�B���N�g�������� |
| 685 |
|
|
hGetCurrentDirectoryW(&prevDir); |
| 686 |
|
|
|
| 687 |
|
|
// �e�[�}�t�@�C���������f�B���N�g���������I������ |
| 688 |
|
|
// �e�[�}�t�@�C�������p�X���������������� |
| 689 |
|
|
if (file != NULL) { |
| 690 |
|
|
wchar_t *dir = ExtractDirNameW(file); |
| 691 |
|
|
SetCurrentDirectoryW(dir); |
| 692 |
|
|
free(dir); |
| 693 |
|
|
} |
| 694 |
|
|
|
| 695 |
|
|
{ |
| 696 |
|
|
wchar_t sections[128]; |
| 697 |
|
|
size_t i; |
| 698 |
|
|
GetPrivateProfileSectionNamesW(sections, _countof(sections), file); |
| 699 |
|
|
for(i = 0; i < _countof(sections); /**/ ) { |
| 700 |
|
|
const wchar_t *p = §ions[i]; |
| 701 |
|
|
size_t len = wcslen(p); |
| 702 |
|
|
if (len == 0) { |
| 703 |
|
|
break; |
| 704 |
|
|
} |
| 705 |
zmatsuo |
10332 |
if (_wcsicmp(p, BG_SECTION_NEW) == 0 || _wcsicmp(p, BG_SECTION_OLD) == 0) { |
| 706 |
zmatsuo |
10256 |
bg = TRUE; |
| 707 |
|
|
} |
| 708 |
zmatsuo |
10332 |
else if(_wcsicmp(p, COLOR_THEME_SECTION) == 0) { |
| 709 |
zmatsuo |
10256 |
color = TRUE; |
| 710 |
|
|
} |
| 711 |
|
|
i += len; |
| 712 |
|
|
} |
| 713 |
|
|
} |
| 714 |
|
|
|
| 715 |
|
|
ThemeGetBGDefault(bg_theme); |
| 716 |
|
|
ThemeGetColorDefault(color_theme); |
| 717 |
|
|
|
| 718 |
|
|
// BG + �J���[�e�[�} ini�t�@�C�� |
| 719 |
|
|
if (bg && color) { |
| 720 |
|
|
ThemeLoadBG(file, bg_theme); |
| 721 |
|
|
ThemeLoadColor(file, color_theme); |
| 722 |
|
|
} |
| 723 |
|
|
// BG�e�[�} ini�t�@�C�� |
| 724 |
|
|
// TODO �������J���[�������������������������� |
| 725 |
|
|
else if (bg) { |
| 726 |
|
|
ThemeLoadBG(file, bg_theme); |
| 727 |
|
|
ThemeLoadColorOld(file, color_theme); |
| 728 |
|
|
} |
| 729 |
|
|
// �J���[�e�[�} ini�t�@�C�� |
| 730 |
|
|
else if (color) { |
| 731 |
|
|
ThemeLoadColor(file, color_theme); |
| 732 |
|
|
} |
| 733 |
|
|
else { |
| 734 |
|
|
#if 0 |
| 735 |
|
|
static const TTMessageBoxInfoW info = { |
| 736 |
|
|
"Tera Term", |
| 737 |
|
|
"MSG_TT_ERROR", L"Tera Term: ERROR", |
| 738 |
|
|
NULL, L"unknown ini file?", |
| 739 |
|
|
MB_OK|MB_ICONEXCLAMATION |
| 740 |
|
|
}; |
| 741 |
|
|
TTMessageBoxW(HVTWin, &info, ts.UILanguageFileW); |
| 742 |
|
|
#endif |
| 743 |
|
|
} |
| 744 |
|
|
|
| 745 |
|
|
// �J�����g�t�H���_���������� |
| 746 |
|
|
SetCurrentDirectoryW(prevDir); |
| 747 |
|
|
free(prevDir); |
| 748 |
|
|
} |