mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-20 21:13:25 +08:00
+ chg: reworked Styling Import/Export
This commit is contained in:
parent
51fed8c5b9
commit
4cb6b0e4ec
@ -410,7 +410,8 @@
|
||||
#define IDS_MUI_LANG_ZH_CN 34515
|
||||
|
||||
#define IDS_MUI_MENU_THEMES 37000
|
||||
#define IDM_THEMES_FILE_ITEM 37001
|
||||
#define IDM_THEMES_DEFAULT 37001
|
||||
#define IDM_THEMES_FILE_ITEM 37002
|
||||
/// !!! dont use IDs until ...37100
|
||||
|
||||
#define IDM_FILE_NEW 40000
|
||||
|
||||
@ -203,7 +203,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "Taal"
|
||||
IDS_MUI_MENU_THEMES "Themes"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -204,7 +204,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "Ìîâû"
|
||||
IDS_MUI_MENU_THEMES "Themes"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -204,7 +204,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "Sprache"
|
||||
IDS_MUI_MENU_THEMES "Farben"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -230,7 +230,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "Language"
|
||||
IDS_MUI_MENU_THEMES "Themes"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -230,7 +230,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "Language"
|
||||
IDS_MUI_MENU_THEMES "Themes"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -204,7 +204,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "&Idioma"
|
||||
IDS_MUI_MENU_THEMES "Themes"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -202,7 +202,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "Langue"
|
||||
IDS_MUI_MENU_THEMES "Themes"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -230,7 +230,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "Nyelv"
|
||||
IDS_MUI_MENU_THEMES "Themes"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -230,7 +230,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "Lingua"
|
||||
IDS_MUI_MENU_THEMES "Themes"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -204,7 +204,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "Œ¾Œê"
|
||||
IDS_MUI_MENU_THEMES "Themes"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -224,7 +224,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "나라말"
|
||||
IDS_MUI_MENU_THEMES "Themes"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -204,7 +204,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "Taal"
|
||||
IDS_MUI_MENU_THEMES "Themes"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -230,7 +230,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "Língua"
|
||||
IDS_MUI_MENU_THEMES "Themes"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -204,7 +204,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "ßçûê"
|
||||
IDS_MUI_MENU_THEMES "Themes"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -204,7 +204,8 @@ STRINGTABLE
|
||||
BEGIN
|
||||
IDS_MUI_MENU_LANGUAGE "ÓïÑÔ(&L)"
|
||||
IDS_MUI_MENU_THEMES "Themes"
|
||||
IDM_THEMES_FILE_ITEM "Standard"
|
||||
IDM_THEMES_DEFAULT "Factory Default"
|
||||
IDM_THEMES_FILE_ITEM "Standard Settings"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@ -809,7 +809,7 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPar
|
||||
|
||||
if (GetOpenFileName(&ofn)) {
|
||||
PathQuoteSpaces(szFile);
|
||||
if (StringCchLen(szArg2,COUNTOF(szArg2)))
|
||||
if (StrIsNotEmpty(szArg2))
|
||||
{
|
||||
StringCchCat(szFile,COUNTOF(szFile),L" ");
|
||||
StringCchCat(szFile,COUNTOF(szFile),szArg2);
|
||||
@ -826,11 +826,13 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPar
|
||||
bool bEnableOK = false;
|
||||
WCHAR args[MAX_PATH] = { L'\0' };
|
||||
|
||||
if (GetDlgItemText(hwnd,IDC_COMMANDLINE,args,MAX_PATH))
|
||||
if (ExtractFirstArgument(args,args,NULL,MAX_PATH))
|
||||
if (StringCchLenW(args,COUNTOF(args)))
|
||||
if (GetDlgItemText(hwnd, IDC_COMMANDLINE, args, MAX_PATH)) {
|
||||
if (ExtractFirstArgument(args, args, NULL, MAX_PATH)) {
|
||||
if (StrIsNotEmpty(args)) {
|
||||
bEnableOK = true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
DialogEnableWindow(hwnd,IDOK,bEnableOK);
|
||||
}
|
||||
break;
|
||||
@ -855,7 +857,7 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPar
|
||||
bQuickExit = true;
|
||||
}
|
||||
|
||||
if (StringCchLenW(Globals.CurrentFile, MAX_PATH)) {
|
||||
if (StrIsNotEmpty(Globals.CurrentFile)) {
|
||||
StringCchCopy(wchDirectory,COUNTOF(wchDirectory),Globals.CurrentFile);
|
||||
PathCchRemoveFileSpec(wchDirectory, COUNTOF(wchDirectory));
|
||||
}
|
||||
@ -1084,7 +1086,7 @@ bool OpenWithDlg(HWND hwnd,LPCWSTR lpstrFile)
|
||||
WCHAR szParam[MAX_PATH] = { L'\0' };
|
||||
WCHAR wchDirectory[MAX_PATH] = { L'\0' };
|
||||
|
||||
if (StringCchLenW(Globals.CurrentFile, MAX_PATH)) {
|
||||
if (StrIsNotEmpty(Globals.CurrentFile)) {
|
||||
StringCchCopy(wchDirectory,COUNTOF(wchDirectory),Globals.CurrentFile);
|
||||
PathCchRemoveFileSpec(wchDirectory, COUNTOF(wchDirectory));
|
||||
}
|
||||
@ -3141,7 +3143,7 @@ void DialogNewWindow(HWND hwnd, bool bSaveOnRunTools, bool bSetCurFile)
|
||||
StringCchCat(szParameters, COUNTOF(szParameters), tch);
|
||||
|
||||
StringCchCat(szParameters, COUNTOF(szParameters), L" -f");
|
||||
if (StringCchLenW(Globals.IniFile, COUNTOF(Globals.IniFile))) {
|
||||
if (StrIsNotEmpty(Globals.IniFile)) {
|
||||
StringCchCat(szParameters, COUNTOF(szParameters), L" \"");
|
||||
StringCchCat(szParameters, COUNTOF(szParameters), Globals.IniFile);
|
||||
StringCchCat(szParameters, COUNTOF(szParameters), L" \"");
|
||||
@ -3202,7 +3204,7 @@ void DialogFileBrowse(HWND hwnd)
|
||||
|
||||
StringCchCopyW(tchTemp, COUNTOF(tchTemp), Settings2.FileBrowserPath);
|
||||
|
||||
if (StringCchLenW(Settings2.FileBrowserPath, 0) > 0)
|
||||
if (StrIsNotEmpty(Settings2.FileBrowserPath))
|
||||
{
|
||||
ExtractFirstArgument(tchTemp, tchExeFile, tchParam, COUNTOF(tchTemp));
|
||||
}
|
||||
@ -3217,10 +3219,10 @@ void DialogFileBrowse(HWND hwnd)
|
||||
StringCchCopy(tchExeFile, COUNTOF(tchExeFile), tchTemp);
|
||||
}
|
||||
}
|
||||
if (StringCchLenW(tchParam, COUNTOF(tchParam)) && StringCchLenW(Globals.CurrentFile, COUNTOF(tchParam))) {
|
||||
if (StrIsNotEmpty(tchParam) && StrIsNotEmpty(Globals.CurrentFile)) {
|
||||
StringCchCat(tchParam, COUNTOF(tchParam), L" ");
|
||||
}
|
||||
if (StringCchLenW(Globals.CurrentFile, MAX_PATH)) {
|
||||
if (StrIsNotEmpty(Globals.CurrentFile)) {
|
||||
StringCchCopy(tchTemp, COUNTOF(tchTemp), Globals.CurrentFile);
|
||||
PathQuoteSpaces(tchTemp);
|
||||
StringCchCat(tchParam, COUNTOF(tchParam), tchTemp);
|
||||
@ -3255,7 +3257,7 @@ void DialogAdminExe(HWND hwnd, bool bExecInstaller)
|
||||
WCHAR tchExe[MAX_PATH];
|
||||
|
||||
StringCchCopyW(tchExe, COUNTOF(tchExe), Settings2.AdministrationTool);
|
||||
if (bExecInstaller && !StringCchLenW(tchExe, COUNTOF(tchExe))) { return; }
|
||||
if (bExecInstaller && StrIsEmpty(tchExe)) { return; }
|
||||
|
||||
WCHAR tchExePath[MAX_PATH];
|
||||
if (!SearchPath(NULL, tchExe, L".exe", COUNTOF(tchExePath), tchExePath, NULL)) {
|
||||
@ -3355,7 +3357,7 @@ bool SetWindowTitle(HWND hwnd, UINT uIDAppName, bool bIsElevated, UINT uIDUntitl
|
||||
StringCchCat(szTitle, COUNTOF(szTitle), szCachedDisplayName);
|
||||
if (iFormat == 1) {
|
||||
WCHAR tchPath[MAX_PATH] = { L'\0' };
|
||||
StringCchCopyN(tchPath, COUNTOF(tchPath), lpszFile, StringCchLen(lpszFile, MAX_PATH));
|
||||
StringCchCopy(tchPath, COUNTOF(tchPath), lpszFile);
|
||||
PathCchRemoveFileSpec(tchPath, COUNTOF(tchPath));
|
||||
StringCchCat(szTitle, COUNTOF(szTitle), L" [");
|
||||
StringCchCat(szTitle, COUNTOF(szTitle), tchPath);
|
||||
|
||||
@ -873,13 +873,13 @@ bool DirList_SelectItem(HWND hwnd,LPCWSTR lpszDisplayName,LPCWSTR lpszFullPath)
|
||||
|
||||
int i = -1;
|
||||
|
||||
if (!lpszFullPath || !StringCchLen(lpszFullPath, MAX_PATH)) {
|
||||
if (StrIsEmpty(lpszFullPath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GetShortPathName(lpszFullPath,szShortPath,MAX_PATH);
|
||||
|
||||
if (!lpszDisplayName || !StringCchLen(lpszDisplayName, MAX_PATH)) {
|
||||
if (StrIsEmpty(lpszDisplayName)) {
|
||||
SHGetFileInfo(lpszFullPath, 0, &shfi, sizeof(SHFILEINFO), SHGFI_DISPLAYNAME);
|
||||
}
|
||||
else {
|
||||
@ -928,8 +928,7 @@ void DirList_CreateFilter(PDL_FILTER pdlf,LPCWSTR lpszFileSpec,
|
||||
StringCchCopyN(pdlf->tFilterBuf,COUNTOF(pdlf->tFilterBuf),lpszFileSpec,DL_FILTER_BUFSIZE);
|
||||
pdlf->bExcludeFilter = bExcludeFilter;
|
||||
|
||||
if (!StringCchCompareX(lpszFileSpec,L"*.*") || !StringCchLen(lpszFileSpec,DL_FILTER_BUFSIZE))
|
||||
return;
|
||||
if (!StringCchCompareX(lpszFileSpec, L"*.*") || StrIsEmpty(lpszFileSpec)) { return; }
|
||||
|
||||
pdlf->nCount = 1;
|
||||
pdlf->pFilter[0] = &pdlf->tFilterBuf[0]; // Zeile zum Ausprobieren
|
||||
|
||||
@ -2481,7 +2481,7 @@ void EditModifyLines(HWND hwnd,LPCWSTR pwszPrefix,LPCWSTR pwszAppend)
|
||||
char mszPrefix2[256*3] = { '\0' };
|
||||
char mszAppend2[256*3] = { '\0' };
|
||||
|
||||
if (StringCchLenA(mszPrefix1,COUNTOF(mszPrefix1)))
|
||||
if (!StrIsEmptyA(mszPrefix1))
|
||||
{
|
||||
char* p = StrStrA(mszPrefix1, "$(");
|
||||
while (!bPrefixNum && p) {
|
||||
@ -2552,7 +2552,7 @@ void EditModifyLines(HWND hwnd,LPCWSTR pwszPrefix,LPCWSTR pwszAppend)
|
||||
|
||||
bool bAppendNum = false;
|
||||
|
||||
if (StringCchLenA(mszAppend1,COUNTOF(mszAppend1)))
|
||||
if (!StrIsEmptyA(mszAppend1))
|
||||
{
|
||||
char* p = StrStrA(mszAppend1, "$(");
|
||||
while (!bAppendNum && p) {
|
||||
|
||||
@ -151,9 +151,7 @@ inline bool IniSetInt(LPCWSTR lpSection, LPCWSTR lpName, int i) {
|
||||
|
||||
#define IniSetBool(lpSection,lpName,nValue) IniSetInt(lpSection,lpName,((nValue) ? 1 : 0))
|
||||
#define LoadIniSection(lpSection,lpBuf,cchBuf) GetPrivateProfileSection(lpSection,lpBuf,(cchBuf),Globals.IniFile)
|
||||
#define LoadStyleIniSection(lpSection,lpBuf,cchBuf) GetPrivateProfileSection(lpSection,lpBuf,(cchBuf),Globals.StyleIniFile)
|
||||
#define SaveIniSection(lpSection,lpBuf) WritePrivateProfileSection(lpSection,lpBuf,Globals.IniFile)
|
||||
#define SaveStyleIniSection(lpSection,lpBuf) WritePrivateProfileSection(lpSection,lpBuf,Globals.StyleIniFile)
|
||||
|
||||
int IniSectionGetString(LPCWSTR lpCachedIniSection, LPCWSTR lpName, LPCWSTR lpDefault, LPWSTR lpReturnedString, int cchReturnedString);
|
||||
int IniSectionGetInt(LPCWSTR lpCachedIniSection, LPCWSTR lpName, int iDefault);
|
||||
@ -466,8 +464,8 @@ inline WCHAR* StrEndW(const WCHAR* pStart, size_t siz) {
|
||||
|
||||
//==== StrIs(Not)Empty() =============================================
|
||||
|
||||
inline bool StrIsEmptyA(LPCSTR s) { return ((s == NULL) || (*s == '\0')); }
|
||||
inline bool StrIsEmptyW(LPCWSTR s) { return ((s == NULL) || (*s == L'\0')); }
|
||||
inline bool StrIsEmptyA(LPCSTR s) { return (!s || (*s == '\0')); }
|
||||
inline bool StrIsEmptyW(LPCWSTR s) { return (!s || (*s == L'\0')); }
|
||||
|
||||
#if defined(UNICODE) || defined(_UNICODE)
|
||||
#define StrIsEmpty(s) StrIsEmptyW(s)
|
||||
|
||||
139
src/Notepad3.c
139
src/Notepad3.c
@ -538,7 +538,7 @@ typedef struct _themeFiles
|
||||
} THEMEFILES, *PTHEMEFILES;
|
||||
|
||||
|
||||
#define THEME_MENU_MAX_ITEMS 24
|
||||
#define THEME_MENU_MAX_ITEMS 26
|
||||
|
||||
static THEMEFILES Theme_Files[THEME_MENU_MAX_ITEMS] =
|
||||
{
|
||||
@ -565,19 +565,37 @@ static THEMEFILES Theme_Files[THEME_MENU_MAX_ITEMS] =
|
||||
{ 0, L"", L"" },
|
||||
{ 0, L"", L"" },
|
||||
{ 0, L"", L"" },
|
||||
{ 0, L"", L"" },
|
||||
{ 0, L"", L"" },
|
||||
{ 0, L"", L"" }
|
||||
};
|
||||
|
||||
static unsigned s_idxSelectedTheme = 0; // Standard
|
||||
|
||||
static bool _FillThemesMenuTable()
|
||||
static void _FillThemesMenuTable()
|
||||
{
|
||||
WCHAR wchStdName[80];
|
||||
|
||||
Theme_Files[0].rid = IDM_THEMES_DEFAULT; // factory default
|
||||
GetLngString(IDM_THEMES_DEFAULT, wchStdName, COUNTOF(wchStdName));
|
||||
StringCchCopy(Theme_Files[0].szFileName, COUNTOF(Theme_Files[0].szFileName), wchStdName);
|
||||
StringCchCopy(Theme_Files[0].szFilePath, COUNTOF(Theme_Files[0].szFilePath), L"");
|
||||
|
||||
Theme_Files[1].rid = IDM_THEMES_FILE_ITEM; // NP3.ini settings
|
||||
GetLngString(IDM_THEMES_FILE_ITEM, wchStdName, COUNTOF(wchStdName));
|
||||
StringCchCopy(Theme_Files[1].szFileName, COUNTOF(Theme_Files[1].szFileName), wchStdName);
|
||||
StringCchCopy(Theme_Files[1].szFilePath, COUNTOF(Theme_Files[1].szFilePath), Globals.IniFile);
|
||||
|
||||
s_idxSelectedTheme = StrIsEmpty(Globals.IniFile) ? 0 : 1;
|
||||
|
||||
WCHAR tchThemeDir[MAX_PATH] = { L'\0' };
|
||||
// find "themes" sub-dir (side-by-side to Notepad3.ini)
|
||||
StringCchCopy(tchThemeDir, COUNTOF(tchThemeDir), Globals.IniFile);
|
||||
PathCchRemoveFileSpec(tchThemeDir, COUNTOF(tchThemeDir));
|
||||
PathCchAppend(tchThemeDir, COUNTOF(tchThemeDir), L"themes");
|
||||
if (!PathIsDirectory(tchThemeDir)) { s_idxSelectedTheme = 0; return false; }
|
||||
if (StrIsNotEmpty(Globals.IniFile)) {
|
||||
StringCchCopy(tchThemeDir, COUNTOF(tchThemeDir), Globals.IniFile);
|
||||
PathCchRemoveFileSpec(tchThemeDir, COUNTOF(tchThemeDir));
|
||||
PathCchAppend(tchThemeDir, COUNTOF(tchThemeDir), L"themes");
|
||||
}
|
||||
if (!PathIsDirectory(tchThemeDir)) { return; }
|
||||
|
||||
WCHAR tchThemePath[MAX_PATH] = { L'\0' };
|
||||
StringCchCopy(tchThemePath, COUNTOF(tchThemePath), tchThemeDir);
|
||||
@ -586,21 +604,14 @@ static bool _FillThemesMenuTable()
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
ZeroMemory(&FindFileData, sizeof(WIN32_FIND_DATA));
|
||||
HANDLE hFindFile = FindFirstFile(tchThemePath, &FindFileData);
|
||||
if (hFindFile == INVALID_HANDLE_VALUE) { return s_idxSelectedTheme = 0; false; }
|
||||
if (hFindFile == INVALID_HANDLE_VALUE) { return; }
|
||||
|
||||
// --- fill table ---
|
||||
// --- fill table by directory entries ---
|
||||
|
||||
Theme_Files[0].rid = IDM_THEMES_FILE_ITEM;
|
||||
|
||||
WCHAR wchStdName[80];
|
||||
GetLngString(IDM_THEMES_FILE_ITEM, wchStdName, COUNTOF(wchStdName));
|
||||
StringCchCopy(Theme_Files[0].szFileName, COUNTOF(Theme_Files[0].szFileName), wchStdName);
|
||||
StringCchCopy(Theme_Files[0].szFilePath, COUNTOF(Theme_Files[0].szFilePath), Globals.IniFile);
|
||||
|
||||
unsigned i = 1;
|
||||
unsigned i = 2;
|
||||
for (; i < THEME_MENU_MAX_ITEMS; ++i)
|
||||
{
|
||||
Theme_Files[i].rid = (i + IDM_THEMES_FILE_ITEM);
|
||||
Theme_Files[i].rid = (i + IDM_THEMES_DEFAULT);
|
||||
|
||||
StringCchCopy(tchThemePath, COUNTOF(tchThemePath), PathFindFileName(FindFileData.cFileName));
|
||||
PathRemoveExtension(tchThemePath);
|
||||
@ -612,13 +623,8 @@ static bool _FillThemesMenuTable()
|
||||
|
||||
if (!FindNextFile(hFindFile, &FindFileData)) { break; }
|
||||
}
|
||||
unsigned const check = s_idxSelectedTheme; // TODO: better string compare
|
||||
|
||||
s_idxSelectedTheme = clampu(s_idxSelectedTheme, 0, i);
|
||||
if (s_idxSelectedTheme != check) {
|
||||
StringCchCopy(Globals.StyleIniFile, COUNTOF(Globals.StyleIniFile), Theme_Files[i].szFilePath);
|
||||
// TODO: Update needed warning message
|
||||
// better restart ?
|
||||
}
|
||||
|
||||
for (++i; i < THEME_MENU_MAX_ITEMS; ++i) {
|
||||
Theme_Files[i].rid = 0; // no themes available
|
||||
@ -627,8 +633,6 @@ static bool _FillThemesMenuTable()
|
||||
}
|
||||
|
||||
FindClose(hFindFile);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -640,10 +644,6 @@ static bool _InsertThemesMenu(HMENU hMenuBar)
|
||||
{
|
||||
_FillThemesMenuTable();
|
||||
|
||||
if (Theme_Files[1].rid == 0) {
|
||||
return false; // no themes available, use Standard (0)
|
||||
}
|
||||
|
||||
HMENU hmenuThemes = CreatePopupMenu();
|
||||
int const pos = GetMenuItemCount(hMenuBar) - 1;
|
||||
|
||||
@ -3216,19 +3216,12 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
i = IDM_VIEW_NOESCFUNC;
|
||||
CheckMenuRadioItem(hmenu,IDM_VIEW_NOESCFUNC,IDM_VIEW_ESCEXIT,i,MF_BYCOMMAND);
|
||||
|
||||
i = (int)StringCchLenW(Globals.IniFile,COUNTOF(Globals.IniFile));
|
||||
CheckCmd(hmenu,IDM_VIEW_SAVESETTINGS,Settings.SaveSettings && i);
|
||||
|
||||
EnableCmd(hmenu,IDM_VIEW_REUSEWINDOW,i);
|
||||
EnableCmd(hmenu,IDM_VIEW_STICKYWINPOS,i);
|
||||
EnableCmd(hmenu,IDM_VIEW_SINGLEFILEINSTANCE,i);
|
||||
EnableCmd(hmenu,IDM_VIEW_NOSAVERECENT,i);
|
||||
EnableCmd(hmenu,IDM_VIEW_NOPRESERVECARET,i);
|
||||
EnableCmd(hmenu,IDM_VIEW_NOSAVEFINDREPL,i);
|
||||
EnableCmd(hmenu,IDM_VIEW_SAVESETTINGS,s_bEnableSaveSettings && i);
|
||||
|
||||
i = (StringCchLenW(Globals.IniFile,COUNTOF(Globals.IniFile)) > 0 || StringCchLenW(s_wchIniFile2,COUNTOF(s_wchIniFile2)) > 0);
|
||||
EnableCmd(hmenu,IDM_VIEW_SAVESETTINGSNOW,s_bEnableSaveSettings && i);
|
||||
|
||||
bool bIsHLink = false;
|
||||
int const iHotSpotStyleID = Style_GetHotspotStyleID();
|
||||
@ -3246,6 +3239,8 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
CheckCmd(hmenu, MUI_LanguageDLLs[lng].rid, MUI_LanguageDLLs[lng].bIsActive);
|
||||
}
|
||||
|
||||
UpdateSettingsCmds();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -3307,7 +3302,7 @@ static void _DynamicLanguageMenuCmd(int cmd)
|
||||
//
|
||||
static void _DynamicThemesMenuCmd(int cmd)
|
||||
{
|
||||
unsigned const iThemeIdx = (unsigned)(cmd - IDM_THEMES_FILE_ITEM); // consecutive IDs
|
||||
unsigned const iThemeIdx = (unsigned)(cmd - IDM_THEMES_DEFAULT); // consecutive IDs
|
||||
|
||||
if ((iThemeIdx < 0) || (iThemeIdx >= THEME_MENU_MAX_ITEMS)) {
|
||||
return;
|
||||
@ -3317,26 +3312,37 @@ static void _DynamicThemesMenuCmd(int cmd)
|
||||
CheckCmd(Globals.hMainMenu, Theme_Files[s_idxSelectedTheme].rid, false);
|
||||
|
||||
if (Settings.SaveSettings) {
|
||||
if ((s_idxSelectedTheme == 0) && s_bEnableSaveSettings) {
|
||||
CreateIniFile();
|
||||
Style_ExportToFile(Theme_Files[s_idxSelectedTheme].szFilePath, false);
|
||||
if (s_idxSelectedTheme == 0) {
|
||||
// nothing to do: internal defaults
|
||||
}
|
||||
else if (s_idxSelectedTheme == 1) {
|
||||
if (s_bEnableSaveSettings) {
|
||||
CreateIniFile();
|
||||
Style_ExportToFile(Globals.IniFile, false);
|
||||
}
|
||||
}
|
||||
else if (PathFileExists(Theme_Files[s_idxSelectedTheme].szFilePath))
|
||||
{
|
||||
Style_ExportToFile(Theme_Files[s_idxSelectedTheme].szFilePath, false);
|
||||
bool const bIndependentFromStandardSettings = true;
|
||||
Style_ExportToFile(Theme_Files[s_idxSelectedTheme].szFilePath, bIndependentFromStandardSettings);
|
||||
}
|
||||
}
|
||||
|
||||
if (PathFileExists(Theme_Files[iThemeIdx].szFilePath))
|
||||
s_idxSelectedTheme = iThemeIdx;
|
||||
|
||||
bool result = true;
|
||||
if ((s_idxSelectedTheme > 1) && PathFileExists(Theme_Files[s_idxSelectedTheme].szFilePath))
|
||||
{
|
||||
StringCchCopy(Globals.StyleIniFile, COUNTOF(Globals.StyleIniFile), Theme_Files[iThemeIdx].szFilePath);
|
||||
result = Style_ImportFromFile(Theme_Files[s_idxSelectedTheme].szFilePath, false);
|
||||
}
|
||||
else if (s_idxSelectedTheme == 1) {
|
||||
result = Style_ImportFromFile(Globals.IniFile, false);
|
||||
}
|
||||
else {
|
||||
StringCchCopy(Globals.StyleIniFile, COUNTOF(Globals.StyleIniFile), Globals.IniFile);
|
||||
result = Style_ImportFromFile(L"", false);
|
||||
}
|
||||
s_idxSelectedTheme = iThemeIdx; // new scheme
|
||||
|
||||
if (Style_ImportFromFile(Globals.StyleIniFile)) {
|
||||
if (result) {
|
||||
Style_ResetCurrentLexer(Globals.hwndEdit);
|
||||
SendWMSize(Globals.hwndMain, NULL);
|
||||
UpdateUI();
|
||||
@ -3366,7 +3372,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool const bIsThemesMenuCmd = ((iLoWParam >= IDM_THEMES_FILE_ITEM) && (iLoWParam < (IDM_THEMES_FILE_ITEM + THEME_MENU_MAX_ITEMS)));
|
||||
bool const bIsThemesMenuCmd = ((iLoWParam >= IDM_THEMES_DEFAULT) && (iLoWParam < (IDM_THEMES_DEFAULT + THEME_MENU_MAX_ITEMS)));
|
||||
if (bIsThemesMenuCmd) {
|
||||
_DynamicThemesMenuCmd(iLoWParam);
|
||||
return FALSE;
|
||||
@ -5457,8 +5463,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
StringCchCopy(Globals.IniFile,COUNTOF(Globals.IniFile),s_wchIniFile2);
|
||||
StringCchCopy(s_wchIniFile2,COUNTOF(s_wchIniFile2),L"");
|
||||
}
|
||||
else
|
||||
else {
|
||||
bCreateFailure = true;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
@ -7925,7 +7932,6 @@ void ParseCommandLine()
|
||||
StringCchCopyN(Globals.IniFile, COUNTOF(Globals.IniFile), lp1, len);
|
||||
TrimStringW(Globals.IniFile);
|
||||
NormalizePathEx(Globals.IniFile, COUNTOF(Globals.IniFile), true, false);
|
||||
StringCchCopy(Globals.StyleIniFile, COUNTOF(Globals.StyleIniFile), Globals.IniFile);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -8371,7 +8377,7 @@ bool FindIniFile()
|
||||
PathCchRemoveFileSpec(tchPath, COUNTOF(tchPath));
|
||||
SetEnvironmentVariable(NOTEPAD3_MODULE_DIR_ENV_VAR, tchPath);
|
||||
|
||||
if (StringCchLenW(Globals.IniFile,COUNTOF(Globals.IniFile))) {
|
||||
if (StrIsNotEmpty(Globals.IniFile)) {
|
||||
if (StringCchCompareXI(Globals.IniFile, L"*?") == 0) {
|
||||
return bFound;
|
||||
}
|
||||
@ -8388,6 +8394,7 @@ bool FindIniFile()
|
||||
else {
|
||||
StringCchCopy(tchPath,COUNTOF(tchPath),PathFindFileName(tchModule));
|
||||
PathCchRenameExtension(tchPath,COUNTOF(tchPath),L".ini");
|
||||
|
||||
bFound = _CheckIniFile(tchPath,tchModule);
|
||||
|
||||
if (!bFound) {
|
||||
@ -8398,7 +8405,8 @@ bool FindIniFile()
|
||||
if (bFound)
|
||||
{
|
||||
// allow two redirections: administrator -> user -> custom
|
||||
if (_CheckIniFileRedirect(_W(SAPPNAME), _W(SAPPNAME) L".ini", tchPath, tchModule)) {
|
||||
if (_CheckIniFileRedirect(_W(SAPPNAME), _W(SAPPNAME) L".ini", tchPath, tchModule))
|
||||
{
|
||||
_CheckIniFileRedirect(_W(SAPPNAME), _W(SAPPNAME) L".ini", tchPath, tchModule);
|
||||
}
|
||||
StringCchCopy(Globals.IniFile,COUNTOF(Globals.IniFile),tchPath);
|
||||
@ -8411,8 +8419,6 @@ bool FindIniFile()
|
||||
|
||||
NormalizePathEx(Globals.IniFile,COUNTOF(Globals.IniFile), true, false);
|
||||
|
||||
StringCchCopy(Globals.StyleIniFile, COUNTOF(Globals.StyleIniFile), Globals.IniFile);
|
||||
|
||||
return bFound;
|
||||
}
|
||||
|
||||
@ -8450,15 +8456,15 @@ int TestIniFile() {
|
||||
}
|
||||
|
||||
|
||||
int CreateIniFile()
|
||||
bool CreateIniFile()
|
||||
{
|
||||
return(CreateIniFileEx(Globals.IniFile));
|
||||
}
|
||||
|
||||
|
||||
int CreateIniFileEx(LPCWSTR lpszIniFile)
|
||||
bool CreateIniFileEx(LPCWSTR lpszIniFile)
|
||||
{
|
||||
if (*lpszIniFile) {
|
||||
if (StrIsNotEmpty(lpszIniFile))
|
||||
{
|
||||
WCHAR *pwchTail = StrRChrW(lpszIniFile, NULL, L'\\');
|
||||
if (pwchTail) {
|
||||
*pwchTail = 0;
|
||||
@ -8477,10 +8483,11 @@ int CreateIniFileEx(LPCWSTR lpszIniFile)
|
||||
Globals.bIniFileFromScratch = true;
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
return(1);
|
||||
StringCchCopy(Theme_Files[1].szFilePath, COUNTOF(Theme_Files[1].szFilePath), lpszIniFile);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -9343,12 +9350,11 @@ void UpdateMarginWidth()
|
||||
//
|
||||
void UpdateSettingsCmds()
|
||||
{
|
||||
HMENU hmenu = GetSystemMenu(Globals.hwndMain, false);
|
||||
bool hasIniFile = (StringCchLenW(Globals.IniFile,COUNTOF(Globals.IniFile)) > 0 || StringCchLenW(s_wchIniFile2,COUNTOF(s_wchIniFile2)) > 0);
|
||||
CheckCmd(hmenu, IDM_VIEW_SAVESETTINGS, Settings.SaveSettings && s_bEnableSaveSettings);
|
||||
EnableCmd(hmenu, IDM_VIEW_SAVESETTINGS, hasIniFile && s_bEnableSaveSettings);
|
||||
EnableCmd(hmenu, IDM_VIEW_SAVESETTINGSNOW, hasIniFile && s_bEnableSaveSettings);
|
||||
COND_SHOW_ZOOM_CALLTIP();
|
||||
//~HMENU hmenu = GetSystemMenu(Globals.hwndMain, false);
|
||||
CheckCmd(Globals.hMainMenu, IDM_VIEW_SAVESETTINGS, Settings.SaveSettings && s_bEnableSaveSettings);
|
||||
EnableCmd(Globals.hMainMenu, IDM_VIEW_SAVESETTINGS, StrIsNotEmpty(Globals.IniFile) && s_bEnableSaveSettings);
|
||||
EnableCmd(Globals.hMainMenu, IDM_VIEW_SAVESETTINGSNOW, (StrIsNotEmpty(Globals.IniFile) || StrIsNotEmpty(s_wchIniFile2)) && s_bEnableSaveSettings);
|
||||
EnableCmd(Globals.hMainMenu, CMD_OPENINIFILE, StrIsNotEmpty(Globals.IniFile) && s_bEnableSaveSettings);
|
||||
}
|
||||
|
||||
|
||||
@ -9789,6 +9795,8 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload,
|
||||
InstallFileWatching(NULL);
|
||||
s_bEnableSaveSettings = true;
|
||||
UpdateSettingsCmds();
|
||||
COND_SHOW_ZOOM_CALLTIP();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -9929,6 +9937,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload,
|
||||
// consistent settings file handling (if loaded in editor)
|
||||
s_bEnableSaveSettings = (StringCchCompareNIW(Globals.CurrentFile, COUNTOF(Globals.CurrentFile), Globals.IniFile, COUNTOF(Globals.IniFile)) == 0) ? false : true;
|
||||
UpdateSettingsCmds();
|
||||
COND_SHOW_ZOOM_CALLTIP();
|
||||
|
||||
// Show warning: Unicode file loaded as ANSI
|
||||
if (fioStatus.bUnicodeErr) {
|
||||
|
||||
@ -130,8 +130,8 @@ void ParseCommandLine();
|
||||
void LoadFlags();
|
||||
bool FindIniFile();
|
||||
int TestIniFile();
|
||||
int CreateIniFile();
|
||||
int CreateIniFileEx(LPCWSTR lpszIniFile);
|
||||
bool CreateIniFile();
|
||||
bool CreateIniFileEx(LPCWSTR lpszIniFile);
|
||||
void ShowZoomCallTip();
|
||||
void CancelCallTip();
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FCT_SETTING_CHANGE, // value -b: rest style bit, 0: get bit-set, +b: set style bit
|
||||
FCT_SETTING_CHANGE, // value -b: reset style bit, 0: get bit-set, +b: set style bit
|
||||
FCT_PASS
|
||||
}
|
||||
LexFunctionType;
|
||||
|
||||
254
src/Styles.c
254
src/Styles.c
@ -225,76 +225,12 @@ float Style_GetCurrentFontSize()
|
||||
//
|
||||
void Style_Load()
|
||||
{
|
||||
|
||||
float const fBFS = GetBaseFontSize(Globals.hwndMain);
|
||||
_SetBaseFontSize(fBFS);
|
||||
_SetCurrentFontSize(fBFS);
|
||||
|
||||
size_t const len = NUMLEXERS * AVG_NUM_OF_STYLES_PER_LEXER * 100;
|
||||
WCHAR *pIniSection = AllocMem(len * sizeof(WCHAR), HEAP_ZERO_MEMORY);
|
||||
if (pIniSection) { ZeroMemory(pIniSection, len * sizeof(WCHAR)); }
|
||||
Style_ImportFromFile(Globals.IniFile, true);
|
||||
|
||||
if (pIniSection) {
|
||||
|
||||
// Default colors
|
||||
s_colorDefault[0] = RGB(0x00, 0x00, 0x00);
|
||||
s_colorDefault[1] = RGB(0x0A, 0x24, 0x6A);
|
||||
s_colorDefault[2] = RGB(0x3A, 0x6E, 0xA5);
|
||||
s_colorDefault[3] = RGB(0x00, 0x3C, 0xE6);
|
||||
s_colorDefault[4] = RGB(0x00, 0x66, 0x33);
|
||||
s_colorDefault[5] = RGB(0x60, 0x80, 0x20);
|
||||
s_colorDefault[6] = RGB(0x64, 0x80, 0x00);
|
||||
s_colorDefault[7] = RGB(0xA4, 0x60, 0x00);
|
||||
s_colorDefault[8] = RGB(0xFF, 0xFF, 0xFF);
|
||||
s_colorDefault[9] = RGB(0xFF, 0xFF, 0xE2);
|
||||
s_colorDefault[10] = RGB(0xFF, 0xF1, 0xA8);
|
||||
s_colorDefault[11] = RGB(0xFF, 0xC0, 0x00);
|
||||
s_colorDefault[12] = RGB(0xFF, 0x40, 0x00);
|
||||
s_colorDefault[13] = RGB(0xC8, 0x00, 0x00);
|
||||
s_colorDefault[14] = RGB(0xB0, 0x00, 0xB0);
|
||||
s_colorDefault[15] = RGB(0xB2, 0x8B, 0x40);
|
||||
|
||||
WCHAR tch[32] = { L'\0' };
|
||||
int const cchIniSection = (int)len;
|
||||
|
||||
LoadStyleIniSection(L"Custom Colors", pIniSection, cchIniSection);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
WCHAR wch[32] = { L'\0' };
|
||||
StringCchPrintf(tch, COUNTOF(tch), L"%02i", i + 1);
|
||||
int itok = 0;
|
||||
if (IniSectionGetString(pIniSection, tch, L"", wch, COUNTOF(wch))) {
|
||||
if (wch[0] == L'#') {
|
||||
unsigned int irgb;
|
||||
itok = swscanf_s(CharNext(wch), L"%x", &irgb);
|
||||
if (itok == 1) {
|
||||
s_colorCustom[i] = RGB((irgb & 0xFF0000) >> 16, (irgb & 0xFF00) >> 8, irgb & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itok != 1) {
|
||||
s_colorCustom[i] = s_colorDefault[i];
|
||||
}
|
||||
}
|
||||
|
||||
LoadStyleIniSection(L"Styles", pIniSection, cchIniSection);
|
||||
|
||||
// 2nd default
|
||||
Style_SetUse2ndDefault(IniSectionGetBool(pIniSection, L"Use2ndDefaultStyle", false));
|
||||
|
||||
// default scheme
|
||||
s_iDefaultLexer = clampi(IniSectionGetInt(pIniSection, L"DefaultScheme", 0), 0, COUNTOF(g_pLexArray) - 1);
|
||||
|
||||
// auto select
|
||||
s_bAutoSelect = IniSectionGetBool(pIniSection, L"AutoSelect", true);
|
||||
|
||||
// scheme select dlg dimensions
|
||||
s_cxStyleSelectDlg = clampi(IniSectionGetInt(pIniSection, L"SelectDlgSizeX", STYLESELECTDLG_X), 0, 8192);
|
||||
s_cyStyleSelectDlg = clampi(IniSectionGetInt(pIniSection, L"SelectDlgSizeY", STYLESELECTDLG_Y), 0, 8192);
|
||||
|
||||
FreeMem(pIniSection);
|
||||
|
||||
Style_ImportFromFile(Globals.StyleIniFile);
|
||||
}
|
||||
// 2nd Default Style has same filename extension list as (1st) Default Style
|
||||
StringCchCopyW(lexStandard2nd.szExtensions, COUNTOF(lexStandard2nd.szExtensions), lexStandard.szExtensions);
|
||||
}
|
||||
@ -327,7 +263,7 @@ bool Style_Import(HWND hwnd)
|
||||
|
||||
if (GetOpenFileName(&ofn))
|
||||
{
|
||||
result = Style_ImportFromFile(szFile);
|
||||
result = Style_ImportFromFile(szFile, true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -337,9 +273,14 @@ bool Style_Import(HWND hwnd)
|
||||
//
|
||||
// Style_ImportFromFile()
|
||||
//
|
||||
bool Style_ImportFromFile(const WCHAR* szFile)
|
||||
bool Style_ImportFromFile(const WCHAR* szFile, bool bDefaultGuard)
|
||||
{
|
||||
if (!szFile || szFile[0] == L'\0') { return false; }
|
||||
bool bResetToDefault = false;
|
||||
|
||||
if (!szFile || szFile[0] == L'\0') {
|
||||
bResetToDefault = true;
|
||||
bDefaultGuard = false;
|
||||
}
|
||||
|
||||
bool result = false;
|
||||
|
||||
@ -349,17 +290,88 @@ bool Style_ImportFromFile(const WCHAR* szFile)
|
||||
|
||||
if (pIniSection) {
|
||||
|
||||
// Default colors
|
||||
s_colorDefault[0] = RGB(0x00, 0x00, 0x00);
|
||||
s_colorDefault[1] = RGB(0x0A, 0x24, 0x6A);
|
||||
s_colorDefault[2] = RGB(0x3A, 0x6E, 0xA5);
|
||||
s_colorDefault[3] = RGB(0x00, 0x3C, 0xE6);
|
||||
s_colorDefault[4] = RGB(0x00, 0x66, 0x33);
|
||||
s_colorDefault[5] = RGB(0x60, 0x80, 0x20);
|
||||
s_colorDefault[6] = RGB(0x64, 0x80, 0x00);
|
||||
s_colorDefault[7] = RGB(0xA4, 0x60, 0x00);
|
||||
s_colorDefault[8] = RGB(0xFF, 0xFF, 0xFF);
|
||||
s_colorDefault[9] = RGB(0xFF, 0xFF, 0xE2);
|
||||
s_colorDefault[10] = RGB(0xFF, 0xF1, 0xA8);
|
||||
s_colorDefault[11] = RGB(0xFF, 0xC0, 0x00);
|
||||
s_colorDefault[12] = RGB(0xFF, 0x40, 0x00);
|
||||
s_colorDefault[13] = RGB(0xC8, 0x00, 0x00);
|
||||
s_colorDefault[14] = RGB(0xB0, 0x00, 0xB0);
|
||||
s_colorDefault[15] = RGB(0xB2, 0x8B, 0x40);
|
||||
|
||||
if (!bResetToDefault)
|
||||
{
|
||||
WCHAR tch[32] = { L'\0' };
|
||||
|
||||
GetPrivateProfileSection(L"Custom Colors", pIniSection, (int)len, szFile);
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
WCHAR wch[32] = { L'\0' };
|
||||
StringCchPrintf(tch, COUNTOF(tch), L"%02i", i + 1);
|
||||
int itok = 0;
|
||||
if (IniSectionGetString(pIniSection, tch, L"", wch, COUNTOF(wch))) {
|
||||
if (wch[0] == L'#') {
|
||||
unsigned int irgb;
|
||||
itok = swscanf_s(CharNext(wch), L"%x", &irgb);
|
||||
if (itok == 1) {
|
||||
s_colorCustom[i] = RGB((irgb & 0xFF0000) >> 16, (irgb & 0xFF00) >> 8, irgb & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itok != 1) {
|
||||
s_colorCustom[i] = s_colorDefault[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Styles
|
||||
if (!bResetToDefault) {
|
||||
GetPrivateProfileSection(L"Styles", pIniSection, (int)len, szFile);
|
||||
}
|
||||
|
||||
// 2nd default
|
||||
Style_SetUse2ndDefault(IniSectionGetBool(pIniSection, L"Use2ndDefaultStyle", false));
|
||||
|
||||
// default scheme
|
||||
s_iDefaultLexer = clampi(IniSectionGetInt(pIniSection, L"DefaultScheme", 0), 0, COUNTOF(g_pLexArray) - 1);
|
||||
|
||||
// auto select
|
||||
s_bAutoSelect = IniSectionGetBool(pIniSection, L"AutoSelect", true);
|
||||
|
||||
// scheme select dlg dimensions
|
||||
s_cxStyleSelectDlg = clampi(IniSectionGetInt(pIniSection, L"SelectDlgSizeX", STYLESELECTDLG_X), 0, 8192);
|
||||
s_cyStyleSelectDlg = clampi(IniSectionGetInt(pIniSection, L"SelectDlgSizeY", STYLESELECTDLG_Y), 0, 8192);
|
||||
|
||||
|
||||
// Lexer
|
||||
for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); iLexer++) {
|
||||
|
||||
LexFunctionPtr_t const pLexFunction = g_pLexArray[iLexer]->pFctPtr;
|
||||
|
||||
GetPrivateProfileSection(g_pLexArray[iLexer]->pszName, pIniSection, (int)len, szFile);
|
||||
if (!bResetToDefault) {
|
||||
GetPrivateProfileSection(g_pLexArray[iLexer]->pszName, pIniSection, (int)len, szFile);
|
||||
}
|
||||
|
||||
if (IniSectionGetString(pIniSection, L"FileNameExtensions", g_pLexArray[iLexer]->pszDefExt,
|
||||
g_pLexArray[iLexer]->szExtensions, COUNTOF(g_pLexArray[iLexer]->szExtensions)) > 0)
|
||||
{
|
||||
if (StringCchCompareXIW(g_pLexArray[iLexer]->szExtensions, g_pLexArray[iLexer]->pszDefExt) != 0) {
|
||||
(*pLexFunction)(FCT_SETTING_CHANGE, 1);
|
||||
if (bDefaultGuard) {
|
||||
if (StringCchCompareXIW(g_pLexArray[iLexer]->szExtensions, g_pLexArray[iLexer]->pszDefExt) != 0)
|
||||
{
|
||||
(*pLexFunction)(FCT_SETTING_CHANGE, 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
(*pLexFunction)(FCT_SETTING_CHANGE, -1); // reset
|
||||
}
|
||||
}
|
||||
unsigned i = 0;
|
||||
@ -370,8 +382,14 @@ bool Style_ImportFromFile(const WCHAR* szFile)
|
||||
g_pLexArray[iLexer]->Styles[i].szValue,
|
||||
COUNTOF(g_pLexArray[iLexer]->Styles[i].szValue)) > 0)
|
||||
{
|
||||
if (StringCchCompareXIW(g_pLexArray[iLexer]->Styles[i].szValue, g_pLexArray[iLexer]->Styles[i].pszDefault) != 0) {
|
||||
(*pLexFunction)(FCT_SETTING_CHANGE, (i + 2));
|
||||
if (bDefaultGuard) {
|
||||
if (StringCchCompareXIW(g_pLexArray[iLexer]->Styles[i].szValue, g_pLexArray[iLexer]->Styles[i].pszDefault) != 0)
|
||||
{
|
||||
(*pLexFunction)(FCT_SETTING_CHANGE, (i + 2));
|
||||
}
|
||||
}
|
||||
else {
|
||||
(*pLexFunction)(FCT_SETTING_CHANGE, 0-(i + 2)); // reset
|
||||
}
|
||||
}
|
||||
++i;
|
||||
@ -390,51 +408,7 @@ bool Style_ImportFromFile(const WCHAR* szFile)
|
||||
//
|
||||
void Style_Save()
|
||||
{
|
||||
size_t const len = NUMLEXERS * AVG_NUM_OF_STYLES_PER_LEXER * 100;
|
||||
WCHAR *pIniSection = AllocMem(len * sizeof(WCHAR), HEAP_ZERO_MEMORY);
|
||||
|
||||
if (pIniSection) {
|
||||
// Custom colors
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (s_colorCustom[i] != s_colorDefault[i]) {
|
||||
WCHAR tch[32] = { L'\0' };
|
||||
WCHAR wch[32] = { L'\0' };
|
||||
StringCchPrintf(tch, COUNTOF(tch), L"%02i", i + 1);
|
||||
StringCchPrintf(wch, COUNTOF(wch), L"#%02X%02X%02X",
|
||||
(int)GetRValue(s_colorCustom[i]), (int)GetGValue(s_colorCustom[i]), (int)GetBValue(s_colorCustom[i]));
|
||||
IniSectionSetString(pIniSection, tch, wch);
|
||||
}
|
||||
}
|
||||
SaveStyleIniSection(L"Custom Colors", pIniSection);
|
||||
ZeroMemory(pIniSection, len * sizeof(WCHAR));
|
||||
|
||||
// auto select
|
||||
bool const bUse2ndSty = Style_GetUse2ndDefault();
|
||||
if (bUse2ndSty) {
|
||||
IniSectionSetBool(pIniSection, L"Use2ndDefaultStyle", bUse2ndSty);
|
||||
}
|
||||
// default scheme
|
||||
if (s_iDefaultLexer != 0) {
|
||||
IniSectionSetInt(pIniSection, L"DefaultScheme", s_iDefaultLexer);
|
||||
}
|
||||
// auto select
|
||||
if (!s_bAutoSelect) {
|
||||
IniSectionSetInt(pIniSection, L"AutoSelect", s_bAutoSelect);
|
||||
}
|
||||
|
||||
// scheme select dlg dimensions
|
||||
if (s_cxStyleSelectDlg != STYLESELECTDLG_X) {
|
||||
IniSectionSetInt(pIniSection, L"SelectDlgSizeX", s_cxStyleSelectDlg);
|
||||
}
|
||||
if (s_cyStyleSelectDlg != STYLESELECTDLG_Y) {
|
||||
IniSectionSetInt(pIniSection, L"SelectDlgSizeY", s_cyStyleSelectDlg);
|
||||
}
|
||||
SaveStyleIniSection(L"Styles", pIniSection);
|
||||
//ZeroMemory(pIniSection, len * sizeof(WCHAR));
|
||||
FreeMem(pIniSection);
|
||||
|
||||
Style_ExportToFile(Globals.StyleIniFile, Globals.bIniFileFromScratch);
|
||||
}
|
||||
Style_ExportToFile(Globals.IniFile, false);
|
||||
}
|
||||
|
||||
|
||||
@ -490,6 +464,50 @@ DWORD Style_ExportToFile(const WCHAR* szFile, bool bForceAll)
|
||||
|
||||
if (pIniSection) {
|
||||
|
||||
// Custom colors
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (bForceAll || (s_colorCustom[i] != s_colorDefault[i])) {
|
||||
WCHAR tch[32] = { L'\0' };
|
||||
WCHAR wch[32] = { L'\0' };
|
||||
StringCchPrintf(tch, COUNTOF(tch), L"%02i", i + 1);
|
||||
StringCchPrintf(wch, COUNTOF(wch), L"#%02X%02X%02X",
|
||||
(int)GetRValue(s_colorCustom[i]), (int)GetGValue(s_colorCustom[i]), (int)GetBValue(s_colorCustom[i]));
|
||||
IniSectionSetString(pIniSection, tch, wch);
|
||||
}
|
||||
}
|
||||
if (!WritePrivateProfileSection(L"Custom Colors", pIniSection, szFile)) {
|
||||
dwError = GetLastError();
|
||||
}
|
||||
ZeroMemory(pIniSection, len * sizeof(WCHAR));
|
||||
|
||||
|
||||
// auto select
|
||||
bool const bUse2ndSty = Style_GetUse2ndDefault();
|
||||
if (bUse2ndSty) {
|
||||
IniSectionSetBool(pIniSection, L"Use2ndDefaultStyle", bUse2ndSty);
|
||||
}
|
||||
// default scheme
|
||||
if (s_iDefaultLexer != 0) {
|
||||
IniSectionSetInt(pIniSection, L"DefaultScheme", s_iDefaultLexer);
|
||||
}
|
||||
// auto select
|
||||
if (!s_bAutoSelect) {
|
||||
IniSectionSetInt(pIniSection, L"AutoSelect", s_bAutoSelect);
|
||||
}
|
||||
|
||||
// scheme select dlg dimensions
|
||||
if (s_cxStyleSelectDlg != STYLESELECTDLG_X) {
|
||||
IniSectionSetInt(pIniSection, L"SelectDlgSizeX", s_cxStyleSelectDlg);
|
||||
}
|
||||
if (s_cyStyleSelectDlg != STYLESELECTDLG_Y) {
|
||||
IniSectionSetInt(pIniSection, L"SelectDlgSizeY", s_cyStyleSelectDlg);
|
||||
}
|
||||
if (!WritePrivateProfileSection(L"Styles", pIniSection, szFile)) {
|
||||
dwError = GetLastError();
|
||||
}
|
||||
ZeroMemory(pIniSection, len * sizeof(WCHAR));
|
||||
|
||||
|
||||
// create canonical order of lexer sections
|
||||
if (bForceAll) {
|
||||
for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); iLexer++)
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
void Style_Load();
|
||||
bool Style_Import(HWND hwnd);
|
||||
bool Style_ImportFromFile(const WCHAR* szFile);
|
||||
bool Style_ImportFromFile(const WCHAR* szFile, bool bDefaultGuard);
|
||||
void Style_Save();
|
||||
bool Style_Export(HWND hwnd);
|
||||
DWORD Style_ExportToFile(const WCHAR* szFile, bool bForceAll);
|
||||
|
||||
@ -318,7 +318,6 @@ typedef struct _globals_t
|
||||
|
||||
WCHAR WorkingDirectory[MAX_PATH];
|
||||
WCHAR IniFile[MAX_PATH];
|
||||
WCHAR StyleIniFile[MAX_PATH];
|
||||
WCHAR CurrentFile[MAX_PATH];
|
||||
|
||||
} GLOBALS_T, *PGLOBALS_T;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user