mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
+ refactoring: global naming
This commit is contained in:
parent
6a8c610f80
commit
1249f4bbe1
@ -650,7 +650,7 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
|
||||
// GeneralPageProc
|
||||
//
|
||||
//
|
||||
extern WCHAR szIniFile[MAX_PATH];
|
||||
extern WCHAR g_wchIniFile[MAX_PATH];
|
||||
extern BOOL bSaveSettings;
|
||||
extern WCHAR szQuickview[MAX_PATH];
|
||||
extern WCHAR szQuickviewParams[MAX_PATH];
|
||||
@ -676,7 +676,7 @@ INT_PTR CALLBACK GeneralPageProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam
|
||||
|
||||
case WM_INITDIALOG:
|
||||
|
||||
if (lstrlen(szIniFile)) {
|
||||
if (lstrlen(g_wchIniFile)) {
|
||||
if (bSaveSettings)
|
||||
CheckDlgButton(hwnd,IDC_SAVESETTINGS,BST_CHECKED);
|
||||
}
|
||||
|
||||
@ -19,22 +19,24 @@ extern UINT16 g_uWinVer;
|
||||
#define UNUSED(expr) (void)(expr)
|
||||
#define COUNTOF(ar) ARRAYSIZE(ar) //#define COUNTOF(ar) (sizeof(ar)/sizeof(ar[0]))
|
||||
|
||||
extern WCHAR szIniFile[MAX_PATH];
|
||||
extern WCHAR g_wchIniFile[MAX_PATH];
|
||||
|
||||
#define IniGetString(lpSection,lpName,lpDefault,lpReturnedStr,nSize) \
|
||||
GetPrivateProfileString(lpSection,lpName,lpDefault,lpReturnedStr,nSize,szIniFile)
|
||||
GetPrivateProfileString(lpSection,lpName,lpDefault,lpReturnedStr,nSize,g_wchIniFile)
|
||||
#define IniGetInt(lpSection,lpName,nDefault) \
|
||||
GetPrivateProfileInt(lpSection,lpName,nDefault,szIniFile)
|
||||
GetPrivateProfileInt(lpSection,lpName,nDefault,g_wchIniFile)
|
||||
#define IniSetString(lpSection,lpName,lpString) \
|
||||
WritePrivateProfileString(lpSection,lpName,lpString,szIniFile)
|
||||
WritePrivateProfileString(lpSection,lpName,lpString,g_wchIniFile)
|
||||
#define IniDeleteSection(lpSection) \
|
||||
WritePrivateProfileSection(lpSection,NULL,szIniFile)
|
||||
WritePrivateProfileSection(lpSection,NULL,g_wchIniFile)
|
||||
__inline BOOL IniSetInt(LPCWSTR lpSection,LPCWSTR lpName,int i) {
|
||||
WCHAR tch[32]; wsprintf(tch,L"%i",i); return WritePrivateProfileString(lpSection,lpName,tch,szIniFile);
|
||||
WCHAR tch[32]; wsprintf(tch,L"%i",i);
|
||||
return WritePrivateProfileString(lpSection,lpName,tch,g_wchIniFile);
|
||||
}
|
||||
#define LoadIniSection(lpSection,lpBuf,cchBuf) \
|
||||
GetPrivateProfileSection(lpSection,lpBuf,cchBuf,szIniFile);
|
||||
GetPrivateProfileSection(lpSection,lpBuf,cchBuf,g_wchIniFile);
|
||||
#define SaveIniSection(lpSection,lpBuf) \
|
||||
WritePrivateProfileSection(lpSection,lpBuf,szIniFile)
|
||||
WritePrivateProfileSection(lpSection,lpBuf,g_wchIniFile)
|
||||
int IniSectionGetString(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,int);
|
||||
int IniSectionGetInt(LPCWSTR,LPCWSTR,int);
|
||||
BOOL IniSectionSetString(LPWSTR,LPCWSTR,LPCWSTR);
|
||||
|
||||
@ -68,8 +68,8 @@ HANDLE hChangeHandle = NULL;
|
||||
|
||||
HISTORY mHistory;
|
||||
|
||||
WCHAR szIniFile[MAX_PATH] = L"";
|
||||
WCHAR szIniFile2[MAX_PATH] = L"";
|
||||
WCHAR g_wchIniFile[MAX_PATH] = L"";
|
||||
WCHAR g_wchIniFile2[MAX_PATH] = L"";
|
||||
BOOL bSaveSettings;
|
||||
WCHAR szQuickview[MAX_PATH];
|
||||
WCHAR szQuickviewParams[MAX_PATH];
|
||||
@ -1222,7 +1222,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
|
||||
CheckCmd(hmenu,SC_ALWAYSONTOP,bAlwaysOnTop);
|
||||
|
||||
i = (lstrlen(szIniFile) > 0 || lstrlen(szIniFile2) > 0);
|
||||
i = (lstrlen(g_wchIniFile) > 0 || lstrlen(g_wchIniFile2) > 0);
|
||||
EnableCmd(hmenu,IDM_VIEW_SAVESETTINGS,i);
|
||||
|
||||
UNUSED(hwnd);
|
||||
@ -1727,9 +1727,9 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
PathQuoteSpaces(szParameters);
|
||||
|
||||
lstrcat(szParameters,L" -f");
|
||||
if (lstrlen(szIniFile)) {
|
||||
if (lstrlen(g_wchIniFile)) {
|
||||
lstrcat(szParameters,L" \"");
|
||||
lstrcat(szParameters,szIniFile);
|
||||
lstrcat(szParameters,g_wchIniFile);
|
||||
lstrcat(szParameters,L"\"");
|
||||
}
|
||||
else
|
||||
@ -1916,12 +1916,12 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
BOOL bCreateFailure = FALSE;
|
||||
|
||||
if (lstrlen(szIniFile) == 0) {
|
||||
if (lstrlen(g_wchIniFile) == 0) {
|
||||
|
||||
if (lstrlen(szIniFile2) > 0) {
|
||||
if (CreateIniFileEx(szIniFile2)) {
|
||||
lstrcpy(szIniFile,szIniFile2);
|
||||
lstrcpy(szIniFile2,L"");
|
||||
if (lstrlen(g_wchIniFile2) > 0) {
|
||||
if (CreateIniFileEx(g_wchIniFile2)) {
|
||||
lstrcpy(g_wchIniFile,g_wchIniFile2);
|
||||
lstrcpy(g_wchIniFile2,L"");
|
||||
}
|
||||
else
|
||||
bCreateFailure = TRUE;
|
||||
@ -1933,7 +1933,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
|
||||
if (!bCreateFailure) {
|
||||
|
||||
if (WritePrivateProfileString(L"Settings",L"WriteTest",L"ok",szIniFile)) {
|
||||
if (WritePrivateProfileString(L"Settings",L"WriteTest",L"ok",g_wchIniFile)) {
|
||||
BeginWaitCursor();
|
||||
SaveSettings(TRUE);
|
||||
EndWaitCursor();
|
||||
@ -2119,9 +2119,9 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
|
||||
|
||||
case ACC_SELECTINIFILE:
|
||||
if (lstrlen(szIniFile)) {
|
||||
if (lstrlen(g_wchIniFile)) {
|
||||
CreateIniFile();
|
||||
DisplayPath(szIniFile,IDS_ERR_INIOPEN);
|
||||
DisplayPath(g_wchIniFile,IDS_ERR_INIOPEN);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -2844,7 +2844,7 @@ void SaveSettings(BOOL bSaveSettingsNow)
|
||||
{
|
||||
WCHAR wchTmp[MAX_PATH];
|
||||
|
||||
if (lstrlen(szIniFile) == 0)
|
||||
if (lstrlen(g_wchIniFile) == 0)
|
||||
return;
|
||||
|
||||
CreateIniFile();
|
||||
@ -2990,11 +2990,11 @@ void ParseCommandLine()
|
||||
|
||||
case L'F':
|
||||
if (*(lp1+1) == L'0' || *CharUpper(lp1+1) == L'O')
|
||||
lstrcpy(szIniFile,L"*?");
|
||||
lstrcpy(g_wchIniFile,L"*?");
|
||||
else if (ExtractFirstArgument(lp2,lp1,lp2)) {
|
||||
StrCpyN(szIniFile,lp1,COUNTOF(szIniFile));
|
||||
TrimString(szIniFile);
|
||||
PathUnquoteSpaces(szIniFile);
|
||||
StrCpyN(g_wchIniFile,lp1,COUNTOF(g_wchIniFile));
|
||||
TrimString(g_wchIniFile);
|
||||
PathUnquoteSpaces(g_wchIniFile);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -3154,17 +3154,17 @@ int FindIniFile() {
|
||||
WCHAR tchModule[MAX_PATH];
|
||||
GetModuleFileName(NULL,tchModule,COUNTOF(tchModule));
|
||||
|
||||
if (lstrlen(szIniFile)) {
|
||||
if (lstrcmpi(szIniFile,L"*?") == 0)
|
||||
if (lstrlen(g_wchIniFile)) {
|
||||
if (lstrcmpi(g_wchIniFile,L"*?") == 0)
|
||||
return(0);
|
||||
else {
|
||||
if (!CheckIniFile(szIniFile,tchModule)) {
|
||||
ExpandEnvironmentStringsEx(szIniFile,COUNTOF(szIniFile));
|
||||
if (PathIsRelative(szIniFile)) {
|
||||
if (!CheckIniFile(g_wchIniFile,tchModule)) {
|
||||
ExpandEnvironmentStringsEx(g_wchIniFile,COUNTOF(g_wchIniFile));
|
||||
if (PathIsRelative(g_wchIniFile)) {
|
||||
lstrcpy(tchTest,tchModule);
|
||||
PathRemoveFileSpec(tchTest);
|
||||
PathAppend(tchTest,szIniFile);
|
||||
lstrcpy(szIniFile,tchTest);
|
||||
PathAppend(tchTest,g_wchIniFile);
|
||||
lstrcpy(g_wchIniFile,tchTest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3184,12 +3184,12 @@ int FindIniFile() {
|
||||
// allow two redirections: administrator -> user -> custom
|
||||
if (CheckIniFileRedirect(tchTest,tchModule))
|
||||
CheckIniFileRedirect(tchTest,tchModule);
|
||||
lstrcpy(szIniFile,tchTest);
|
||||
lstrcpy(g_wchIniFile,tchTest);
|
||||
}
|
||||
|
||||
else {
|
||||
lstrcpy(szIniFile,tchModule);
|
||||
PathRenameExtension(szIniFile,L".ini");
|
||||
lstrcpy(g_wchIniFile,tchModule);
|
||||
PathRenameExtension(g_wchIniFile,L".ini");
|
||||
}
|
||||
|
||||
return(1);
|
||||
@ -3198,29 +3198,29 @@ int FindIniFile() {
|
||||
|
||||
int TestIniFile() {
|
||||
|
||||
if (lstrcmpi(szIniFile,L"*?") == 0) {
|
||||
lstrcpy(szIniFile2,L"");
|
||||
lstrcpy(szIniFile,L"");
|
||||
if (lstrcmpi(g_wchIniFile,L"*?") == 0) {
|
||||
lstrcpy(g_wchIniFile2,L"");
|
||||
lstrcpy(g_wchIniFile,L"");
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (PathIsDirectory(szIniFile) || *CharPrev(szIniFile,StrEnd(szIniFile)) == L'\\') {
|
||||
if (PathIsDirectory(g_wchIniFile) || *CharPrev(g_wchIniFile,StrEnd(g_wchIniFile)) == L'\\') {
|
||||
WCHAR wchModule[MAX_PATH];
|
||||
GetModuleFileName(NULL,wchModule,COUNTOF(wchModule));
|
||||
PathAppend(szIniFile,PathFindFileName(wchModule));
|
||||
PathRenameExtension(szIniFile,L".ini");
|
||||
if (!PathFileExists(szIniFile)) {
|
||||
lstrcpy(PathFindFileName(szIniFile),L"minipath.ini");
|
||||
if (!PathFileExists(szIniFile)) {
|
||||
lstrcpy(PathFindFileName(szIniFile),PathFindFileName(wchModule));
|
||||
PathRenameExtension(szIniFile,L".ini");
|
||||
PathAppend(g_wchIniFile,PathFindFileName(wchModule));
|
||||
PathRenameExtension(g_wchIniFile,L".ini");
|
||||
if (!PathFileExists(g_wchIniFile)) {
|
||||
lstrcpy(PathFindFileName(g_wchIniFile),L"minipath.ini");
|
||||
if (!PathFileExists(g_wchIniFile)) {
|
||||
lstrcpy(PathFindFileName(g_wchIniFile),PathFindFileName(wchModule));
|
||||
PathRenameExtension(g_wchIniFile,L".ini");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!PathFileExists(szIniFile) || PathIsDirectory(szIniFile)) {
|
||||
lstrcpy(szIniFile2,szIniFile);
|
||||
lstrcpy(szIniFile,L"");
|
||||
if (!PathFileExists(g_wchIniFile) || PathIsDirectory(g_wchIniFile)) {
|
||||
lstrcpy(g_wchIniFile2,g_wchIniFile);
|
||||
lstrcpy(g_wchIniFile,L"");
|
||||
return(0);
|
||||
}
|
||||
else
|
||||
@ -3230,7 +3230,7 @@ int TestIniFile() {
|
||||
|
||||
int CreateIniFile() {
|
||||
|
||||
return(CreateIniFileEx(szIniFile));
|
||||
return(CreateIniFileEx(g_wchIniFile));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2403,9 +2403,9 @@ void DialogNewWindow(HWND hwnd, BOOL bSaveOnRunTools, BOOL bSetCurFile)
|
||||
StringCchCat(szParameters, COUNTOF(szParameters), tch);
|
||||
|
||||
StringCchCat(szParameters, COUNTOF(szParameters), L" -f");
|
||||
if (StringCchLenW(szIniFile, COUNTOF(szIniFile))) {
|
||||
if (StringCchLenW(g_wchIniFile, COUNTOF(g_wchIniFile))) {
|
||||
StringCchCat(szParameters, COUNTOF(szParameters), L" \"");
|
||||
StringCchCat(szParameters, COUNTOF(szParameters), szIniFile);
|
||||
StringCchCat(szParameters, COUNTOF(szParameters), g_wchIniFile);
|
||||
StringCchCat(szParameters, COUNTOF(szParameters), L" \"");
|
||||
}
|
||||
else
|
||||
@ -2557,7 +2557,7 @@ void DialogUpdateCheck(HWND hwnd)
|
||||
// InfoBox()
|
||||
//
|
||||
//
|
||||
extern WCHAR szIniFile[MAX_PATH];
|
||||
extern WCHAR g_wchIniFile[MAX_PATH];
|
||||
|
||||
INT_PTR InfoBox(int iType,LPCWSTR lpstrSetting,int uidMessage,...)
|
||||
{
|
||||
@ -2574,7 +2574,7 @@ INT_PTR InfoBox(int iType,LPCWSTR lpstrSetting,int uidMessage,...)
|
||||
ib.lpstrMessage = LocalAlloc(LPTR, HUGE_BUFFER * sizeof(WCHAR));
|
||||
StringCchVPrintfW(ib.lpstrMessage,HUGE_BUFFER,wchFormat,(LPVOID)((PUINT_PTR)&uidMessage + 1));
|
||||
ib.lpstrSetting = (LPWSTR)lpstrSetting;
|
||||
ib.bDisableCheckBox = (StringCchLenW(szIniFile,COUNTOF(szIniFile)) == 0 || lstrlen(lpstrSetting) == 0 || iMode == 2) ? TRUE : FALSE;
|
||||
ib.bDisableCheckBox = (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)) == 0 || lstrlen(lpstrSetting) == 0 || iMode == 2) ? TRUE : FALSE;
|
||||
|
||||
int idDlg = IDD_INFOBOX;
|
||||
if (iType == MBYESNO)
|
||||
|
||||
@ -16,13 +16,21 @@
|
||||
#ifndef _NP3_HELPERS_H_
|
||||
#define _NP3_HELPERS_H_
|
||||
|
||||
#include "TypeDefs.h"
|
||||
#include <VersionHelpers.h>
|
||||
#define STRSAFE_NO_CB_FUNCTIONS
|
||||
#undef STRSAFE_NO_DEPRECATE // don't allow deprecated functions
|
||||
#include <strsafe.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
#include "TypeDefs.h"
|
||||
|
||||
// ============================================================================
|
||||
|
||||
extern WCHAR g_wchIniFile[MAX_PATH];
|
||||
|
||||
|
||||
// ============================================================================
|
||||
|
||||
#define STRGFY(X) L##X
|
||||
#define MKWSTRG(strg) STRGFY(strg)
|
||||
|
||||
@ -31,21 +39,20 @@
|
||||
#define COUNTOF(ar) ARRAYSIZE(ar) //#define COUNTOF(ar) (sizeof(ar)/sizeof(ar[0]))
|
||||
#define CSTRLEN(s) (COUNTOF(s)-1)
|
||||
|
||||
extern WCHAR szIniFile[MAX_PATH];
|
||||
|
||||
__forceinline void swapi(int* a, int* b) { int t = *a; *a = *b; *b = t; }
|
||||
__forceinline void swapos(DocPos* a, DocPos* b) { DocPos t = *a; *a = *b; *b = t; }
|
||||
|
||||
#define IniGetString(lpSection,lpName,lpDefault,lpReturnedStr,nSize) \
|
||||
GetPrivateProfileString(lpSection,lpName,(lpDefault),(lpReturnedStr),(nSize),szIniFile)
|
||||
GetPrivateProfileString(lpSection,lpName,(lpDefault),(lpReturnedStr),(nSize),g_wchIniFile)
|
||||
#define IniGetInt(lpSection,lpName,nDefault) \
|
||||
GetPrivateProfileInt(lpSection,lpName,(nDefault),szIniFile)
|
||||
GetPrivateProfileInt(lpSection,lpName,(nDefault),g_wchIniFile)
|
||||
#define IniGetBool(lpSection,lpName,nDefault) \
|
||||
(GetPrivateProfileInt(lpSection,lpName,(int)(nDefault),szIniFile) ? TRUE : FALSE)
|
||||
(GetPrivateProfileInt(lpSection,lpName,(int)(nDefault),g_wchIniFile) ? TRUE : FALSE)
|
||||
#define IniSetString(lpSection,lpName,lpString) \
|
||||
WritePrivateProfileString(lpSection,lpName,(lpString),szIniFile)
|
||||
WritePrivateProfileString(lpSection,lpName,(lpString),g_wchIniFile)
|
||||
#define IniDeleteSection(lpSection) \
|
||||
WritePrivateProfileSection(lpSection,NULL,szIniFile)
|
||||
WritePrivateProfileSection(lpSection,NULL,g_wchIniFile)
|
||||
__inline BOOL IniSetInt(LPCWSTR lpSection, LPCWSTR lpName, int i)
|
||||
{
|
||||
WCHAR tch[32] = { L'\0' }; StringCchPrintf(tch, COUNTOF(tch), L"%i", i); return IniSetString(lpSection, lpName, tch);
|
||||
@ -53,9 +60,9 @@ __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),szIniFile)
|
||||
GetPrivateProfileSection(lpSection,lpBuf,(cchBuf),g_wchIniFile)
|
||||
#define SaveIniSection(lpSection,lpBuf) \
|
||||
WritePrivateProfileSection(lpSection,lpBuf,szIniFile)
|
||||
WritePrivateProfileSection(lpSection,lpBuf,g_wchIniFile)
|
||||
int IniSectionGetString(LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, int);
|
||||
int IniSectionGetInt(LPCWSTR, LPCWSTR, int);
|
||||
UINT IniSectionGetUInt(LPCWSTR, LPCWSTR, UINT);
|
||||
@ -102,17 +109,6 @@ __inline BOOL IniSectionSetBool(LPWSTR lpCachedIniSection, LPCWSTR lpName, BOOL
|
||||
#define IsWinServer() IsWindowsServer() // Indicates if the current OS is a Windows Server release.
|
||||
// Applications that need to distinguish between server and client versions of Windows should call this function.
|
||||
|
||||
enum BufferSizes {
|
||||
MICRO_BUFFER = 32,
|
||||
MINI_BUFFER = 64,
|
||||
SMALL_BUFFER = 128,
|
||||
MIDSZ_BUFFER = 256,
|
||||
LARGE_BUFFER = 512,
|
||||
HUGE_BUFFER = 1024,
|
||||
XHUGE_BUFFER = 2048,
|
||||
FILE_ARG_BUF = MAX_PATH+4
|
||||
};
|
||||
|
||||
BOOL PrivateIsAppThemed();
|
||||
HRESULT PrivateSetCurrentProcessExplicitAppUserModelID(PCWSTR);
|
||||
BOOL IsElevated();
|
||||
|
||||
100
src/Notepad3.c
100
src/Notepad3.c
@ -107,8 +107,8 @@ TBBUTTON tbbMainWnd[] = { { 0,IDT_FILE_NEW,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0
|
||||
};
|
||||
|
||||
|
||||
WCHAR szIniFile[MAX_PATH] = { L'\0' };
|
||||
WCHAR szIniFile2[MAX_PATH] = { L'\0' };
|
||||
WCHAR g_wchIniFile[MAX_PATH] = { L'\0' };
|
||||
WCHAR g_wchIniFile2[MAX_PATH] = { L'\0' };
|
||||
WCHAR szBufferFile[MAX_PATH] = { L'\0' };
|
||||
BOOL bSaveSettings;
|
||||
BOOL bEnableSaveSettings;
|
||||
@ -1531,7 +1531,7 @@ void MsgEndSession(HWND hwnd, UINT umsg)
|
||||
// call SaveSettings() when hwndToolbar is still valid
|
||||
SaveSettings(FALSE);
|
||||
|
||||
if (StringCchLenW(szIniFile,COUNTOF(szIniFile)) != 0) {
|
||||
if (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)) != 0) {
|
||||
|
||||
// Cleanup unwanted MRU's
|
||||
if (!bSaveRecentFiles) {
|
||||
@ -2333,7 +2333,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
i = IDM_VIEW_NOESCFUNC;
|
||||
CheckMenuRadioItem(hmenu,IDM_VIEW_NOESCFUNC,IDM_VIEW_ESCEXIT,i,MF_BYCOMMAND);
|
||||
|
||||
i = StringCchLenW(szIniFile,COUNTOF(szIniFile));
|
||||
i = StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile));
|
||||
CheckCmd(hmenu,IDM_VIEW_SAVESETTINGS,bSaveSettings && i);
|
||||
|
||||
EnableCmd(hmenu,IDM_VIEW_REUSEWINDOW,i);
|
||||
@ -2344,7 +2344,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
EnableCmd(hmenu,IDM_VIEW_NOSAVEFINDREPL,i);
|
||||
EnableCmd(hmenu,IDM_VIEW_SAVESETTINGS,bEnableSaveSettings && i);
|
||||
|
||||
i = (StringCchLenW(szIniFile,COUNTOF(szIniFile)) > 0 || StringCchLenW(szIniFile2,COUNTOF(szIniFile2)) > 0);
|
||||
i = (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)) > 0 || StringCchLenW(g_wchIniFile2,COUNTOF(g_wchIniFile2)) > 0);
|
||||
EnableCmd(hmenu,IDM_VIEW_SAVESETTINGSNOW,bEnableSaveSettings && i);
|
||||
|
||||
BOOL bIsHLink = FALSE;
|
||||
@ -4296,12 +4296,12 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
BOOL bCreateFailure = FALSE;
|
||||
|
||||
if (StringCchLenW(szIniFile,COUNTOF(szIniFile)) == 0) {
|
||||
if (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)) == 0) {
|
||||
|
||||
if (StringCchLenW(szIniFile2,COUNTOF(szIniFile2)) > 0) {
|
||||
if (CreateIniFileEx(szIniFile2)) {
|
||||
StringCchCopy(szIniFile,COUNTOF(szIniFile),szIniFile2);
|
||||
StringCchCopy(szIniFile2,COUNTOF(szIniFile2),L"");
|
||||
if (StringCchLenW(g_wchIniFile2,COUNTOF(g_wchIniFile2)) > 0) {
|
||||
if (CreateIniFileEx(g_wchIniFile2)) {
|
||||
StringCchCopy(g_wchIniFile,COUNTOF(g_wchIniFile),g_wchIniFile2);
|
||||
StringCchCopy(g_wchIniFile2,COUNTOF(g_wchIniFile2),L"");
|
||||
}
|
||||
else
|
||||
bCreateFailure = TRUE;
|
||||
@ -4313,7 +4313,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
if (!bCreateFailure) {
|
||||
|
||||
if (WritePrivateProfileString(L"Settings",L"WriteTest",L"ok",szIniFile)) {
|
||||
if (WritePrivateProfileString(L"Settings",L"WriteTest",L"ok",g_wchIniFile)) {
|
||||
|
||||
BeginWaitCursorID(IDS_SAVINGSETTINGS);
|
||||
SaveSettings(TRUE);
|
||||
@ -4917,9 +4917,9 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
|
||||
case CMD_OPENINIFILE:
|
||||
if (StringCchLenW(szIniFile,COUNTOF(szIniFile))) {
|
||||
if (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile))) {
|
||||
CreateIniFile();
|
||||
FileLoad(FALSE,FALSE,FALSE,FALSE,szIniFile);
|
||||
FileLoad(FALSE,FALSE,FALSE,FALSE,g_wchIniFile);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -6061,7 +6061,7 @@ void SaveSettings(BOOL bSaveSettingsNow) {
|
||||
|
||||
WCHAR wchTmp[MAX_PATH] = { L'\0' };
|
||||
|
||||
if (StringCchLenW(szIniFile,COUNTOF(szIniFile)) == 0)
|
||||
if (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)) == 0)
|
||||
return;
|
||||
|
||||
if (!bEnableSaveSettings)
|
||||
@ -6335,12 +6335,12 @@ void ParseCommandLine()
|
||||
|
||||
case L'F':
|
||||
if (*(lp1+1) == L'0' || *CharUpper(lp1+1) == L'O')
|
||||
StringCchCopy(szIniFile,COUNTOF(szIniFile),L"*?");
|
||||
StringCchCopy(g_wchIniFile,COUNTOF(g_wchIniFile),L"*?");
|
||||
else if (ExtractFirstArgument(lp2,lp1,lp2,len)) {
|
||||
StringCchCopyN(szIniFile,COUNTOF(szIniFile),lp1,len);
|
||||
TrimString(szIniFile);
|
||||
PathUnquoteSpaces(szIniFile);
|
||||
NormalizePathEx(szIniFile,COUNTOF(szIniFile));
|
||||
StringCchCopyN(g_wchIniFile,COUNTOF(g_wchIniFile),lp1,len);
|
||||
TrimString(g_wchIniFile);
|
||||
PathUnquoteSpaces(g_wchIniFile);
|
||||
NormalizePathEx(g_wchIniFile,COUNTOF(g_wchIniFile));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -6757,17 +6757,17 @@ int FindIniFile() {
|
||||
WCHAR tchModule[MAX_PATH] = { L'\0' };
|
||||
GetModuleFileName(NULL,tchModule,COUNTOF(tchModule));
|
||||
|
||||
if (StringCchLenW(szIniFile,COUNTOF(szIniFile))) {
|
||||
if (StringCchCompareIX(szIniFile,L"*?") == 0)
|
||||
if (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile))) {
|
||||
if (StringCchCompareIX(g_wchIniFile,L"*?") == 0)
|
||||
return(0);
|
||||
else {
|
||||
if (!CheckIniFile(szIniFile,tchModule)) {
|
||||
ExpandEnvironmentStringsEx(szIniFile,COUNTOF(szIniFile));
|
||||
if (PathIsRelative(szIniFile)) {
|
||||
if (!CheckIniFile(g_wchIniFile,tchModule)) {
|
||||
ExpandEnvironmentStringsEx(g_wchIniFile,COUNTOF(g_wchIniFile));
|
||||
if (PathIsRelative(g_wchIniFile)) {
|
||||
StringCchCopy(tchTest,COUNTOF(tchTest),tchModule);
|
||||
PathRemoveFileSpec(tchTest);
|
||||
PathCchAppend(tchTest,COUNTOF(tchTest),szIniFile);
|
||||
StringCchCopy(szIniFile,COUNTOF(szIniFile),tchTest);
|
||||
PathCchAppend(tchTest,COUNTOF(tchTest),g_wchIniFile);
|
||||
StringCchCopy(g_wchIniFile,COUNTOF(g_wchIniFile),tchTest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6788,15 +6788,15 @@ int FindIniFile() {
|
||||
if (CheckIniFileRedirect(tchTest,tchModule))
|
||||
CheckIniFileRedirect(tchTest,tchModule);
|
||||
|
||||
StringCchCopy(szIniFile,COUNTOF(szIniFile),tchTest);
|
||||
StringCchCopy(g_wchIniFile,COUNTOF(g_wchIniFile),tchTest);
|
||||
}
|
||||
else {
|
||||
StringCchCopy(szIniFile,COUNTOF(szIniFile),tchModule);
|
||||
PathCchRenameExtension(szIniFile,COUNTOF(szIniFile),L".ini");
|
||||
StringCchCopy(g_wchIniFile,COUNTOF(g_wchIniFile),tchModule);
|
||||
PathCchRenameExtension(g_wchIniFile,COUNTOF(g_wchIniFile),L".ini");
|
||||
}
|
||||
}
|
||||
|
||||
NormalizePathEx(szIniFile,COUNTOF(szIniFile));
|
||||
NormalizePathEx(g_wchIniFile,COUNTOF(g_wchIniFile));
|
||||
|
||||
return(1);
|
||||
}
|
||||
@ -6804,31 +6804,31 @@ int FindIniFile() {
|
||||
|
||||
int TestIniFile() {
|
||||
|
||||
if (StringCchCompareIX(szIniFile,L"*?") == 0) {
|
||||
StringCchCopy(szIniFile2,COUNTOF(szIniFile2),L"");
|
||||
StringCchCopy(szIniFile,COUNTOF(szIniFile),L"");
|
||||
if (StringCchCompareIX(g_wchIniFile,L"*?") == 0) {
|
||||
StringCchCopy(g_wchIniFile2,COUNTOF(g_wchIniFile2),L"");
|
||||
StringCchCopy(g_wchIniFile,COUNTOF(g_wchIniFile),L"");
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (PathIsDirectory(szIniFile) || *CharPrev(szIniFile,StrEnd(szIniFile)) == L'\\') {
|
||||
if (PathIsDirectory(g_wchIniFile) || *CharPrev(g_wchIniFile,StrEnd(g_wchIniFile)) == L'\\') {
|
||||
WCHAR wchModule[MAX_PATH] = { L'\0' };
|
||||
GetModuleFileName(NULL,wchModule,COUNTOF(wchModule));
|
||||
PathCchAppend(szIniFile,COUNTOF(szIniFile),PathFindFileName(wchModule));
|
||||
PathCchRenameExtension(szIniFile,COUNTOF(szIniFile),L".ini");
|
||||
if (!PathFileExists(szIniFile)) {
|
||||
StringCchCopy(PathFindFileName(szIniFile),COUNTOF(szIniFile),L"Notepad3.ini");
|
||||
if (!PathFileExists(szIniFile)) {
|
||||
StringCchCopy(PathFindFileName(szIniFile),COUNTOF(szIniFile),PathFindFileName(wchModule));
|
||||
PathCchRenameExtension(szIniFile,COUNTOF(szIniFile),L".ini");
|
||||
PathCchAppend(g_wchIniFile,COUNTOF(g_wchIniFile),PathFindFileName(wchModule));
|
||||
PathCchRenameExtension(g_wchIniFile,COUNTOF(g_wchIniFile),L".ini");
|
||||
if (!PathFileExists(g_wchIniFile)) {
|
||||
StringCchCopy(PathFindFileName(g_wchIniFile),COUNTOF(g_wchIniFile),L"Notepad3.ini");
|
||||
if (!PathFileExists(g_wchIniFile)) {
|
||||
StringCchCopy(PathFindFileName(g_wchIniFile),COUNTOF(g_wchIniFile),PathFindFileName(wchModule));
|
||||
PathCchRenameExtension(g_wchIniFile,COUNTOF(g_wchIniFile),L".ini");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NormalizePathEx(szIniFile,COUNTOF(szIniFile));
|
||||
NormalizePathEx(g_wchIniFile,COUNTOF(g_wchIniFile));
|
||||
|
||||
if (!PathFileExists(szIniFile) || PathIsDirectory(szIniFile)) {
|
||||
StringCchCopy(szIniFile2,COUNTOF(szIniFile2),szIniFile);
|
||||
StringCchCopy(szIniFile,COUNTOF(szIniFile),L"");
|
||||
if (!PathFileExists(g_wchIniFile) || PathIsDirectory(g_wchIniFile)) {
|
||||
StringCchCopy(g_wchIniFile2,COUNTOF(g_wchIniFile2),g_wchIniFile);
|
||||
StringCchCopy(g_wchIniFile,COUNTOF(g_wchIniFile),L"");
|
||||
return(0);
|
||||
}
|
||||
else
|
||||
@ -6838,7 +6838,7 @@ int TestIniFile() {
|
||||
|
||||
int CreateIniFile() {
|
||||
|
||||
return(CreateIniFileEx(szIniFile));
|
||||
return(CreateIniFileEx(g_wchIniFile));
|
||||
}
|
||||
|
||||
|
||||
@ -7135,7 +7135,7 @@ void UpdateLineNumberWidth()
|
||||
void UpdateSettingsCmds()
|
||||
{
|
||||
HMENU hmenu = GetSystemMenu(g_hwndMain, FALSE);
|
||||
BOOL hasIniFile = (StringCchLenW(szIniFile,COUNTOF(szIniFile)) > 0 || StringCchLenW(szIniFile2,COUNTOF(szIniFile2)) > 0);
|
||||
BOOL hasIniFile = (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)) > 0 || StringCchLenW(g_wchIniFile2,COUNTOF(g_wchIniFile2)) > 0);
|
||||
CheckCmd(hmenu, IDM_VIEW_SAVESETTINGS, bSaveSettings && bEnableSaveSettings);
|
||||
EnableCmd(hmenu, IDM_VIEW_SAVESETTINGS, hasIniFile && bEnableSaveSettings);
|
||||
EnableCmd(hmenu, IDM_VIEW_SAVESETTINGSNOW, hasIniFile && bEnableSaveSettings);
|
||||
@ -7624,7 +7624,7 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp
|
||||
UpdateVisibleUrlHotspot(0);
|
||||
|
||||
// consistent settings file handling (if loaded in editor)
|
||||
bEnableSaveSettings = (StringCchCompareINW(g_wchCurFile, COUNTOF(g_wchCurFile), szIniFile, COUNTOF(szIniFile)) == 0) ? FALSE : TRUE;
|
||||
bEnableSaveSettings = (StringCchCompareINW(g_wchCurFile, COUNTOF(g_wchCurFile), g_wchIniFile, COUNTOF(g_wchIniFile)) == 0) ? FALSE : TRUE;
|
||||
UpdateSettingsCmds();
|
||||
|
||||
// Show warning: Unicode file loaded as ANSI
|
||||
@ -8362,8 +8362,8 @@ BOOL RelaunchElevated(LPWSTR lpArgs) {
|
||||
StringCchCopy(szArguments,COUNTOF(szArguments),szArgs);
|
||||
}
|
||||
else {
|
||||
if (StringCchLenW(szIniFile,COUNTOF(szIniFile)) > 0)
|
||||
StringCchPrintf(szArguments,COUNTOF(szArguments),L"/f \"%s\" %s",szIniFile,szArgs);
|
||||
if (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)) > 0)
|
||||
StringCchPrintf(szArguments,COUNTOF(szArguments),L"/f \"%s\" %s",g_wchIniFile,szArgs);
|
||||
else
|
||||
StringCchCopy(szArguments,COUNTOF(szArguments),szArgs);
|
||||
}
|
||||
|
||||
@ -5937,7 +5937,7 @@ void Style_ConfigDlg(HWND hwnd)
|
||||
}
|
||||
else {
|
||||
g_fStylesModified = TRUE;
|
||||
if (!g_fWarnedNoIniFile && (StringCchLenW(szIniFile,COUNTOF(szIniFile)) == 0)) {
|
||||
if (!g_fWarnedNoIniFile && (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)) == 0)) {
|
||||
MsgBox(MBWARN,IDS_SETTINGSNOTSAVED);
|
||||
g_fWarnedNoIniFile = TRUE;
|
||||
}
|
||||
|
||||
@ -29,6 +29,21 @@ typedef int DocLn;
|
||||
//typedef ptrdiff_t DocLn; // compile test
|
||||
#endif
|
||||
|
||||
|
||||
enum BufferSizes
|
||||
{
|
||||
MICRO_BUFFER = 32,
|
||||
MINI_BUFFER = 64,
|
||||
SMALL_BUFFER = 128,
|
||||
MIDSZ_BUFFER = 256,
|
||||
LARGE_BUFFER = 512,
|
||||
HUGE_BUFFER = 1024,
|
||||
XHUGE_BUFFER = 2048,
|
||||
FILE_ARG_BUF = MAX_PATH + 2
|
||||
};
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
#endif //_NP3_TYPEDEFS_H_
|
||||
|
||||
Loading…
Reference in New Issue
Block a user