diff --git a/Build/Notepad3.ini b/Build/Notepad3.ini index 48a363964..9662e4903 100644 Binary files a/Build/Notepad3.ini and b/Build/Notepad3.ini differ diff --git a/Versions/build.txt b/Versions/build.txt index 09e35abcf..42ba96426 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -1113 +1116 diff --git a/crypto/crypto.c b/crypto/crypto.c index 22fb030fa..4e94665c2 100644 --- a/crypto/crypto.c +++ b/crypto/crypto.c @@ -34,9 +34,6 @@ see ecryption-doc.txt for details #include "rijndael-api-fst.h" #include "crypto.h" -extern HMODULE g_hLngResContainer; -extern HICON g_hDlgIcon; - #define WKEY_LEN 256 #define KEY_LEN 512 #define PAD_SLOP 16 @@ -115,7 +112,7 @@ INT_PTR CALLBACK SetKeysDlgProc(HWND hDlg, UINT umsg, WPARAM wParam, LPARAM lPar case WM_INITDIALOG: { - if (g_hDlgIcon) { SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } SetDlgItemText(hDlg, IDC_PWD_EDIT1, unicodeFileKey); SetDlgItemText(hDlg, IDC_PWD_EDIT2, unicodeMasterKey); ShowWindow(GetDlgItem(hDlg, IDC_PWD_CHECK3), hasMasterFileKey); @@ -240,7 +237,7 @@ INT_PTR CALLBACK GetKeysDlgProc(HWND hDlg, UINT umsg, WPARAM wParam, LPARAM lPar case WM_INITDIALOG: { - if (g_hDlgIcon) { SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } int vis = masterKeyAvailable ? SW_SHOW : SW_HIDE; ShowWindow(GetDlgItem(hDlg, IDC_PWD_STATMPW), vis); ShowWindow(GetDlgItem(hDlg, IDC_PWD_CHECK3), vis); @@ -306,7 +303,7 @@ INT_PTR CALLBACK GetKeysDlgProc(HWND hDlg, UINT umsg, WPARAM wParam, LPARAM lPar // set passphrases for output bool GetFileKey(HWND hwnd) { - return (IDOK == DialogBoxParam(g_hLngResContainer, MAKEINTRESOURCE(IDD_MUI_PASSWORDS), + return (IDOK == DialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_PASSWORDS), GetParent(hwnd), SetKeysDlgProc, (LPARAM)hwnd)); } @@ -314,7 +311,7 @@ bool GetFileKey(HWND hwnd) bool ReadFileKey(HWND hwnd, bool master) { masterKeyAvailable = master; - return (IDOK == DialogBoxParam(g_hLngResContainer, MAKEINTRESOURCE(IDD_MUI_READPW), + return (IDOK == DialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_READPW), GetParent(hwnd), GetKeysDlgProc, (LPARAM)hwnd)); } diff --git a/minipath/src/minipath.c b/minipath/src/minipath.c index f990a7f05..c53bb194d 100644 --- a/minipath/src/minipath.c +++ b/minipath/src/minipath.c @@ -157,7 +157,7 @@ UINT16 g_uWinVer; HINSTANCE g_hInstance = NULL; HMODULE g_hLngResContainer = NULL; -WCHAR g_tchPrefLngLocName[64]; +WCHAR g_tchPrefLngLocName[LOCALE_NAME_MAX_LENGTH + 1]; LANGID g_iPrefLANGID = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); static WCHAR* const g_tchAvailableLanguages = L"af-ZA de-DE es-ES en-GB fr-FR ja-JP nl-NL zh-CN"; // en-US internal diff --git a/np3portableapp/Notepad3Portable/App/DefaultData/settings/Notepad3.ini b/np3portableapp/Notepad3Portable/App/DefaultData/settings/Notepad3.ini index 48a363964..9662e4903 100644 Binary files a/np3portableapp/Notepad3Portable/App/DefaultData/settings/Notepad3.ini and b/np3portableapp/Notepad3Portable/App/DefaultData/settings/Notepad3.ini differ diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index efc18ad9a..712219795 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 TinyExpr diff --git a/scintilla/cppcheck.suppress b/scintilla/cppcheck.suppress index ba11ddfb5..b54604e34 100644 --- a/scintilla/cppcheck.suppress +++ b/scintilla/cppcheck.suppress @@ -29,6 +29,7 @@ variableScope:scintilla/lexers/LexErlang.cxx variableScope:scintilla/lexers/LexGui4Cli.cxx variableScope:scintilla/lexers/LexInno.cxx variableScope:scintilla/lexers/LexLaTeX.cxx +copyCtorAndEqOperator:scintilla/lexers/LexLaTeX.cxx variableScope:scintilla/lexers/LexMetapost.cxx variableScope:scintilla/lexers/LexModula.cxx variableScope:scintilla/lexers/LexNimrod.cxx diff --git a/scintilla/doc/ScintillaHistory.html b/scintilla/doc/ScintillaHistory.html index 97ea20408..2654c0619 100644 --- a/scintilla/doc/ScintillaHistory.html +++ b/scintilla/doc/ScintillaHistory.html @@ -535,6 +535,7 @@

Luke Rasmussen maboroshin + Gokul Krishnan

@@ -554,8 +555,16 @@

Released 9 September 2018.
  • + C++ lexer fixes evaluation of "#elif". + Bug #2045. +
  • +
  • Markdown lexer fixes highlighting of non-ASCII characters in links.
  • +
  • + SciTE on Win32 makes Del key work again in find and replace strips. + Bug #2044. +
  • Release 4.1.1 diff --git a/scintilla/lexers/LexCPP.cxx b/scintilla/lexers/LexCPP.cxx index fb1fe026a..4f4a0f648 100644 --- a/scintilla/lexers/LexCPP.cxx +++ b/scintilla/lexers/LexCPP.cxx @@ -1279,7 +1279,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i // Ensure only one chosen out of #if .. #elif .. #elif .. #else .. #endif if (!preproc.CurrentIfTaken()) { // Similar to #if - std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 2, true); + std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 4, true); const bool ifGood = EvaluateExpression(restOfLine, preprocessorDefinitions); if (ifGood) { preproc.InvertCurrentLevel(); diff --git a/src/ChooseFont/ChooseFont.cpp b/src/ChooseFont/ChooseFont.cpp index d21de8300..37d81f90b 100644 --- a/src/ChooseFont/ChooseFont.cpp +++ b/src/ChooseFont/ChooseFont.cpp @@ -11,14 +11,17 @@ #include "ChooseFont.h" #include "FontEnumeration.h" #include "GdiTextRenderer.h" + +extern "C" { #include "../resource.h" +#include "TypeDefs.h" +} //---------------------------------------------------------------------------- IDWriteFactory* g_dwrite = nullptr; static HINSTANCE g_hInstanceNP3; -extern "C" HMODULE g_hLngResContainer; extern "C" void CenterDlgInParent(HWND hDlg); @@ -29,7 +32,7 @@ extern "C" void CenterDlgInParent(HWND hDlg); // static int LoadLngStringW(UINT uID, LPWSTR lpBuffer, int nBufferMax) { - const int nLen = LoadStringW(g_hLngResContainer, uID, lpBuffer, nBufferMax); + const int nLen = LoadStringW(Globals.hLngResContainer, uID, lpBuffer, nBufferMax); return (nLen != 0) ? nLen : LoadStringW(g_hInstanceNP3, uID, lpBuffer, nBufferMax); } @@ -170,8 +173,8 @@ HRESULT ChooseFontDialog::GetTextFormat(IDWriteTextFormat** textFormat) // Open the dialog if (SUCCEEDED(hr)) { - if (g_hLngResContainer) { - hr = (HRESULT)DialogBoxParam(g_hLngResContainer, MAKEINTRESOURCE(IDD_MUI_CHOOSEFONT), m_parent, CFDialogProc, (LPARAM)this); + if (Globals.hLngResContainer) { + hr = (HRESULT)DialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_CHOOSEFONT), m_parent, CFDialogProc, (LPARAM)this); } else { hr = (HRESULT)DialogBoxParam(g_hInstanceNP3, MAKEINTRESOURCE(IDD_MUI_CHOOSEFONT), m_parent, CFDialogProc, (LPARAM)this); @@ -215,8 +218,8 @@ HRESULT ChooseFontDialog::GetTextFormat(IDWriteTextFormat* textFormatIn, IDWrite // Open the dialog if (SUCCEEDED(hr)) { - if (g_hLngResContainer) { - hr = (HRESULT)DialogBoxParam(g_hLngResContainer, MAKEINTRESOURCE(IDD_MUI_CHOOSEFONT), m_parent, CFDialogProc, (LPARAM)this); + if (Globals.hLngResContainer) { + hr = (HRESULT)DialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_CHOOSEFONT), m_parent, CFDialogProc, (LPARAM)this); } else { hr = (HRESULT)DialogBoxParam(g_hInstanceNP3, MAKEINTRESOURCE(IDD_MUI_CHOOSEFONT), m_parent, CFDialogProc, (LPARAM)this); @@ -801,7 +804,7 @@ void ChooseFontDialog::OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT* lpDrawItem) // ############################################################################ -static void __fastcall SetChosenFontFromTextFormat( +static void SetChosenFontFromTextFormat( IDWriteTextFormat* textFormat, LPCHOOSEFONT lpCF, const UINT dpi) { diff --git a/src/Dialogs.c b/src/Dialogs.c index dc3be55ad..42f82c5af 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -45,33 +45,13 @@ #include "version.h" #include "helpers.h" #include "encoding.h" +#include "TypeDefs.h" #include "SciCall.h" #include "dialogs.h" -extern HWND g_hwndMain; -extern HINSTANCE g_hInstance; -extern HMODULE g_hLngResContainer; -extern LANGID g_iPrefLANGID; -extern HICON g_hDlgIcon; - -extern WCHAR g_wchWorkingDirectory[]; -extern WCHAR g_wchCurFile[]; -extern WCHAR g_wchAppUserModelID[]; - -extern DWORD dwLastIOError; -extern bool bUseDefaultForFileEncoding; -extern bool bSkipUnicodeDetection; -extern bool bSkipANSICodePageDetection; -extern bool g_bLoadASCIIasUTF8; -extern bool g_bLoadNFOasOEM; -extern bool g_bNoEncodingTags; -extern bool bFixLineEndings; -extern bool bAutoStripBlanks; - -extern int g_flagNoFileVariables; -extern int g_flagUseSystemMRU; +extern DWORD g_dwLastIOError; @@ -132,8 +112,8 @@ int MsgBoxLng(int iType, UINT uIdMsg, ...) FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, - dwLastIOError, - g_iPrefLANGID, + g_dwLastIOError, + Globals.iPrefLANGID, (LPTSTR)&lpMsgBuf, 0, NULL); @@ -166,12 +146,12 @@ int MsgBoxLng(int iType, UINT uIdMsg, ...) // center message box to main HWND focus = GetFocus(); - HWND hwnd = focus ? focus : g_hwndMain; + HWND hwnd = focus ? focus : Globals.hwndMain; hhkMsgBox = SetWindowsHookEx(WH_CBT, &_MsgBoxProc, 0, GetCurrentThreadId()); //return MessageBox(hwnd, szText, szTitle, iIcon); //return MessageBoxEx(hwnd, szText, szTitle, iIcon, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)); - return MessageBoxEx(hwnd, szText, szTitle, iIcon, g_iPrefLANGID); + return MessageBoxEx(hwnd, szText, szTitle, iIcon, Globals.iPrefLANGID); } @@ -194,7 +174,7 @@ INT_PTR CALLBACK InfoBoxDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lPar { case WM_INITDIALOG: { - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } lpib = (LPINFOBOX)lParam; SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam); SendDlgItemMessage(hwnd, IDC_INFOBOXICON, STM_SETICON, (WPARAM)LoadIcon(NULL, IDI_EXCLAMATION), 0); @@ -230,7 +210,6 @@ INT_PTR CALLBACK InfoBoxDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lPar // InfoBoxLng() // // -extern WCHAR g_wchIniFile[MAX_PATH]; INT_PTR InfoBoxLng(int iType, LPCWSTR lpstrSetting, int uidMessage, ...) { @@ -248,7 +227,7 @@ INT_PTR InfoBoxLng(int iType, LPCWSTR lpstrSetting, int uidMessage, ...) if (ib.lpstrMessage) StringCchVPrintfW(ib.lpstrMessage, HUGE_BUFFER, wchFormat, (LPVOID)((PUINT_PTR)&uidMessage + 1)); ib.lpstrSetting = (LPWSTR)lpstrSetting; - ib.bDisableCheckBox = (StrIsEmpty(g_wchIniFile) || StrIsEmpty(lpstrSetting) || iMode == 2) ? true : false; + ib.bDisableCheckBox = (StrIsEmpty(Globals.IniFile) || StrIsEmpty(lpstrSetting) || iMode == 2) ? true : false; int idDlg; switch (iType) { @@ -266,9 +245,9 @@ INT_PTR InfoBoxLng(int iType, LPCWSTR lpstrSetting, int uidMessage, ...) MessageBeep(MB_ICONEXCLAMATION); HWND focus = GetFocus(); - HWND hwnd = focus ? focus : g_hwndMain; + HWND hwnd = focus ? focus : Globals.hwndMain; - return ThemedDialogBoxParam(g_hLngResContainer, MAKEINTRESOURCE(idDlg), hwnd, InfoBoxDlgProc, (LPARAM)&ib); + return ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(idDlg), hwnd, InfoBoxDlgProc, (LPARAM)&ib); } @@ -288,14 +267,14 @@ void DisplayCmdLineHelp(HWND hwnd) ZeroMemory(&mbp, sizeof(MSGBOXPARAMS)); mbp.cbSize = sizeof(MSGBOXPARAMS); mbp.hwndOwner = hwnd; - mbp.hInstance = g_hInstance; + mbp.hInstance = Globals.hInstance; mbp.lpszText = szText; mbp.lpszCaption = szTitle; mbp.dwStyle = MB_OK | MB_USERICON | MB_SETFOREGROUND; mbp.lpszIcon = MAKEINTRESOURCE(IDR_MAINWND48); mbp.dwContextHelpId = 0; mbp.lpfnMsgBoxCallback = NULL; - mbp.dwLanguageId = g_iPrefLANGID; + mbp.dwLanguageId = Globals.iPrefLANGID; hhkMsgBox = SetWindowsHookEx(WH_CBT, &_MsgBoxProc, 0, GetCurrentThreadId()); @@ -366,16 +345,16 @@ static DWORD _LoadStringEx(UINT nResId, LPCTSTR pszRsType, LPSTR strOut) { LPTSTR pszResId = MAKEINTRESOURCE(nResId); - if (g_hInstance == NULL) + if (Globals.hInstance == NULL) return 0L; - HRSRC hRsrc = FindResource(g_hInstance, pszResId, pszRsType); + HRSRC hRsrc = FindResource(Globals.hInstance, pszResId, pszRsType); if (hRsrc == NULL) { return 0L; } - HGLOBAL hGlobal = LoadResource(g_hInstance, hRsrc); + HGLOBAL hGlobal = LoadResource(Globals.hInstance, hRsrc); if (hGlobal == NULL) { return 0L; @@ -388,7 +367,7 @@ static DWORD _LoadStringEx(UINT nResId, LPCTSTR pszRsType, LPSTR strOut) return 0L; } - DWORD dwSize = SizeofResource(g_hInstance, hRsrc); + DWORD dwSize = SizeofResource(Globals.hInstance, hRsrc); if (strOut) { memcpy(strOut, (LPCSTR)pData, dwSize); @@ -456,10 +435,10 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam { { if (!hIcon) { - hIcon = LoadImage(g_hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, 128, 128, LR_DEFAULTCOLOR); + hIcon = LoadImage(Globals.hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, 128, 128, LR_DEFAULTCOLOR); } - SetDlgItemText(hwnd, IDC_VERSION, L"" VERSION_FILEVERSION_LONG); + SetDlgItemText(hwnd, IDC_VERSION, MKWCS(VERSION_FILEVERSION_LONG)); if (hFontTitle) { DeleteObject(hFontTitle); } @@ -635,13 +614,13 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam { WCHAR wchVerInfo[1024] = { L'\0' }; WCHAR wchAuthInfo[128] = { L'\0' }; - StringCchCopy(wchVerInfo, COUNTOF(wchVerInfo), L"" VERSION_FILEVERSION_LONG); + StringCchCopy(wchVerInfo, COUNTOF(wchVerInfo), MKWCS(VERSION_FILEVERSION_LONG)); StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n" VERSION_SCIVERSION); StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n" VERSION_COMPILER); StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n"); GetLngString(IDS_MUI_TRANSL_AUTHOR, wchAuthInfo, COUNTOF(wchAuthInfo)); StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchAuthInfo); - SetClipboardTextW(g_hwndMain, wchVerInfo, StringCchLen(wchVerInfo,0)); + SetClipboardTextW(Globals.hwndMain, wchVerInfo, StringCchLen(wchVerInfo,0)); } break; @@ -668,8 +647,8 @@ INT_PTR CALLBACK RunDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) { case WM_INITDIALOG: { - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } - // MakeBitmapButton(hwnd,IDC_SEARCHEXE,g_hInstance,IDB_OPEN); + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } + // MakeBitmapButton(hwnd,IDC_SEARCHEXE,Globals.hInstance,IDB_OPEN); SendDlgItemMessage(hwnd,IDC_COMMANDLINE,EM_LIMITTEXT,MAX_PATH - 1,0); SetDlgItemText(hwnd,IDC_COMMANDLINE,(LPCWSTR)lParam); SHAutoComplete(GetDlgItem(hwnd,IDC_COMMANDLINE),SHACF_FILESYSTEM); @@ -756,14 +735,14 @@ INT_PTR CALLBACK RunDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) ExpandEnvironmentStringsEx(arg1,COUNTOF(arg1)); ExtractFirstArgument(arg1,arg1,arg2,MAX_PATH); - if (StringCchCompareNI(arg1,COUNTOF(arg1), TSTRG(APPNAME),CSTRLEN(TSTRG(APPNAME))) == 0 || + if (StringCchCompareNI(arg1,COUNTOF(arg1), STRGW(APPNAME),CSTRLEN(STRGW(APPNAME))) == 0 || StringCchCompareNI(arg1,COUNTOF(arg1),L"notepad3.exe", CSTRLEN(L"notepad3.exe")) == 0) { GetModuleFileName(NULL,arg1,COUNTOF(arg1)); bQuickExit = true; } - if (StringCchLenW(g_wchCurFile, FILE_ARG_BUF)) { - StringCchCopy(wchDirectory,COUNTOF(wchDirectory),g_wchCurFile); + if (StringCchLenW(Globals.CurrentFile, (MAX_PATH+1))) { + StringCchCopy(wchDirectory,COUNTOF(wchDirectory),Globals.CurrentFile); PathRemoveFileSpec(wchDirectory); } @@ -818,7 +797,7 @@ INT_PTR CALLBACK RunDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) // void RunDlg(HWND hwnd,LPCWSTR lpstrDefault) { - ThemedDialogBoxParam(g_hLngResContainer, MAKEINTRESOURCE(IDD_MUI_RUN), hwnd, RunDlgProc, (LPARAM)lpstrDefault); + ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_RUN), hwnd, RunDlgProc, (LPARAM)lpstrDefault); } @@ -826,12 +805,6 @@ void RunDlg(HWND hwnd,LPCWSTR lpstrDefault) // // OpenWithDlgProc() // -extern WCHAR g_tchOpenWithDir[MAX_PATH]; -extern int g_flagNoFadeHidden; - -extern int cxOpenWithDlg; -extern int cyOpenWithDlg; - INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) { @@ -840,11 +813,11 @@ INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam case WM_INITDIALOG: { - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; - ResizeDlg_Init(hwnd,cxOpenWithDlg,cyOpenWithDlg,IDC_RESIZEGRIP3); + ResizeDlg_Init(hwnd,Settings.OpenWithDlgSizeX,Settings.OpenWithDlgSizeY,IDC_RESIZEGRIP3); SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)lParam); @@ -852,11 +825,11 @@ INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam ListView_SetExtendedListViewStyle(GetDlgItem(hwnd,IDC_OPENWITHDIR),/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP); ListView_InsertColumn(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,&lvc); DirList_Init(GetDlgItem(hwnd,IDC_OPENWITHDIR),NULL); - DirList_Fill(GetDlgItem(hwnd,IDC_OPENWITHDIR),g_tchOpenWithDir,DL_ALLOBJECTS,NULL,false,g_flagNoFadeHidden,DS_NAME,false); + DirList_Fill(GetDlgItem(hwnd,IDC_OPENWITHDIR),Settings.OpenWithDir,DL_ALLOBJECTS,NULL,false,Flags.NoFadeHidden,DS_NAME,false); DirList_StartIconThread(GetDlgItem(hwnd,IDC_OPENWITHDIR)); ListView_SetItemState(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,LVIS_FOCUSED,LVIS_FOCUSED); - MakeBitmapButton(hwnd,IDC_GETOPENWITHDIR,g_hInstance,IDB_OPEN); + MakeBitmapButton(hwnd,IDC_GETOPENWITHDIR,Globals.hInstance,IDB_OPEN); CenterDlgInParent(hwnd); } @@ -867,7 +840,7 @@ INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam DirList_Destroy(GetDlgItem(hwnd,IDC_OPENWITHDIR)); DeleteBitmapButton(hwnd,IDC_GETOPENWITHDIR); - ResizeDlg_Destroy(hwnd,&cxOpenWithDlg,&cyOpenWithDlg); + ResizeDlg_Destroy(hwnd,&Settings.OpenWithDlgSizeX,&Settings.OpenWithDlgSizeY); return false; @@ -907,7 +880,7 @@ INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam switch(pnmh->code) { case LVN_GETDISPINFO: - DirList_GetDispInfo(GetDlgItem(hwnd,IDC_OPENWITHDIR),lParam,g_flagNoFadeHidden); + DirList_GetDispInfo(GetDlgItem(hwnd,IDC_OPENWITHDIR),lParam,Flags.NoFadeHidden); break; case LVN_DELETEITEM: @@ -937,9 +910,9 @@ INT_PTR CALLBACK OpenWithDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam case IDC_GETOPENWITHDIR: { - if (GetDirectory(hwnd,IDS_MUI_OPENWITH,g_tchOpenWithDir,g_tchOpenWithDir,true)) + if (GetDirectory(hwnd,IDS_MUI_OPENWITH,Settings.OpenWithDir,Settings.OpenWithDir,true)) { - DirList_Fill(GetDlgItem(hwnd,IDC_OPENWITHDIR),g_tchOpenWithDir,DL_ALLOBJECTS,NULL,false,g_flagNoFadeHidden,DS_NAME,false); + DirList_Fill(GetDlgItem(hwnd,IDC_OPENWITHDIR),Settings.OpenWithDir,DL_ALLOBJECTS,NULL,false,Flags.NoFadeHidden,DS_NAME,false); DirList_StartIconThread(GetDlgItem(hwnd,IDC_OPENWITHDIR)); ListView_EnsureVisible(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,false); ListView_SetItemState(GetDlgItem(hwnd,IDC_OPENWITHDIR),0,LVIS_FOCUSED,LVIS_FOCUSED); @@ -989,14 +962,14 @@ bool OpenWithDlg(HWND hwnd,LPCWSTR lpstrFile) DLITEM dliOpenWith; dliOpenWith.mask = DLI_FILENAME; - if (IDOK == ThemedDialogBoxParam(g_hLngResContainer,MAKEINTRESOURCE(IDD_MUI_OPENWITH), + if (IDOK == ThemedDialogBoxParam(Globals.hLngResContainer,MAKEINTRESOURCE(IDD_MUI_OPENWITH), hwnd,OpenWithDlgProc,(LPARAM)&dliOpenWith)) { WCHAR szParam[MAX_PATH] = { L'\0' }; WCHAR wchDirectory[MAX_PATH] = { L'\0' }; - if (StringCchLenW(g_wchCurFile, FILE_ARG_BUF)) { - StringCchCopy(wchDirectory,COUNTOF(wchDirectory),g_wchCurFile); + if (StringCchLenW(Globals.CurrentFile, (MAX_PATH+1))) { + StringCchCopy(wchDirectory,COUNTOF(wchDirectory),Globals.CurrentFile); PathRemoveFileSpec(wchDirectory); } @@ -1028,11 +1001,6 @@ bool OpenWithDlg(HWND hwnd,LPCWSTR lpstrFile) // // FavoritesDlgProc() // -extern WCHAR g_tchFavoritesDir[MAX_PATH]; - -extern int cxFavoritesDlg; -extern int cyFavoritesDlg; - INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) { switch(umsg) @@ -1040,11 +1008,11 @@ INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPara case WM_INITDIALOG: { - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; - ResizeDlg_Init(hwnd,cxFavoritesDlg,cyFavoritesDlg,IDC_RESIZEGRIP3); + ResizeDlg_Init(hwnd,Settings.FavoritesDlgSizeX,Settings.FavoritesDlgSizeY,IDC_RESIZEGRIP3); SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)lParam); @@ -1052,11 +1020,11 @@ INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPara ListView_SetExtendedListViewStyle(GetDlgItem(hwnd,IDC_FAVORITESDIR),/*LVS_EX_FULLROWSELECT|*/LVS_EX_DOUBLEBUFFER|LVS_EX_LABELTIP); ListView_InsertColumn(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,&lvc); DirList_Init(GetDlgItem(hwnd,IDC_FAVORITESDIR),NULL); - DirList_Fill(GetDlgItem(hwnd,IDC_FAVORITESDIR),g_tchFavoritesDir,DL_ALLOBJECTS,NULL,false,g_flagNoFadeHidden,DS_NAME,false); + DirList_Fill(GetDlgItem(hwnd,IDC_FAVORITESDIR),Settings.FavoritesDir,DL_ALLOBJECTS,NULL,false,Flags.NoFadeHidden,DS_NAME,false); DirList_StartIconThread(GetDlgItem(hwnd,IDC_FAVORITESDIR)); ListView_SetItemState(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,LVIS_FOCUSED,LVIS_FOCUSED); - MakeBitmapButton(hwnd,IDC_GETFAVORITESDIR,g_hInstance,IDB_OPEN); + MakeBitmapButton(hwnd,IDC_GETFAVORITESDIR,Globals.hInstance,IDB_OPEN); CenterDlgInParent(hwnd); } @@ -1067,7 +1035,7 @@ INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPara DirList_Destroy(GetDlgItem(hwnd,IDC_FAVORITESDIR)); DeleteBitmapButton(hwnd,IDC_GETFAVORITESDIR); - ResizeDlg_Destroy(hwnd,&cxFavoritesDlg,&cyFavoritesDlg); + ResizeDlg_Destroy(hwnd,&Settings.FavoritesDlgSizeX,&Settings.FavoritesDlgSizeY); return false; @@ -1106,7 +1074,7 @@ INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPara switch(pnmh->code) { case LVN_GETDISPINFO: - DirList_GetDispInfo(GetDlgItem(hwnd,IDC_OPENWITHDIR),lParam,g_flagNoFadeHidden); + DirList_GetDispInfo(GetDlgItem(hwnd,IDC_OPENWITHDIR),lParam,Flags.NoFadeHidden); break; case LVN_DELETEITEM: @@ -1136,9 +1104,9 @@ INT_PTR CALLBACK FavoritesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPara case IDC_GETFAVORITESDIR: { - if (GetDirectory(hwnd,IDS_MUI_FAVORITES,g_tchFavoritesDir,g_tchFavoritesDir,true)) + if (GetDirectory(hwnd,IDS_MUI_FAVORITES,Settings.FavoritesDir,Settings.FavoritesDir,true)) { - DirList_Fill(GetDlgItem(hwnd,IDC_FAVORITESDIR),g_tchFavoritesDir,DL_ALLOBJECTS,NULL,false,g_flagNoFadeHidden,DS_NAME,false); + DirList_Fill(GetDlgItem(hwnd,IDC_FAVORITESDIR),Settings.FavoritesDir,DL_ALLOBJECTS,NULL,false,Flags.NoFadeHidden,DS_NAME,false); DirList_StartIconThread(GetDlgItem(hwnd,IDC_FAVORITESDIR)); ListView_EnsureVisible(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,false); ListView_SetItemState(GetDlgItem(hwnd,IDC_FAVORITESDIR),0,LVIS_FOCUSED,LVIS_FOCUSED); @@ -1188,7 +1156,7 @@ bool FavoritesDlg(HWND hwnd,LPWSTR lpstrFile) ZeroMemory(&dliFavorite, sizeof(DLITEM)); dliFavorite.mask = DLI_FILENAME; - if (IDOK == ThemedDialogBoxParam(g_hLngResContainer,MAKEINTRESOURCE(IDD_MUI_FAVORITES), + if (IDOK == ThemedDialogBoxParam(Globals.hLngResContainer,MAKEINTRESOURCE(IDD_MUI_FAVORITES), hwnd,FavoritesDlgProc,(LPARAM)&dliFavorite)) { StringCchCopyN(lpstrFile,MAX_PATH,dliFavorite.szFileName,MAX_PATH); @@ -1214,7 +1182,7 @@ INT_PTR CALLBACK AddToFavDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lPa pszName = (LPWSTR)lParam; SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)pszName); - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } SendDlgItemMessage(hwnd, 100, EM_LIMITTEXT, MAX_PATH - 1, 0); SetDlgItemText(hwnd, 100, pszName); @@ -1259,14 +1227,14 @@ bool AddToFavDlg(HWND hwnd,LPCWSTR lpszName,LPCWSTR lpszTarget) StringCchCopy(pszName,COUNTOF(pszName),lpszName); iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_ADDTOFAV), hwnd, AddToFavDlgProc,(LPARAM)pszName); if (iResult == IDOK) { - if (!PathCreateFavLnk(pszName,lpszTarget,g_tchFavoritesDir)) { + if (!PathCreateFavLnk(pszName,lpszTarget,Settings.FavoritesDir)) { MsgBoxLng(MBWARN,IDS_MUI_FAV_FAILURE); return false; } @@ -1287,14 +1255,6 @@ bool AddToFavDlg(HWND hwnd,LPCWSTR lpszName,LPCWSTR lpszTarget) // FileMRUDlgProc() // // -extern LPMRULIST g_pFileMRU; -extern bool g_bSaveRecentFiles; -extern bool g_bPreserveCaretPos; -extern bool g_bSaveFindReplace; -extern int cxFileMRUDlg; -extern int cyFileMRUDlg; -extern int g_flagNoFadeHidden; - typedef struct tagIconThreadInfo { HWND hwnd; // HWND of ListView Control @@ -1368,7 +1328,7 @@ DWORD WINAPI FileMRUIconThread(LPVOID lpParam) { else dwAttr = GetFileAttributes(tch); - if (!g_flagNoFadeHidden && + if (!Flags.NoFadeHidden && dwAttr != INVALID_FILE_ATTRIBUTES && dwAttr & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) { lvi.mask |= LVIF_STATE; @@ -1401,7 +1361,7 @@ INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) ZeroMemory(&shfi, sizeof(SHFILEINFO)); LVCOLUMN lvc = { LVCF_FMT|LVCF_TEXT, LVCFMT_LEFT, 0, L"", -1, 0, 0, 0 }; - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } LPICONTHREADINFO lpit = (LPICONTHREADINFO)AllocMem(sizeof(ICONTHREADINFO),HEAP_ZERO_MEMORY); if (lpit) { @@ -1413,7 +1373,7 @@ INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) } SetWindowLongPtr(hwnd,DWLP_USER,(LONG_PTR)lParam); - ResizeDlg_Init(hwnd,cxFileMRUDlg,cyFileMRUDlg,IDC_RESIZEGRIP); + ResizeDlg_Init(hwnd,Settings.FileMRUDlgSizeX,Settings.FileMRUDlgSizeY,IDC_RESIZEGRIP); ListView_SetImageList(GetDlgItem(hwnd,IDC_FILEMRU), (HIMAGELIST)SHGetFileInfo(L"C:\\",FILE_ATTRIBUTE_DIRECTORY, @@ -1432,11 +1392,11 @@ INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) // Update view SendMessage(hwnd,WM_COMMAND,MAKELONG(0x00A0,1),0); - CheckDlgButton(hwnd, IDC_SAVEMRU, DlgBtnChk(g_bSaveRecentFiles)); - CheckDlgButton(hwnd, IDC_PRESERVECARET, DlgBtnChk(g_bPreserveCaretPos)); - CheckDlgButton(hwnd, IDC_REMEMBERSEARCHPATTERN, DlgBtnChk(g_bSaveFindReplace)); + CheckDlgButton(hwnd, IDC_SAVEMRU, DlgBtnChk(Settings.SaveRecentFiles)); + CheckDlgButton(hwnd, IDC_PRESERVECARET, DlgBtnChk(Settings.PreserveCaretPos)); + CheckDlgButton(hwnd, IDC_REMEMBERSEARCHPATTERN, DlgBtnChk(Settings.SaveFindReplace)); - //if (!g_bSaveRecentFiles) { + //if (!Settings.SaveRecentFiles) { // DialogEnableWindow(hwnd,IDC_PRESERVECARET, false); // DialogEnableWindow(hwnd,IDC_REMEMBERSEARCHPATTERN, false); //} @@ -1463,11 +1423,11 @@ INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) RemoveProp(hwnd,L"it"); FreeMem(lpit); - g_bSaveFindReplace = (IsDlgButtonChecked(hwnd, IDC_REMEMBERSEARCHPATTERN)) ? true : false; - g_bPreserveCaretPos = (IsDlgButtonChecked(hwnd, IDC_PRESERVECARET)) ? true : false; - g_bSaveRecentFiles = (IsDlgButtonChecked(hwnd, IDC_SAVEMRU)) ? true : false; + Settings.SaveFindReplace = (IsDlgButtonChecked(hwnd, IDC_REMEMBERSEARCHPATTERN)) ? true : false; + Settings.PreserveCaretPos = (IsDlgButtonChecked(hwnd, IDC_PRESERVECARET)) ? true : false; + Settings.SaveRecentFiles = (IsDlgButtonChecked(hwnd, IDC_SAVEMRU)) ? true : false; - ResizeDlg_Destroy(hwnd,&cxFileMRUDlg,&cyFileMRUDlg); + ResizeDlg_Destroy(hwnd,&Settings.FileMRUDlgSizeX,&Settings.FileMRUDlgSizeY); } return false; @@ -1563,7 +1523,7 @@ INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) dwAttr = GetFileAttributes(tch); - if (!g_flagNoFadeHidden && + if (!Flags.NoFadeHidden && dwAttr != INVALID_FILE_ATTRIBUTES && dwAttr & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) { lpdi->item.mask |= LVIF_STATE; @@ -1629,8 +1589,8 @@ INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) lvi.iImage = shfi.iIcon; - for (i = 0; i < MRU_Count(g_pFileMRU); i++) { - MRU_Enum(g_pFileMRU,i,tch,COUNTOF(tch)); + for (i = 0; i < MRU_Count(Globals.pFileMRU); i++) { + MRU_Enum(Globals.pFileMRU,i,tch,COUNTOF(tch)); PathAbsoluteFromApp(tch,NULL,0,true); // SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_ADDSTRING,0,(LPARAM)tch); } // SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_SETCARETINDEX,0,false); @@ -1682,7 +1642,7 @@ INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) // don't remove myself int iCur = 0; - if (!MRU_FindFile(g_pFileMRU, g_wchCurFile, &iCur)) { + if (!MRU_FindFile(Globals.pFileMRU, Globals.CurrentFile, &iCur)) { iCur = -1; } @@ -1692,8 +1652,8 @@ INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) if (IDYES == answ) { - MRU_Delete(g_pFileMRU,lvi.iItem); - MRU_DeleteFileFromStore(g_pFileMRU,tchFileName); + MRU_Delete(Globals.pFileMRU,lvi.iItem); + MRU_DeleteFileFromStore(Globals.pFileMRU,tchFileName); //SendDlgItemMessage(hwnd,IDC_FILEMRU,LB_DELETESTRING,(WPARAM)iItem,0); //ListView_DeleteItem(GetDlgItem(hwnd,IDC_FILEMRU),lvi.iItem); @@ -1741,7 +1701,7 @@ INT_PTR CALLBACK FileMRUDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) bool FileMRUDlg(HWND hwnd,LPWSTR lpstrFile) { - if (IDOK == ThemedDialogBoxParam(g_hLngResContainer,MAKEINTRESOURCE(IDD_MUI_FILEMRU), + if (IDOK == ThemedDialogBoxParam(Globals.hLngResContainer,MAKEINTRESOURCE(IDD_MUI_FILEMRU), hwnd,FileMRUDlgProc,(LPARAM)lpstrFile)) return true; else @@ -1759,8 +1719,6 @@ bool FileMRUDlg(HWND hwnd,LPWSTR lpstrFile) // 102 Radio Button (Auto-Reload) // 103 Check Box (Reset on New) // -extern int g_iFileWatchingMode; -extern bool g_bResetFileWatching; extern bool g_bChasingDocTail; INT_PTR CALLBACK ChangeNotifyDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) @@ -1768,9 +1726,9 @@ INT_PTR CALLBACK ChangeNotifyDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM switch (umsg) { case WM_INITDIALOG: { - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } - CheckRadioButton(hwnd, 100, 102, 100 + g_iFileWatchingMode); - if (g_bResetFileWatching) + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } + CheckRadioButton(hwnd, 100, 102, 100 + Settings.FileWatchingMode); + if (Settings.ResetFileWatching) CheckDlgButton(hwnd, 103, BST_CHECKED); CenterDlgInParent(hwnd); } @@ -1780,15 +1738,15 @@ INT_PTR CALLBACK ChangeNotifyDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM switch (LOWORD(wParam)) { case IDOK: if (IsDlgButtonChecked(hwnd, 100) == BST_CHECKED) - g_iFileWatchingMode = 0; + Settings.FileWatchingMode = 0; else if (IsDlgButtonChecked(hwnd, 101) == BST_CHECKED) - g_iFileWatchingMode = 1; + Settings.FileWatchingMode = 1; else - g_iFileWatchingMode = 2; + Settings.FileWatchingMode = 2; - g_bResetFileWatching = (IsDlgButtonChecked(hwnd, 103) == BST_CHECKED) ? true : false; + Settings.ResetFileWatching = (IsDlgButtonChecked(hwnd, 103) == BST_CHECKED) ? true : false; - if (g_bChasingDocTail) { SendMessage(g_hwndMain, WM_COMMAND, MAKELONG(IDM_VIEW_CHASING_DOCTAIL, 1), 0); } + if (g_bChasingDocTail) { SendMessage(Globals.hwndMain, WM_COMMAND, MAKELONG(IDM_VIEW_CHASING_DOCTAIL, 1), 0); } EndDialog(hwnd, IDOK); break; @@ -1815,7 +1773,7 @@ bool ChangeNotifyDlg(HWND hwnd) INT_PTR iResult; iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCEW(IDD_MUI_CHANGENOTIFY), hwnd, ChangeNotifyDlgProc, @@ -1841,7 +1799,7 @@ INT_PTR CALLBACK ColumnWrapDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM l case WM_INITDIALOG: { piNumber = (UINT*)lParam; - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } SetDlgItemInt(hwnd, IDC_COLUMNWRAP, *piNumber, false); SendDlgItemMessage(hwnd, IDC_COLUMNWRAP, EM_LIMITTEXT, 15, 0); CenterDlgInParent(hwnd); @@ -1888,7 +1846,7 @@ bool ColumnWrapDlg(HWND hwnd,UINT uidDlg, UINT *iNumber) INT_PTR iResult; iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCE(uidDlg), hwnd, ColumnWrapDlgProc,(LPARAM)iNumber); @@ -1911,11 +1869,6 @@ bool ColumnWrapDlg(HWND hwnd,UINT uidDlg, UINT *iNumber) // 202 Text // 203 Text // -extern int iWordWrapMode; -extern int iWordWrapIndent; -extern int iWordWrapSymbols; -extern bool bShowWordWrapSymbols; - INT_PTR CALLBACK WordWrapSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { UNUSED(lParam); @@ -1924,7 +1877,7 @@ INT_PTR CALLBACK WordWrapSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LP case WM_INITDIALOG: { - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } WCHAR tch[512]; for (int i = 0; i < 4; i++) { GetDlgItemText(hwnd, 200 + i, tch, COUNTOF(tch)); @@ -1940,10 +1893,10 @@ INT_PTR CALLBACK WordWrapSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LP } SendDlgItemMessage(hwnd, 100 + i, CB_SETEXTENDEDUI, true, 0); } - SendDlgItemMessage(hwnd, 100, CB_SETCURSEL, (WPARAM)iWordWrapIndent, 0); - SendDlgItemMessage(hwnd, 101, CB_SETCURSEL, (WPARAM)(bShowWordWrapSymbols) ? iWordWrapSymbols % 10 : 0, 0); - SendDlgItemMessage(hwnd, 102, CB_SETCURSEL, (WPARAM)(bShowWordWrapSymbols) ? ((iWordWrapSymbols % 100) - (iWordWrapSymbols % 10)) / 10 : 0, 0); - SendDlgItemMessage(hwnd, 103, CB_SETCURSEL, (WPARAM)iWordWrapMode, 0); + SendDlgItemMessage(hwnd, 100, CB_SETCURSEL, (WPARAM)Settings.WordWrapIndent, 0); + SendDlgItemMessage(hwnd, 101, CB_SETCURSEL, (WPARAM)(Settings.ShowWordWrapSymbols ? Settings.WordWrapSymbols % 10 : 0), 0); + SendDlgItemMessage(hwnd, 102, CB_SETCURSEL, (WPARAM)(Settings.ShowWordWrapSymbols ? ((Settings.WordWrapSymbols % 100) - (Settings.WordWrapSymbols % 10)) / 10 : 0), 0); + SendDlgItemMessage(hwnd, 103, CB_SETCURSEL, (WPARAM)Settings.WordWrapMode, 0); CenterDlgInParent(hwnd); } @@ -1957,18 +1910,18 @@ INT_PTR CALLBACK WordWrapSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LP case IDOK: { int iSel = (int)SendDlgItemMessage(hwnd, 100, CB_GETCURSEL, 0, 0); - iWordWrapIndent = iSel; + Settings.WordWrapIndent = iSel; - bShowWordWrapSymbols = false; + Settings.ShowWordWrapSymbols = false; iSel = (int)SendDlgItemMessage(hwnd, 101, CB_GETCURSEL, 0, 0); int iSel2 = (int)SendDlgItemMessage(hwnd, 102, CB_GETCURSEL, 0, 0); if (iSel > 0 || iSel2 > 0) { - bShowWordWrapSymbols = true; - iWordWrapSymbols = iSel + iSel2 * 10; + Settings.ShowWordWrapSymbols = true; + Settings.WordWrapSymbols = iSel + iSel2 * 10; } iSel = (int)SendDlgItemMessage(hwnd, 103, CB_GETCURSEL, 0, 0); - iWordWrapMode = iSel; + Settings.WordWrapMode = iSel; EndDialog(hwnd, IDOK); } @@ -1998,7 +1951,7 @@ bool WordWrapSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber) INT_PTR iResult; iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCE(uidDlg), hwnd, WordWrapSettingsDlgProc,(LPARAM)iNumber); @@ -2016,8 +1969,6 @@ bool WordWrapSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber) // 101 Radio1 // 102 Radio2 // -extern int iLongLineMode; - INT_PTR CALLBACK LongLineSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { static int *piNumber; @@ -2026,12 +1977,12 @@ INT_PTR CALLBACK LongLineSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LP case WM_INITDIALOG: { - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } piNumber = (int*)lParam; SetDlgItemInt(hwnd, 100, *piNumber, false); SendDlgItemMessage(hwnd, 100, EM_LIMITTEXT, 15, 0); - if (iLongLineMode == EDGE_LINE) + if (Settings.LongLineMode == EDGE_LINE) CheckRadioButton(hwnd, 101, 102, 101); else CheckRadioButton(hwnd, 101, 102, 102); @@ -2056,7 +2007,7 @@ INT_PTR CALLBACK LongLineSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LP if (fTranslated) { *piNumber = iNewNumber; - iLongLineMode = (IsDlgButtonChecked(hwnd, 101)) ? EDGE_LINE : EDGE_BACKGROUND; + Settings.LongLineMode = (IsDlgButtonChecked(hwnd, 101)) ? EDGE_LINE : EDGE_BACKGROUND; EndDialog(hwnd, IDOK); } @@ -2089,7 +2040,7 @@ bool LongLineSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber) INT_PTR iResult; iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCE(uidDlg), hwnd, LongLineSettingsDlgProc,(LPARAM)iNumber); @@ -2109,35 +2060,29 @@ bool LongLineSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber) // 103 Check // 104 Check // -extern int g_iTabWidth; -extern int g_iIndentWidth; -extern bool g_bTabsAsSpaces; -extern bool g_bTabIndents; -extern bool bBackspaceUnindents; INT_PTR CALLBACK TabSettingsDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) { - switch(umsg) { case WM_INITDIALOG: { - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } - SetDlgItemInt(hwnd,100,g_iTabWidth,false); + SetDlgItemInt(hwnd,100,Settings.TabWidth,false); SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,15,0); - SetDlgItemInt(hwnd,101,g_iIndentWidth,false); + SetDlgItemInt(hwnd,101,Settings.IndentWidth,false); SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,15,0); - if (g_bTabsAsSpaces) + if (Settings.TabsAsSpaces) CheckDlgButton(hwnd,102,BST_CHECKED); - if (g_bTabIndents) + if (Settings.TabIndents) CheckDlgButton(hwnd,103,BST_CHECKED); - if (bBackspaceUnindents) + if (Settings.BackspaceUnindents) CheckDlgButton(hwnd,104,BST_CHECKED); CenterDlgInParent(hwnd); @@ -2160,14 +2105,14 @@ INT_PTR CALLBACK TabSettingsDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPa if (fTranslated1 && fTranslated2) { - g_iTabWidth = iNewTabWidth; - g_iIndentWidth = iNewIndentWidth; + Settings.TabWidth = iNewTabWidth; + Settings.IndentWidth = iNewIndentWidth; - g_bTabsAsSpaces = (IsDlgButtonChecked(hwnd,102)) ? true : false; + Settings.TabsAsSpaces = (IsDlgButtonChecked(hwnd,102)) ? true : false; - g_bTabIndents = (IsDlgButtonChecked(hwnd,103)) ? true : false; + Settings.TabIndents = (IsDlgButtonChecked(hwnd,103)) ? true : false; - bBackspaceUnindents = (IsDlgButtonChecked(hwnd,104)) ? true : false; + Settings.BackspaceUnindents = (IsDlgButtonChecked(hwnd,104)) ? true : false; EndDialog(hwnd,IDOK); } @@ -2205,7 +2150,7 @@ bool TabSettingsDlg(HWND hwnd,UINT uidDlg,int *iNumber) INT_PTR iResult; iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCE(uidDlg), hwnd, TabSettingsDlgProc,(LPARAM)iNumber); @@ -2239,9 +2184,9 @@ INT_PTR CALLBACK SelectDefEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR HIMAGELIST himl; pdd = (PENCODEDLG)lParam; - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } - hbmp = LoadImage(g_hInstance,MAKEINTRESOURCE(IDB_ENCODING),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); + hbmp = LoadImage(Globals.hInstance,MAKEINTRESOURCE(IDB_ENCODING),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); hbmp = ResizeImageForCurrentDPI(hbmp); himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,0); @@ -2252,12 +2197,12 @@ INT_PTR CALLBACK SelectDefEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR Encoding_AddToComboboxEx(GetDlgItem(hwnd,IDC_ENCODINGLIST),pdd->idEncoding,0); - CheckDlgButton(hwnd, IDC_USEASREADINGFALLBACK, DlgBtnChk(bUseDefaultForFileEncoding)); - CheckDlgButton(hwnd,IDC_NOUNICODEDETECTION, DlgBtnChk(bSkipUnicodeDetection)); - CheckDlgButton(hwnd, IDC_NOANSICPDETECTION, DlgBtnChk(bSkipANSICodePageDetection)); - CheckDlgButton(hwnd,IDC_ASCIIASUTF8, DlgBtnChk(g_bLoadASCIIasUTF8)); - CheckDlgButton(hwnd,IDC_NFOASOEM, DlgBtnChk(g_bLoadNFOasOEM)); - CheckDlgButton(hwnd,IDC_ENCODINGFROMFILEVARS, DlgBtnChk(g_bNoEncodingTags)); + CheckDlgButton(hwnd, IDC_USEASREADINGFALLBACK, DlgBtnChk(Settings.UseDefaultForFileEncoding)); + CheckDlgButton(hwnd,IDC_NOUNICODEDETECTION, DlgBtnChk(Settings.SkipUnicodeDetection)); + CheckDlgButton(hwnd, IDC_NOANSICPDETECTION, DlgBtnChk(Settings.SkipANSICodePageDetection)); + CheckDlgButton(hwnd,IDC_ASCIIASUTF8, DlgBtnChk(Settings.LoadASCIIasUTF8)); + CheckDlgButton(hwnd,IDC_NFOASOEM, DlgBtnChk(Settings.LoadNFOasOEM)); + CheckDlgButton(hwnd,IDC_ENCODINGFROMFILEVARS, DlgBtnChk(Settings.NoEncodingTags)); CenterDlgInParent(hwnd); } @@ -2274,12 +2219,12 @@ INT_PTR CALLBACK SelectDefEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR EndDialog(hwnd,IDCANCEL); } else { - bUseDefaultForFileEncoding = (IsDlgButtonChecked(hwnd, IDC_USEASREADINGFALLBACK) == BST_CHECKED); - bSkipUnicodeDetection = (IsDlgButtonChecked(hwnd,IDC_NOUNICODEDETECTION) == BST_CHECKED); - bSkipANSICodePageDetection = (IsDlgButtonChecked(hwnd, IDC_NOANSICPDETECTION) == BST_CHECKED); - g_bLoadASCIIasUTF8 = (IsDlgButtonChecked(hwnd,IDC_ASCIIASUTF8) == BST_CHECKED); - g_bLoadNFOasOEM = (IsDlgButtonChecked(hwnd,IDC_NFOASOEM) == BST_CHECKED); - g_bNoEncodingTags = (IsDlgButtonChecked(hwnd,IDC_ENCODINGFROMFILEVARS) == BST_CHECKED); + Settings.UseDefaultForFileEncoding = (IsDlgButtonChecked(hwnd, IDC_USEASREADINGFALLBACK) == BST_CHECKED); + Settings.SkipUnicodeDetection = (IsDlgButtonChecked(hwnd,IDC_NOUNICODEDETECTION) == BST_CHECKED); + Settings.SkipANSICodePageDetection = (IsDlgButtonChecked(hwnd, IDC_NOANSICPDETECTION) == BST_CHECKED); + Settings.LoadASCIIasUTF8 = (IsDlgButtonChecked(hwnd,IDC_ASCIIASUTF8) == BST_CHECKED); + Settings.LoadNFOasOEM = (IsDlgButtonChecked(hwnd,IDC_NFOASOEM) == BST_CHECKED); + Settings.NoEncodingTags = (IsDlgButtonChecked(hwnd,IDC_ENCODINGFROMFILEVARS) == BST_CHECKED); EndDialog(hwnd,IDOK); } } @@ -2312,7 +2257,7 @@ bool SelectDefEncodingDlg(HWND hwnd,int *pidREncoding) dd.idEncoding = *pidREncoding; iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_DEFENCODING), hwnd, SelectDefEncodingDlgProc, @@ -2350,13 +2295,13 @@ INT_PTR CALLBACK SelectEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM pdd = (PENCODEDLG)lParam; - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } ResizeDlg_Init(hwnd,pdd->cxDlg,pdd->cyDlg,IDC_RESIZEGRIP4); hwndLV = GetDlgItem(hwnd,IDC_ENCODINGLIST); - hbmp = LoadImage(g_hInstance,MAKEINTRESOURCE(IDB_ENCODING),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); + hbmp = LoadImage(Globals.hInstance,MAKEINTRESOURCE(IDB_ENCODING),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); hbmp = ResizeImageForCurrentDPI(hbmp); himl = ImageList_Create(16,16,ILC_COLOR32|ILC_MASK,0,0); @@ -2466,9 +2411,6 @@ INT_PTR CALLBACK SelectEncodingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM // // SelectEncodingDlg() // -extern int cxEncodingDlg; -extern int cyEncodingDlg; - bool SelectEncodingDlg(HWND hwnd,int *pidREncoding) { @@ -2477,18 +2419,18 @@ bool SelectEncodingDlg(HWND hwnd,int *pidREncoding) dd.bRecodeOnly = false; dd.idEncoding = *pidREncoding; - dd.cxDlg = cxEncodingDlg; - dd.cyDlg = cyEncodingDlg; + dd.cxDlg = Settings.EncodingDlgSizeX; + dd.cyDlg = Settings.EncodingDlgSizeY; iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_ENCODING), hwnd, SelectEncodingDlgProc, (LPARAM)&dd); - cxEncodingDlg = dd.cxDlg; - cyEncodingDlg = dd.cyDlg; + Settings.EncodingDlgSizeX = dd.cxDlg; + Settings.EncodingDlgSizeY = dd.cyDlg; if (iResult == IDOK) { *pidREncoding = dd.idEncoding; @@ -2504,9 +2446,6 @@ bool SelectEncodingDlg(HWND hwnd,int *pidREncoding) // // RecodeDlg() // -extern int cxRecodeDlg; -extern int cyRecodeDlg; - bool RecodeDlg(HWND hwnd,int *pidREncoding) { @@ -2515,18 +2454,18 @@ bool RecodeDlg(HWND hwnd,int *pidREncoding) dd.bRecodeOnly = true; dd.idEncoding = *pidREncoding; - dd.cxDlg = cxRecodeDlg; - dd.cyDlg = cyRecodeDlg; + dd.cxDlg = Settings.RecodeDlgSizeX; + dd.cyDlg = Settings.RecodeDlgSizeY; iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_RECODE), hwnd, SelectEncodingDlgProc, (LPARAM)&dd); - cxRecodeDlg = dd.cxDlg; - cyRecodeDlg = dd.cyDlg; + Settings.RecodeDlgSizeX = dd.cxDlg; + Settings.RecodeDlgSizeY = dd.cyDlg; if (iResult == IDOK) { *pidREncoding = dd.idEncoding; @@ -2559,7 +2498,7 @@ INT_PTR CALLBACK SelectDefLineEndingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LP piOption = (int*)lParam; - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } // Load options for (i = 0; i < 3; i++) { @@ -2570,8 +2509,8 @@ INT_PTR CALLBACK SelectDefLineEndingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LP SendDlgItemMessage(hwnd,100,CB_SETCURSEL,(WPARAM)*piOption,0); SendDlgItemMessage(hwnd,100,CB_SETEXTENDEDUI,true,0); - CheckDlgButton(hwnd,IDC_CONSISTENTEOLS, DlgBtnChk(bFixLineEndings)); - CheckDlgButton(hwnd,IDC_AUTOSTRIPBLANKS, DlgBtnChk(bAutoStripBlanks)); + CheckDlgButton(hwnd,IDC_CONSISTENTEOLS, DlgBtnChk(Settings.FixLineEndings)); + CheckDlgButton(hwnd,IDC_AUTOSTRIPBLANKS, DlgBtnChk(Settings.FixTrailingBlanks)); CenterDlgInParent(hwnd); } @@ -2583,8 +2522,8 @@ INT_PTR CALLBACK SelectDefLineEndingDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LP { case IDOK: { *piOption = (int)SendDlgItemMessage(hwnd,100,CB_GETCURSEL,0,0); - bFixLineEndings = (IsDlgButtonChecked(hwnd,IDC_CONSISTENTEOLS) == BST_CHECKED); - bAutoStripBlanks = (IsDlgButtonChecked(hwnd,IDC_AUTOSTRIPBLANKS) == BST_CHECKED); + Settings.FixLineEndings = (IsDlgButtonChecked(hwnd,IDC_CONSISTENTEOLS) == BST_CHECKED); + Settings.FixTrailingBlanks = (IsDlgButtonChecked(hwnd,IDC_AUTOSTRIPBLANKS) == BST_CHECKED); EndDialog(hwnd,IDOK); } break; @@ -2609,7 +2548,7 @@ bool SelectDefLineEndingDlg(HWND hwnd,int *iOption) INT_PTR iResult; iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_DEFEOLMODE), hwnd, SelectDefLineEndingDlgProc, @@ -2787,16 +2726,16 @@ void DialogNewWindow(HWND hwnd, bool bSaveOnRunTools, bool bSetCurFile) GetModuleFileName(NULL, szModuleName, COUNTOF(szModuleName)); NormalizePathEx(szModuleName, COUNTOF(szModuleName)); - StringCchPrintf(tch, COUNTOF(tch), L"\"-appid=%s\"", g_wchAppUserModelID); + StringCchPrintf(tch, COUNTOF(tch), L"\"-appid=%s\"", Settings2.AppUserModelID); StringCchCopy(szParameters, COUNTOF(szParameters), tch); - StringCchPrintf(tch, COUNTOF(tch), L"\" -sysmru=%i\"", (g_flagUseSystemMRU == 2) ? 1 : 0); + StringCchPrintf(tch, COUNTOF(tch), L"\" -sysmru=%i\"", (Flags.ShellUseSystemMRU == 2) ? 1 : 0); StringCchCat(szParameters, COUNTOF(szParameters), tch); StringCchCat(szParameters, COUNTOF(szParameters), L" -f"); - if (StringCchLenW(g_wchIniFile, COUNTOF(g_wchIniFile))) { + if (StringCchLenW(Globals.IniFile, COUNTOF(Globals.IniFile))) { StringCchCat(szParameters, COUNTOF(szParameters), L" \""); - StringCchCat(szParameters, COUNTOF(szParameters), g_wchIniFile); + StringCchCat(szParameters, COUNTOF(szParameters), Globals.IniFile); StringCchCat(szParameters, COUNTOF(szParameters), L" \""); } else @@ -2819,9 +2758,9 @@ void DialogNewWindow(HWND hwnd, bool bSaveOnRunTools, bool bSetCurFile) StringCchPrintf(tch, COUNTOF(tch), L" -pos %i,%i,%i,%i,%i", wi.x, wi.y, wi.cx, wi.cy, wi.max); StringCchCat(szParameters, COUNTOF(szParameters), tch); - if (bSetCurFile && StringCchLenW(g_wchCurFile, FILE_ARG_BUF)) + if (bSetCurFile && StringCchLenW(Globals.CurrentFile, (MAX_PATH+1))) { - StringCchCopy(szFileName, COUNTOF(szFileName), g_wchCurFile); + StringCchCopy(szFileName, COUNTOF(szFileName), Globals.CurrentFile); PathQuoteSpaces(szFileName); StringCchCat(szParameters, COUNTOF(szParameters), L" "); StringCchCat(szParameters, COUNTOF(szParameters), szFileName); @@ -2835,7 +2774,7 @@ void DialogNewWindow(HWND hwnd, bool bSaveOnRunTools, bool bSetCurFile) sei.lpVerb = NULL; sei.lpFile = szModuleName; sei.lpParameters = szParameters; - sei.lpDirectory = g_wchWorkingDirectory; + sei.lpDirectory = Globals.WorkingDirectory; sei.nShow = SW_SHOWNORMAL; ShellExecuteEx(&sei); } @@ -2849,11 +2788,13 @@ void DialogNewWindow(HWND hwnd, bool bSaveOnRunTools, bool bSetCurFile) // void DialogFileBrowse(HWND hwnd) { - WCHAR tchParam[MAX_PATH+2] = L""; - WCHAR tchExeFile[MAX_PATH+4]; - WCHAR tchTemp[MAX_PATH+2]; + WCHAR tchParam[MAX_PATH+1] = L""; + WCHAR tchExeFile[MAX_PATH+1]; + WCHAR tchTemp[MAX_PATH+1]; + + StringCchCopyW(tchTemp, COUNTOF(tchTemp), Settings2.FileBrowserPath); - if (IniGetString(L"Settings2", L"filebrowser.exe", L"", tchTemp, COUNTOF(tchTemp))) + if (StringCchLenW(Settings2.FileBrowserPath,0) > 0) { ExtractFirstArgument(tchTemp, tchExeFile, tchParam, MAX_PATH+2); if (PathIsRelative(tchExeFile)) { @@ -2866,18 +2807,18 @@ void DialogFileBrowse(HWND hwnd) } } else { - if (!SearchPath(NULL, L"minipath.exe", L".exe", COUNTOF(tchExeFile), tchExeFile, NULL)) { + if (!SearchPath(NULL, Constants.FileBrowserMiniPath, L".exe", COUNTOF(tchExeFile), tchExeFile, NULL)) { GetModuleFileName(NULL, tchExeFile, COUNTOF(tchExeFile)); PathRemoveFileSpec(tchExeFile); - PathCchAppend(tchExeFile, COUNTOF(tchExeFile), L"minipath.exe"); + PathCchAppend(tchExeFile, COUNTOF(tchExeFile), Constants.FileBrowserMiniPath); } } - if (StringCchLenW(tchParam, COUNTOF(tchParam)) && StringCchLenW(g_wchCurFile, FILE_ARG_BUF)) + if (StringCchLenW(tchParam, COUNTOF(tchParam)) && StringCchLenW(Globals.CurrentFile, (MAX_PATH+1))) StringCchCat(tchParam, COUNTOF(tchParam), L" "); - if (StringCchLenW(g_wchCurFile, FILE_ARG_BUF)) { - StringCchCopy(tchTemp, COUNTOF(tchTemp), g_wchCurFile); + if (StringCchLenW(Globals.CurrentFile, (MAX_PATH+1))) { + StringCchCopy(tchTemp, COUNTOF(tchTemp), Globals.CurrentFile); PathQuoteSpaces(tchTemp); StringCchCat(tchParam, COUNTOF(tchParam), tchTemp); } @@ -2905,13 +2846,12 @@ void DialogFileBrowse(HWND hwnd) // DialogAdminExe() // // -extern WCHAR g_tchAdministrationExe[]; void DialogAdminExe(HWND hwnd, bool bExecInstaller) { WCHAR tchExe[MAX_PATH+2]; - StringCchCopyW(tchExe, COUNTOF(tchExe), g_tchAdministrationExe); + StringCchCopyW(tchExe, COUNTOF(tchExe), Settings2.AdministrationTool); if (bExecInstaller && !StringCchLenW(tchExe, COUNTOF(tchExe))) { return; } WCHAR tchExePath[MAX_PATH + 2]; @@ -2930,7 +2870,7 @@ void DialogAdminExe(HWND hwnd, bool bExecInstaller) sei.lpVerb = NULL; sei.lpFile = tchExePath; sei.lpParameters = NULL; // tchParam; - sei.lpDirectory = g_wchWorkingDirectory; + sei.lpDirectory = Globals.WorkingDirectory; sei.nShow = SW_SHOWNORMAL; if (bExecInstaller) { @@ -3057,7 +2997,7 @@ void SetWindowTransparentMode(HWND hwnd, bool bTransparentMode) if (bTransparentMode) { SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); // get opacity level from registry - int const iAlphaPercent = clampi(IniGetInt(L"Settings2", L"OpacityLevel", 75), 0, 100); + int const iAlphaPercent = Settings2.OpacityLevel; BYTE const bAlpha = (BYTE)MulDiv(iAlphaPercent, 255, 100); SetLayeredWindowAttributes(hwnd, 0, bAlpha, LWA_ALPHA); return; @@ -3371,9 +3311,9 @@ LRESULT SendWMSize(HWND hwnd, RECT* rc) if (!rc) { RECT _rc; GetClientRect(hwnd, &_rc); - return (SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELPARAM(_rc.right, _rc.bottom))); + return SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELPARAM(_rc.right, _rc.bottom)); } - return (SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELPARAM(rc->right, rc->bottom))); + return SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELPARAM(rc->right, rc->bottom)); } diff --git a/src/Edit.c b/src/Edit.c index 6c826ada7..a997d3bce 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -47,6 +47,7 @@ #include "helpers.h" #include "encoding.h" +#include "TypeDefs.h" #include "SciCall.h" #include "scilexer.h" @@ -61,80 +62,45 @@ // find free bits in scintilla.h SCFIND_ defines #define SCFIND_NP3_REGEX (SCFIND_REGEXP | SCFIND_POSIX) -extern HMODULE g_hLngResContainer; -extern HWND g_hwndMain; -extern HWND g_hwndStatus; -extern HWND g_hwndDlgFindReplace; -extern HICON g_hDlgIcon; - -//extern LPMALLOC g_lpMalloc; - -extern DWORD dwLastIOError; -extern bool bReplaceInitialized; -extern bool g_bUseOldStyleBraceMatching; -extern bool bUseDefaultForFileEncoding; +extern DWORD g_dwLastIOError; +extern bool g_bReplaceInitialized; extern bool g_bFindReplCopySelOrClip; -static EDITFINDREPLACE efrSave; -static bool bSwitchedFindReplace = false; - -extern int xFindReplaceDlg; -extern int yFindReplaceDlg; -static int xFindReplaceDlgSave; -static int yFindReplaceDlgSave; +static EDITFINDREPLACE s_efrSave; +static bool s_bSwitchedFindReplace = false; -extern int g_iDefaultEOLMode; -extern int g_iEOLMode; -extern bool bFixLineEndings; -extern bool bAutoStripBlanks; +static int s_xFindReplaceDlgSave; +static int s_yFindReplaceDlgSave; // Default Codepage and Character Set -extern int g_iDefaultNewFileEncoding; extern int g_iDefaultCharSet; -extern bool g_bLoadASCIIasUTF8; extern bool g_bForceLoadASCIIasUTF8; -extern bool g_bLoadNFOasOEM; -extern bool g_bNoEncodingTags; extern bool g_bUseLimitedAutoCCharSet; extern bool g_bIsCJKInputCodePage; -extern bool g_bAutoCompleteWords; -extern bool g_bAutoCLexerKeyWords; -extern bool g_bAccelWordNavigation; - extern int g_iReplacedOccurrences; -extern int g_iMarkOccurrences; extern int g_iMarkOccurrencesCount; -extern int g_iMarkOccurrencesMaxCount; -extern bool g_bMarkOccurrencesMatchVisible; -extern bool g_bHyperlinkHotspot; extern bool g_bCodeFoldingAvailable; -extern bool g_bShowCodeFolding; -extern bool g_bTabsAsSpaces; -extern bool g_bTabIndents; -extern int g_iTabWidth; -extern int g_iIndentWidth; extern bool g_bZeroBasedColumnIndex; extern CALLTIPTYPE g_CallTipType; extern FR_STATES g_FindReplaceMatchFoundState; -#define ANSI_CAHR_BUFFER 258 -static char DelimChars[ANSI_CAHR_BUFFER] = { '\0' }; -static char DelimCharsAccel[ANSI_CAHR_BUFFER] = { '\0' }; -static char WordCharsDefault[ANSI_CAHR_BUFFER] = { '\0' }; -static char WhiteSpaceCharsDefault[ANSI_CAHR_BUFFER] = { '\0' }; -static char PunctuationCharsDefault[ANSI_CAHR_BUFFER] = { '\0' }; -static char WordCharsAccelerated[ANSI_CAHR_BUFFER] = { '\0' }; -static char WhiteSpaceCharsAccelerated[ANSI_CAHR_BUFFER] = { '\0' }; +static char DelimChars[ANSI_CHAR_BUFFER] = { '\0' }; +static char DelimCharsAccel[ANSI_CHAR_BUFFER] = { '\0' }; +static char WordCharsDefault[ANSI_CHAR_BUFFER] = { '\0' }; +static char WhiteSpaceCharsDefault[ANSI_CHAR_BUFFER] = { '\0' }; +static char PunctuationCharsDefault[ANSI_CHAR_BUFFER] = { '\0' }; +static char WordCharsAccelerated[ANSI_CHAR_BUFFER] = { '\0' }; +static char WhiteSpaceCharsAccelerated[ANSI_CHAR_BUFFER] = { '\0' }; static char PunctuationCharsAccelerated[1] = { '\0' }; // empty! #define W_AUTOC_WORD_ANSI1252 L"#$%&@0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyzÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ" -static char AutoCompleteWordCharSet[ANSI_CAHR_BUFFER] = { L'\0' }; +static char AutoCompleteWordCharSet[ANSI_CHAR_BUFFER] = { L'\0' }; //static WCHAR W_DelimChars[ANSI_CAHR_BUFFER] = { L'\0' }; //static WCHAR W_DelimCharsAccel[ANSI_CAHR_BUFFER] = { L'\0' }; @@ -170,31 +136,23 @@ enum SortOrderMask { }; -extern LPMRULIST g_pMRUfind; -extern LPMRULIST g_pMRUreplace; - -extern bool g_bMarkOccurrencesMatchCase; -extern bool g_bMarkOccurrencesMatchWords; -extern bool g_bMarkOccurrencesCurrentWord; - - //============================================================================= // // _EnterTargetTransaction(), _LeaveTargetTransaction() // static volatile LONG s_lTargetTransactionGuard = 0L; -static bool __fastcall _IsInTargetTransaction() +static bool _IsInTargetTransaction() { return (InterlockedOr(&s_lTargetTransactionGuard, 0L) != 0L); } -static void __fastcall _EnterTargetTransaction() +static void _EnterTargetTransaction() { InterlockedIncrement(&s_lTargetTransactionGuard); } -static void __fastcall _LeaveTargetTransaction() +static void _LeaveTargetTransaction() { if (_IsInTargetTransaction()) { InterlockedDecrement(&s_lTargetTransactionGuard); @@ -232,7 +190,7 @@ static int msgcmp(void* mqc1, void* mqc2) #define _MQ_ms(T) ((T) / USER_TIMER_MINIMUM) -static void __fastcall _MQ_AppendCmd(CmdMessageQueue_t* const pMsgQCmd, int cycles) +static void _MQ_AppendCmd(CmdMessageQueue_t* const pMsgQCmd, int cycles) { CmdMessageQueue_t* pmqc = NULL; DL_SEARCH(MessageQueue, pmqc, pMsgQCmd, msgcmp); @@ -258,7 +216,7 @@ static void __fastcall _MQ_AppendCmd(CmdMessageQueue_t* const pMsgQCmd, int cycl // ---------------------------------------------------------------------------- -static void __fastcall _MQ_RemoveCmd(CmdMessageQueue_t* const pMsgQCmd) +static void _MQ_RemoveCmd(CmdMessageQueue_t* const pMsgQCmd) { CmdMessageQueue_t* pmqc = NULL; @@ -326,13 +284,10 @@ void EditInitWordDelimiter(HWND hwnd) StringCchCatA(DelimChars, COUNTOF(DelimChars), lineEnds); // 2nd get user settings - WCHAR buffer[ANSI_CAHR_BUFFER] = { L'\0' }; - ZeroMemory(buffer, ANSI_CAHR_BUFFER * sizeof(WCHAR)); - IniGetString(L"Settings2", L"ExtendedWhiteSpaceChars", L"", buffer, COUNTOF(buffer)); - char whitesp[ANSI_CAHR_BUFFER] = { '\0' }; - if (StringCchLen(buffer, COUNTOF(buffer)) > 0) { - WideCharToMultiByteStrg(Encoding_SciCP, buffer, whitesp); + char whitesp[ANSI_CHAR_BUFFER*2] = { '\0' }; + if (StringCchLen(Settings2.ExtendedWhiteSpaceChars, COUNTOF(Settings2.ExtendedWhiteSpaceChars)) > 0) { + WideCharToMultiByteStrg(Encoding_SciCP, Settings2.ExtendedWhiteSpaceChars, whitesp); } // 3rd set accelerated arrays @@ -341,7 +296,7 @@ void EditInitWordDelimiter(HWND hwnd) StringCchCopyA(WhiteSpaceCharsAccelerated, COUNTOF(WhiteSpaceCharsAccelerated), WhiteSpaceCharsDefault); // add only 7-bit-ASCII chars to accelerated whitespace list - for (size_t i = 0; i < StringCchLenA(whitesp, ANSI_CAHR_BUFFER); i++) { + for (size_t i = 0; i < StringCchLenA(whitesp, ANSI_CHAR_BUFFER); i++) { if (whitesp[i] & 0x7F) { if (!StrChrA(WhiteSpaceCharsAccelerated, whitesp[i])) { StringCchCatNA(WhiteSpaceCharsAccelerated, COUNTOF(WhiteSpaceCharsAccelerated), &(whitesp[i]), 1); @@ -352,7 +307,7 @@ void EditInitWordDelimiter(HWND hwnd) // construct word char array StringCchCopyA(WordCharsAccelerated, COUNTOF(WordCharsAccelerated), WordCharsDefault); // init // add punctuation chars not listed in white-space array - for (size_t i = 0; i < StringCchLenA(PunctuationCharsDefault, ANSI_CAHR_BUFFER); i++) { + for (size_t i = 0; i < StringCchLenA(PunctuationCharsDefault, ANSI_CHAR_BUFFER); i++) { if (!StrChrA(WhiteSpaceCharsAccelerated, PunctuationCharsDefault[i])) { StringCchCatNA(WordCharsAccelerated, COUNTOF(WordCharsAccelerated), &(PunctuationCharsDefault[i]), 1); } @@ -362,10 +317,9 @@ void EditInitWordDelimiter(HWND hwnd) StringCchCopyA(DelimCharsAccel, COUNTOF(DelimCharsAccel), WhiteSpaceCharsDefault); StringCchCatA(DelimCharsAccel, COUNTOF(DelimCharsAccel), lineEnds); - IniGetString(L"Settings2", L"AutoCompleteWordCharSet", L"", buffer, COUNTOF(buffer)); - if (StringCchLen(buffer, COUNTOF(buffer)) > 0) + if (StringCchLen(Settings2.AutoCompleteWordCharSet, COUNTOF(Settings2.AutoCompleteWordCharSet)) > 0) { - WideCharToMultiByteStrg(Encoding_SciCP, buffer, AutoCompleteWordCharSet); + WideCharToMultiByteStrg(Encoding_SciCP, Settings2.AutoCompleteWordCharSet, AutoCompleteWordCharSet); g_bUseLimitedAutoCCharSet = true; } else { WideCharToMultiByteStrg(Encoding_SciCP, W_AUTOC_WORD_ANSI1252, AutoCompleteWordCharSet); @@ -384,7 +338,7 @@ void EditInitWordDelimiter(HWND hwnd) // // _ClearTextBuffer() // -void __fastcall _ClearTextBuffer(HWND hwnd) +void _ClearTextBuffer(HWND hwnd) { UndoRedoRecordingStop(); @@ -395,8 +349,8 @@ void __fastcall _ClearTextBuffer(HWND hwnd) if (SciCall_GetReadOnly()) { SciCall_SetReadOnly(false); } EditClearAllOccurrenceMarkers(hwnd); - if (EditToggleView(g_hwndEdit, false)) { - EditToggleView(g_hwndEdit, true); + if (EditToggleView(Globals.hwndEdit, false)) { + EditToggleView(Globals.hwndEdit, true); } SendMessage(hwnd, SCI_CLEARALL, 0, 0); @@ -413,7 +367,7 @@ void __fastcall _ClearTextBuffer(HWND hwnd) // // _InitTextBuffer() // -void __fastcall _InitTextBuffer(HWND hwnd, const char* lpstrText, DocPos textLen, bool bSetSavePoint) +void _InitTextBuffer(HWND hwnd, const char* lpstrText, DocPos textLen, bool bSetSavePoint) { if (textLen > 0) { SciCall_AddText(textLen, lpstrText); @@ -612,7 +566,7 @@ char* EditGetClipboardText(HWND hwnd, bool bCheckEncoding, int* pLineCount, int* const DocPos iAnchor = SciCall_GetAnchor(); // switch encoding to universal UTF-8 codepage - SendMessage(g_hwndMain,WM_COMMAND,(WPARAM)MAKELONG(IDM_ENCODING_UTF8,1),0); + SendMessage(Globals.hwndMain,WM_COMMAND,(WPARAM)MAKELONG(IDM_ENCODING_UTF8,1),0); // restore and adjust selection if (iPos > iAnchor) { @@ -875,7 +829,7 @@ bool EditCopyAppend(HWND hwnd, bool bAppend) HANDLE const hOld = GetClipboardData(CF_UNICODETEXT); const WCHAR* pszOld = GlobalLock(hOld); - const WCHAR *pszSep = ((g_iEOLMode == SC_EOL_CRLF) ? L"\r\n" : ((g_iEOLMode == SC_EOL_CR) ? L"\r" : L"\n")); + const WCHAR *pszSep = ((Globals.iEOLMode == SC_EOL_CRLF) ? L"\r\n" : ((Globals.iEOLMode == SC_EOL_CR) ? L"\r" : L"\n")); size_t cchNewText = cchTextW; if (pszOld && *pszOld) { @@ -910,7 +864,7 @@ bool EditCopyAppend(HWND hwnd, bool bAppend) int EditDetectEOLMode(HWND hwnd, char* lpData) { UNUSED(hwnd); - int iEOLMode = g_iDefaultEOLMode; + int iEOLMode = Settings.DefaultEOLMode; LPCSTR cp = lpData ? StrPBrkA(lpData, "\r\n") : NULL; @@ -964,7 +918,7 @@ bool EditLoadFile( OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - dwLastIOError = GetLastError(); + g_dwLastIOError = GetLastError(); if (hFile == INVALID_HANDLE_VALUE) { Encoding_SrcCmdLn(CPI_NONE); @@ -990,8 +944,8 @@ bool EditLoadFile( } // Check if a warning message should be displayed for large files - DWORD dwFileSizeLimit = IniGetInt(L"Settings2",L"FileLoadWarningMB",1); - if (dwFileSizeLimit != 0 && dwFileSizeLimit * 1024 * 1024 < dwFileSize) { + DWORD dwFileSizeLimit = Settings2.FileLoadWarningMB; + if ((dwFileSizeLimit != 0) && ((dwFileSizeLimit * 1024 * 1024) < dwFileSize)) { if (InfoBoxLng(MBYESNO,L"MsgFileSizeWarning",IDS_MUI_WARN_LOAD_BIG_FILE) != IDYES) { CloseHandle(hFile); if (pbFileTooBig) @@ -1017,7 +971,7 @@ bool EditLoadFile( char* lpData = AllocMem(dwBufSize, HEAP_ZERO_MEMORY); - dwLastIOError = GetLastError(); + g_dwLastIOError = GetLastError(); if (!lpData) { CloseHandle(hFile); @@ -1030,7 +984,7 @@ bool EditLoadFile( DWORD cbData = 0L; int const readFlag = ReadAndDecryptFile(hwnd, hFile, dwBufSize - 2, &lpData, &cbData); - dwLastIOError = GetLastError(); + g_dwLastIOError = GetLastError(); CloseHandle(hFile); bool bReadSuccess = ((readFlag & DECRYPT_FATAL_ERROR) || (readFlag & DECRYPT_FREAD_FAILED)) ? false : true; @@ -1053,7 +1007,7 @@ bool EditLoadFile( } bool bNfoDizDetected = false; - if (g_bLoadNFOasOEM) + if (Settings.LoadNFOasOEM) { if (lpszExt && !(StringCchCompareXI(lpszExt,L".nfo") && StringCchCompareXI(lpszExt,L".diz"))) bNfoDizDetected = true; @@ -1062,7 +1016,7 @@ bool EditLoadFile( size_t const cbNbytes4Analysis = (cbData < 200000L) ? cbData : 200000L; int iPreferedEncoding = (bNfoDizDetected) ? g_DOSEncoding : - ((bUseDefaultForFileEncoding || (cbNbytes4Analysis == 0)) ? g_iDefaultNewFileEncoding : CPI_ANSI_DEFAULT); + ((Settings.UseDefaultForFileEncoding || (cbNbytes4Analysis == 0)) ? Settings.DefaultEncoding : CPI_ANSI_DEFAULT); // -------------------------------------------------------------------------- bool bIsReliable = false; @@ -1073,7 +1027,7 @@ bool EditLoadFile( bool const bIsUnicode = Encoding_IsUTF8(iAnalyzedEncoding) || Encoding_IsUNICODE(iAnalyzedEncoding); if (iAnalyzedEncoding == CPI_ASCII_7BIT) { - iAnalyzedEncoding = g_bLoadASCIIasUTF8 ? CPI_UTF8 : iPreferedEncoding; // stay on prefered + iAnalyzedEncoding = Settings.LoadASCIIasUTF8 ? CPI_UTF8 : iPreferedEncoding; // stay on prefered } else { if ((bSkipUTFDetection && bIsUnicode) || (bSkipANSICPDetection && !bIsUnicode)) { @@ -1117,10 +1071,10 @@ bool EditLoadFile( if (cbData == 0) { FileVars_Init(NULL,0,&fvCurFile); - *iEOLMode = g_iDefaultEOLMode; - *iEncoding = !Encoding_IsNONE(iForcedEncoding) ? iForcedEncoding : (g_bLoadASCIIasUTF8 ? CPI_UTF8 : iPreferedEncoding); + *iEOLMode = Settings.DefaultEOLMode; + *iEncoding = !Encoding_IsNONE(iForcedEncoding) ? iForcedEncoding : (Settings.LoadASCIIasUTF8 ? CPI_UTF8 : iPreferedEncoding); EditSetNewText(hwnd,"",0); - SendMessage(hwnd,SCI_SETEOLMODE,g_iDefaultEOLMode,0); + SendMessage(hwnd,SCI_SETEOLMODE,Settings.DefaultEOLMode,0); FreeMem(lpData); } // === UNICODE === @@ -1183,14 +1137,14 @@ bool EditLoadFile( FileVars_Init(lpData,cbData,&fvCurFile); // === UTF-8 === - bool const bHardRulesUTF8 = Encoding_IsUTF8(iForcedEncoding) || (FileVars_IsUTF8(&fvCurFile) && !g_bNoEncodingTags); + bool const bHardRulesUTF8 = Encoding_IsUTF8(iForcedEncoding) || (FileVars_IsUTF8(&fvCurFile) && !Settings.NoEncodingTags); bool const bForcedNonUTF8 = !Encoding_IsNONE(iForcedEncoding) && !Encoding_IsUTF8(iForcedEncoding); bool const bValidUTF8 = IsValidUTF8(lpData, cbData); bool const bAnalysisUTF8 = Encoding_IsUTF8(iAnalyzedEncoding) && bIsReliable; bool const bSoftHintUTF8 = Encoding_IsUTF8(iAnalyzedEncoding) || Encoding_IsUTF8(iPreferedEncoding); // non-reliable analysis = soft-hint - bool const bRejectUTF8 = bSkipUTFDetection || bForcedNonUTF8 || (FileVars_IsNonUTF8(&fvCurFile) && !g_bNoEncodingTags); + bool const bRejectUTF8 = bSkipUTFDetection || bForcedNonUTF8 || (FileVars_IsNonUTF8(&fvCurFile) && !Settings.NoEncodingTags); //if (bHardRulesUTF8 || (!bRejectUTF8 && bValidUTF8 && (bIsUTF8Sig || bAnalysisUTF8))) if (bHardRulesUTF8 || (!bRejectUTF8 && bValidUTF8 && (bIsUTF8Sig || bAnalysisUTF8 || bSoftHintUTF8))) // soft-hint = prefer UTF-8 @@ -1302,7 +1256,7 @@ bool EditSaveFile( OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - dwLastIOError = GetLastError(); + g_dwLastIOError = GetLastError(); // failure could be due to missing attributes (2k/XP) if (hFile == INVALID_HANDLE_VALUE) @@ -1318,7 +1272,7 @@ bool EditSaveFile( OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | dwAttributes, NULL); - dwLastIOError = GetLastError(); + g_dwLastIOError = GetLastError(); } } @@ -1326,13 +1280,13 @@ bool EditSaveFile( return false; // ensure consistent line endings - if (bFixLineEndings) { + if (Settings.FixLineEndings) { SendMessage(hwnd,SCI_CONVERTEOLS, SciCall_GetEOLMode(),0); EditFixPositions(hwnd); } // strip trailing blanks - if (bAutoStripBlanks) + if (Settings.FixTrailingBlanks) EditStripLastCharacter(hwnd, true, true); // get text @@ -1342,7 +1296,7 @@ bool EditSaveFile( if (cbData == 0) { bWriteSuccess = SetEndOfFile(hFile); - dwLastIOError = GetLastError(); + g_dwLastIOError = GetLastError(); } else { @@ -1386,7 +1340,7 @@ bool EditSaveFile( _swab((char*)lpDataWide, (char*)lpDataWide, cbDataWide * sizeof(WCHAR)); } bWriteSuccess = EncryptAndWriteFile(hwnd, hFile, (BYTE*)lpDataWide, cbDataWide * sizeof(WCHAR), &dwBytesWritten); - dwLastIOError = GetLastError(); + g_dwLastIOError = GetLastError(); FreeMem(lpDataWide); FreeMem(lpData); @@ -1405,7 +1359,7 @@ bool EditSaveFile( } //bWriteSuccess = WriteFile(hFile,lpData,cbData,&dwBytesWritten,NULL); bWriteSuccess = EncryptAndWriteFile(hwnd, hFile, (BYTE*)lpData, cbData, &dwBytesWritten); - dwLastIOError = GetLastError(); + g_dwLastIOError = GetLastError(); FreeMem(lpData); } @@ -1436,7 +1390,7 @@ bool EditSaveFile( if (!bCancelDataLoss || InfoBoxLng(MBOKCANCEL,L"MsgConv3",IDS_MUI_ERR_UNICODE2) == IDOK) { SetEndOfFile(hFile); bWriteSuccess = EncryptAndWriteFile(hwnd, hFile, (BYTE*)lpData, cbData, &dwBytesWritten); - dwLastIOError = GetLastError(); + g_dwLastIOError = GetLastError(); } else { bWriteSuccess = false; @@ -1449,7 +1403,7 @@ bool EditSaveFile( else { SetEndOfFile(hFile); bWriteSuccess = EncryptAndWriteFile(hwnd, hFile, (BYTE*)lpData, cbData, &dwBytesWritten); - dwLastIOError = GetLastError(); + g_dwLastIOError = GetLastError(); FreeMem(lpData); } } @@ -2326,7 +2280,7 @@ void EditSpacesToTabs(HWND hwnd,int nTabWidth,bool bOnlyIndentingWS) // // _EditMoveLines() // -static void __fastcall _EditMoveLines(bool bMoveUp) +static void _EditMoveLines(bool bMoveUp) { if (SciCall_IsSelectionRectangle()) { MsgBoxLng(MBWARN, IDS_MUI_SELRECT); @@ -3146,7 +3100,7 @@ void EditToggleLineComments(HWND hwnd, LPCWSTR pwszComment, bool bInsertAtStart) // // _AppendSpaces() // -static DocPos __fastcall _AppendSpaces(HWND hwnd, DocLn iLineStart, DocLn iLineEnd, DocPos iMaxColumn, bool bSkipEmpty) +static DocPos _AppendSpaces(HWND hwnd, DocLn iLineStart, DocLn iLineEnd, DocPos iMaxColumn, bool bSkipEmpty) { UNUSED(hwnd); @@ -3849,10 +3803,10 @@ void EditWrapToColumn(HWND hwnd,DocPos nColumn/*,int nTabWidth*/) DocPos iLineLength = 0; //#define W_DELIMITER L"!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~" // underscore counted as part of word - //WCHAR* W_DELIMITER = g_bAccelWordNavigation ? W_DelimCharsAccel : W_DelimChars; + //WCHAR* W_DELIMITER = Settings.AccelWordNavigation ? W_DelimCharsAccel : W_DelimChars; //#define ISDELIMITER(wc) StrChr(W_DELIMITER,wc) - //WCHAR* W_WHITESPACE = g_bAccelWordNavigation ? W_WhiteSpaceCharsAccelerated : W_WhiteSpaceCharsDefault; + //WCHAR* W_WHITESPACE = Settings.AccelWordNavigation ? W_WhiteSpaceCharsAccelerated : W_WhiteSpaceCharsDefault; //#define ISWHITE(wc) StrChr(W_WHITESPACE,wc) #define ISWHITE(wc) StrChr(L" \t\f",wc) @@ -3970,7 +3924,7 @@ void EditSplitLines(HWND hwnd) // // ~_ENTER_TARGET_TRANSACTION_; // ~SciCall_TargetFromSelection(); -// ~SendMessage(g_hwndEdit, SCI_LINESJOIN, 0, 0); +// ~SendMessage(Globals.hwndEdit, SCI_LINESJOIN, 0, 0); // ~_LEAVE_TARGET_TRANSACTION_; // void EditJoinLinesEx(HWND hwnd, bool bPreserveParagraphs, bool bCRLF2Space) @@ -4588,11 +4542,11 @@ void EditGetExcerpt(HWND hwnd,LPWSTR lpszExcerpt,DWORD cchExcerpt) // // _EditSetSearchFlags() // -static void __fastcall _SetSearchFlags(HWND hwnd, LPEDITFINDREPLACE lpefr) +static void _SetSearchFlags(HWND hwnd, LPEDITFINDREPLACE lpefr) { char szBuf[FNDRPL_BUFFER]; - bool bIsFindDlg = (GetDlgItem(g_hwndDlgFindReplace, IDC_REPLACE) == NULL); + bool bIsFindDlg = (GetDlgItem(Globals.hwndDlgFindReplace, IDC_REPLACE) == NULL); GetDlgItemTextW2MB(hwnd, IDC_FINDTEXT, szBuf, COUNTOF(szBuf)); if (StringCchCompareXA(szBuf, lpefr->szFind) != 0) { @@ -4787,7 +4741,7 @@ static void __fastcall _SetSearchFlags(HWND hwnd, LPEDITFINDREPLACE lpefr) // Wildcard search uses the regexp engine to perform a simple search with * ? as wildcards // instead of more advanced and user-unfriendly regexp syntax // for speed, we only need POSIX syntax here -static void __fastcall _EscapeWildcards(char* szFind2, LPCEDITFINDREPLACE lpefr) +static void _EscapeWildcards(char* szFind2, LPCEDITFINDREPLACE lpefr) { char szWildcardEscaped[FNDRPL_BUFFER] = { '\0' }; int iSource = 0; @@ -4838,7 +4792,7 @@ static void __fastcall _EscapeWildcards(char* szFind2, LPCEDITFINDREPLACE lpefr) // // _EditGetFindStrg() // -static int __fastcall _EditGetFindStrg(HWND hwnd, LPCEDITFINDREPLACE lpefr, LPSTR szFind, int cchCnt) +static int _EditGetFindStrg(HWND hwnd, LPCEDITFINDREPLACE lpefr, LPSTR szFind, int cchCnt) { UNUSED(hwnd); if (StringCchLenA(lpefr->szFind, COUNTOF(lpefr->szFind))) { @@ -4869,7 +4823,7 @@ static int __fastcall _EditGetFindStrg(HWND hwnd, LPCEDITFINDREPLACE lpefr, LPST // // _FindInTarget() // -static DocPos __fastcall _FindInTarget(HWND hwnd, LPCSTR szFind, DocPos length, int flags, +static DocPos _FindInTarget(HWND hwnd, LPCSTR szFind, DocPos length, int flags, DocPos* start, DocPos* end, bool bForceNext, FR_UPD_MODES fMode) { DocPos _start = *start; @@ -4927,7 +4881,7 @@ static DocPos __fastcall _FindInTarget(HWND hwnd, LPCSTR szFind, DocPos length, // typedef enum { MATCH = 0, NO_MATCH = 1, INVALID = 2 } RegExResult_t; -static RegExResult_t __fastcall _FindHasMatch(HWND hwnd, LPCEDITFINDREPLACE lpefr, DocPos iStartPos, bool bMarkAll, bool bFirstMatchOnly) +static RegExResult_t _FindHasMatch(HWND hwnd, LPCEDITFINDREPLACE lpefr, DocPos iStartPos, bool bMarkAll, bool bFirstMatchOnly) { char szFind[FNDRPL_BUFFER]; DocPos slen = _EditGetFindStrg(hwnd, lpefr, szFind, COUNTOF(szFind)); @@ -4940,8 +4894,8 @@ static RegExResult_t __fastcall _FindHasMatch(HWND hwnd, LPCEDITFINDREPLACE lpef DocPos end = iTextEnd; const DocPos iPos = _FindInTarget(hwnd, szFind, slen, (int)(lpefr->fuFlags), &start, &end, false, FRMOD_IGNORE); - if (bFirstMatchOnly && !bReplaceInitialized) { - if (GetForegroundWindow() == g_hwndDlgFindReplace) { + if (bFirstMatchOnly && !g_bReplaceInitialized) { + if (GetForegroundWindow() == Globals.hwndDlgFindReplace) { if (iPos >= 0) { SciCall_SetSel(start, end); SciCall_ScrollRange(iPos, iPos); @@ -4966,7 +4920,7 @@ static RegExResult_t __fastcall _FindHasMatch(HWND hwnd, LPCEDITFINDREPLACE lpef // // _DeleteLineStateAll() // -static void __fastcall _DeleteLineStateAll(int const iLineStateBit) +static void _DeleteLineStateAll(int const iLineStateBit) { DocLn const iLastLine = SciCall_GetLineCount(); for (DocLn iLine = 0; iLine < iLastLine; ++iLine) { @@ -4983,7 +4937,7 @@ static void __fastcall _DeleteLineStateAll(int const iLineStateBit) // _DelayMarkAll() // // -static void __fastcall _DelayMarkAll(HWND hwnd, int delay, DocPos iStartPos) +static void _DelayMarkAll(HWND hwnd, int delay, DocPos iStartPos) { static CmdMessageQueue_t mqc = { NULL, WM_COMMAND, (WPARAM)MAKELONG(IDT_TIMER_MAIN_MRKALL, 1), (LPARAM)0 , 0 }; mqc.hwnd = hwnd; @@ -5028,7 +4982,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA // the global static Find/Replace data structure SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam); - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } //sg_pefrData = (LPEDITFINDREPLACE)lParam; sg_pefrData = (LPEDITFINDREPLACE)GetWindowLongPtr(hwnd, DWLP_USER); @@ -5036,19 +4990,19 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA g_iReplacedOccurrences = 0; g_FindReplaceMatchFoundState = FND_NOP; - iSaveMarkOcc = bSwitchedFindReplace ? iSaveMarkOcc : g_iMarkOccurrences; - bSaveOccVisible = bSwitchedFindReplace ? bSaveOccVisible : g_bMarkOccurrencesMatchVisible; + iSaveMarkOcc = s_bSwitchedFindReplace ? iSaveMarkOcc : Settings.MarkOccurrences; + bSaveOccVisible = s_bSwitchedFindReplace ? bSaveOccVisible : Settings.MarkOccurrencesMatchVisible; //const WORD wTabSpacing = (WORD)SendMessage(sg_pefrData->hwnd, SCI_GETTABWIDTH, 0, 0);; // dialog box units //SendDlgItemMessage(hwnd, IDC_FINDTEXT, EM_SETTABSTOPS, 1, (LPARAM)&wTabSpacing); // Load MRUs - for (int i = 0; i < MRU_Count(g_pMRUfind); i++) { - MRU_Enum(g_pMRUfind, i, tchBuf, COUNTOF(tchBuf)); + for (int i = 0; i < MRU_Count(Globals.pMRUfind); i++) { + MRU_Enum(Globals.pMRUfind, i, tchBuf, COUNTOF(tchBuf)); SendDlgItemMessage(hwnd, IDC_FINDTEXT, CB_ADDSTRING, 0, (LPARAM)tchBuf); } - for (int i = 0; i < MRU_Count(g_pMRUreplace); i++) { - MRU_Enum(g_pMRUreplace, i, tchBuf, COUNTOF(tchBuf)); + for (int i = 0; i < MRU_Count(Globals.pMRUreplace); i++) { + MRU_Enum(Globals.pMRUreplace, i, tchBuf, COUNTOF(tchBuf)); SendDlgItemMessage(hwnd, IDC_REPLACETEXT, CB_ADDSTRING, 0, (LPARAM)tchBuf); } @@ -5108,19 +5062,19 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA } if (sg_pefrData->bMarkOccurences) { - g_iMarkOccurrences = 0; - g_bMarkOccurrencesMatchVisible = false; + Settings.MarkOccurrences = 0; + Settings.MarkOccurrencesMatchVisible = false; CheckDlgButton(hwnd, IDC_ALL_OCCURRENCES, BST_CHECKED); - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, false); - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_TOGGLE_VIEW, false); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, false); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_TOGGLE_VIEW, false); DialogEnableWindow(hwnd, IDC_TOGGLE_VISIBILITY, true); } else { CheckDlgButton(hwnd, IDC_ALL_OCCURRENCES, BST_UNCHECKED); DialogEnableWindow(hwnd, IDC_TOGGLE_VISIBILITY, false); - EditClearAllOccurrenceMarkers(g_hwndEdit); + EditClearAllOccurrenceMarkers(Globals.hwndEdit); } - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_MARKOCCUR_VISIBLE, g_bMarkOccurrencesMatchVisible); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_MARKOCCUR_VISIBLE, Settings.MarkOccurrencesMatchVisible); if (sg_pefrData->fuFlags & SCFIND_REGEXP) { @@ -5136,7 +5090,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA } if (GetDlgItem(hwnd, IDC_REPLACE)) { - if (bSwitchedFindReplace) { + if (s_bSwitchedFindReplace) { if (sg_pefrData->bFindClose) CheckDlgButton(hwnd, IDC_FINDCLOSE, BST_CHECKED); } @@ -5146,7 +5100,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA } } else { - if (bSwitchedFindReplace) { + if (s_bSwitchedFindReplace) { if (sg_pefrData->bReplaceClose) CheckDlgButton(hwnd, IDC_FINDCLOSE, BST_CHECKED); } @@ -5156,16 +5110,16 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA } } - if (!bSwitchedFindReplace) { - if (xFindReplaceDlg == 0 || yFindReplaceDlg == 0) + if (!s_bSwitchedFindReplace) { + if (Settings.FindReplaceDlgPosX == 0 || Settings.FindReplaceDlgPosY == 0) CenterDlgInParent(hwnd); else - SetDlgPos(hwnd, xFindReplaceDlg, yFindReplaceDlg); + SetDlgPos(hwnd, Settings.FindReplaceDlgPosX, Settings.FindReplaceDlgPosY); } else { - SetDlgPos(hwnd, xFindReplaceDlgSave, yFindReplaceDlgSave); - bSwitchedFindReplace = false; - CopyMemory(sg_pefrData, &efrSave, sizeof(EDITFINDREPLACE)); + SetDlgPos(hwnd, s_xFindReplaceDlgSave, s_yFindReplaceDlgSave); + s_bSwitchedFindReplace = false; + CopyMemory(sg_pefrData, &s_efrSave, sizeof(EDITFINDREPLACE)); } _SetSearchFlags(hwnd, sg_pefrData); // sync s_anyMatch = s_fwrdMatch = NO_MATCH; @@ -5188,31 +5142,31 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA case WM_DESTROY: { - if (!bSwitchedFindReplace) + if (!s_bSwitchedFindReplace) { if (s_anyMatch == MATCH) { // Save MRUs if (StringCchLenA(sg_pefrData->szFind, COUNTOF(sg_pefrData->szFind))) { if (GetDlgItemText(hwnd, IDC_FINDTEXT, tchBuf, COUNTOF(tchBuf))) { - MRU_Add(g_pMRUfind, tchBuf, 0, 0, NULL); + MRU_Add(Globals.pMRUfind, tchBuf, 0, 0, NULL); SetFindPattern(tchBuf); } } } sg_pefrData->szFind[0] = '\0'; - g_iMarkOccurrences = iSaveMarkOcc; - g_bMarkOccurrencesMatchVisible = bSaveOccVisible; + Settings.MarkOccurrences = iSaveMarkOcc; + Settings.MarkOccurrencesMatchVisible = bSaveOccVisible; - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, true); - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_MARKOCCUR_VISIBLE, true); - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_TOGGLE_VIEW, true); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, true); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_MARKOCCUR_VISIBLE, true); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_TOGGLE_VIEW, true); g_iReplacedOccurrences = 0; g_FindReplaceMatchFoundState = FND_NOP; - if (EditToggleView(g_hwndEdit, false)) { - EditToggleView(g_hwndEdit, true); + if (EditToggleView(Globals.hwndEdit, false)) { + EditToggleView(Globals.hwndEdit, true); } MarkAllOccurrences(50, true); @@ -5222,9 +5176,9 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA } else { if (s_fwrdMatch == NO_MATCH) { - EditSetSelectionEx(g_hwndEdit, s_InitialAnchorPos, s_InitialCaretPos, -1, -1); + EditSetSelectionEx(Globals.hwndEdit, s_InitialAnchorPos, s_InitialCaretPos, -1, -1); } - EditEnsureSelectionVisible(g_hwndEdit); + EditEnsureSelectionVisible(Globals.hwndEdit); } CmdMessageQueue_t* pmqc = NULL; @@ -5268,7 +5222,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA s_InitialTopLine = SciCall_DocLineFromVisible(SciCall_GetFirstVisibleLine()); } - EditEnsureSelectionVisible(g_hwndEdit); + EditEnsureSelectionVisible(Globals.hwndEdit); DialogEnableWindow(hwnd, IDC_REPLACEINSEL, !SciCall_IsSelectionEmpty()); @@ -5340,7 +5294,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA GetFindPattern(tchBuf, FNDRPL_BUFFER); } if (tchBuf[0] == L'\0') { - MRU_Enum(g_pMRUfind, 0, tchBuf, COUNTOF(tchBuf)); + MRU_Enum(Globals.pMRUfind, 0, tchBuf, COUNTOF(tchBuf)); } SetDlgItemText(hwnd, IDC_FINDTEXT, tchBuf); GetDlgItemTextW2MB(hwnd, IDC_FINDTEXT, szFind, FNDRPL_BUFFER); @@ -5362,7 +5316,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA bool bEnableR = (GetWindowTextLengthW(GetDlgItem(hwnd, IDC_REPLACETEXT)) || CB_ERR != SendDlgItemMessage(hwnd, IDC_REPLACETEXT, CB_GETCURSEL, 0, 0)); - bool bEnableIS = !(bool)SendMessage(g_hwndEdit, SCI_GETSELECTIONEMPTY, 0, 0); + bool bEnableIS = !(bool)SendMessage(Globals.hwndEdit, SCI_GETSELECTIONEMPTY, 0, 0); DialogEnableWindow(hwnd, IDOK, bEnableF); DialogEnableWindow(hwnd, IDC_FINDPREV, bEnableF); @@ -5391,26 +5345,26 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA if (sg_pefrData->bMarkOccurences) { if (sg_pefrData->bStateChanged || (StringCchCompareXA(g_lastFind, sg_pefrData->szFind) != 0)) { _IGNORE_NOTIFY_CHANGE_; - if (EditToggleView(g_hwndEdit, false)) { _DeleteLineStateAll(LINESTATE_OCCURRENCE_MARK); } + if (EditToggleView(Globals.hwndEdit, false)) { _DeleteLineStateAll(LINESTATE_OCCURRENCE_MARK); } StringCchCopyA(g_lastFind, COUNTOF(g_lastFind), sg_pefrData->szFind); - RegExResult_t match = _FindHasMatch(g_hwndEdit, sg_pefrData, 0, (sg_pefrData->bMarkOccurences), false); + RegExResult_t match = _FindHasMatch(Globals.hwndEdit, sg_pefrData, 0, (sg_pefrData->bMarkOccurences), false); if (s_anyMatch != match) { s_anyMatch = match; } // we have to set Sci's regex instance to first find (have substitution in place) DocPos const iStartPos = (DocPos)lParam; - s_fwrdMatch = _FindHasMatch(g_hwndEdit, sg_pefrData, iStartPos, false, true); + s_fwrdMatch = _FindHasMatch(Globals.hwndEdit, sg_pefrData, iStartPos, false, true); sg_pefrData->bStateChanged = false; InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, true); if (match != MATCH) { - EditClearAllOccurrenceMarkers(g_hwndEdit); + EditClearAllOccurrenceMarkers(Globals.hwndEdit); if (s_InitialTopLine >= 0) { SciCall_SetFirstVisibleLine(s_InitialTopLine); } else { - EditSetSelectionEx(g_hwndEdit, s_InitialAnchorPos, s_InitialCaretPos, -1, -1); - EditEnsureSelectionVisible(g_hwndEdit); + EditSetSelectionEx(Globals.hwndEdit, s_InitialAnchorPos, s_InitialCaretPos, -1, -1); + EditEnsureSelectionVisible(Globals.hwndEdit); } } - if (EditToggleView(g_hwndEdit, false)) { EditHideNotMarkedLineRange(g_hwndEdit, -1, -1, true); } + if (EditToggleView(Globals.hwndEdit, false)) { EditHideNotMarkedLineRange(Globals.hwndEdit, -1, -1, true); } _OBSERVE_NOTIFY_CHANGE_; } } @@ -5427,30 +5381,30 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA if (IsDlgButtonChecked(hwnd, IDC_ALL_OCCURRENCES) == BST_CHECKED) { - iSaveMarkOcc = g_iMarkOccurrences; - bSaveOccVisible = g_bMarkOccurrencesMatchVisible; + iSaveMarkOcc = Settings.MarkOccurrences; + bSaveOccVisible = Settings.MarkOccurrencesMatchVisible; - g_iMarkOccurrences = 0; - g_bMarkOccurrencesMatchVisible = false; + Settings.MarkOccurrences = 0; + Settings.MarkOccurrencesMatchVisible = false; DialogEnableWindow(hwnd, IDC_TOGGLE_VISIBILITY, true); - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, false); - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_MARKOCCUR_VISIBLE, false); - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_TOGGLE_VIEW, false); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, false); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_MARKOCCUR_VISIBLE, false); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_TOGGLE_VIEW, false); } else { // switched OFF - g_iMarkOccurrences = iSaveMarkOcc; - g_bMarkOccurrencesMatchVisible = bSaveOccVisible; - //DialogEnableWindow(hwnd, IDC_TOGGLE_VISIBILITY, (g_iMarkOccurrences > 0) && !g_bMarkOccurrencesMatchVisible); + Settings.MarkOccurrences = iSaveMarkOcc; + Settings.MarkOccurrencesMatchVisible = bSaveOccVisible; + //DialogEnableWindow(hwnd, IDC_TOGGLE_VISIBILITY, (Settings.MarkOccurrences > 0) && !Settings.MarkOccurrencesMatchVisible); DialogEnableWindow(hwnd, IDC_TOGGLE_VISIBILITY, false); - if (EditToggleView(g_hwndEdit, false)) { + if (EditToggleView(Globals.hwndEdit, false)) { PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_TOGGLE_VISIBILITY, 1), 0); } InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, true); - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, true); - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_MARKOCCUR_VISIBLE, true); - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_TOGGLE_VIEW, true); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_MARKOCCUR_ONOFF, true); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_MARKOCCUR_VISIBLE, true); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_TOGGLE_VIEW, true); } _DelayMarkAll(hwnd, 0, s_InitialSearchStart); } @@ -5458,15 +5412,15 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA case IDC_TOGGLE_VISIBILITY: - if (EditToggleView(g_hwndEdit, false)) { - EditToggleView(g_hwndEdit, true); + if (EditToggleView(Globals.hwndEdit, false)) { + EditToggleView(Globals.hwndEdit, true); sg_pefrData->bStateChanged = true; s_InitialTopLine = -1; - EditClearAllOccurrenceMarkers(g_hwndEdit); + EditClearAllOccurrenceMarkers(Globals.hwndEdit); _DelayMarkAll(hwnd, 0, s_InitialSearchStart); } else { - EditToggleView(g_hwndEdit, true); + EditToggleView(Globals.hwndEdit, true); } break; @@ -5544,16 +5498,16 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA case IDMSG_SWITCHTOFIND: case IDMSG_SWITCHTOREPLACE: { - bool bIsFindDlg = (GetDlgItem(g_hwndDlgFindReplace, IDC_REPLACE) == NULL); + bool bIsFindDlg = (GetDlgItem(Globals.hwndDlgFindReplace, IDC_REPLACE) == NULL); if ((bIsFindDlg && LOWORD(wParam) == IDMSG_SWITCHTOREPLACE || !bIsFindDlg && LOWORD(wParam) == IDMSG_SWITCHTOFIND)) { - GetDlgPos(hwnd, &xFindReplaceDlgSave, &yFindReplaceDlgSave); - bSwitchedFindReplace = true; - CopyMemory(&efrSave, sg_pefrData, sizeof(EDITFINDREPLACE)); + GetDlgPos(hwnd, &s_xFindReplaceDlgSave, &s_yFindReplaceDlgSave); + s_bSwitchedFindReplace = true; + CopyMemory(&s_efrSave, sg_pefrData, sizeof(EDITFINDREPLACE)); } - if (!bSwitchedFindReplace && + if (!s_bSwitchedFindReplace && !GetDlgItemTextW2MB(hwnd, IDC_FINDTEXT, sg_pefrData->szFind, COUNTOF(sg_pefrData->szFind))) { DialogEnableWindow(hwnd, IDOK, false); DialogEnableWindow(hwnd, IDC_FINDPREV, false); @@ -5569,17 +5523,17 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA WCHAR tchBuf2[FNDRPL_BUFFER] = { L'\0' }; - if (!bSwitchedFindReplace) { + if (!s_bSwitchedFindReplace) { // Save MRUs if (StringCchLenA(sg_pefrData->szFind, COUNTOF(sg_pefrData->szFind))) { if (GetDlgItemText(hwnd, IDC_FINDTEXT, tchBuf2, COUNTOF(tchBuf2))) { - MRU_Add(g_pMRUfind, tchBuf2, 0, 0, NULL); + MRU_Add(Globals.pMRUfind, tchBuf2, 0, 0, NULL); SetFindPattern(tchBuf2); } } if (StringCchLenA(sg_pefrData->szReplace, COUNTOF(sg_pefrData->szReplace))) { if (GetDlgItemText(hwnd, IDC_REPLACETEXT, tchBuf2, COUNTOF(tchBuf2))) { - MRU_Add(g_pMRUreplace, tchBuf2, 0, 0, NULL); + MRU_Add(Globals.pMRUreplace, tchBuf2, 0, 0, NULL); } } } @@ -5588,19 +5542,19 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA SendDlgItemMessage(hwnd, IDC_FINDTEXT, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(hwnd, IDC_REPLACETEXT, CB_RESETCONTENT, 0, 0); - for (int i = 0; i < MRU_Count(g_pMRUfind); i++) { - MRU_Enum(g_pMRUfind, i, tchBuf2, COUNTOF(tchBuf2)); + for (int i = 0; i < MRU_Count(Globals.pMRUfind); i++) { + MRU_Enum(Globals.pMRUfind, i, tchBuf2, COUNTOF(tchBuf2)); SendDlgItemMessage(hwnd, IDC_FINDTEXT, CB_ADDSTRING, 0, (LPARAM)tchBuf2); } - for (int i = 0; i < MRU_Count(g_pMRUreplace); i++) { - MRU_Enum(g_pMRUreplace, i, tchBuf2, COUNTOF(tchBuf2)); + for (int i = 0; i < MRU_Count(Globals.pMRUreplace); i++) { + MRU_Enum(Globals.pMRUreplace, i, tchBuf2, COUNTOF(tchBuf2)); SendDlgItemMessage(hwnd, IDC_REPLACETEXT, CB_ADDSTRING, 0, (LPARAM)tchBuf2); } SetDlgItemTextMB2W(hwnd, IDC_FINDTEXT, sg_pefrData->szFind); SetDlgItemTextMB2W(hwnd, IDC_REPLACETEXT, sg_pefrData->szReplace); - if (!bSwitchedFindReplace) + if (!s_bSwitchedFindReplace) SendMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetFocus()), 1); bool bCloseDlg = false; @@ -5619,7 +5573,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA switch (LOWORD(wParam)) { case IDOK: // find next case IDACC_SELTONEXT: - if (!bIsFindDlg) { bReplaceInitialized = true; } + if (!bIsFindDlg) { g_bReplaceInitialized = true; } if (!SciCall_IsSelectionEmpty()) { EditJumpToSelectionEnd(hwnd); } EditFindNext(sg_pefrData->hwnd, sg_pefrData, (LOWORD(wParam) == IDACC_SELTONEXT), HIBYTE(GetKeyState(VK_F3))); s_InitialSearchStart = SciCall_GetSelectionStart(); @@ -5630,7 +5584,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA case IDC_FINDPREV: // find previous case IDACC_SELTOPREV: - if (!bIsFindDlg) { bReplaceInitialized = true; } + if (!bIsFindDlg) { g_bReplaceInitialized = true; } if (!SciCall_IsSelectionEmpty()) { EditJumpToSelectionStart(hwnd); } EditFindPrev(sg_pefrData->hwnd, sg_pefrData, (LOWORD(wParam) == IDACC_SELTOPREV), HIBYTE(GetKeyState(VK_F3))); s_InitialSearchStart = SciCall_GetSelectionStart(); @@ -5641,7 +5595,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA case IDC_REPLACE: { - bReplaceInitialized = true; + g_bReplaceInitialized = true; _BEGIN_UNDO_ACTION_; EditReplace(sg_pefrData->hwnd, sg_pefrData); _END_UNDO_ACTION_; @@ -5649,7 +5603,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA break; case IDC_REPLACEALL: - bReplaceInitialized = true; + g_bReplaceInitialized = true; _BEGIN_UNDO_ACTION_; EditReplaceAll(sg_pefrData->hwnd, sg_pefrData, true); _END_UNDO_ACTION_; @@ -5657,7 +5611,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA case IDC_REPLACEINSEL: if (!SciCall_IsSelectionEmpty()) { - bReplaceInitialized = true; + g_bReplaceInitialized = true; EditReplaceAllInSelection(sg_pefrData->hwnd, sg_pefrData, true); } break; @@ -5695,23 +5649,23 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA break; case IDACC_SAVEPOS: - GetDlgPos(hwnd, &xFindReplaceDlg, &yFindReplaceDlg); + GetDlgPos(hwnd, &Settings.FindReplaceDlgPosX, &Settings.FindReplaceDlgPosY); break; case IDACC_RESETPOS: CenterDlgInParent(hwnd); - xFindReplaceDlg = yFindReplaceDlg = 0; + Settings.FindReplaceDlgPosX = Settings.FindReplaceDlgPosY = 0; break; case IDACC_FINDNEXT: - //SetFocus(g_hwndMain); - //SetForegroundWindow(g_hwndMain); + //SetFocus(Globals.hwndMain); + //SetForegroundWindow(Globals.hwndMain); PostMessage(hwnd, WM_COMMAND, MAKELONG(IDOK, 1), 0); break; case IDACC_FINDPREV: - //SetFocus(g_hwndMain); - //SetForegroundWindow(g_hwndMain); + //SetFocus(Globals.hwndMain); + //SetForegroundWindow(Globals.hwndMain); PostMessage(hwnd, WM_COMMAND, MAKELONG(IDC_FINDPREV, 1), 0); break; @@ -5722,7 +5676,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA case IDACC_SAVEFIND: g_FindReplaceMatchFoundState = FND_NOP; - SendMessage(g_hwndMain, WM_COMMAND, MAKELONG(IDM_EDIT_SAVEFIND, 1), 0); + SendMessage(Globals.hwndMain, WM_COMMAND, MAKELONG(IDM_EDIT_SAVEFIND, 1), 0); SetDlgItemTextMB2W(hwnd, IDC_FINDTEXT, sg_pefrData->szFind); CheckDlgButton(hwnd, IDC_FINDREGEXP, BST_UNCHECKED); CheckDlgButton(hwnd, IDC_DOT_MATCH_ALL, BST_UNCHECKED); @@ -5846,7 +5800,7 @@ HWND EditFindReplaceDlg(HWND hwnd,LPCEDITFINDREPLACE lpefr,bool bReplace) (void)CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_SPEED_OVER_MEMORY); lpefr->hwnd = hwnd; - HWND hDlg = CreateThemedDialogParam(g_hLngResContainer, + HWND hDlg = CreateThemedDialogParam(Globals.hLngResContainer, (bReplace) ? MAKEINTRESOURCEW(IDD_MUI_REPLACE) : MAKEINTRESOURCEW(IDD_MUI_FIND), GetParent(hwnd), EditFindReplaceDlgProcW, @@ -6029,7 +5983,7 @@ void EditMarkAllOccurrences(HWND hwnd, bool bForceClear) EditClearAllOccurrenceMarkers(hwnd); } - if (g_iMarkOccurrences <= 0) { + if (Settings.MarkOccurrences <= 0) { g_iMarkOccurrencesCount = -1; return; } @@ -6039,7 +5993,7 @@ void EditMarkAllOccurrences(HWND hwnd, bool bForceClear) _IGNORE_NOTIFY_CHANGE_; _ENTER_TARGET_TRANSACTION_; - if (g_bMarkOccurrencesMatchVisible) { + if (Settings.MarkOccurrencesMatchVisible) { // get visible lines for update DocLn const iFirstVisibleLine = SciCall_DocLineFromVisible(SciCall_GetFirstVisibleLine()); @@ -6051,10 +6005,10 @@ void EditMarkAllOccurrences(HWND hwnd, bool bForceClear) // !!! don't clear all marks, else this method is re-called // !!! on UpdateUI notification on drawing indicator mark - EditMarkAll(hwnd, NULL, g_bMarkOccurrencesCurrentWord, iPosStart, iPosEnd, g_bMarkOccurrencesMatchCase, g_bMarkOccurrencesMatchWords); + EditMarkAll(hwnd, NULL, Settings.MarkOccurrencesCurrentWord, iPosStart, iPosEnd, Settings.MarkOccurrencesMatchCase, Settings.MarkOccurrencesMatchWholeWords); } else { - EditMarkAll(hwnd, NULL, g_bMarkOccurrencesCurrentWord, 0, Sci_GetDocEndPosition(), g_bMarkOccurrencesMatchCase, g_bMarkOccurrencesMatchWords); + EditMarkAll(hwnd, NULL, Settings.MarkOccurrencesCurrentWord, 0, Sci_GetDocEndPosition(), Settings.MarkOccurrencesMatchCase, Settings.MarkOccurrencesMatchWholeWords); } _LEAVE_TARGET_TRANSACTION_; @@ -6085,7 +6039,7 @@ void EditUpdateVisibleUrlHotspot(bool bEnabled) DocPos iPosStart = SciCall_PositionFromLine(iStartLine); DocPos iPosEnd = SciCall_GetLineEndPosition(iEndLine); - EditUpdateUrlHotspots(g_hwndEdit, iPosStart, iPosEnd, bEnabled); + EditUpdateUrlHotspots(Globals.hwndEdit, iPosStart, iPosEnd, bEnabled); _LEAVE_TARGET_TRANSACTION_; _OBSERVE_NOTIFY_CHANGE_; @@ -6097,7 +6051,7 @@ void EditUpdateVisibleUrlHotspot(bool bEnabled) // // _GetReplaceString() // -static char* __fastcall _GetReplaceString(HWND hwnd, LPCEDITFINDREPLACE lpefr, int* iReplaceMsg) +static char* _GetReplaceString(HWND hwnd, LPCEDITFINDREPLACE lpefr, int* iReplaceMsg) { char* pszReplace = NULL; // replace text of arbitrary size if (StringCchCompareNIA(lpefr->szReplace, FNDRPL_BUFFER, "^c", 2) == 0) { @@ -6356,7 +6310,7 @@ void EditClearAllOccurrenceMarkers(HWND hwnd) SendMessage(hwnd, SCI_SETINDICATORCURRENT, INDIC_NP3_MARK_OCCURANCE, 0); SendMessage(hwnd, SCI_INDICATORCLEARRANGE, 0, SciCall_GetTextLength()); _DeleteLineStateAll(LINESTATE_OCCURRENCE_MARK); - g_iMarkOccurrencesCount = (g_iMarkOccurrences > 0) ? 0 : -1; + g_iMarkOccurrencesCount = (Settings.MarkOccurrences > 0) ? 0 : -1; _OBSERVE_NOTIFY_CHANGE_; } @@ -6385,16 +6339,16 @@ bool EditToggleView(HWND hwnd, bool bToggleView) if (!bHideNonMatchedLines) { bSaveFoldingAvailable = g_bCodeFoldingAvailable; - bSaveShowFolding = g_bShowCodeFolding; - bSaveHyperlinkHotspots = g_bHyperlinkHotspot; - g_bHyperlinkHotspot = false; + bSaveShowFolding = Settings.ShowCodeFolding; + bSaveHyperlinkHotspots = Settings.HyperlinkHotspot; + Settings.HyperlinkHotspot = false; } else { g_bCodeFoldingAvailable = bSaveFoldingAvailable; - g_bShowCodeFolding = bSaveShowFolding; - g_bHyperlinkHotspot = bSaveHyperlinkHotspots; + Settings.ShowCodeFolding = bSaveShowFolding; + Settings.HyperlinkHotspot = bSaveHyperlinkHotspots; } - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_HYPERLINKHOTSPOTS, g_bHyperlinkHotspot); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_HYPERLINKHOTSPOTS, Settings.HyperlinkHotspot); bHideNonMatchedLines = bHideNonMatchedLines ? false : true; // toggle @@ -6467,7 +6421,7 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, DocPos rangeStart, DocPos // exit if selection is not a word and Match whole words only is enabled if (bMatchWords) { DocPos iSelStart2 = 0; - const char* delims = (g_bAccelWordNavigation ? DelimCharsAccel : DelimChars); + const char* delims = (Settings.AccelWordNavigation ? DelimCharsAccel : DelimChars); while ((iSelStart2 <= iSelCount) && pszText[iSelStart2]) { if (StrChrIA(delims, pszText[iSelStart2])) { return; @@ -6515,14 +6469,14 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, DocPos rangeStart, DocPos start = end; end = rangeEnd; - } while ((++g_iMarkOccurrencesCount < g_iMarkOccurrencesMaxCount) && (start < end)); + } while ((++g_iMarkOccurrencesCount < Settings2.MarkOccurrencesMaxCount) && (start < end)); } } //============================================================================= // -// EditCompleteWord() +// EditAutoCompleteWord() // Auto-complete words (by Aleksandar Lekov) // @@ -6534,17 +6488,17 @@ typedef struct WLIST { } WLIST, *PWLIST; -static int __fastcall wordcmp(PWLIST a, PWLIST b) { +static int wordcmp(PWLIST a, PWLIST b) { return StringCchCompareXA(a->word, b->word); } -static int __fastcall wordcmpi(PWLIST a, PWLIST b) { +static int wordcmpi(PWLIST a, PWLIST b) { return StringCchCompareXIA(a->word, b->word); } // ---------------------------------------------- -static const char* __fastcall _strNextLexKeyWord(const char* strg, const char* const wdroot, DocPosCR* pwdlen) +static const char* _strNextLexKeyWord(const char* strg, const char* const wdroot, DocPosCR* pwdlen) { char const sep = ' '; bool found = false; @@ -6573,63 +6527,72 @@ static const char* __fastcall _strNextLexKeyWord(const char* strg, const char* c // ---------------------------------------------- -void EditCompleteWord(HWND hwnd, bool autoInsert) +bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) { - UNUSED(hwnd); + if (SciCall_IsIMEModeCJK()) { + SciCall_AutoCCancel(); + return false; + } - char const* const pchAllowdWordChars = ((g_bIsCJKInputCodePage || g_bUseLimitedAutoCCharSet) ? - AutoCompleteWordCharSet : - (g_bAccelWordNavigation ? WordCharsAccelerated : WordCharsDefault)); + DocPos const iMinWdChCnt = 2; // min number of typed chars before AutoC + + char const* const pchAllowdWordChars = + ((g_bIsCJKInputCodePage || g_bUseLimitedAutoCCharSet) ? AutoCompleteWordCharSet : + (Settings.AccelWordNavigation ? WordCharsAccelerated : WordCharsDefault)); + + SciCall_SetWordChars(pchAllowdWordChars); + DocPos const iDocEndPos = Sci_GetDocEndPosition(); DocPos const iCurrentPos = SciCall_GetCurrentPos(); - DocLn const iLine = SciCall_LineFromPosition(iCurrentPos); - DocPos const iLineStart = SciCall_PositionFromLine(iLine); - DocPos const iCurrentLinePos = iCurrentPos - iLineStart; + DocPos const iCol = SciCall_GetColumn(iCurrentPos); + DocPos const iPosBefore = SciCall_PositionBefore(iCurrentPos); + DocPos const iWordStartPos = SciCall_WordStartPosition(iPosBefore, true); - DocPos iLineLen = SciCall_LineLength(iLine); - const char* pLine = SciCall_GetRangePointer(iLineStart, iLineLen); + if ((iWordStartPos == iPosBefore) || (iCol < iMinWdChCnt) || ((iCurrentPos - iWordStartPos) < iMinWdChCnt)) { + EditSetAccelWordNav(hwnd, Settings.AccelWordNavigation); + return true; + } + DocPos iPos = iWordStartPos; bool bWordAllNumbers = true; - DocPos iStartWordPos = iCurrentLinePos; - while (iStartWordPos > 0 && StrChrIA(pchAllowdWordChars, pLine[iStartWordPos - 1])) { - iStartWordPos--; - if (pLine[iStartWordPos] < '0' || pLine[iStartWordPos] > '9') { + while ((iPos < iCurrentPos) && bWordAllNumbers && (iPos != iDocEndPos)) { + char const ch = SciCall_GetCharAt(iPos); + if (ch < '0' || ch > '9') { bWordAllNumbers = false; } + iPos = SciCall_PositionAfter(iPos); } - - if ((iStartWordPos == iCurrentLinePos) || bWordAllNumbers || ((iCurrentLinePos - iStartWordPos) < 2)) { - return; + if (bWordAllNumbers) { + EditSetAccelWordNav(hwnd, Settings.AccelWordNavigation); + return true; } - char pRoot[_MAX_AUTOC_WORD_LEN]; - DocPosCR const iRootLen = (DocPosCR)(iCurrentLinePos - iStartWordPos); - StringCchCopyNA(pRoot, COUNTOF(pRoot), pLine + iStartWordPos, (size_t)iRootLen); + char pRoot[_MAX_AUTOC_WORD_LEN]; + DocPos const iRootLen = (iCurrentPos - iWordStartPos); + StringCchCopyNA(pRoot, COUNTOF(pRoot), SciCall_GetRangePointer(iWordStartPos, iRootLen), (size_t)iRootLen); int iNumWords = 0; size_t iWListSize = 0; PWLIST pListHead = NULL; - if (g_bAutoCompleteWords) + if (Settings.AutoCompleteWords) { - DocPosCR const iDocLen = (DocPosCR)SciCall_GetTextLength(); struct Sci_TextToFind ft = { { 0, 0 }, 0, { 0, 0 } }; ft.lpstrText = pRoot; - ft.chrg.cpMax = iDocLen; + ft.chrg.cpMax = (DocPosCR)iDocEndPos; DocPos iPosFind = SciCall_FindText(SCFIND_WORDSTART, &ft); PWLIST pwlNewWord = NULL; - while ((iPosFind >= 0) && (iPosFind < iDocLen)) + + while ((iPosFind >= 0) && ((iPosFind + iRootLen) < iDocEndPos)) { - DocPos wordEnd = (DocPosCR)(iPosFind + iRootLen); + DocPos const iWordEndPos = SciCall_WordEndPosition(iPosFind + iRootLen, true); if (iPosFind != (iCurrentPos - iRootLen)) { - while ((wordEnd < iDocLen) && StrChrIA(pchAllowdWordChars, SciCall_GetCharAt(wordEnd))) { ++wordEnd; } - - DocPos const wordLength = (wordEnd - iPosFind); + DocPos const wordLength = (iWordEndPos - iPosFind); if (wordLength > iRootLen) { if (!pwlNewWord) { pwlNewWord = (PWLIST)AllocMem(sizeof(WLIST), HEAP_ZERO_MEMORY); } @@ -6650,15 +6613,15 @@ void EditCompleteWord(HWND hwnd, bool autoInsert) } } } - ft.chrg.cpMin = (DocPosCR)wordEnd; + + ft.chrg.cpMin = (DocPosCR)iWordEndPos; iPosFind = SciCall_FindText(SCFIND_WORDSTART, &ft); } if (pwlNewWord) { FreeMem(pwlNewWord); pwlNewWord = NULL; } } - // -------------------------------------------------------------------------- - - if (g_bAutoCLexerKeyWords) + if (Settings.AutoCLexerKeyWords) + // -------------------------------------------------------------------------- { PKEYWORDLIST const pKeyWordList = Style_GetCurrentLexerPtr()->pKeyWords; @@ -6706,7 +6669,7 @@ void EditCompleteWord(HWND hwnd, bool autoInsert) SciCall_AutoCSetChooseSingle(autoInsert); //SciCall_AutoCSetOrder(SC_ORDER_PERFORMSORT); // already sorted SciCall_AutoCSetFillups("\t\n\r"); - //SciCall_AutoCSetFillups(g_bAccelWordNavigation ? WhiteSpaceCharsDefault : WhiteSpaceCharsAccelerated); + //SciCall_AutoCSetFillups(Settings.AccelWordNavigation ? WhiteSpaceCharsDefault : WhiteSpaceCharsAccelerated); ++iWListSize; // zero termination char* const pList = AllocMem(iWListSize, HEAP_ZERO_MEMORY); @@ -6726,6 +6689,9 @@ void EditCompleteWord(HWND hwnd, bool autoInsert) FreeMem(pList); } } + + EditSetAccelWordNav(hwnd, Settings.AccelWordNavigation); + return true; } @@ -6755,12 +6721,10 @@ void EditUpdateUrlHotspots(HWND hwnd, DocPos startPos, DocPos endPos, bool bActi startPos = SciCall_PositionFromLine(lineNo); endPos = SciCall_GetLineEndPosition(lineNo); } - if (endPos == startPos) - return; + if (endPos == startPos) { return; } DocPos start = startPos; DocPos end = endPos; - do { DocPos const iPos = _FindInTarget(hwnd, pszUrlRegEx, iRegExLen, SCFIND_NP3_REGEX, &start, &end, false, FRMOD_IGNORE); @@ -6814,7 +6778,7 @@ void EditHideNotMarkedLineRange(HWND hwnd, DocPos iStartPos, DocPos iEndPos, boo DocLn const iLnCount = SciCall_GetLineCount(); for (DocLn iLine = 0; iLine < iLnCount; ++iLine) { SciCall_SetFoldLevel(iLine, SC_FOLDLEVELBASE); } SciCall_SetFoldFlags(0); - Style_SetFolding(hwnd, g_bCodeFoldingAvailable && g_bShowCodeFolding); + Style_SetFolding(hwnd, g_bCodeFoldingAvailable && Settings.ShowCodeFolding); EditApplyLexerStyle(hwnd, 0, -1); SciCall_FoldAll(EXPAND); } @@ -6824,7 +6788,7 @@ void EditHideNotMarkedLineRange(HWND hwnd, DocPos iStartPos, DocPos iEndPos, boo // prepare hidden (folding) settings g_bCodeFoldingAvailable = true; // saved before - g_bShowCodeFolding = true; // saved before + Settings.ShowCodeFolding = true; // saved before SciCall_SetProperty("fold", "1"); SciCall_SetProperty("fold.foldsyntaxbased", "1"); SciCall_SetProperty("fold.comment", "1"); @@ -6897,14 +6861,14 @@ void EditHideNotMarkedLineRange(HWND hwnd, DocPos iStartPos, DocPos iEndPos, boo // // EditHighlightIfBrace() // -static bool __fastcall _HighlightIfBrace(HWND hwnd, DocPos iPos) +static bool _HighlightIfBrace(HWND hwnd, DocPos iPos) { UNUSED(hwnd); if (iPos < 0) { // clear indicator SciCall_BraceBadLight(INVALID_POSITION); SciCall_SetHighLightGuide(0); - if (!g_bUseOldStyleBraceMatching) + if (!Settings2.UseOldStyleBraceMatching) SciCall_BraceBadLightIndicator(false, INDIC_NP3_BAD_BRACE); return true; } @@ -6918,14 +6882,14 @@ static bool __fastcall _HighlightIfBrace(HWND hwnd, DocPos iPos) DocPos col2 = SciCall_GetColumn(iBrace2); SciCall_BraceHighLight(iPos, iBrace2); SciCall_SetHighLightGuide(min_p(col1, col2)); - if (!g_bUseOldStyleBraceMatching) { + if (!Settings2.UseOldStyleBraceMatching) { SciCall_BraceHighLightIndicator(true, INDIC_NP3_MATCH_BRACE); } } else { SciCall_BraceBadLight(iPos); SciCall_SetHighLightGuide(0); - if (!g_bUseOldStyleBraceMatching) { + if (!Settings2.UseOldStyleBraceMatching) { SciCall_BraceHighLightIndicator(true, INDIC_NP3_BAD_BRACE); } } @@ -7013,7 +6977,7 @@ INT_PTR CALLBACK EditLinenumDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPa { case WM_INITDIALOG: { - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } DocLn iCurLine = SciCall_LineFromPosition(SciCall_GetCurrentPos())+1; DocPos iCurColumn = SciCall_GetColumn(SciCall_GetCurrentPos()) + 1; @@ -7036,7 +7000,7 @@ INT_PTR CALLBACK EditLinenumDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPa BOOL fTranslated = TRUE; DocLn iNewLine = (DocLn)GetDlgItemInt(hwnd,IDC_LINENUM,&fTranslated,FALSE); - DocLn iMaxLine = (DocLn)SendMessage(g_hwndEdit,SCI_GETLINECOUNT,0,0); + DocLn iMaxLine = (DocLn)SendMessage(Globals.hwndEdit,SCI_GETLINECOUNT,0,0); DocPos iNewCol = 1; BOOL fTranslated2 = TRUE; @@ -7052,7 +7016,7 @@ INT_PTR CALLBACK EditLinenumDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPa if ((iNewLine > 0) && (iNewLine <= iMaxLine) && (iNewCol > 0)) { - EditJumpTo(g_hwndEdit,iNewLine,iNewCol); + EditJumpTo(Globals.hwndEdit,iNewLine,iNewCol); EndDialog(hwnd,IDOK); } else { @@ -7083,7 +7047,7 @@ INT_PTR CALLBACK EditLinenumDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPa bool EditLinenumDlg(HWND hwnd) { - if (IDOK == ThemedDialogBoxParam(g_hLngResContainer,MAKEINTRESOURCE(IDD_MUI_LINENUM), + if (IDOK == ThemedDialogBoxParam(Globals.hLngResContainer,MAKEINTRESOURCE(IDD_MUI_LINENUM), GetParent(hwnd),EditLinenumDlgProc,(LPARAM)hwnd)) return true; @@ -7105,7 +7069,6 @@ typedef struct _modlinesdata { LPWSTR pwsz2; } MODLINESDATA, *PMODLINESDATA; -extern HINSTANCE g_hInstance; INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) { @@ -7129,7 +7092,7 @@ INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM id_hover = 0; id_capture = 0; - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } if (NULL == (hFontNormal = (HFONT)SendDlgItemMessage(hwnd,200,WM_GETFONT,0,0))) hFontNormal = GetStockObject(DEFAULT_GUI_FONT); @@ -7140,7 +7103,7 @@ INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM hCursorNormal = LoadCursor(NULL,IDC_ARROW); hCursorHover = LoadCursor(NULL,IDC_HAND); if (!hCursorHover) - hCursorHover = LoadCursor(g_hInstance, IDC_ARROW); + hCursorHover = LoadCursor(Globals.hInstance, IDC_ARROW); pdata = (PMODLINESDATA)lParam; SetDlgItemTextW(hwnd,100,pdata->pwsz1); @@ -7294,7 +7257,7 @@ bool EditModifyLinesDlg(HWND hwnd,LPWSTR pwsz1,LPWSTR pwsz2) data.pwsz1 = pwsz1; data.pwsz2 = pwsz2; iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCEW(IDD_MUI_MODIFYLINES), hwnd, EditModifyLinesDlgProc, @@ -7323,7 +7286,7 @@ INT_PTR CALLBACK EditAlignDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lPara case WM_INITDIALOG: { piAlignMode = (int*)lParam; - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } CheckRadioButton(hwnd,100,104,*piAlignMode+100); CenterDlgInParent(hwnd); } @@ -7366,7 +7329,7 @@ bool EditAlignDlg(HWND hwnd,int *piAlignMode) INT_PTR iResult; iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCEW(IDD_MUI_ALIGN), hwnd, EditAlignDlgProc, @@ -7398,7 +7361,7 @@ INT_PTR CALLBACK EditEncloseSelectionDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,L case WM_INITDIALOG: { pdata = (PENCLOSESELDATA)lParam; - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,255,0); SetDlgItemTextW(hwnd,100,pdata->pwsz1); SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,255,0); @@ -7437,7 +7400,7 @@ bool EditEncloseSelectionDlg(HWND hwnd,LPWSTR pwszOpen,LPWSTR pwszClose) data.pwsz1 = pwszOpen; data.pwsz2 = pwszClose; iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCEW(IDD_MUI_ENCLOSESELECTION), hwnd, EditEncloseSelectionDlgProc, @@ -7469,7 +7432,7 @@ INT_PTR CALLBACK EditInsertTagDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM l case WM_INITDIALOG: { pdata = (PTAGSDATA)lParam; - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } SendDlgItemMessage(hwnd,100,EM_LIMITTEXT,254,0); SetDlgItemTextW(hwnd,100,L""); SendDlgItemMessage(hwnd,101,EM_LIMITTEXT,255,0); @@ -7566,7 +7529,7 @@ bool EditInsertTagDlg(HWND hwnd,LPWSTR pwszOpen,LPWSTR pwszClose) data.pwsz1 = pwszOpen; data.pwsz2 = pwszClose; iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCEW(IDD_MUI_INSERTTAG), hwnd, EditInsertTagDlgProc, @@ -7597,7 +7560,7 @@ INT_PTR CALLBACK EditSortDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam *piSortFlags = SORT_ASCENDING | SORT_REMZEROLEN; } - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } if (*piSortFlags & SORT_DESCENDING) { CheckRadioButton(hwnd, 100, 102, 101); @@ -7736,7 +7699,7 @@ bool EditSortDlg(HWND hwnd,int* piSortFlags) INT_PTR iResult; iResult = ThemedDialogBoxParam( - g_hLngResContainer, + Globals.hLngResContainer, MAKEINTRESOURCEW(IDD_MUI_SORT), hwnd, EditSortDlgProc, @@ -7753,15 +7716,15 @@ bool EditSortDlg(HWND hwnd,int* piSortFlags) // void EditSetAccelWordNav(HWND hwnd,bool bAccelWordNav) { - g_bAccelWordNavigation = bAccelWordNav; - - if (g_bAccelWordNavigation) { - SendMessage(hwnd, SCI_SETWORDCHARS, 0, (LPARAM)WordCharsAccelerated); - SendMessage(hwnd, SCI_SETWHITESPACECHARS, 0,(LPARAM)WhiteSpaceCharsAccelerated); - SendMessage(hwnd, SCI_SETPUNCTUATIONCHARS,0,(LPARAM)PunctuationCharsAccelerated); + UNUSED(hwnd); + Settings.AccelWordNavigation = bAccelWordNav; + if (Settings.AccelWordNavigation) { + SciCall_SetWordChars(WordCharsAccelerated); + SciCall_SetWhitespaceChars(WhiteSpaceCharsAccelerated); + SciCall_SetPunctuationChars(PunctuationCharsAccelerated); } else - SendMessage(hwnd, SCI_SETCHARSDEFAULT, 0, 0); + SciCall_SetCharsDefault(); } @@ -7820,15 +7783,12 @@ void EditSetBookmarkList(HWND hwnd, LPCWSTR pszBookMarks) // // _SetFileVars() // -extern bool g_bNoEncodingTags; -extern int g_flagNoFileVariables; - -static void __fastcall _SetFileVars(char* lpData, char* tch, LPFILEVARS lpfv) +static void _SetFileVars(char* lpData, char* tch, LPFILEVARS lpfv) { int i; bool bDisableFileVar = false; - if (!g_flagNoFileVariables) { + if (!Flags.NoFileVariables) { if (FileVars_ParseInt(tch, "enable-local-variables", &i) && (!i)) bDisableFileVar = true; @@ -7867,7 +7827,7 @@ static void __fastcall _SetFileVars(char* lpData, char* tch, LPFILEVARS lpfv) } } - if (!IsUTF8Signature(lpData) && !g_bNoEncodingTags && !bDisableFileVar) { + if (!IsUTF8Signature(lpData) && !Settings.NoEncodingTags && !bDisableFileVar) { if (FileVars_ParseStr(tch, "encoding", lpfv->tchEncoding, COUNTOF(lpfv->tchEncoding))) lpfv->mask |= FV_ENCODING; @@ -7877,7 +7837,7 @@ static void __fastcall _SetFileVars(char* lpData, char* tch, LPFILEVARS lpfv) lpfv->mask |= FV_ENCODING; } - if (!g_flagNoFileVariables && !bDisableFileVar) { + if (!Flags.NoFileVariables && !bDisableFileVar) { if (FileVars_ParseStr(tch, "mode", lpfv->tchMode, COUNTOF(lpfv->tchMode))) lpfv->mask |= FV_MODE; } @@ -7893,7 +7853,7 @@ bool FileVars_Init(char *lpData, DWORD cbData, LPFILEVARS lpfv) { char tch[LARGE_BUFFER]; ZeroMemory(lpfv,sizeof(FILEVARS)); - if ((g_flagNoFileVariables && g_bNoEncodingTags) || !lpData || !cbData) + if ((Flags.NoFileVariables && Settings.NoEncodingTags) || !lpData || !cbData) return true; StringCchCopyNA(tch,COUNTOF(tch),lpData,min_s(cbData + 1,COUNTOF(tch))); @@ -7915,61 +7875,58 @@ bool FileVars_Init(char *lpData, DWORD cbData, LPFILEVARS lpfv) { // // FileVars_Apply() // -extern bool bTabsAsSpacesG; -extern bool bTabIndentsG; -extern int iTabWidthG; -extern int iIndentWidthG; -extern bool g_bWordWrap; -extern bool bWordWrapG; -extern int iWordWrapMode; -extern int g_iLongLinesLimit; -extern int iLongLinesLimitG; +extern bool g_bTabsAsSpacesG; +extern bool g_bTabIndentsG; +extern int g_iTabWidthG; +extern int g_iIndentWidthG; +extern bool g_bWordWrapG; +extern int g_iLongLinesLimitG; extern int iWrapCol; bool FileVars_Apply(HWND hwnd,LPFILEVARS lpfv) { if (lpfv->mask & FV_TABWIDTH) - g_iTabWidth = lpfv->iTabWidth; + Settings.TabWidth = lpfv->iTabWidth; else - g_iTabWidth = iTabWidthG; - SendMessage(hwnd,SCI_SETTABWIDTH,g_iTabWidth,0); + Settings.TabWidth = g_iTabWidthG; + SendMessage(hwnd,SCI_SETTABWIDTH,Settings.TabWidth,0); if (lpfv->mask & FV_INDENTWIDTH) - g_iIndentWidth = lpfv->iIndentWidth; + Settings.IndentWidth = lpfv->iIndentWidth; else if (lpfv->mask & FV_TABWIDTH) - g_iIndentWidth = 0; + Settings.IndentWidth = 0; else - g_iIndentWidth = iIndentWidthG; - SendMessage(hwnd,SCI_SETINDENT,g_iIndentWidth,0); + Settings.IndentWidth = g_iIndentWidthG; + SendMessage(hwnd,SCI_SETINDENT,Settings.IndentWidth,0); if (lpfv->mask & FV_TABSASSPACES) - g_bTabsAsSpaces = lpfv->bTabsAsSpaces; + Settings.TabsAsSpaces = lpfv->bTabsAsSpaces; else - g_bTabsAsSpaces = bTabsAsSpacesG; - SendMessage(hwnd,SCI_SETUSETABS,!g_bTabsAsSpaces,0); + Settings.TabsAsSpaces = g_bTabsAsSpacesG; + SendMessage(hwnd,SCI_SETUSETABS,!Settings.TabsAsSpaces,0); if (lpfv->mask & FV_TABINDENTS) - g_bTabIndents = lpfv->bTabIndents; + Settings.TabIndents = lpfv->bTabIndents; else - g_bTabIndents = bTabIndentsG; - SendMessage(g_hwndEdit,SCI_SETTABINDENTS,g_bTabIndents,0); + Settings.TabIndents = g_bTabIndentsG; + SendMessage(Globals.hwndEdit,SCI_SETTABINDENTS,Settings.TabIndents,0); if (lpfv->mask & FV_WORDWRAP) - g_bWordWrap = lpfv->fWordWrap; + Settings.WordWrap = lpfv->fWordWrap; else - g_bWordWrap = bWordWrapG; + Settings.WordWrap = g_bWordWrapG; - if (!g_bWordWrap) - SendMessage(g_hwndEdit,SCI_SETWRAPMODE,SC_WRAP_NONE,0); + if (!Settings.WordWrap) + SendMessage(Globals.hwndEdit,SCI_SETWRAPMODE,SC_WRAP_NONE,0); else - SendMessage(g_hwndEdit,SCI_SETWRAPMODE,(iWordWrapMode == 0) ? SC_WRAP_WHITESPACE : SC_WRAP_CHAR,0); + SendMessage(Globals.hwndEdit,SCI_SETWRAPMODE,(Settings.WordWrapMode == 0) ? SC_WRAP_WHITESPACE : SC_WRAP_CHAR,0); if (lpfv->mask & FV_LONGLINESLIMIT) - g_iLongLinesLimit = lpfv->iLongLinesLimit; + Settings.LongLinesLimit = lpfv->iLongLinesLimit; else - g_iLongLinesLimit = iLongLinesLimitG; + Settings.LongLinesLimit = g_iLongLinesLimitG; - SendMessage(hwnd,SCI_SETEDGECOLUMN,g_iLongLinesLimit,0); + SendMessage(hwnd,SCI_SETEDGECOLUMN,Settings.LongLinesLimit,0); iWrapCol = 0; @@ -8224,7 +8181,7 @@ void EditToggleFolds(FOLD_ACTION action, bool bForceAll) fToggled |= _FoldToggleNode(ln, action); } } - if (fToggled) { EditEnsureSelectionVisible(g_hwndEdit); } + if (fToggled) { EditEnsureSelectionVisible(Globals.hwndEdit); } } } } @@ -8268,14 +8225,14 @@ void EditFoldClick(DocLn ln, int mode) EditFoldPerformAction(ln, mode, SNIFF); if (fGotoFoldPoint) { - EditJumpTo(g_hwndEdit, ln + 1, 0); + EditJumpTo(Globals.hwndEdit, ln + 1, 0); } } void EditFoldAltArrow(FOLD_MOVE move, FOLD_ACTION action) { - if (g_bCodeFoldingAvailable && g_bShowCodeFolding) + if (g_bCodeFoldingAvailable && Settings.ShowCodeFolding) { DocLn ln = SciCall_LineFromPosition(SciCall_GetCurrentPos()); @@ -8287,7 +8244,7 @@ void EditFoldAltArrow(FOLD_MOVE move, FOLD_ACTION action) { if ((SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG) && SciCall_GetLineVisible(ln)) { - EditJumpTo(g_hwndEdit, ln + 1, 0); + EditJumpTo(Globals.hwndEdit, ln + 1, 0); return; } } @@ -8298,7 +8255,7 @@ void EditFoldAltArrow(FOLD_MOVE move, FOLD_ACTION action) { if ((SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG) && SciCall_GetLineVisible(ln)) { - EditJumpTo(g_hwndEdit, ln + 1, 0); + EditJumpTo(Globals.hwndEdit, ln + 1, 0); return; } } diff --git a/src/Edit.h b/src/Edit.h index e8b895c8b..3bcb8bbe6 100644 --- a/src/Edit.h +++ b/src/Edit.h @@ -104,7 +104,7 @@ bool EditToggleView(HWND hwnd, bool bToggleView); void EditMarkAll(HWND, char*, int, DocPos, DocPos, bool, bool); void EditUpdateUrlHotspots(HWND, DocPos, DocPos, bool); void EditSetAccelWordNav(HWND,bool); -void EditCompleteWord(HWND,bool); +bool EditAutoCompleteWord(HWND,bool); void EditGetBookmarkList(HWND,LPWSTR,int); void EditSetBookmarkList(HWND,LPCWSTR); void EditApplyLexerStyle(HWND, DocPos, DocPos); diff --git a/src/Encoding.c b/src/Encoding.c index c04274395..75c4343da 100644 --- a/src/Encoding.c +++ b/src/Encoding.c @@ -48,7 +48,6 @@ int g_DOSEncoding = CPI_NONE; bool g_bForceCompEncDetection = false; -extern HMODULE g_hLngResContainer; extern bool g_bIsCJKInputCodePage; // ============================================================================ @@ -702,7 +701,7 @@ Return value : size (in bytes) of a NULL-terminated UTF-8 string. -1 if invalid NULL-terminated UTF-8 string --*/ -size_t __fastcall UTF8_mbslen_bytes(LPCSTR utf8_string) +size_t UTF8_mbslen_bytes(LPCSTR utf8_string) { size_t length = 0; size_t code_size; @@ -743,7 +742,7 @@ Return value : size (in characters) of a UTF-8 string. -1 if invalid UTF-8 string --*/ -size_t __fastcall UTF8_mbslen(LPCSTR utf8_string, size_t byte_length) +size_t UTF8_mbslen(LPCSTR utf8_string, size_t byte_length) { size_t wchar_length = 0; size_t code_size; @@ -780,7 +779,7 @@ size_t __fastcall UTF8_mbslen(LPCSTR utf8_string, size_t byte_length) } // ---------------------------------------------------------------------------- -bool __fastcall UTF8_ContainsInvalidChars(LPCSTR utf8_string, size_t byte_length) +bool UTF8_ContainsInvalidChars(LPCSTR utf8_string, size_t byte_length) { return ((UTF8_mbslen_bytes(UTF8StringStart(utf8_string)) - 1) != UTF8_mbslen(UTF8StringStart(utf8_string), IsUTF8Signature(utf8_string) ? (byte_length - 3) : byte_length)); diff --git a/src/EncodingCED.cpp b/src/EncodingCED.cpp index 12791e55f..2af7cb876 100644 --- a/src/EncodingCED.cpp +++ b/src/EncodingCED.cpp @@ -291,7 +291,7 @@ extern "C" int Encoding_CountOf() // ============================================================================ -static int __fastcall MapCPI2Encoding(const int iNP3Encoding) +static int MapCPI2Encoding(const int iNP3Encoding) { if ((iNP3Encoding < 0) || (iNP3Encoding >= Encoding_CountOf())) { return UNKNOWN_ENCODING; // CPI_NONE, CPI_GET @@ -305,7 +305,7 @@ static int __fastcall MapCPI2Encoding(const int iNP3Encoding) -static int __fastcall FindCodePage(const Encoding& encoding) +static int FindCodePage(const Encoding& encoding) { int iCodePage = -1; @@ -377,7 +377,7 @@ static int __fastcall FindCodePage(const Encoding& encoding) -static int __fastcall MapEncoding2CPI(const char* const text, const size_t len, const Encoding& encoding, bool* pIsReliable) +static int MapEncoding2CPI(const char* const text, const size_t len, const Encoding& encoding, bool* pIsReliable) { int iNP3Encoding = CPI_NONE; diff --git a/src/Helpers.c b/src/Helpers.c index 4d5438c4a..172ce3675 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -42,12 +42,6 @@ //============================================================================= -extern HINSTANCE g_hInstance; -extern HMODULE g_hLngResContainer; -extern LANGID g_iPrefLANGID; - - -//============================================================================= #if (defined(_DEBUG) || defined(DEBUG)) && !defined(NDEBUG) void DbgLog(const char *fmt, ...) { @@ -273,7 +267,7 @@ bool IniSectionSetString(LPWSTR lpCachedIniSection,LPCWSTR lpName,LPCWSTR lpStri { // TODO: length limit of lpCachedIniSection WCHAR* p = lpCachedIniSection; - if (p) { + if (p && lpString) { while (*p) { p = StrEnd(p,0) + 1; // skip '\0\0's } @@ -305,7 +299,7 @@ DWORD GetLastErrorToMsgBox(LPWSTR lpszFunction, DWORD dwErrID) FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwErrID, - g_iPrefLANGID, + Globals.iPrefLANGID, (LPTSTR)&lpMsgBuf, 0, NULL); @@ -336,7 +330,7 @@ DWORD GetLastErrorToMsgBox(LPWSTR lpszFunction, DWORD dwErrID) UINT GetCurrentDPI(HWND hwnd) { UINT dpi = 0; if (IsWin10()) { - HMODULE const hModule = GetModuleHandle(_T("user32.dll")); + HMODULE const hModule = GetModuleHandle(MKWCS("user32.dll")); if (hModule) { FARPROC const pfnGetDpiForWindow = GetProcAddress(hModule, "GetDpiForWindow"); if (pfnGetDpiForWindow) { @@ -408,9 +402,9 @@ HBITMAP ResizeImageForCurrentDPI(HBITMAP hbmp) UINT const uDPIUnit = (UINT)(USER_DEFAULT_SCREEN_DPI / 2U); UINT uDPIScaleFactor = max_u(1U, (UINT)MulDiv(bmp.bmHeight, 8, 64)); UINT const uDPIBase = (uDPIScaleFactor - 1U) * uDPIUnit; - if (g_uCurrentDPI > (uDPIBase + uDPIUnit)) { - int width = MulDiv(bmp.bmWidth, (g_uCurrentDPI - uDPIBase), uDPIUnit); - int height = MulDiv(bmp.bmHeight, (g_uCurrentDPI - uDPIBase), uDPIUnit); + if (Globals.uCurrentDPI > (uDPIBase + uDPIUnit)) { + int width = MulDiv(bmp.bmWidth, (Globals.uCurrentDPI - uDPIBase), uDPIUnit); + int height = MulDiv(bmp.bmHeight, (Globals.uCurrentDPI - uDPIBase), uDPIUnit); HBITMAP hCopy = CopyImage(hbmp, IMAGE_BITMAP, width, height, LR_CREATEDIBSECTION | LR_COPYRETURNORG | LR_COPYDELETEORG); if (hCopy) { hbmp = hCopy; @@ -678,8 +672,8 @@ bool IsCmdEnabled(HWND hwnd,UINT uId) // int LoadLngStringW(UINT uID, LPWSTR lpBuffer, int nBufferMax) { - const int nLen = LoadStringW(g_hLngResContainer, uID, lpBuffer, nBufferMax); - return (nLen != 0) ? nLen : LoadStringW(g_hInstance, uID, lpBuffer, nBufferMax); + const int nLen = LoadStringW(Globals.hLngResContainer, uID, lpBuffer, nBufferMax); + return (nLen != 0) ? nLen : LoadStringW(Globals.hInstance, uID, lpBuffer, nBufferMax); } //============================================================================= @@ -690,8 +684,8 @@ static WCHAR s_tmpStringBuffer[512]; int LoadLngStringW2MB(UINT uID, LPSTR lpBuffer, int nBufferMax) { - const int nLen = LoadStringW(g_hLngResContainer, uID, s_tmpStringBuffer, COUNTOF(s_tmpStringBuffer)); - if (nLen == 0) { LoadStringW(g_hInstance, uID, s_tmpStringBuffer, COUNTOF(s_tmpStringBuffer)); } + const int nLen = LoadStringW(Globals.hLngResContainer, uID, s_tmpStringBuffer, COUNTOF(s_tmpStringBuffer)); + if (nLen == 0) { LoadStringW(Globals.hInstance, uID, s_tmpStringBuffer, COUNTOF(s_tmpStringBuffer)); } return WideCharToMultiByte(CP_UTF8, 0, s_tmpStringBuffer, -1, lpBuffer, nBufferMax, NULL, NULL); } @@ -701,8 +695,8 @@ int LoadLngStringW2MB(UINT uID, LPSTR lpBuffer, int nBufferMax) // int LoadLngStringA(UINT uID, LPSTR lpBuffer, int nBufferMax) { - const int nLen = LoadStringA(g_hLngResContainer, uID, lpBuffer, nBufferMax); - return (nLen != 0) ? nLen : LoadStringA(g_hInstance, uID, lpBuffer, nBufferMax); + const int nLen = LoadStringA(Globals.hLngResContainer, uID, lpBuffer, nBufferMax); + return (nLen != 0) ? nLen : LoadStringA(Globals.hInstance, uID, lpBuffer, nBufferMax); } @@ -1291,7 +1285,7 @@ void ExpandEnvironmentStringsEx(LPWSTR lpSrc,DWORD dwSrc) // void PathCanonicalizeEx(LPWSTR lpszPath,int len) { - WCHAR szDst[FILE_ARG_BUF] = { L'\0' }; + WCHAR szDst[(MAX_PATH+1)] = { L'\0' }; if (PathCchCanonicalize(szDst,len,lpszPath) == S_OK) StringCchCopy(lpszPath,len,szDst); } @@ -1479,9 +1473,6 @@ UINT CharSetFromCodePage(UINT uCodePage) { } -extern bool g_bPreserveCaretPos; -extern bool g_bSaveFindReplace; - //============================================================================= // // MRU functions @@ -1538,7 +1529,7 @@ bool MRU_Add(LPMRULIST pmru,LPCWSTR pszNew, int iEnc, DocPos iPos, LPCWSTR pszBo pmru->pszItems[0] = StrDup(pszNew); // LocalAlloc() pmru->iEncoding[0] = iEnc; - pmru->iCaretPos[0] = (g_bPreserveCaretPos ? iPos : 0); + pmru->iCaretPos[0] = (Settings.PreserveCaretPos ? iPos : 0); pmru->pszBookMarks[0] = (pszBookMarks ? StrDup(pszBookMarks) : NULL); // LocalAlloc() return true; } @@ -1592,7 +1583,7 @@ bool MRU_AddFile(LPMRULIST pmru,LPCWSTR pszFile,bool bRelativePath,bool bUnexpan pmru->pszItems[0] = StrDup(pszFile); // LocalAlloc() } pmru->iEncoding[0] = iEnc; - pmru->iCaretPos[0] = (g_bPreserveCaretPos ? iPos : 0); + pmru->iCaretPos[0] = (Settings.PreserveCaretPos ? iPos : 0); pmru->pszBookMarks[0] = (pszBookMarks ? StrDup(pszBookMarks) : NULL); // LocalAlloc() return true; @@ -1710,7 +1701,7 @@ bool MRU_Load(LPMRULIST pmru) pmru->iEncoding[n] = Encoding_MapIniSetting(true, iCP); StringCchPrintf(tchName, COUNTOF(tchName), L"POS%.2i", i + 1); - pmru->iCaretPos[n] = (g_bPreserveCaretPos) ? IniSectionGetInt(pIniSection, tchName, 0) : 0; + pmru->iCaretPos[n] = (Settings.PreserveCaretPos) ? IniSectionGetInt(pIniSection, tchName, 0) : 0; StringCchPrintf(tchName, COUNTOF(tchName), L"BMRK%.2i", i + 1); IniSectionGetString(pIniSection, tchName, L"", wchBookMarks, COUNTOF(wchBookMarks)); diff --git a/src/Helpers.h b/src/Helpers.h index 139cebb6b..210bf949c 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -33,22 +33,18 @@ // ============================================================================ -extern WCHAR g_wchIniFile[MAX_PATH]; -extern UINT g_uCurrentDPI; -extern UINT g_uCurrentPPI; - // ============================================================================ -#ifndef _T -#if !defined(ISPP_INVOKED) && (defined(UNICODE) || defined(_UNICODE)) -#define _T(text) L##text -#else -#define _T(text) text -#endif +#ifndef _MKWCS +#define _DO_STRINGIFYA(s) #s +#define _DO_STRINGIFYW(s) L ## #s +#define STRG(s) _DO_STRINGIFYA(s) +#define STRGW(s) _DO_STRINGIFYW(s) + +#define _MKWCS(s) L ## s +#define MKWCS(s) _MKWCS(s) #endif -#define STRGFY(X) L##(X) -#define MKWSTRG(strg) STRGFY(strg) #define UNUSED(expr) (void)(expr) #define SIZEOF(ar) sizeof(ar) @@ -60,24 +56,25 @@ extern UINT g_uCurrentPPI; // ============================================================================ // direct heap allocation - -#define DEFAULT_ALLOC_FLAGS (0) ///~ HEAP_GENERATE_EXCEPTIONS - -extern HANDLE g_hndlProcessHeap; +#if (defined(_DEBUG) || defined(DEBUG)) && !defined(NDEBUG) + #define DEFAULT_ALLOC_FLAGS (HEAP_GENERATE_EXCEPTIONS) +#else + #define DEFAULT_ALLOC_FLAGS (0) +#endif __forceinline LPVOID AllocMem(size_t numBytes, DWORD dwFlags) { - return HeapAlloc(g_hndlProcessHeap, (dwFlags | DEFAULT_ALLOC_FLAGS), numBytes); + return HeapAlloc(Globals.hndlProcessHeap, (dwFlags | DEFAULT_ALLOC_FLAGS), numBytes); } __forceinline bool FreeMem(LPVOID lpMemory) { - return (lpMemory ? HeapFree(g_hndlProcessHeap, 0, lpMemory) : true); + return (lpMemory ? HeapFree(Globals.hndlProcessHeap, 0, lpMemory) : true); } __forceinline size_t SizeOfMem(LPCVOID lpMemory) { - return (lpMemory ? HeapSize(g_hndlProcessHeap, 0, lpMemory) : 0); + return (lpMemory ? HeapSize(Globals.hndlProcessHeap, 0, lpMemory) : 0); } // ============================================================================ @@ -140,19 +137,19 @@ inline bool HasNonZeroFraction(float f) { return ((float2int(f * 10.0f) % 10) != // ---------------------------------------------------------------------------- -#define IniGetString(lpSection,lpName,lpDefault,lpReturnedStr,nSize) GetPrivateProfileString(lpSection,lpName,(lpDefault),(lpReturnedStr),(nSize),g_wchIniFile) -#define IniGetInt(lpSection,lpName,nDefault) GetPrivateProfileInt(lpSection,lpName,(nDefault),g_wchIniFile) -#define IniGetBool(lpSection,lpName,nDefault) (GetPrivateProfileInt(lpSection,lpName,(int)(nDefault),g_wchIniFile) ? true : false) -#define IniSetString(lpSection,lpName,lpString) WritePrivateProfileString(lpSection,lpName,(lpString),g_wchIniFile) -#define IniDeleteSection(lpSection) WritePrivateProfileSection(lpSection,NULL,g_wchIniFile) +#define IniGetString(lpSection,lpName,lpDefault,lpReturnedStr,nSize) GetPrivateProfileString(lpSection,lpName,(lpDefault),(lpReturnedStr),(nSize),Globals.IniFile) +#define IniGetInt(lpSection,lpName,nDefault) GetPrivateProfileInt(lpSection,lpName,(nDefault),Globals.IniFile) +#define IniGetBool(lpSection,lpName,nDefault) (GetPrivateProfileInt(lpSection,lpName,(int)(nDefault),Globals.IniFile) ? true : false) +#define IniSetString(lpSection,lpName,lpString) WritePrivateProfileString(lpSection,lpName,(lpString),Globals.IniFile) +#define IniDeleteSection(lpSection) WritePrivateProfileSection(lpSection,NULL,Globals.IniFile) 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); } #define IniSetBool(lpSection,lpName,nValue) IniSetInt(lpSection,lpName,((nValue) ? 1 : 0)) -#define LoadIniSection(lpSection,lpBuf,cchBuf) GetPrivateProfileSection(lpSection,lpBuf,(cchBuf),g_wchIniFile) -#define SaveIniSection(lpSection,lpBuf) WritePrivateProfileSection(lpSection,lpBuf,g_wchIniFile) +#define LoadIniSection(lpSection,lpBuf,cchBuf) GetPrivateProfileSection(lpSection,lpBuf,(cchBuf),Globals.IniFile) +#define SaveIniSection(lpSection,lpBuf) WritePrivateProfileSection(lpSection,lpBuf,Globals.IniFile) int IniSectionGetString(LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, int); int IniSectionGetInt(LPCWSTR, LPCWSTR, int); @@ -213,11 +210,11 @@ bool SetClipboardTextW(HWND, LPCWSTR, size_t); UINT GetCurrentDPI(HWND hwnd); UINT GetCurrentPPI(HWND hwnd); HBITMAP ResizeImageForCurrentDPI(HBITMAP hbmp); -#define ScaleIntToCurrentDPI(val) MulDiv((val), g_uCurrentDPI, USER_DEFAULT_SCREEN_DPI) -inline int ScaleToCurrentDPI(float fVal) { return float2int((fVal * g_uCurrentDPI) / (float)USER_DEFAULT_SCREEN_DPI); } -#define ScaleIntFontSize(val) MulDiv((val), g_uCurrentDPI, g_uCurrentPPI) -inline int ScaleFontSize(float fSize) { return float2int((fSize * g_uCurrentDPI) / (float)g_uCurrentPPI); } -inline int ScaleFractionalFontSize(float fSize) { return float2int((fSize * 10.0f * g_uCurrentDPI) / (float)g_uCurrentPPI) * 10; } +#define ScaleIntToCurrentDPI(val) MulDiv((val), Globals.uCurrentDPI, USER_DEFAULT_SCREEN_DPI) +inline int ScaleToCurrentDPI(float fVal) { return float2int((fVal * Globals.uCurrentDPI) / (float)USER_DEFAULT_SCREEN_DPI); } +#define ScaleIntFontSize(val) MulDiv((val), Globals.uCurrentDPI, Globals.uCurrentPPI) +inline int ScaleFontSize(float fSize) { return float2int((fSize * Globals.uCurrentDPI) / (float)Globals.uCurrentPPI); } +inline int ScaleFractionalFontSize(float fSize) { return float2int((fSize * 10.0f * Globals.uCurrentDPI) / (float)Globals.uCurrentPPI) * 10; } HRESULT PrivateSetCurrentProcessExplicitAppUserModelID(PCWSTR); bool IsElevated(); @@ -272,16 +269,25 @@ bool PathCreateFavLnk(LPCWSTR,LPCWSTR,LPCWSTR); bool StrLTrim(LPWSTR,LPCWSTR); + inline bool TrimStringA(LPSTR lpString) { if (!lpString || !*lpString) { return false; } StrTrimA(lpString, " "); return true; }; + inline bool TrimStringW(LPWSTR lpString) { if (!lpString || !*lpString) { return false; } StrTrimW(lpString, L" "); return true; }; + +#if (defined(UNICODE) || defined(_UNICODE)) +#define TrimString TrimStringW +#else +#define TrimString TrimStringA +#endif + bool ExtractFirstArgument(LPCWSTR, LPWSTR, LPWSTR, int); void PrepareFilterStr(LPWSTR); @@ -314,25 +320,6 @@ UINT CharSetFromCodePage(UINT); //==== MRU Functions ========================================================== -#define MRU_MAXITEMS 32 -#define MRU_ITEMSFILE 32 -#define MRU_ITEMSFNDRPL 16 -#define MRU_NOCASE 1 -#define MRU_UTF8 2 -#define MRU_BMRK_SIZE 512 - -typedef struct _mrulist -{ - LPCWSTR szRegKey; - int iFlags; - int iSize; - LPWSTR pszItems[MRU_MAXITEMS]; - int iEncoding[MRU_MAXITEMS]; - DocPos iCaretPos[MRU_MAXITEMS]; - LPWSTR pszBookMarks[MRU_MAXITEMS]; -} -MRULIST, *PMRULIST, *LPMRULIST; - LPMRULIST MRU_Create(LPCWSTR,int,int); bool MRU_Destroy(LPMRULIST); diff --git a/src/Notepad3.c b/src/Notepad3.c index fdd67b833..395ad7f9d 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -60,255 +60,48 @@ * Local and global Variables for Notepad3.c * */ -HWND g_hwndMain = NULL; -HWND g_hwndStatus = NULL; -HWND g_hwndToolbar = NULL; -HWND g_hwndDlgFindReplace = NULL; -HWND g_hwndDlgCustomizeSchemes = NULL; -HWND g_hwndReBar = NULL; -HWND hwndEditFrame = NULL; -HWND hwndNextCBChain = NULL; -HICON g_hDlgIcon = NULL; -UINT g_uCurrentDPI = USER_DEFAULT_SCREEN_DPI; -UINT g_uCurrentPPI = USER_DEFAULT_SCREEN_DPI; - -bool g_bExternalBitmap = false; +GLOBALS_T Globals; +SETTINGS_T Settings; +SETTINGS2_T Settings2; +FLAGS_T Flags; +CONSTANTS_T Constants; -#define INISECTIONBUFCNT 32 +static SETTINGS_T Defaults; +static SETTINGS2_T Defaults2; +static FLAGS_T DefaultFlags; -TBBUTTON tbbMainWnd[] = { { 0,IDT_FILE_NEW,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 1,IDT_FILE_OPEN,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 3,IDT_FILE_SAVE,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 2,IDT_FILE_BROWSE,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 0,0,0,BTNS_SEP,0,0 }, - { 4,IDT_EDIT_UNDO,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 5,IDT_EDIT_REDO,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 0,0,0,BTNS_SEP,0,0 }, - { 6,IDT_EDIT_CUT,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 7,IDT_EDIT_COPY,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 8,IDT_EDIT_PASTE,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 0,0,0,BTNS_SEP,0,0 }, - { 9,IDT_EDIT_FIND,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 10,IDT_EDIT_REPLACE,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 0,0,0,BTNS_SEP,0,0 }, - { 11,IDT_VIEW_WORDWRAP,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 0,0,0,BTNS_SEP,0,0 }, - { 23,IDT_VIEW_TOGGLEFOLDS,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 25,IDT_VIEW_TOGGLE_VIEW,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 0,0,0,BTNS_SEP,0,0 }, - { 21,IDT_FILE_OPENFAV,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 22,IDT_FILE_ADDTOFAV,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 0,0,0,BTNS_SEP,0,0 }, - { 12,IDT_VIEW_ZOOMIN,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 13,IDT_VIEW_ZOOMOUT,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 0,0,0,BTNS_SEP,0,0 }, - { 26,IDT_VIEW_CHASING_DOCTAIL,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 0,0,0,BTNS_SEP,0,0 }, - { 14,IDT_VIEW_SCHEME,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 0,0,0,BTNS_SEP,0,0 }, - { 24,IDT_FILE_LAUNCH,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 0,0,0,BTNS_SEP,0,0 }, - { 16,IDT_FILE_EXIT,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 0,0,0,BTNS_SEP,0,0 }, - { 15,IDT_VIEW_SCHEMECONFIG,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 0,0,0,BTNS_SEP,0,0 }, - { 17,IDT_FILE_SAVEAS,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 18,IDT_FILE_SAVECOPY,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 19,IDT_EDIT_CLEAR,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, - { 20,IDT_FILE_PRINT,TBSTATE_ENABLED,BTNS_BUTTON,0,0 } -}; +// ------------------------------------ -#define NUMTOOLBITMAPS 27 -#define NUMINITIALTOOLS 33 -#define TBBUTTON_DEFAULT_IDS L"1 2 4 3 0 5 6 0 7 8 9 0 10 11 0 12 0 24 26 0 22 23 0 13 14 0 27 0 15 0 25 0 17" +static HWND s_hwndEditFrame = NULL; +static HWND s_hwndNextCBChain = NULL; +static HWND s_hwndToolbar = NULL; +static HWND s_hwndReBar = NULL; -HINSTANCE g_hInstance = NULL; -HINSTANCE g_hPrevInst = NULL; -HANDLE g_hScintilla = INVALID_HANDLE_VALUE; -HANDLE g_hwndEdit = INVALID_HANDLE_VALUE; -HANDLE g_hndlProcessHeap = INVALID_HANDLE_VALUE; - -WCHAR g_wchIniFile[MAX_PATH] = { L'\0' }; -WCHAR g_wchIniFile2[MAX_PATH] = { L'\0' }; -static WCHAR g_szTmpFilePath[MAX_PATH] = { L'\0' }; - -static int g_iSettingsVersion = CFG_VER_NONE; -static bool g_bSaveSettings; -static bool g_bEnableSaveSettings; -bool g_bIniFileFromScratch = false; -bool g_bSaveRecentFiles; -bool g_bPreserveCaretPos; -bool g_bSaveFindReplace; -bool g_bFindReplCopySelOrClip = true; - -WCHAR g_tchPrefLngLocName[LOCALE_NAME_MAX_LENGTH]; -LANGID g_iPrefLANGID = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); -HMODULE g_hLngResContainer = NULL; - -static WCHAR* const g_tchAvailableLanguages = L"af-ZA de-DE es-ES en-GB fr-FR ja-JP nl-NL zh-CN"; // en-US internal - -WCHAR g_tchFileDlgFilters[XHUGE_BUFFER] = { L'\0' }; - -WCHAR g_tchLastSaveCopyDir[MAX_PATH] = { L'\0' }; -WCHAR g_tchOpenWithDir[MAX_PATH] = { L'\0' }; -WCHAR g_tchFavoritesDir[MAX_PATH] = { L'\0' }; -WCHAR g_tchAdministrationExe[MAX_PATH] = { L'\0' }; - -static WCHAR g_tchDefaultExtension[64] = { L'\0' }; -static WCHAR g_tchDefaultDir[MAX_PATH] = { L'\0' }; -static WCHAR g_tchToolbarButtons[MIDSZ_BUFFER] = { L'\0' }; - - -static prefix_t g_mxSBPrefix[STATUS_SECTOR_COUNT]; -static prefix_t g_mxSBPostfix[STATUS_SECTOR_COUNT]; - -static int g_iStatusbarSections[STATUS_SECTOR_COUNT] = SBS_INIT_MINUS; -static bool g_iStatusbarVisible[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO; -static int g_vSBSOrder[STATUS_SECTOR_COUNT] = SBS_INIT_MINUS; - -static int g_iStatusbarWidthSpec[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO; - -static WCHAR g_tchToolbarBitmap[MAX_PATH] = { L'\0' }; -static WCHAR g_tchToolbarBitmapHot[MAX_PATH] = { L'\0' }; -static WCHAR g_tchToolbarBitmapDisabled[MAX_PATH] = { L'\0' }; - -static WININFO g_WinInfo = INIT_WININFO; -static WININFO g_DefWinInfo = INIT_WININFO; -static int g_WinCurrentWidth = 0; - -int iPathNameFormat; -bool g_bWordWrap; -bool bWordWrapG; -int iWordWrapMode; -int iWordWrapIndent; -int iWordWrapSymbols; -bool bShowWordWrapSymbols; -bool bMatchBraces; -bool bAutoIndent; -bool bAutoCloseTags; -bool bShowIndentGuides; -bool bHiliteCurrentLine; -bool g_bHyperlinkHotspot; -bool bScrollPastEOF; -bool g_bTabsAsSpaces; -bool bTabsAsSpacesG; -bool g_bTabIndents; -bool bTabIndentsG; -bool bBackspaceUnindents; -int g_iTabWidth; -int iTabWidthG; -int g_iIndentWidth; -int iIndentWidthG; -bool g_bMarkLongLines; -int g_iLongLinesLimit; -int iLongLinesLimitG; -int iLongLineMode; -int iWrapCol = 0; -bool g_bShowSelectionMargin; -bool g_bShowLineNumbers; -bool g_bZeroBasedColumnIndex; -bool g_bZeroBasedCharacterCount; -int g_iReplacedOccurrences; -int g_iMarkOccurrences; -int g_iMarkOccurrencesCount; -int g_iMarkOccurrencesMaxCount; -bool g_bMarkOccurrencesMatchVisible; -bool g_bMarkOccurrencesMatchCase; -bool g_bMarkOccurrencesMatchWords; -bool g_bMarkOccurrencesCurrentWord; -bool g_bUseOldStyleBraceMatching; -bool g_bAutoCompleteWords; -bool g_bAutoCLexerKeyWords; -bool g_bAccelWordNavigation; -bool g_bDenyVirtualSpaceAccess; -bool g_bCodeFoldingAvailable; -bool g_bShowCodeFolding; -bool bViewWhiteSpace; -bool bViewEOLs; -bool bUseDefaultForFileEncoding; -bool bSkipUnicodeDetection; -bool bSkipANSICodePageDetection; -bool g_bLoadASCIIasUTF8 = false; -bool g_bForceLoadASCIIasUTF8 = false; -bool g_bLoadNFOasOEM; -bool g_bNoEncodingTags; -bool bFixLineEndings; -bool bAutoStripBlanks; -int iPrintHeader; -int iPrintFooter; -int iPrintColor; -int iPrintZoom; -RECT pagesetupMargin; -bool bSaveBeforeRunningTools; -int g_iFileWatchingMode; -bool g_bResetFileWatching; -DWORD dwFileCheckInverval; -DWORD dwAutoReloadTimeout; -int iEscFunction; -bool bAlwaysOnTop; -bool bMinimizeToTray; -bool g_bTransparentMode; -bool bShowToolbar; -bool bShowStatusbar; -int iHighDpiToolBar; -int iUpdateDelayHyperlinkStyling; -int iUpdateDelayMarkAllCoccurrences; -int iCurrentLineHorizontalSlop = 0; -int iCurrentLineVerticalSlop = 0; -bool g_bChasingDocTail = false; -bool g_bUseLimitedAutoCCharSet = false; -bool g_bIsCJKInputCodePage = false; +static WCHAR s_wchIniFile2[MAX_PATH + 1] = { L'\0' }; +static WCHAR s_wchTmpFilePath[MAX_PATH + 1] = { L'\0' }; -CALLTIPTYPE g_CallTipType = CT_NONE; +static WCHAR* const s_tchAvailableLanguages = L"af-ZA de-DE es-ES en-GB fr-FR ja-JP nl-NL zh-CN"; // en-US internal +static int s_iSettingsVersion = CFG_VER_NONE; +static bool s_bSaveSettings = true; +static bool s_bEnableSaveSettings = true; -int g_iRenderingTechnology = 0; -const int DirectWriteTechnology[4] = { - SC_TECHNOLOGY_DEFAULT - , SC_TECHNOLOGY_DIRECTWRITE - , SC_TECHNOLOGY_DIRECTWRITERETAIN - , SC_TECHNOLOGY_DIRECTWRITEDC -}; +static prefix_t s_mxSBPrefix[STATUS_SECTOR_COUNT]; +static prefix_t s_mxSBPostfix[STATUS_SECTOR_COUNT]; +static int s_iStatusbarSections[STATUS_SECTOR_COUNT] = SBS_INIT_MINUS; +static bool s_iStatusbarVisible[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO; +static int s_vSBSOrder[STATUS_SECTOR_COUNT] = SBS_INIT_MINUS; + +static int s_iStatusbarWidthSpec[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO; + +static WCHAR s_tchToolbarBitmap[MAX_PATH + 1] = { L'\0' }; +static WCHAR s_tchToolbarBitmapHot[MAX_PATH + 1] = { L'\0' }; +static WCHAR s_tchToolbarBitmapDisabled[MAX_PATH + 1] = { L'\0' }; -static int g_iBidirectional = 0; -const int SciBidirectional[3] = { - SC_BIDIRECTIONAL_DISABLED - , SC_BIDIRECTIONAL_L2R - , SC_BIDIRECTIONAL_R2L -}; - - -int g_iSciFontQuality = 0; -const int FontQuality[4] = { - SC_EFF_QUALITY_DEFAULT - , SC_EFF_QUALITY_NON_ANTIALIASED - , SC_EFF_QUALITY_ANTIALIASED - , SC_EFF_QUALITY_LCD_OPTIMIZED -}; - -bool g_bStickyWinPos; - -bool bIsAppThemed; -int cyReBar; -int cyReBarFrame; -int cxEditFrame; -int cyEditFrame; - -int cxEncodingDlg; -int cyEncodingDlg; -int cxRecodeDlg; -int cyRecodeDlg; -int cxFileMRUDlg; -int cyFileMRUDlg; -int cxOpenWithDlg; -int cyOpenWithDlg; -int cxFavoritesDlg; -int cyFavoritesDlg; -int xFindReplaceDlg; -int yFindReplaceDlg; -int xCustomSchemesDlg; -int yCustomSchemesDlg; +static WININFO s_WinInfo = INIT_WININFO; +static WININFO s_DefWinInfo = INIT_WININFO; +static int s_WinCurrentWidth = 0; #define FILE_LIST_SIZE 32 static LPWSTR lpFileList[FILE_LIST_SIZE] = { NULL }; @@ -322,18 +115,47 @@ static LPWSTR lpEncodingArg = NULL; static WCHAR* const _s_RecentFiles = L"Recent Files"; static WCHAR* const _s_RecentFind = L"Recent Find"; static WCHAR* const _s_RecentReplace = L"Recent Replace"; -LPMRULIST g_pFileMRU; -LPMRULIST g_pMRUfind; -LPMRULIST g_pMRUreplace; -int g_iEOLMode = SC_EOL_CRLF; -int g_iDefaultEOLMode = SC_EOL_CRLF; +static WCHAR s_tchLastSaveCopyDir[MAX_PATH + 1] = { L'\0' }; + +// Globals <= @@@ +bool g_bWordWrapG; +bool g_bTabsAsSpacesG; +bool g_bTabIndentsG; +int g_iTabWidthG; +int g_iIndentWidthG; +int g_iLongLinesLimitG; +bool g_bCodeFoldingAvailable; +bool g_bForceLoadASCIIasUTF8 = false; + + +int iWrapCol = 0; + +bool g_bZeroBasedColumnIndex; +bool g_bZeroBasedCharacterCount; +int g_iReplacedOccurrences; +int g_iMarkOccurrencesCount; + +int iHighDpiToolBar; +bool g_bChasingDocTail = false; +bool g_bUseLimitedAutoCCharSet = false; +bool g_bIsCJKInputCodePage = false; + +bool g_bIniFileFromScratch = false; +bool g_bFindReplCopySelOrClip = true; + +CALLTIPTYPE g_CallTipType = CT_NONE; + + +bool bIsAppThemed; +int cyReBar; +int cyReBarFrame; +int cxEditFrame; +int cyEditFrame; -DWORD dwLastIOError = 0; +DWORD g_dwLastIOError = 0; -int g_iDefaultNewFileEncoding = 0; int g_iDefaultCharSet = 0; -int g_IMEInteraction = 0; int iInitialLine; int iInitialColumn; @@ -356,8 +178,7 @@ HMODULE hRichEdit = NULL; static bool g_bRunningWatch = false; -static EDITFINDREPLACE g_efrData = EFR_INIT_DATA; -bool bReplaceInitialized = false; +bool g_bReplaceInitialized = false; WCHAR wchPrefixSelection[256] = { L'\0' }; WCHAR wchAppendSelection[256] = { L'\0' }; @@ -369,11 +190,8 @@ static int iSortOptions = 0; static int iAlignMode = 0; bool flagIsElevated = false; -WCHAR wchWndClass[16] = L"" APPNAME; +WCHAR wchWndClass[16] = MKWCS(APPNAME); -WCHAR g_wchAppUserModelID[32] = { L'\0' }; -WCHAR g_wchWorkingDirectory[MAX_PATH+2] = { L'\0' }; -WCHAR g_wchCurFile[FILE_ARG_BUF] = { L'\0' }; FILEVARS fvCurFile; bool g_bFileReadOnly = false; @@ -382,15 +200,90 @@ static double g_dExpression = 0.0; static int g_iExprError = -1; +static bool s_bExternalBitmap = false; + +#define INISECTIONBUFCNT 32 + +TBBUTTON tbbMainWnd[] = { { 0,IDT_FILE_NEW,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 1,IDT_FILE_OPEN,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 3,IDT_FILE_SAVE,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 2,IDT_FILE_BROWSE,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 0,0,0,BTNS_SEP,0,0 }, + { 4,IDT_EDIT_UNDO,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 5,IDT_EDIT_REDO,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 0,0,0,BTNS_SEP,0,0 }, + { 6,IDT_EDIT_CUT,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 7,IDT_EDIT_COPY,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 8,IDT_EDIT_PASTE,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 0,0,0,BTNS_SEP,0,0 }, + { 9,IDT_EDIT_FIND,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 10,IDT_EDIT_REPLACE,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 0,0,0,BTNS_SEP,0,0 }, + { 11,IDT_VIEW_WORDWRAP,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 0,0,0,BTNS_SEP,0,0 }, + { 23,IDT_VIEW_TOGGLEFOLDS,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 25,IDT_VIEW_TOGGLE_VIEW,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 0,0,0,BTNS_SEP,0,0 }, + { 21,IDT_FILE_OPENFAV,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 22,IDT_FILE_ADDTOFAV,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 0,0,0,BTNS_SEP,0,0 }, + { 12,IDT_VIEW_ZOOMIN,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 13,IDT_VIEW_ZOOMOUT,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 0,0,0,BTNS_SEP,0,0 }, + { 26,IDT_VIEW_CHASING_DOCTAIL,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 0,0,0,BTNS_SEP,0,0 }, + { 14,IDT_VIEW_SCHEME,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 0,0,0,BTNS_SEP,0,0 }, + { 24,IDT_FILE_LAUNCH,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 0,0,0,BTNS_SEP,0,0 }, + { 16,IDT_FILE_EXIT,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 0,0,0,BTNS_SEP,0,0 }, + { 15,IDT_VIEW_SCHEMECONFIG,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 0,0,0,BTNS_SEP,0,0 }, + { 17,IDT_FILE_SAVEAS,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 18,IDT_FILE_SAVECOPY,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 19,IDT_EDIT_CLEAR,TBSTATE_ENABLED,BTNS_BUTTON,0,0 }, + { 20,IDT_FILE_PRINT,TBSTATE_ENABLED,BTNS_BUTTON,0,0 } +}; + +#define NUMTOOLBITMAPS 27 +#define NUMINITIALTOOLS 33 +#define TBBUTTON_DEFAULT_IDS L"1 2 4 3 0 5 6 0 7 8 9 0 10 11 0 12 0 24 26 0 22 23 0 13 14 0 27 0 15 0 25 0 17" + +//============================================================================= + +static int const DirectWriteTechnology[4] = { + SC_TECHNOLOGY_DEFAULT + , SC_TECHNOLOGY_DIRECTWRITE + , SC_TECHNOLOGY_DIRECTWRITERETAIN + , SC_TECHNOLOGY_DIRECTWRITEDC +}; + +static int const SciBidirectional[3] = { + SC_BIDIRECTIONAL_DISABLED + , SC_BIDIRECTIONAL_L2R + , SC_BIDIRECTIONAL_R2L +}; + + +int const FontQuality[4] = { + SC_EFF_QUALITY_DEFAULT + , SC_EFF_QUALITY_NON_ANTIALIASED + , SC_EFF_QUALITY_ANTIALIASED + , SC_EFF_QUALITY_LCD_OPTIMIZED +}; + +//============================================================================= + // declarations // undo / redo selections static UT_icd UndoRedoSelection_icd = { sizeof(UndoRedoSelection_t), NULL, NULL, NULL }; static UT_array* UndoRedoSelectionUTArray = NULL; -static bool __fastcall _InUndoRedoTransaction(); -static void __fastcall _SaveRedoSelection(int token); -static int __fastcall _SaveUndoSelection(); -static int __fastcall _UndoRedoActionMap(int token, UndoRedoSelection_t* const selection); +static bool _InUndoRedoTransaction(); +static void _SaveRedoSelection(int token); +static int _SaveUndoSelection(); +static int _UndoRedoActionMap(int token, UndoRedoSelection_t* const selection); #ifdef _EXTRA_DRAG_N_DROP_HANDLER_ @@ -400,8 +293,6 @@ static PDROPTARGET pDropTarget = NULL; static DWORD DropFilesProc(CLIPFORMAT cf, HGLOBAL hData, HWND hWnd, DWORD dwKeyState, POINTL pt, void *pUserData); #endif -//============================================================================= - //============================================================================= // @@ -462,7 +353,7 @@ static int msgcmp(void* mqc1, void* mqc2) #define _MQ_ms(T) ((T) / USER_TIMER_MINIMUM) -static void __fastcall _MQ_AppendCmd(CmdMessageQueue_t* const pMsgQCmd, int cycles) +static void _MQ_AppendCmd(CmdMessageQueue_t* const pMsgQCmd, int cycles) { CmdMessageQueue_t* pmqc = NULL; DL_SEARCH(MessageQueue, pmqc, pMsgQCmd, msgcmp); @@ -487,7 +378,7 @@ static void __fastcall _MQ_AppendCmd(CmdMessageQueue_t* const pMsgQCmd, int cycl } // ---------------------------------------------------------------------------- -static void __fastcall _MQ_RemoveCmd(CmdMessageQueue_t* const pMsgQCmd) +static void _MQ_RemoveCmd(CmdMessageQueue_t* const pMsgQCmd) { CmdMessageQueue_t* pmqc; @@ -532,47 +423,32 @@ static void CALLBACK MQ_ExecuteNext(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWOR //============================================================================= // -// Flags -// -int g_flagNoFadeHidden = 0; -int g_flagSimpleIndentGuides = 0; -int g_flagNoHTMLGuess = 0; -int g_flagNoCGIGuess = 0; -int g_flagNoFileVariables = 0; -int g_flagUseSystemMRU = 0; -int g_flagPrintFileAndLeave = 0; - -static int g_flagNoReuseWindow = 0; -static int g_flagReuseWindow = 0; -static int g_flagMultiFileArg = 0; -static int g_flagSingleFileInstance = 0; -static int g_flagStartAsTrayIcon = 0; -static int g_flagAlwaysOnTop = 0; -static int g_flagRelativeFileMRU = 0; -static int g_flagPortableMyDocs = 0; -static int g_flagToolbarLook = 0; -static int g_flagPosParam = 0; -static int g_flagWindowPos = 0; -static int g_flagNewFromClipboard = 0; -static int g_flagPasteBoard = 0; -static int g_flagSetEncoding = 0; -static int g_flagSetEOLMode = 0; -static int g_flagJumpTo = 0; -static int g_flagMatchText = 0; -static int g_flagChangeNotify = 0; -static int g_flagLexerSpecified = 0; -static int g_flagQuietCreate = 0; -static int g_flagRelaunchElevated = 0; -static int g_flagDisplayHelp = 0; -static int g_flagBufferFile = 0; +// Static Flags +// +static int s_flagStartAsTrayIcon = 0; +static int s_flagAlwaysOnTop = 0; +static int s_flagPosParam = 0; +static int s_flagWindowPos = 0; +static int s_flagNewFromClipboard = 0; +static int s_flagPasteBoard = 0; +static int s_flagSetEncoding = 0; +static int s_flagSetEOLMode = 0; +static int s_flagJumpTo = 0; +static int s_flagMatchText = 0; +static int s_flagChangeNotify = 0; +static int s_flagLexerSpecified = 0; +static int s_flagQuietCreate = 0; +static int s_flagRelaunchElevated = 0; +static int s_flagDisplayHelp = 0; +static int s_flagBufferFile = 0; //============================================================================== -// decalarations -static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw); -static void __fastcall _UpdateToolbarDelayed(); -static HMODULE __fastcall _LoadLanguageResources(const WCHAR* localeName, LANGID const langID); -static bool __fastcall _RegisterWndClass(HINSTANCE hInstance); +// static forward declarations +static void _UpdateStatusbarDelayed(bool bForceRedraw); +static void _UpdateToolbarDelayed(); +static bool _RegisterWndClass(HINSTANCE hInstance); +static HMODULE _LoadLanguageResources(const WCHAR* localeName, LANGID const langID); //============================================================================== // @@ -581,7 +457,7 @@ static bool __fastcall _RegisterWndClass(HINSTANCE hInstance); // static bool IsDocumentModified = false; -static void __fastcall _SetDocumentModified(bool bModified) +static void _SetDocumentModified(bool bModified) { if (IsDocumentModified != bModified) { IsDocumentModified = bModified; @@ -589,8 +465,8 @@ static void __fastcall _SetDocumentModified(bool bModified) UpdateStatusbar(false); } if (bModified) { - if (IsWindow(g_hwndDlgFindReplace)) { - SendMessage(g_hwndDlgFindReplace, WM_COMMAND, MAKELONG(IDC_DOC_MODIFIED, 1), 0); + if (IsWindow(Globals.hwndDlgFindReplace)) { + SendMessage(Globals.hwndDlgFindReplace, WM_COMMAND, MAKELONG(IDC_DOC_MODIFIED, 1), 0); } } } @@ -598,6 +474,11 @@ static void __fastcall _SetDocumentModified(bool bModified) //============================================================================== +static void _InitConstants() +{ + Constants.FileBrowserMiniPath = L"minipath.exe"; +} + //============================================================================= // // WinMain() @@ -605,20 +486,20 @@ static void __fastcall _SetDocumentModified(bool bModified) // int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInst, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) { - UNUSED(hPrevInst); + _InitConstants(); - // Set global variable g_hInstance - g_hInstance = hInstance; - g_hPrevInst = hPrevInst; - g_hndlProcessHeap = GetProcessHeap(); + // Set global variable Globals.hInstance + Globals.hInstance = hInstance; + Globals.hPrevInst = hPrevInst; + Globals.hndlProcessHeap = GetProcessHeap(); WCHAR wchAppDir[2 * MAX_PATH + 4] = { L'\0' }; GetModuleFileName(NULL,wchAppDir,COUNTOF(wchAppDir)); PathRemoveFileSpec(wchAppDir); PathCanonicalizeEx(wchAppDir,COUNTOF(wchAppDir)); - if (!GetCurrentDirectory(COUNTOF(g_wchWorkingDirectory),g_wchWorkingDirectory)) { - StringCchCopy(g_wchWorkingDirectory,COUNTOF(g_wchWorkingDirectory),wchAppDir); + if (!GetCurrentDirectory(COUNTOF(Globals.WorkingDirectory),Globals.WorkingDirectory)) { + StringCchCopy(Globals.WorkingDirectory,COUNTOF(Globals.WorkingDirectory),wchAppDir); } // Don't keep working directory locked @@ -646,10 +527,10 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInst, _In_ LoadFlags(); // set AppUserModelID - PrivateSetCurrentProcessExplicitAppUserModelID(g_wchAppUserModelID); + PrivateSetCurrentProcessExplicitAppUserModelID(Settings2.AppUserModelID); // Command Line Help Dialog - if (g_flagDisplayHelp) { + if (s_flagDisplayHelp) { DisplayCmdLineHelp(NULL); return 0; } @@ -657,7 +538,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInst, _In_ // Adapt window class name if (flagIsElevated) StringCchCat(wchWndClass,COUNTOF(wchWndClass),L"U"); - if (g_flagPasteBoard) + if (s_flagPasteBoard) StringCchCat(wchWndClass,COUNTOF(wchWndClass),L"B"); // Relaunch with elevated privileges @@ -681,21 +562,21 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInst, _In_ bool bPrefLngNotAvail = false; int res = 0; - if (StringCchLen(g_tchPrefLngLocName, COUNTOF(g_tchPrefLngLocName)) > 0) + if (StringCchLen(Settings2.PreferredLanguageLocaleName, COUNTOF(Settings2.PreferredLanguageLocaleName)) > 0) { WCHAR wchLngLocalName[LOCALE_NAME_MAX_LENGTH]; - res = ResolveLocaleName(g_tchPrefLngLocName, wchLngLocalName, LOCALE_NAME_MAX_LENGTH); + res = ResolveLocaleName(Settings2.PreferredLanguageLocaleName, wchLngLocalName, LOCALE_NAME_MAX_LENGTH); if (res > 0) { - StringCchCopy(g_tchPrefLngLocName, COUNTOF(g_tchPrefLngLocName), wchLngLocalName); // put back resolved name + StringCchCopy(Settings2.PreferredLanguageLocaleName, COUNTOF(Settings2.PreferredLanguageLocaleName), wchLngLocalName); // put back resolved name } // get LANGID - g_iPrefLANGID = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); - res = GetLocaleInfoEx(g_tchPrefLngLocName, LOCALE_ILANGUAGE | LOCALE_RETURN_NUMBER, (LPWSTR)&g_iPrefLANGID, sizeof(LANGID)); + Globals.iPrefLANGID = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); + res = GetLocaleInfoEx(Settings2.PreferredLanguageLocaleName, LOCALE_ILANGUAGE | LOCALE_RETURN_NUMBER, (LPWSTR)&Globals.iPrefLANGID, sizeof(LANGID)); } if (res == 0) // No preferred language defined or retrievable, try to get User UI Language { - //~GetUserDefaultLocaleName(&g_tchPrefLngLocName[0], COUNTOF(g_tchPrefLngLocName)); + //~GetUserDefaultLocaleName(&Settings2.PreferredLanguageLocaleName[0], COUNTOF(Settings2.PreferredLanguageLocaleName)); ULONG numLngs = 0; DWORD cchLngsBuffer = 0; BOOL hr = GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numLngs, NULL, &cchLngsBuffer); @@ -705,27 +586,27 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInst, _In_ hr = GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numLngs, pwszLngsBuffer, &cchLngsBuffer); if (hr && (numLngs > 0)) { // get the first - StringCchCopy(g_tchPrefLngLocName, COUNTOF(g_tchPrefLngLocName), pwszLngsBuffer); - g_iPrefLANGID = LANGIDFROMLCID(LocaleNameToLCID(g_tchPrefLngLocName, 0)); + StringCchCopy(Settings2.PreferredLanguageLocaleName, COUNTOF(Settings2.PreferredLanguageLocaleName), pwszLngsBuffer); + Globals.iPrefLANGID = LANGIDFROMLCID(LocaleNameToLCID(Settings2.PreferredLanguageLocaleName, 0)); res = 1; } FreeMem(pwszLngsBuffer); } } if (res == 0) { // last try - g_iPrefLANGID = GetUserDefaultUILanguage(); - LCID const lcid = MAKELCID(g_iPrefLANGID, SORT_DEFAULT); - res = LCIDToLocaleName(lcid, g_tchPrefLngLocName, COUNTOF(g_tchPrefLngLocName), 0); + Globals.iPrefLANGID = GetUserDefaultUILanguage(); + LCID const lcid = MAKELCID(Globals.iPrefLANGID, SORT_DEFAULT); + res = LCIDToLocaleName(lcid, Settings2.PreferredLanguageLocaleName, COUNTOF(Settings2.PreferredLanguageLocaleName), 0); } } - g_hLngResContainer = _LoadLanguageResources(g_tchPrefLngLocName, g_iPrefLANGID); + Globals.hLngResContainer = _LoadLanguageResources(Settings2.PreferredLanguageLocaleName, Globals.iPrefLANGID); - if (!g_hLngResContainer) // fallback en-US (1033) + if (!Globals.hLngResContainer) // fallback en-US (1033) { LANGID const langID = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); - g_hLngResContainer = g_hInstance; - if (g_iPrefLANGID != langID) { bPrefLngNotAvail = true; } + Globals.hLngResContainer = Globals.hInstance; + if (Globals.iPrefLANGID != langID) { bPrefLngNotAvail = true; } } // ---------------------------------------------------- @@ -741,19 +622,19 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInst, _In_ hRichEdit = LoadLibrary(L"RICHED20.DLL"); // Use "RichEdit20W" for control in .rc //hRichEdit = LoadLibrary(L"MSFTEDIT.DLL"); // Use "RichEdit50W" for control in .rc - if (!_RegisterWndClass(g_hInstance)) { return 1; } + if (!_RegisterWndClass(Globals.hInstance)) { return 1; } - Scintilla_RegisterClasses(g_hInstance); + Scintilla_RegisterClasses(Globals.hInstance); HMENU hMainMenu = NULL; - if (g_hLngResContainer != g_hInstance) { - hMainMenu = LoadMenu(g_hLngResContainer, MAKEINTRESOURCE(IDR_MUI_MAINMENU)); + if (Globals.hLngResContainer != Globals.hInstance) { + hMainMenu = LoadMenu(Globals.hLngResContainer, MAKEINTRESOURCE(IDR_MUI_MAINMENU)); if (!hMainMenu) { GetLastErrorToMsgBox(L"LoadMenu()", 0); } } - HWND hwnd = InitInstance(g_hInstance, lpCmdLine, nCmdShow); + HWND hwnd = InitInstance(Globals.hInstance, lpCmdLine, nCmdShow); if (!hwnd) { return 1; } if (hMainMenu) { SetMenu(hwnd, hMainMenu); } @@ -769,21 +650,21 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInst, _In_ SetTimer(hwnd, IDT_TIMER_MRKALL, USER_TIMER_MINIMUM, (TIMERPROC)MQ_ExecuteNext); if (bPrefLngNotAvail) { - InfoBoxLng(MBWARN, L"MsgPrefLanguageNotAvailable", IDS_WARN_PREF_LNG_NOT_AVAIL, g_tchPrefLngLocName); + InfoBoxLng(MBWARN, L"MsgPrefLanguageNotAvailable", IDS_WARN_PREF_LNG_NOT_AVAIL, Settings2.PreferredLanguageLocaleName); } MSG msg; while (GetMessage(&msg,NULL,0,0)) { - if (IsWindow(g_hwndDlgFindReplace) && ((msg.hwnd == g_hwndDlgFindReplace) || IsChild(g_hwndDlgFindReplace, msg.hwnd))) + if (IsWindow(Globals.hwndDlgFindReplace) && ((msg.hwnd == Globals.hwndDlgFindReplace) || IsChild(Globals.hwndDlgFindReplace, msg.hwnd))) { - const int iTr = TranslateAccelerator(g_hwndDlgFindReplace, hAccFindReplace, &msg); - if (iTr || IsDialogMessage(g_hwndDlgFindReplace, &msg)) + const int iTr = TranslateAccelerator(Globals.hwndDlgFindReplace, hAccFindReplace, &msg); + if (iTr || IsDialogMessage(Globals.hwndDlgFindReplace, &msg)) continue; } - if (IsWindow(g_hwndDlgCustomizeSchemes) && ((msg.hwnd == g_hwndDlgCustomizeSchemes) || IsChild(g_hwndDlgCustomizeSchemes, msg.hwnd))) { - const int iTr = TranslateAccelerator(g_hwndDlgCustomizeSchemes, hAccCoustomizeSchemes, &msg); - if (iTr || IsDialogMessage(g_hwndDlgCustomizeSchemes, &msg)) + if (IsWindow(Globals.hwndDlgCustomizeSchemes) && ((msg.hwnd == Globals.hwndDlgCustomizeSchemes) || IsChild(Globals.hwndDlgCustomizeSchemes, msg.hwnd))) { + const int iTr = TranslateAccelerator(Globals.hwndDlgCustomizeSchemes, hAccCoustomizeSchemes, &msg); + if (iTr || IsDialogMessage(Globals.hwndDlgCustomizeSchemes, &msg)) continue; } if (!TranslateAccelerator(hwnd,hAccMain,&msg)) { @@ -806,11 +687,11 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInst, _In_ if (hMainMenu) { DestroyMenu(hMainMenu); } Scintilla_ReleaseResources(); - UnregisterClass(wchWndClass, g_hInstance); + UnregisterClass(wchWndClass, Globals.hInstance); OleUninitialize(); - if (g_hLngResContainer != g_hInstance) { FreeMUILibrary(g_hLngResContainer); } + if (Globals.hLngResContainer != Globals.hInstance) { FreeMUILibrary(Globals.hLngResContainer); } return (int)(msg.wParam); } @@ -821,10 +702,10 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInst, _In_ // _RegisterWndClass() // // -static bool __fastcall _RegisterWndClass(HINSTANCE hInstance) +static bool _RegisterWndClass(HINSTANCE hInstance) { - if (!g_hDlgIcon) { - g_hDlgIcon = LoadImage(g_hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, + if (!Globals.hDlgIcon) { + Globals.hDlgIcon = LoadImage(Globals.hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); } @@ -835,7 +716,7 @@ static bool __fastcall _RegisterWndClass(HINSTANCE hInstance) wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; - wc.hIcon = g_hDlgIcon; + wc.hIcon = Globals.hDlgIcon; wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_3DFACE+1); wc.lpszMenuName = MAKEINTRESOURCE(IDR_MUI_MAINMENU); @@ -850,7 +731,7 @@ static bool __fastcall _RegisterWndClass(HINSTANCE hInstance) // _LngStrToMultiLngStr // // -static bool __fastcall _LngStrToMultiLngStr(WCHAR* pLngStr, WCHAR* pLngMultiStr, size_t lngMultiStrSize) +static bool _LngStrToMultiLngStr(WCHAR* pLngStr, WCHAR* pLngMultiStr, size_t lngMultiStrSize) { bool rtnVal = true; @@ -890,13 +771,13 @@ static bool __fastcall _LngStrToMultiLngStr(WCHAR* pLngStr, WCHAR* pLngMultiStr, // _LoadLanguageResources // // -static HMODULE __fastcall _LoadLanguageResources(const WCHAR* localeName, LANGID const langID) +static HMODULE _LoadLanguageResources(const WCHAR* localeName, LANGID const langID) { - bool bLngAvailable = (StrStrIW(g_tchAvailableLanguages, localeName) != NULL); + bool bLngAvailable = (StrStrIW(s_tchAvailableLanguages, localeName) != NULL); if (!bLngAvailable) { return NULL; } WCHAR tchAvailLngs[LARGE_BUFFER] = { L'\0' }; - StringCchCopyW(tchAvailLngs, LARGE_BUFFER, g_tchAvailableLanguages); + StringCchCopyW(tchAvailLngs, LARGE_BUFFER, s_tchAvailableLanguages); WCHAR tchUserLangMultiStrg[LARGE_BUFFER] = { L'\0' }; if (!_LngStrToMultiLngStr(tchAvailLngs, tchUserLangMultiStrg, LARGE_BUFFER)) { @@ -949,7 +830,7 @@ static volatile LONG iWaitCursorStackCounter = 0L; // CheckWaitCursorStack() // // -static bool __fastcall CheckWaitCursorStack() +static bool CheckWaitCursorStack() { return (InterlockedOr(&iWaitCursorStackCounter, 0L) == 0L); } @@ -965,8 +846,8 @@ void BeginWaitCursor(LPCWSTR text) if (CheckWaitCursorStack()) { SciCall_SetCursor(SC_CURSORWAIT); // delayed to SCN_DWELLSTART - StatusSetText(g_hwndStatus, STATUS_HELP, (LPCWSTR)text); - //StatusSetTextID(g_hwndStatus, STATUS_HELP, uid); + StatusSetText(Globals.hwndStatus, STATUS_HELP, (LPCWSTR)text); + //StatusSetTextID(Globals.hwndStatus, STATUS_HELP, uid); } InterlockedIncrement(&iWaitCursorStackCounter); } @@ -987,7 +868,7 @@ void EndWaitCursor() POINT pt; SciCall_SetCursor(SC_CURSORNORMAL); GetCursorPos(&pt); SetCursorPos(pt.x, pt.y); - StatusSetSimple(g_hwndStatus, false); + StatusSetSimple(Globals.hwndStatus, false); UpdateStatusbar(false); } } @@ -998,7 +879,7 @@ void EndWaitCursor() // _InitWindowPosition() // // -static WININFO __fastcall _InitDefaultWndPos(const int flagsPos) +static WININFO _InitDefaultWndPos(const int flagsPos) { RECT rc; GetWindowRect(GetDesktopWindow(), &rc); @@ -1015,7 +896,7 @@ static WININFO __fastcall _InitDefaultWndPos(const int flagsPos) } // ---------------------------------------------------------------------------- -static void __fastcall _InitWindowPosition(WININFO* pWinInfo, const int flagsPos) +static void _InitWindowPosition(WININFO* pWinInfo, const int flagsPos) { WININFO winfo = *pWinInfo; @@ -1026,7 +907,7 @@ static void __fastcall _InitWindowPosition(WININFO* pWinInfo, const int flagsPos } else if (flagsPos == 2) { - winfo = g_DefWinInfo; // NP3 default window position + winfo = s_DefWinInfo; // NP3 default window position } else if (flagsPos == 3) { @@ -1069,7 +950,7 @@ static void __fastcall _InitWindowPosition(WININFO* pWinInfo, const int flagsPos winfo.cy = height; } if (flagsPos & 128) { - winfo = g_DefWinInfo; + winfo = s_DefWinInfo; winfo.max = true; winfo.zoom = 100; } @@ -1093,19 +974,18 @@ static void __fastcall _InitWindowPosition(WININFO* pWinInfo, const int flagsPos // // InitInstance() // -// HWND InitInstance(HINSTANCE hInstance,LPWSTR pszCmdLine,int nCmdShow) { UNUSED(pszCmdLine); - _InitWindowPosition(&g_WinInfo, g_flagWindowPos); - g_WinCurrentWidth = g_WinInfo.cx; + _InitWindowPosition(&s_WinInfo, s_flagWindowPos); + s_WinCurrentWidth = s_WinInfo.cx; // get monitor coordinates from g_WinInfo - WININFO srcninfo = g_WinInfo; + WININFO srcninfo = s_WinInfo; WinInfoToScreen(&srcninfo); - g_hwndMain = CreateWindowEx( + Globals.hwndMain = CreateWindowEx( 0, wchWndClass, TEXT(APPNAME), @@ -1119,30 +999,30 @@ HWND InitInstance(HINSTANCE hInstance,LPWSTR pszCmdLine,int nCmdShow) hInstance, NULL); - if (g_WinInfo.max) { + if (s_WinInfo.max) { nCmdShow = SW_SHOWMAXIMIZED; } - if ((bAlwaysOnTop || g_flagAlwaysOnTop == 2) && g_flagAlwaysOnTop != 1) { - SetWindowPos(g_hwndMain, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + if ((Settings.AlwaysOnTop || s_flagAlwaysOnTop == 2) && s_flagAlwaysOnTop != 1) { + SetWindowPos(Globals.hwndMain, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } - if (g_bTransparentMode) { - SetWindowTransparentMode(g_hwndMain, true); + if (Settings.TransparentMode) { + SetWindowTransparentMode(Globals.hwndMain, true); } - if (g_WinInfo.zoom) { - SciCall_SetZoom(g_WinInfo.zoom); + if (s_WinInfo.zoom) { + SciCall_SetZoom(s_WinInfo.zoom); } // Current file information -- moved in front of ShowWindow() - FileLoad(true,true,false,bSkipUnicodeDetection,bSkipANSICodePageDetection,L""); + FileLoad(true,true,false,Settings.SkipUnicodeDetection,Settings.SkipANSICodePageDetection,L""); - if (!g_flagStartAsTrayIcon) { - ShowWindow(g_hwndMain,nCmdShow); - UpdateWindow(g_hwndMain); + if (!s_flagStartAsTrayIcon) { + ShowWindow(Globals.hwndMain,nCmdShow); + UpdateWindow(Globals.hwndMain); } else { - ShowWindow(g_hwndMain,SW_HIDE); // trick ShowWindow() - ShowNotifyIcon(g_hwndMain,true); + ShowWindow(Globals.hwndMain,SW_HIDE); // trick ShowWindow() + ShowNotifyIcon(Globals.hwndMain,true); } // Source Encoding @@ -1150,41 +1030,41 @@ HWND InitInstance(HINSTANCE hInstance,LPWSTR pszCmdLine,int nCmdShow) Encoding_SrcCmdLn(Encoding_MatchW(lpEncodingArg)); // Pathname parameter - if (g_flagBufferFile || (lpFileArg /*&& !g_flagNewFromClipboard*/)) + if (s_flagBufferFile || (lpFileArg /*&& !g_flagNewFromClipboard*/)) { bool bOpened = false; // Open from Directory - if (!g_flagBufferFile && PathIsDirectory(lpFileArg)) { + if (!s_flagBufferFile && PathIsDirectory(lpFileArg)) { WCHAR tchFile[MAX_PATH] = { L'\0' }; - if (OpenFileDlg(g_hwndMain, tchFile, COUNTOF(tchFile), lpFileArg)) - bOpened = FileLoad(false, false, false, bSkipUnicodeDetection, bSkipANSICodePageDetection, tchFile); + if (OpenFileDlg(Globals.hwndMain, tchFile, COUNTOF(tchFile), lpFileArg)) + bOpened = FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, tchFile); } else { - LPCWSTR lpFileToOpen = g_flagBufferFile ? g_szTmpFilePath : lpFileArg; - bOpened = FileLoad(false, false, false, bSkipUnicodeDetection, bSkipANSICodePageDetection, lpFileToOpen); + LPCWSTR lpFileToOpen = s_flagBufferFile ? s_wchTmpFilePath : lpFileArg; + bOpened = FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, lpFileToOpen); if (bOpened) { - if (g_flagBufferFile) { + if (s_flagBufferFile) { if (lpFileArg) { InstallFileWatching(NULL); // Terminate file watching - StringCchCopy(g_wchCurFile,COUNTOF(g_wchCurFile),lpFileArg); - InstallFileWatching(g_wchCurFile); + StringCchCopy(Globals.CurrentFile,COUNTOF(Globals.CurrentFile),lpFileArg); + InstallFileWatching(Globals.CurrentFile); } else - StringCchCopy(g_wchCurFile,COUNTOF(g_wchCurFile),L""); + StringCchCopy(Globals.CurrentFile,COUNTOF(Globals.CurrentFile),L""); - if (!g_flagLexerSpecified) - Style_SetLexerFromFile(g_hwndEdit,g_wchCurFile); + if (!s_flagLexerSpecified) + Style_SetLexerFromFile(Globals.hwndEdit,Globals.CurrentFile); _SetDocumentModified(true); // check for temp file and delete - if (flagIsElevated && PathFileExists(g_szTmpFilePath)) { - DeleteFile(g_szTmpFilePath); + if (flagIsElevated && PathFileExists(s_wchTmpFilePath)) { + DeleteFile(s_wchTmpFilePath); } } - if (g_flagJumpTo) { // Jump to position - EditJumpTo(g_hwndEdit,iInitialLine,iInitialColumn); + if (s_flagJumpTo) { // Jump to position + EditJumpTo(Globals.hwndEdit,iInitialLine,iInitialColumn); } } } @@ -1193,19 +1073,19 @@ HWND InitInstance(HINSTANCE hInstance,LPWSTR pszCmdLine,int nCmdShow) lpFileArg = NULL; } if (bOpened) { - if (g_flagChangeNotify == 1) { - g_iFileWatchingMode = 0; - g_bResetFileWatching = true; - InstallFileWatching(g_wchCurFile); + if (s_flagChangeNotify == 1) { + Settings.FileWatchingMode = 0; + Settings.ResetFileWatching = true; + InstallFileWatching(Globals.CurrentFile); } - else if (g_flagChangeNotify == 2) { + else if (s_flagChangeNotify == 2) { if (!g_bChasingDocTail) { - SendMessage(g_hwndMain, WM_COMMAND, MAKELONG(IDM_VIEW_CHASING_DOCTAIL, 1), 0); + SendMessage(Globals.hwndMain, WM_COMMAND, MAKELONG(IDM_VIEW_CHASING_DOCTAIL, 1), 0); } else { - g_iFileWatchingMode = 2; - g_bResetFileWatching = true; - InstallFileWatching(g_wchCurFile); + Settings.FileWatchingMode = 2; + Settings.ResetFileWatching = true; + InstallFileWatching(Globals.CurrentFile); } } } @@ -1219,7 +1099,7 @@ HWND InitInstance(HINSTANCE hInstance,LPWSTR pszCmdLine,int nCmdShow) // reset Encoding_SrcCmdLn(CPI_NONE); - g_flagQuietCreate = 0; + s_flagQuietCreate = 0; fKeepTitleExcerpt = 0; // undo / redo selections @@ -1232,66 +1112,66 @@ HWND InitInstance(HINSTANCE hInstance,LPWSTR pszCmdLine,int nCmdShow) utarray_reserve(UndoRedoSelectionUTArray,256); // Check for /c [if no file is specified] -- even if a file is specified - /*else */if (g_flagNewFromClipboard) { - if (SendMessage(g_hwndEdit, SCI_CANPASTE, 0, 0)) { - bool bAutoIndent2 = bAutoIndent; - bAutoIndent = 0; - EditJumpTo(g_hwndEdit, -1, 0); + /*else */if (s_flagNewFromClipboard) { + if (SendMessage(Globals.hwndEdit, SCI_CANPASTE, 0, 0)) { + bool bAutoIndent2 = Settings.AutoIndent; + Settings.AutoIndent = 0; + EditJumpTo(Globals.hwndEdit, -1, 0); _BEGIN_UNDO_ACTION_; - if (SendMessage(g_hwndEdit, SCI_GETLENGTH, 0, 0) > 0) { - SendMessage(g_hwndEdit, SCI_NEWLINE, 0, 0); + if (SendMessage(Globals.hwndEdit, SCI_GETLENGTH, 0, 0) > 0) { + SendMessage(Globals.hwndEdit, SCI_NEWLINE, 0, 0); } - SendMessage(g_hwndEdit, SCI_PASTE, 0, 0); - SendMessage(g_hwndEdit, SCI_NEWLINE, 0, 0); + SendMessage(Globals.hwndEdit, SCI_PASTE, 0, 0); + SendMessage(Globals.hwndEdit, SCI_NEWLINE, 0, 0); _END_UNDO_ACTION_; - bAutoIndent = bAutoIndent2; - if (g_flagJumpTo) - EditJumpTo(g_hwndEdit, iInitialLine, iInitialColumn); + Settings.AutoIndent = bAutoIndent2; + if (s_flagJumpTo) + EditJumpTo(Globals.hwndEdit, iInitialLine, iInitialColumn); else - EditEnsureSelectionVisible(g_hwndEdit); + EditEnsureSelectionVisible(Globals.hwndEdit); } } // Encoding - if (0 != g_flagSetEncoding) { + if (0 != s_flagSetEncoding) { SendMessage( - g_hwndMain, + Globals.hwndMain, WM_COMMAND, - MAKELONG(IDM_ENCODING_ANSI + g_flagSetEncoding -1,1), + MAKELONG(IDM_ENCODING_ANSI + s_flagSetEncoding -1,1), 0); - g_flagSetEncoding = 0; + s_flagSetEncoding = 0; } // EOL mode - if (0 != g_flagSetEOLMode) { + if (0 != s_flagSetEOLMode) { SendMessage( - g_hwndMain, + Globals.hwndMain, WM_COMMAND, - MAKELONG(IDM_LINEENDINGS_CRLF + g_flagSetEOLMode -1,1), + MAKELONG(IDM_LINEENDINGS_CRLF + s_flagSetEOLMode -1,1), 0); - g_flagSetEOLMode = 0; + s_flagSetEOLMode = 0; } // Match Text - if (g_flagMatchText && lpMatchArg) { - if (StrIsNotEmpty(lpMatchArg) && SendMessage(g_hwndEdit,SCI_GETLENGTH,0,0)) { + if (s_flagMatchText && lpMatchArg) { + if (StrIsNotEmpty(lpMatchArg) && SendMessage(Globals.hwndEdit,SCI_GETLENGTH,0,0)) { - WideCharToMultiByteStrg(Encoding_SciCP,lpMatchArg,g_efrData.szFind); + WideCharToMultiByteStrg(Encoding_SciCP,lpMatchArg,Settings.EFR_Data.szFind); - if (g_flagMatchText & 4) - g_efrData.fuFlags |= (SCFIND_REGEXP | SCFIND_POSIX); - else if (g_flagMatchText & 8) - g_efrData.bTransformBS = true; + if (s_flagMatchText & 4) + Settings.EFR_Data.fuFlags |= (SCFIND_REGEXP | SCFIND_POSIX); + else if (s_flagMatchText & 8) + Settings.EFR_Data.bTransformBS = true; - if (g_flagMatchText & 2) { - if (!g_flagJumpTo) { SendMessage(g_hwndEdit, SCI_DOCUMENTEND, 0, 0); } - EditFindPrev(g_hwndEdit,&g_efrData,false,false); - EditEnsureSelectionVisible(g_hwndEdit); + if (s_flagMatchText & 2) { + if (!s_flagJumpTo) { SendMessage(Globals.hwndEdit, SCI_DOCUMENTEND, 0, 0); } + EditFindPrev(Globals.hwndEdit,&Settings.EFR_Data,false,false); + EditEnsureSelectionVisible(Globals.hwndEdit); } else { - if (!g_flagJumpTo) { SendMessage(g_hwndEdit, SCI_DOCUMENTSTART, 0, 0); } - EditFindNext(g_hwndEdit,&g_efrData,false,false); - EditEnsureSelectionVisible(g_hwndEdit); + if (!s_flagJumpTo) { SendMessage(Globals.hwndEdit, SCI_DOCUMENTSTART, 0, 0); } + EditFindNext(Globals.hwndEdit,&Settings.EFR_Data,false,false); + EditEnsureSelectionVisible(Globals.hwndEdit); } } LocalFree(lpMatchArg); // StrDup() @@ -1299,48 +1179,48 @@ HWND InitInstance(HINSTANCE hInstance,LPWSTR pszCmdLine,int nCmdShow) } // Check for Paste Board option -- after loading files - if (g_flagPasteBoard) { + if (s_flagPasteBoard) { bLastCopyFromMe = true; - hwndNextCBChain = SetClipboardViewer(g_hwndMain); + s_hwndNextCBChain = SetClipboardViewer(Globals.hwndMain); uidsAppTitle = IDS_MUI_APPTITLE_PASTEBOARD; bLastCopyFromMe = false; dwLastCopyTime = 0; - SetTimer(g_hwndMain,ID_PASTEBOARDTIMER,100,PasteBoardTimer); + SetTimer(Globals.hwndMain,ID_PASTEBOARDTIMER,100,PasteBoardTimer); } // check if a lexer was specified from the command line - if (g_flagLexerSpecified) { + if (s_flagLexerSpecified) { if (lpSchemeArg) { - Style_SetLexerFromName(g_hwndEdit,g_wchCurFile,lpSchemeArg); + Style_SetLexerFromName(Globals.hwndEdit,Globals.CurrentFile,lpSchemeArg); LocalFree(lpSchemeArg); // StrDup() } else if (iInitialLexer >=0 && iInitialLexer < NUMLEXERS) - Style_SetLexerFromID(g_hwndEdit,iInitialLexer); - g_flagLexerSpecified = 0; + Style_SetLexerFromID(Globals.hwndEdit,iInitialLexer); + s_flagLexerSpecified = 0; } // If start as tray icon, set current filename as tooltip - if (g_flagStartAsTrayIcon) - SetNotifyIconTitle(g_hwndMain); + if (s_flagStartAsTrayIcon) + SetNotifyIconTitle(Globals.hwndMain); g_iReplacedOccurrences = 0; - g_iMarkOccurrencesCount = (g_iMarkOccurrences > 0) ? 0 : -1; + g_iMarkOccurrencesCount = (Settings.MarkOccurrences > 0) ? 0 : -1; UpdateToolbar(); UpdateStatusbar(false); UpdateMarginWidth(); // print file immediately and quit - if (g_flagPrintFileAndLeave) + if (Flags.PrintFileAndLeave) { SHFILEINFO shfi; WCHAR *pszTitle; WCHAR tchUntitled[32] = { L'\0' }; WCHAR tchPageFmt[32] = { L'\0' }; - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { - SHGetFileInfo2(g_wchCurFile, FILE_ATTRIBUTE_NORMAL, &shfi, sizeof(SHFILEINFO), SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES); + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { + SHGetFileInfo2(Globals.CurrentFile, FILE_ATTRIBUTE_NORMAL, &shfi, sizeof(SHFILEINFO), SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES); pszTitle = shfi.szDisplayName; } else { @@ -1350,12 +1230,12 @@ HWND InitInstance(HINSTANCE hInstance,LPWSTR pszCmdLine,int nCmdShow) GetLngString(IDS_MUI_PRINT_PAGENUM, tchPageFmt, COUNTOF(tchPageFmt)); - if (!EditPrint(g_hwndEdit, pszTitle, tchPageFmt)) + if (!EditPrint(Globals.hwndEdit, pszTitle, tchPageFmt)) MsgBoxLng(MBWARN, IDS_MUI_PRINT_ERROR, pszTitle); - PostMessage(g_hwndMain, WM_CLOSE, 0, 0); + PostMessage(Globals.hwndMain, WM_CLOSE, 0, 0); } - return(g_hwndMain); + return(Globals.hwndMain); } @@ -1393,7 +1273,7 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { if (!bAltKeyIsDown) { bAltKeyIsDown = true; - if (!g_bDenyVirtualSpaceAccess) { + if (!Settings2.DenyVirtualSpaceAccess) { SciCall_SetVirtualSpaceOptions(SCVS_RECTANGULARSELECTION | SCVS_NOWRAPLINESTART | SCVS_USERACCESSIBLE); } } @@ -1405,7 +1285,7 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { if (bAltKeyIsDown) { bAltKeyIsDown = false; - SciCall_SetVirtualSpaceOptions(g_bDenyVirtualSpaceAccess ? SCVS_NONE : SCVS_RECTANGULARSELECTION); + SciCall_SetVirtualSpaceOptions(Settings2.DenyVirtualSpaceAccess ? SCVS_NONE : SCVS_RECTANGULARSELECTION); } } return DefWindowProc(hwnd, umsg, wParam, lParam); @@ -1413,7 +1293,7 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case WM_KILLFOCUS: if (bAltKeyIsDown) { bAltKeyIsDown = false; - SciCall_SetVirtualSpaceOptions(g_bDenyVirtualSpaceAccess ? SCVS_NONE : SCVS_RECTANGULARSELECTION); + SciCall_SetVirtualSpaceOptions(Settings2.DenyVirtualSpaceAccess ? SCVS_NONE : SCVS_RECTANGULARSELECTION); } return DefWindowProc(hwnd, umsg, wParam, lParam); @@ -1455,7 +1335,7 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) return MsgSize(hwnd, wParam, lParam); case WM_SETFOCUS: - SetFocus(g_hwndEdit); + SetFocus(Globals.hwndEdit); break; case WM_DROPFILES: @@ -1503,15 +1383,15 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) else bLastCopyFromMe = false; - if (hwndNextCBChain) - SendMessage(hwndNextCBChain,WM_DRAWCLIPBOARD,wParam,lParam); + if (s_hwndNextCBChain) + SendMessage(s_hwndNextCBChain,WM_DRAWCLIPBOARD,wParam,lParam); break; case WM_CHANGECBCHAIN: - if ((HWND)wParam == hwndNextCBChain) - hwndNextCBChain = (HWND)lParam; - if (hwndNextCBChain) - SendMessage(hwndNextCBChain,WM_CHANGECBCHAIN,lParam,wParam); + if ((HWND)wParam == s_hwndNextCBChain) + s_hwndNextCBChain = (HWND)lParam; + if (s_hwndNextCBChain) + SendMessage(s_hwndNextCBChain,WM_CHANGECBCHAIN,lParam,wParam); break; case WM_SYSCOMMAND: @@ -1519,7 +1399,7 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; case WM_MOUSEWHEEL: - if (wParam & MK_CONTROL) { EditShowZoomCallTip(g_hwndEdit); } + if (wParam & MK_CONTROL) { EditShowZoomCallTip(Globals.hwndEdit); } break; case WM_INPUTLANGCHANGE: @@ -1542,14 +1422,14 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) // // _SetWrapStartIndent() // -static void __fastcall _SetWrapStartIndent(HWND hwndEditCtrl) +static void _SetWrapStartIndent(HWND hwndEditCtrl) { int i = 0; - switch (iWordWrapIndent) { + switch (Settings.WordWrapIndent) { case 1: i = 1; break; case 2: i = 2; break; - case 3: i = (g_iIndentWidth) ? 1 * g_iIndentWidth : 1 * g_iTabWidth; break; - case 4: i = (g_iIndentWidth) ? 2 * g_iIndentWidth : 2 * g_iTabWidth; break; + case 3: i = (Settings.IndentWidth) ? 1 * Settings.IndentWidth : 1 * Settings.TabWidth; break; + case 4: i = (Settings.IndentWidth) ? 2 * Settings.IndentWidth : 2 * Settings.TabWidth; break; } SendMessage(hwndEditCtrl, SCI_SETWRAPSTARTINDENT, i, 0); } @@ -1559,19 +1439,19 @@ static void __fastcall _SetWrapStartIndent(HWND hwndEditCtrl) // // _SetWrapIndentMode() // -static void __fastcall _SetWrapIndentMode(HWND hwndEditCtrl) +static void _SetWrapIndentMode(HWND hwndEditCtrl) { - int const wrap_mode = (!g_bWordWrap ? SC_WRAP_NONE : ((iWordWrapMode == 0) ? SC_WRAP_WHITESPACE : SC_WRAP_CHAR)); + int const wrap_mode = (!Settings.WordWrap ? SC_WRAP_NONE : ((Settings.WordWrapMode == 0) ? SC_WRAP_WHITESPACE : SC_WRAP_CHAR)); SendMessage(hwndEditCtrl, SCI_SETWRAPMODE, wrap_mode, 0); - if (iWordWrapIndent == 5) { + if (Settings.WordWrapIndent == 5) { SendMessage(hwndEditCtrl, SCI_SETWRAPINDENTMODE, SC_WRAPINDENT_SAME, 0); } - else if (iWordWrapIndent == 6) { + else if (Settings.WordWrapIndent == 6) { SendMessage(hwndEditCtrl, SCI_SETWRAPINDENTMODE, SC_WRAPINDENT_INDENT, 0); } - else if (iWordWrapIndent == 7) { + else if (Settings.WordWrapIndent == 7) { SendMessage(hwndEditCtrl, SCI_SETWRAPINDENTMODE, SC_WRAPINDENT_DEEPINDENT, 0); } else { @@ -1585,15 +1465,15 @@ static void __fastcall _SetWrapIndentMode(HWND hwndEditCtrl) // // _SetWrapVisualFlags() // -static void __fastcall _SetWrapVisualFlags(HWND hwndEditCtrl) +static void _SetWrapVisualFlags(HWND hwndEditCtrl) { - if (bShowWordWrapSymbols) { + if (Settings.ShowWordWrapSymbols) { int wrapVisualFlags = 0; int wrapVisualFlagsLocation = 0; - if (iWordWrapSymbols == 0) { - iWordWrapSymbols = 22; + if (Settings.WordWrapSymbols == 0) { + Settings.WordWrapSymbols = 22; } - switch (iWordWrapSymbols % 10) { + switch (Settings.WordWrapSymbols % 10) { case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_END; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_END_BY_TEXT; @@ -1602,7 +1482,7 @@ static void __fastcall _SetWrapVisualFlags(HWND hwndEditCtrl) wrapVisualFlags |= SC_WRAPVISUALFLAG_END; break; } - switch (((iWordWrapSymbols % 100) - (iWordWrapSymbols % 10)) / 10) { + switch (((Settings.WordWrapSymbols % 100) - (Settings.WordWrapSymbols % 10)) / 10) { case 1: wrapVisualFlags |= SC_WRAPVISUALFLAG_START; wrapVisualFlagsLocation |= SC_WRAPVISUALFLAGLOC_START_BY_TEXT; @@ -1625,20 +1505,20 @@ static void __fastcall _SetWrapVisualFlags(HWND hwndEditCtrl) // // InitializeSciEditCtrl() // -static void __fastcall _InitializeSciEditCtrl(HWND hwndEditCtrl) +static void _InitializeSciEditCtrl(HWND hwndEditCtrl) { if (IsVista()) { // Current platforms perform window buffering so it is almost always better for this option to be turned off. // There are some older platforms and unusual modes where buffering may still be useful - so keep it ON //~SciCall_SetBufferedDraw(true); // default is true - if (g_iRenderingTechnology > 0) { - SciCall_SetTechnology(DirectWriteTechnology[g_iRenderingTechnology]); + if (Settings.RenderingTechnology > 0) { + SciCall_SetTechnology(DirectWriteTechnology[Settings.RenderingTechnology]); SciCall_SetBufferedDraw(false); // experimental - SciCall_SetBidirectional(SciBidirectional[g_iBidirectional]); + SciCall_SetBidirectional(SciBidirectional[Settings.Bidirectional]); } } - Encoding_Current(g_iDefaultNewFileEncoding); + Encoding_Current(Settings.DefaultEncoding); //int const evtMask = SC_MODEVENTMASKALL; // The possible notification types are the same as the modificationType bit flags used by SCN_MODIFIED: @@ -1710,54 +1590,54 @@ static void __fastcall _InitializeSciEditCtrl(HWND hwndEditCtrl) #define _CARET_SYMETRY CARET_EVEN /// CARET_EVEN or 0 #define _CARET_ENFORCE CARET_STRICT /// CARET_STRICT or 0 - if (iCurrentLineHorizontalSlop > 0) - SendMessage(hwndEditCtrl, SCI_SETXCARETPOLICY, (WPARAM)(CARET_SLOP | _CARET_SYMETRY | _CARET_ENFORCE), iCurrentLineHorizontalSlop); + if (Settings2.CurrentLineHorizontalSlop > 0) + SendMessage(hwndEditCtrl, SCI_SETXCARETPOLICY, (WPARAM)(CARET_SLOP | _CARET_SYMETRY | _CARET_ENFORCE), Settings2.CurrentLineHorizontalSlop); else SendMessage(hwndEditCtrl, SCI_SETXCARETPOLICY, (WPARAM)(CARET_SLOP | _CARET_SYMETRY | _CARET_ENFORCE), (LPARAM)0); - if (iCurrentLineVerticalSlop > 0) - SendMessage(hwndEditCtrl, SCI_SETYCARETPOLICY, (WPARAM)(CARET_SLOP | _CARET_SYMETRY | _CARET_ENFORCE), iCurrentLineVerticalSlop); + if (Settings2.CurrentLineVerticalSlop > 0) + SendMessage(hwndEditCtrl, SCI_SETYCARETPOLICY, (WPARAM)(CARET_SLOP | _CARET_SYMETRY | _CARET_ENFORCE), Settings2.CurrentLineVerticalSlop); else SendMessage(hwndEditCtrl, SCI_SETYCARETPOLICY, (WPARAM)(_CARET_SYMETRY), 0); - SendMessage(hwndEditCtrl, SCI_SETVIRTUALSPACEOPTIONS, (WPARAM)(g_bDenyVirtualSpaceAccess ? SCVS_NONE : SCVS_RECTANGULARSELECTION), 0); - SendMessage(hwndEditCtrl, SCI_SETENDATLASTLINE, (WPARAM)((bScrollPastEOF) ? 0 : 1), 0); + SendMessage(hwndEditCtrl, SCI_SETVIRTUALSPACEOPTIONS, (WPARAM)(Settings2.DenyVirtualSpaceAccess ? SCVS_NONE : SCVS_RECTANGULARSELECTION), 0); + SendMessage(hwndEditCtrl, SCI_SETENDATLASTLINE, (WPARAM)((Settings.ScrollPastEOF) ? 0 : 1), 0); // Tabs - SendMessage(hwndEditCtrl, SCI_SETUSETABS, (WPARAM)!g_bTabsAsSpaces, 0); - SendMessage(hwndEditCtrl, SCI_SETTABINDENTS, (WPARAM)g_bTabIndents, 0); - SendMessage(hwndEditCtrl, SCI_SETBACKSPACEUNINDENTS, (WPARAM)bBackspaceUnindents, 0); - SendMessage(hwndEditCtrl, SCI_SETTABWIDTH, (WPARAM)g_iTabWidth, 0); - SendMessage(hwndEditCtrl, SCI_SETINDENT, (WPARAM)g_iIndentWidth, 0); + SendMessage(hwndEditCtrl, SCI_SETUSETABS, (WPARAM)!Settings.TabsAsSpaces, 0); + SendMessage(hwndEditCtrl, SCI_SETTABINDENTS, (WPARAM)Settings.TabIndents, 0); + SendMessage(hwndEditCtrl, SCI_SETBACKSPACEUNINDENTS, (WPARAM)Settings.BackspaceUnindents, 0); + SendMessage(hwndEditCtrl, SCI_SETTABWIDTH, (WPARAM)Settings.TabWidth, 0); + SendMessage(hwndEditCtrl, SCI_SETINDENT, (WPARAM)Settings.IndentWidth, 0); // Indent Guides - Style_SetIndentGuides(hwndEditCtrl, bShowIndentGuides); + Style_SetIndentGuides(hwndEditCtrl, Settings.ShowIndentGuides); // Word Wrap _SetWrapIndentMode(hwndEditCtrl); _SetWrapVisualFlags(hwndEditCtrl); // Long Lines - if (g_bMarkLongLines) - SendMessage(hwndEditCtrl, SCI_SETEDGEMODE, (WPARAM)((iLongLineMode == EDGE_LINE) ? EDGE_LINE : EDGE_BACKGROUND), 0); + if (Settings.MarkLongLines) + SendMessage(hwndEditCtrl, SCI_SETEDGEMODE, (WPARAM)((Settings.LongLineMode == EDGE_LINE) ? EDGE_LINE : EDGE_BACKGROUND), 0); else SendMessage(hwndEditCtrl, SCI_SETEDGEMODE, (WPARAM)EDGE_NONE, 0); - SendMessage(hwndEditCtrl, SCI_SETEDGECOLUMN, (WPARAM)g_iLongLinesLimit, 0); + SendMessage(hwndEditCtrl, SCI_SETEDGECOLUMN, (WPARAM)Settings.LongLinesLimit, 0); // general margin SendMessage(hwndEditCtrl, SCI_SETMARGINOPTIONS, (WPARAM)SC_MARGINOPTION_SUBLINESELECT, 0); // Nonprinting characters - SendMessage(hwndEditCtrl, SCI_SETVIEWWS, (WPARAM)(bViewWhiteSpace ? SCWS_VISIBLEALWAYS : SCWS_INVISIBLE), 0); - SendMessage(hwndEditCtrl, SCI_SETVIEWEOL, (WPARAM)bViewEOLs, 0); + SendMessage(hwndEditCtrl, SCI_SETVIEWWS, (WPARAM)(Settings.ViewWhiteSpace ? SCWS_VISIBLEALWAYS : SCWS_INVISIBLE), 0); + SendMessage(hwndEditCtrl, SCI_SETVIEWEOL, (WPARAM)Settings.ViewEOLs, 0); // IME Interaction - SendMessage(hwndEditCtrl, SCI_SETIMEINTERACTION, (WPARAM)g_IMEInteraction, 0); + SendMessage(hwndEditCtrl, SCI_SETIMEINTERACTION, (WPARAM)Settings2.IMEInteraction, 0); // word delimiter handling EditInitWordDelimiter(hwndEditCtrl); - EditSetAccelWordNav(hwndEditCtrl, g_bAccelWordNavigation); + EditSetAccelWordNav(hwndEditCtrl, Settings.AccelWordNavigation); UpdateMarginWidth(); } @@ -1773,13 +1653,13 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam,LPARAM lParam) { UNUSED(wParam); - HINSTANCE hInstance = ((LPCREATESTRUCT)lParam)->hInstance; + HINSTANCE const hInstance = ((LPCREATESTRUCT)lParam)->hInstance; - g_uCurrentDPI = GetCurrentDPI(hwnd); - g_uCurrentPPI = GetCurrentPPI(hwnd); + Globals.uCurrentDPI = GetCurrentDPI(hwnd); + Globals.uCurrentPPI = GetCurrentPPI(hwnd); // Setup edit control - g_hwndEdit = CreateWindowEx( + Globals.hwndEdit = CreateWindowEx( WS_EX_CLIENTEDGE, L"Scintilla", NULL, @@ -1790,11 +1670,11 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam,LPARAM lParam) hInstance, NULL); - g_hScintilla = (HANDLE)SendMessage(g_hwndEdit, SCI_GETDIRECTPOINTER, 0, 0); + Globals.hndlScintilla = (HANDLE)SendMessage(Globals.hwndEdit, SCI_GETDIRECTPOINTER, 0, 0); - _InitializeSciEditCtrl(g_hwndEdit); + _InitializeSciEditCtrl(Globals.hwndEdit); - hwndEditFrame = CreateWindowEx( + s_hwndEditFrame = CreateWindowEx( WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL, @@ -1811,8 +1691,8 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam,LPARAM lParam) bIsAppThemed = true; - SetWindowLongPtr(g_hwndEdit,GWL_EXSTYLE,GetWindowLongPtr(g_hwndEdit,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE); - SetWindowPos(g_hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); + SetWindowLongPtr(Globals.hwndEdit,GWL_EXSTYLE,GetWindowLongPtr(Globals.hwndEdit,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE); + SetWindowPos(Globals.hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); if (IsVista()) { cxEditFrame = 0; @@ -1820,8 +1700,8 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam,LPARAM lParam) } else { - GetClientRect(hwndEditFrame,&rc); - GetWindowRect(hwndEditFrame,&rc2); + GetClientRect(s_hwndEditFrame,&rc); + GetWindowRect(s_hwndEditFrame,&rc2); cxEditFrame = ((rc2.right-rc2.left) - (rc.right-rc.left)) / 2; cyEditFrame = ((rc2.bottom-rc2.top) - (rc.bottom-rc.top)) / 2; @@ -1849,7 +1729,7 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam,LPARAM lParam) hInstance, NULL); - SetDlgItemText(hwnd,IDC_FILENAME,g_wchCurFile); + SetDlgItemText(hwnd,IDC_FILENAME,Globals.CurrentFile); (void)CreateWindow( WC_STATIC, @@ -1869,25 +1749,25 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam,LPARAM lParam) // Drag & Drop DragAcceptFiles(hwnd,true); #ifdef _EXTRA_DRAG_N_DROP_HANDLER_ - pDropTarget = RegisterDragAndDrop(hwnd, &cfDrpF, 1, WM_NULL, DropFilesProc, (void*)g_hwndEdit); + pDropTarget = RegisterDragAndDrop(hwnd, &cfDrpF, 1, WM_NULL, DropFilesProc, (void*)Globals.hwndEdit); #endif // File MRU - g_pFileMRU = MRU_Create(_s_RecentFiles, MRU_NOCASE, MRU_ITEMSFILE); - MRU_Load(g_pFileMRU); + Globals.pFileMRU = MRU_Create(_s_RecentFiles, MRU_NOCASE, MRU_ITEMSFILE); + MRU_Load(Globals.pFileMRU); - g_pMRUfind = MRU_Create(_s_RecentFind, (/*IsWindowsNT()*/true) ? MRU_UTF8 : 0, MRU_ITEMSFNDRPL); - MRU_Load(g_pMRUfind); - SetFindPattern(g_pMRUfind->pszItems[0]); + Globals.pMRUfind = MRU_Create(_s_RecentFind, (/*IsWindowsNT()*/true) ? MRU_UTF8 : 0, MRU_ITEMSFNDRPL); + MRU_Load(Globals.pMRUfind); + SetFindPattern(Globals.pMRUfind->pszItems[0]); - g_pMRUreplace = MRU_Create(_s_RecentReplace, (/*IsWindowsNT()*/true) ? MRU_UTF8 : 0, MRU_ITEMSFNDRPL); - MRU_Load(g_pMRUreplace); + Globals.pMRUreplace = MRU_Create(_s_RecentReplace, (/*IsWindowsNT()*/true) ? MRU_UTF8 : 0, MRU_ITEMSFNDRPL); + MRU_Load(Globals.pMRUreplace); - if (g_hwndEdit == NULL || hwndEditFrame == NULL || - g_hwndStatus == NULL || g_hwndToolbar == NULL || g_hwndReBar == NULL) + if (Globals.hwndEdit == NULL || s_hwndEditFrame == NULL || + Globals.hwndStatus == NULL || s_hwndToolbar == NULL || s_hwndReBar == NULL) return -1LL; - Style_SetDefaultLexer(g_hwndEdit); + Style_SetDefaultLexer(Globals.hwndEdit); ObserveNotifyChangeEvent(); @@ -1903,24 +1783,24 @@ LRESULT MsgCreate(HWND hwnd, WPARAM wParam,LPARAM lParam) void CreateBars(HWND hwnd, HINSTANCE hInstance) { DWORD dwToolbarStyle = NP3_WS_TOOLBAR; - g_hwndToolbar = CreateWindowEx(0,TOOLBARCLASSNAME,NULL,dwToolbarStyle, + s_hwndToolbar = CreateWindowEx(0,TOOLBARCLASSNAME,NULL,dwToolbarStyle, 0,0,0,0,hwnd,(HMENU)IDC_TOOLBAR,hInstance,NULL); - SendMessage(g_hwndToolbar,TB_BUTTONSTRUCTSIZE,(WPARAM)sizeof(TBBUTTON),0); + SendMessage(s_hwndToolbar,TB_BUTTONSTRUCTSIZE,(WPARAM)sizeof(TBBUTTON),0); // Add Toolbar Bitmap HBITMAP hbmp = NULL; HBITMAP hbmpCopy = NULL; WCHAR szTmp[MAX_PATH] = { L'\0' }; - if (StringCchLenW(g_tchToolbarBitmap,COUNTOF(g_tchToolbarBitmap))) + if (StringCchLenW(s_tchToolbarBitmap,COUNTOF(s_tchToolbarBitmap))) { - if (!SearchPath(NULL,g_tchToolbarBitmap,L".bmp",COUNTOF(szTmp),szTmp,NULL)) - StringCchCopy(szTmp,COUNTOF(szTmp),g_tchToolbarBitmap); + if (!SearchPath(NULL,s_tchToolbarBitmap,L".bmp",COUNTOF(szTmp),szTmp,NULL)) + StringCchCopy(szTmp,COUNTOF(szTmp),s_tchToolbarBitmap); hbmp = LoadImage(NULL,szTmp,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE); } if (hbmp) { - g_bExternalBitmap = true; + s_bExternalBitmap = true; } else { LPWSTR toolBarIntRes = (iHighDpiToolBar > 0) ? MAKEINTRESOURCE(IDR_MAINWNDTB2) : MAKEINTRESOURCE(IDR_MAINWNDTB); @@ -1939,14 +1819,14 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance) HIMAGELIST himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0); ImageList_AddMasked(himl,hbmp,CLR_DEFAULT); DeleteObject(hbmp); - SendMessage(g_hwndToolbar,TB_SETIMAGELIST,0,(LPARAM)himl); + SendMessage(s_hwndToolbar,TB_SETIMAGELIST,0,(LPARAM)himl); // Optionally add hot Toolbar Bitmap hbmp = NULL; - if (StringCchLenW(g_tchToolbarBitmapHot,COUNTOF(g_tchToolbarBitmapHot))) + if (StringCchLenW(s_tchToolbarBitmapHot,COUNTOF(s_tchToolbarBitmapHot))) { - if (!SearchPath(NULL,g_tchToolbarBitmapHot,L".bmp",COUNTOF(szTmp),szTmp,NULL)) - StringCchCopy(szTmp,COUNTOF(szTmp),g_tchToolbarBitmapHot); + if (!SearchPath(NULL,s_tchToolbarBitmapHot,L".bmp",COUNTOF(szTmp),szTmp,NULL)) + StringCchCopy(szTmp,COUNTOF(szTmp),s_tchToolbarBitmapHot); hbmp = LoadImage(NULL, szTmp, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE); hbmp = ResizeImageForCurrentDPI(hbmp); @@ -1956,16 +1836,16 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance) himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0); ImageList_AddMasked(himl,hbmp,CLR_DEFAULT); DeleteObject(hbmp); - SendMessage(g_hwndToolbar,TB_SETHOTIMAGELIST,0,(LPARAM)himl); + SendMessage(s_hwndToolbar,TB_SETHOTIMAGELIST,0,(LPARAM)himl); } } // Optionally add disabled Toolbar Bitmap hbmp = NULL; - if (StringCchLenW(g_tchToolbarBitmapDisabled,COUNTOF(g_tchToolbarBitmapDisabled))) + if (StringCchLenW(s_tchToolbarBitmapDisabled,COUNTOF(s_tchToolbarBitmapDisabled))) { - if (!SearchPath(NULL,g_tchToolbarBitmapDisabled,L".bmp",COUNTOF(szTmp),szTmp,NULL)) - StringCchCopy(szTmp,COUNTOF(szTmp),g_tchToolbarBitmapDisabled); + if (!SearchPath(NULL,s_tchToolbarBitmapDisabled,L".bmp",COUNTOF(szTmp),szTmp,NULL)) + StringCchCopy(szTmp,COUNTOF(szTmp),s_tchToolbarBitmapDisabled); hbmp = LoadImage(NULL, szTmp, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE); hbmp = ResizeImageForCurrentDPI(hbmp); @@ -1975,23 +1855,23 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance) himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0); ImageList_AddMasked(himl,hbmp,CLR_DEFAULT); DeleteObject(hbmp); - SendMessage(g_hwndToolbar,TB_SETDISABLEDIMAGELIST,0,(LPARAM)himl); - g_bExternalBitmap = true; + SendMessage(s_hwndToolbar,TB_SETDISABLEDIMAGELIST,0,(LPARAM)himl); + s_bExternalBitmap = true; } } - if (!g_bExternalBitmap) { + if (!s_bExternalBitmap) { bool fProcessed = false; - if (g_flagToolbarLook == 1) + if (Flags.ToolbarLook == 1) fProcessed = BitmapAlphaBlend(hbmpCopy,GetSysColor(COLOR_3DFACE),0x60); - else if (g_flagToolbarLook == 2 || (!IsXP() && g_flagToolbarLook == 0)) + else if (Flags.ToolbarLook == 2 || (!IsXP() && Flags.ToolbarLook == 0)) fProcessed = BitmapGrayScale(hbmpCopy); if (fProcessed && !IsXP()) BitmapMergeAlpha(hbmpCopy,GetSysColor(COLOR_3DFACE)); if (fProcessed) { himl = ImageList_Create(bmp.bmWidth/NUMTOOLBITMAPS,bmp.bmHeight,ILC_COLOR32|ILC_MASK,0,0); ImageList_AddMasked(himl,hbmpCopy,CLR_DEFAULT); - SendMessage(g_hwndToolbar,TB_SETDISABLEDIMAGELIST,0,(LPARAM)himl); + SendMessage(s_hwndToolbar,TB_SETDISABLEDIMAGELIST,0,(LPARAM)himl); } } if (hbmpCopy) { @@ -2013,48 +1893,48 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance) StringCchPrintf(tchIndex, COUNTOF(tchIndex), L"%02i", n); if (IniSectionGetString(pIniSection, tchIndex, L"", tchDesc, COUNTOF(tchDesc)) > 0) { - tbbMainWnd[i].iString = SendMessage(g_hwndToolbar, TB_ADDSTRING, 0, (LPARAM)tchDesc); + tbbMainWnd[i].iString = SendMessage(s_hwndToolbar, TB_ADDSTRING, 0, (LPARAM)tchDesc); tbbMainWnd[i].fsStyle |= BTNS_AUTOSIZE | BTNS_SHOWTEXT; } else { GetLngString(tbbMainWnd[i].idCommand, tchDesc, COUNTOF(tchDesc)); - tbbMainWnd[i].iString = SendMessage(g_hwndToolbar, TB_ADDSTRING, 0, (LPARAM)tchDesc); // tooltip + tbbMainWnd[i].iString = SendMessage(s_hwndToolbar, TB_ADDSTRING, 0, (LPARAM)tchDesc); // tooltip tbbMainWnd[i].fsStyle &= ~(BTNS_AUTOSIZE | BTNS_SHOWTEXT); } } FreeMem(pIniSection); } - //~SendMessage(g_hwndToolbar, TB_SETMAXTEXTROWS, 0, 0); + //~SendMessage(s_hwndToolbar, TB_SETMAXTEXTROWS, 0, 0); - SendMessage(g_hwndToolbar,TB_SETEXTENDEDSTYLE,0, - (SendMessage(g_hwndToolbar,TB_GETEXTENDEDSTYLE,0,0) | (TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_EX_DOUBLEBUFFER))); + SendMessage(s_hwndToolbar,TB_SETEXTENDEDSTYLE,0, + (SendMessage(s_hwndToolbar,TB_GETEXTENDEDSTYLE,0,0) | (TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_EX_DOUBLEBUFFER))); - SendMessage(g_hwndToolbar,TB_ADDBUTTONS,NUMINITIALTOOLS,(LPARAM)tbbMainWnd); + SendMessage(s_hwndToolbar,TB_ADDBUTTONS,NUMINITIALTOOLS,(LPARAM)tbbMainWnd); - if (Toolbar_SetButtons(g_hwndToolbar, IDT_FILE_NEW, g_tchToolbarButtons, tbbMainWnd, COUNTOF(tbbMainWnd)) == 0) { - SendMessage(g_hwndToolbar, TB_ADDBUTTONS, NUMINITIALTOOLS, (LPARAM)tbbMainWnd); + if (Toolbar_SetButtons(s_hwndToolbar, IDT_FILE_NEW, Settings.ToolbarButtons, tbbMainWnd, COUNTOF(tbbMainWnd)) == 0) { + SendMessage(s_hwndToolbar, TB_ADDBUTTONS, NUMINITIALTOOLS, (LPARAM)tbbMainWnd); } RECT rc; - SendMessage(g_hwndToolbar,TB_GETITEMRECT,0,(LPARAM)&rc); - //SendMessage(g_hwndToolbar,TB_SETINDENT,2,0); + SendMessage(s_hwndToolbar,TB_GETITEMRECT,0,(LPARAM)&rc); + //SendMessage(s_hwndToolbar,TB_SETINDENT,2,0); // Create Statusbar - DWORD const dwStatusbarStyle = bShowStatusbar ? (WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE) : (WS_CHILD | WS_CLIPSIBLINGS); - g_hwndStatus = CreateStatusWindow(dwStatusbarStyle,NULL,hwnd,IDC_STATUSBAR); + DWORD const dwStatusbarStyle = Settings.ShowStatusbar ? (WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE) : (WS_CHILD | WS_CLIPSIBLINGS); + Globals.hwndStatus = CreateStatusWindow(dwStatusbarStyle,NULL,hwnd,IDC_STATUSBAR); // Create ReBar and add Toolbar - DWORD const dwReBarStyle = bShowToolbar ? (NP3_WS_REBAR | WS_VISIBLE) : (NP3_WS_REBAR); - g_hwndReBar = CreateWindowEx(WS_EX_TOOLWINDOW,REBARCLASSNAME,NULL,dwReBarStyle, + DWORD const dwReBarStyle = Settings.ShowToolbar ? (NP3_WS_REBAR | WS_VISIBLE) : (NP3_WS_REBAR); + s_hwndReBar = CreateWindowEx(WS_EX_TOOLWINDOW,REBARCLASSNAME,NULL,dwReBarStyle, 0,0,0,0,hwnd,(HMENU)IDC_REBAR,hInstance,NULL); REBARINFO rbi; rbi.cbSize = sizeof(REBARINFO); rbi.fMask = 0; rbi.himl = (HIMAGELIST)NULL; - SendMessage(g_hwndReBar,RB_SETBARINFO,0,(LPARAM)&rbi); + SendMessage(s_hwndReBar,RB_SETBARINFO,0,(LPARAM)&rbi); REBARBANDINFO rbBand; @@ -2066,14 +1946,14 @@ void CreateBars(HWND hwnd, HINSTANCE hInstance) rbBand.fStyle = bIsAppThemed ? (RBBS_FIXEDSIZE | RBBS_CHILDEDGE) : RBBS_FIXEDSIZE; rbBand.hbmBack = NULL; rbBand.lpText = L"Toolbar"; - rbBand.hwndChild = g_hwndToolbar; + rbBand.hwndChild = s_hwndToolbar; rbBand.cxMinChild = (rc.right - rc.left) * COUNTOF(tbbMainWnd); rbBand.cyMinChild = (rc.bottom - rc.top) + 2 * rc.top; rbBand.cx = 0; - SendMessage(g_hwndReBar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&rbBand); + SendMessage(s_hwndReBar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&rbBand); - SetWindowPos(g_hwndReBar,NULL,0,0,0,0,SWP_NOZORDER); - GetWindowRect(g_hwndReBar,&rc); + SetWindowPos(s_hwndReBar,NULL,0,0,0,0,SWP_NOZORDER); + GetWindowRect(s_hwndReBar,&rc); cyReBar = rc.bottom - rc.top; cyReBarFrame = bIsAppThemed ? 0 : 2; @@ -2097,8 +1977,8 @@ LRESULT MsgEndSession(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) // Terminate file watching InstallFileWatching(NULL); - // GetWindowPlacement - g_WinInfo = GetMyWindowPlacement(hwnd, NULL); + // remember window position + s_WinInfo = GetMyWindowPlacement(hwnd, NULL); DragAcceptFiles(hwnd, true); #ifdef _EXTRA_DRAG_N_DROP_HANDLER_ @@ -2106,46 +1986,47 @@ LRESULT MsgEndSession(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) #endif // Terminate clipboard watching - if (g_flagPasteBoard) { + if (s_flagPasteBoard) { KillTimer(hwnd, ID_PASTEBOARDTIMER); - ChangeClipboardChain(hwnd, hwndNextCBChain); + ChangeClipboardChain(hwnd, s_hwndNextCBChain); } // Destroy find / replace dialog - if (IsWindow(g_hwndDlgFindReplace)) - DestroyWindow(g_hwndDlgFindReplace); - + if (IsWindow(Globals.hwndDlgFindReplace)) { + DestroyWindow(Globals.hwndDlgFindReplace); + } // Destroy customize schemes - if (IsWindow(g_hwndDlgCustomizeSchemes)) - DestroyWindow(g_hwndDlgCustomizeSchemes); - - // call SaveSettings() when g_hwndToolbar is still valid + if (IsWindow(Globals.hwndDlgCustomizeSchemes)) { + DestroyWindow(Globals.hwndDlgCustomizeSchemes); + } + + // call SaveSettings() when s_hwndToolbar is still valid SaveSettings(false); - if (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)) != 0) { - + if (StringCchLenW(Globals.IniFile,COUNTOF(Globals.IniFile)) != 0) + { // Cleanup unwanted MRU's - if (!g_bSaveRecentFiles) { - MRU_Empty(g_pFileMRU); - MRU_Save(g_pFileMRU); + if (!Settings.SaveRecentFiles) { + MRU_Empty(Globals.pFileMRU); + MRU_Save(Globals.pFileMRU); } else - MRU_MergeSave(g_pFileMRU, true, g_flagRelativeFileMRU, g_flagPortableMyDocs); + MRU_MergeSave(Globals.pFileMRU, true, Flags.RelativeFileMRU, Flags.PortableMyDocs); - MRU_Destroy(g_pFileMRU); + MRU_Destroy(Globals.pFileMRU); - if (!g_bSaveFindReplace) { - MRU_Empty(g_pMRUfind); - MRU_Empty(g_pMRUreplace); - MRU_Save(g_pMRUfind); - MRU_Save(g_pMRUreplace); + if (!Settings.SaveFindReplace) { + MRU_Empty(Globals.pMRUfind); + MRU_Empty(Globals.pMRUreplace); + MRU_Save(Globals.pMRUfind); + MRU_Save(Globals.pMRUreplace); } else { - MRU_MergeSave(g_pMRUfind, false, false, false); - MRU_MergeSave(g_pMRUreplace, false, false, false); + MRU_MergeSave(Globals.pMRUfind, false, false, false); + MRU_MergeSave(Globals.pMRUreplace, false, false, false); } - MRU_Destroy(g_pMRUfind); - MRU_Destroy(g_pMRUreplace); + MRU_Destroy(Globals.pMRUfind); + MRU_Destroy(Globals.pMRUreplace); } // Remove tray icon if necessary @@ -2169,8 +2050,8 @@ LRESULT MsgEndSession(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) // LRESULT MsgDPIChanged(HWND hwnd, WPARAM wParam, LPARAM lParam) { - g_uCurrentDPI = HIWORD(wParam); - g_uCurrentPPI = GetCurrentPPI(hwnd); + Globals.uCurrentDPI = HIWORD(wParam); + Globals.uCurrentPPI = GetCurrentPPI(hwnd); DocPos const pos = SciCall_GetCurrentPos(); @@ -2178,19 +2059,19 @@ LRESULT MsgDPIChanged(HWND hwnd, WPARAM wParam, LPARAM lParam) #if 0 char buf[128]; - sprintf(buf, "WM_DPICHANGED: dpi=%u, %u\n", g_uCurrentDPI, g_uCurrentPPI); - SendMessage(g_hwndEdit, SCI_INSERTTEXT, 0, (LPARAM)buf); + sprintf(buf, "WM_DPICHANGED: dpi=%u, %u\n", Globals.uCurrentDPI, Globals.uCurrentPPI); + SendMessage(Globals.hwndEdit, SCI_INSERTTEXT, 0, (LPARAM)buf); #endif - Style_ResetCurrentLexer(g_hwndEdit); + Style_ResetCurrentLexer(Globals.hwndEdit); SciCall_GotoPos(pos); // recreate toolbar and statusbar - Toolbar_GetButtons(g_hwndToolbar, IDT_FILE_NEW, g_tchToolbarButtons, COUNTOF(g_tchToolbarButtons)); + Toolbar_GetButtons(s_hwndToolbar, IDT_FILE_NEW, Settings.ToolbarButtons, COUNTOF(Settings.ToolbarButtons)); - DestroyWindow(g_hwndToolbar); - DestroyWindow(g_hwndReBar); - DestroyWindow(g_hwndStatus); + DestroyWindow(s_hwndToolbar); + DestroyWindow(s_hwndReBar); + DestroyWindow(Globals.hwndStatus); CreateBars(hwnd, hInstance); RECT* const rc = (RECT*)lParam; @@ -2224,8 +2105,8 @@ LRESULT MsgThemeChanged(HWND hwnd, WPARAM wParam ,LPARAM lParam) if (IsAppThemed()) { bIsAppThemed = true; - SetWindowLongPtr(g_hwndEdit,GWL_EXSTYLE,GetWindowLongPtr(g_hwndEdit,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE); - SetWindowPos(g_hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE); + SetWindowLongPtr(Globals.hwndEdit,GWL_EXSTYLE,GetWindowLongPtr(Globals.hwndEdit,GWL_EXSTYLE) & ~WS_EX_CLIENTEDGE); + SetWindowPos(Globals.hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE); if (IsVista()) { cxEditFrame = 0; @@ -2233,9 +2114,9 @@ LRESULT MsgThemeChanged(HWND hwnd, WPARAM wParam ,LPARAM lParam) } else { - SetWindowPos(hwndEditFrame,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); - GetClientRect(hwndEditFrame,&rc); - GetWindowRect(hwndEditFrame,&rc2); + SetWindowPos(s_hwndEditFrame,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); + GetClientRect(s_hwndEditFrame,&rc); + GetWindowRect(s_hwndEditFrame,&rc2); cxEditFrame = ((rc2.right-rc2.left) - (rc.right-rc.left)) / 2; cyEditFrame = ((rc2.bottom-rc2.top) - (rc.bottom-rc.top)) / 2; @@ -2245,30 +2126,30 @@ LRESULT MsgThemeChanged(HWND hwnd, WPARAM wParam ,LPARAM lParam) else { bIsAppThemed = false; - SetWindowLongPtr(g_hwndEdit,GWL_EXSTYLE,WS_EX_CLIENTEDGE|GetWindowLongPtr(g_hwndEdit,GWL_EXSTYLE)); - SetWindowPos(g_hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); + SetWindowLongPtr(Globals.hwndEdit,GWL_EXSTYLE,WS_EX_CLIENTEDGE|GetWindowLongPtr(Globals.hwndEdit,GWL_EXSTYLE)); + SetWindowPos(Globals.hwndEdit,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); cxEditFrame = 0; cyEditFrame = 0; } // recreate toolbar and statusbar - Toolbar_GetButtons(g_hwndToolbar,IDT_FILE_NEW,g_tchToolbarButtons,COUNTOF(g_tchToolbarButtons)); + Toolbar_GetButtons(s_hwndToolbar,IDT_FILE_NEW,Settings.ToolbarButtons,COUNTOF(Settings.ToolbarButtons)); - DestroyWindow(g_hwndToolbar); - DestroyWindow(g_hwndReBar); - DestroyWindow(g_hwndStatus); + DestroyWindow(s_hwndToolbar); + DestroyWindow(s_hwndReBar); + DestroyWindow(Globals.hwndStatus); CreateBars(hwnd,hInstance); SendWMSize(hwnd, NULL); - EditFinalizeStyling(g_hwndEdit, -1); + EditFinalizeStyling(Globals.hwndEdit, -1); - if (EditToggleView(g_hwndEdit, false)) { - EditToggleView(g_hwndEdit, true); + if (EditToggleView(Globals.hwndEdit, false)) { + EditToggleView(Globals.hwndEdit, true); } MarkAllOccurrences(0, true); - EditUpdateUrlHotspots(g_hwndEdit, 0, Sci_GetDocEndPosition(), g_bHyperlinkHotspot); + EditUpdateUrlHotspots(Globals.hwndEdit, 0, Sci_GetDocEndPosition(), Settings.HyperlinkHotspot); UpdateUI(); UpdateToolbar(); @@ -2297,45 +2178,45 @@ LRESULT MsgSize(HWND hwnd, WPARAM wParam, LPARAM lParam) int cx = LOWORD(lParam); int cy = HIWORD(lParam); - if (bShowToolbar) + if (Settings.ShowToolbar) { -/* SendMessage(g_hwndToolbar,WM_SIZE,0,0); +/* SendMessage(s_hwndToolbar,WM_SIZE,0,0); RECT rc; - GetWindowRect(g_hwndToolbar,&rc); + GetWindowRect(s_hwndToolbar,&rc); y = (rc.bottom - rc.top); cy -= (rc.bottom - rc.top);*/ - //SendMessage(g_hwndToolbar,TB_GETITEMRECT,0,(LPARAM)&rc); - SetWindowPos(g_hwndReBar,NULL,0,0,LOWORD(lParam),cyReBar,SWP_NOZORDER); + //SendMessage(s_hwndToolbar,TB_GETITEMRECT,0,(LPARAM)&rc); + SetWindowPos(s_hwndReBar,NULL,0,0,LOWORD(lParam),cyReBar,SWP_NOZORDER); // the ReBar automatically sets the correct height // calling SetWindowPos() with the height of one toolbar button // causes the control not to temporarily use the whole client area // and prevents flickering - //GetWindowRect(g_hwndReBar,&rc); + //GetWindowRect(s_hwndReBar,&rc); y = cyReBar + cyReBarFrame; // define cy -= cyReBar + cyReBarFrame; // border } - if (bShowStatusbar) + if (Settings.ShowStatusbar) { RECT rc; - SendMessage(g_hwndStatus,WM_SIZE,0,0); - GetWindowRect(g_hwndStatus,&rc); + SendMessage(Globals.hwndStatus,WM_SIZE,0,0); + GetWindowRect(Globals.hwndStatus,&rc); cy -= (rc.bottom - rc.top); } HDWP hdwp = BeginDeferWindowPos(2); - DeferWindowPos(hdwp,hwndEditFrame,NULL,x,y,cx,cy, SWP_NOZORDER | SWP_NOACTIVATE); + DeferWindowPos(hdwp,s_hwndEditFrame,NULL,x,y,cx,cy, SWP_NOZORDER | SWP_NOACTIVATE); - DeferWindowPos(hdwp,g_hwndEdit,NULL,x+cxEditFrame,y+cyEditFrame, + DeferWindowPos(hdwp,Globals.hwndEdit,NULL,x+cxEditFrame,y+cyEditFrame, cx-2*cxEditFrame,cy-2*cyEditFrame, SWP_NOZORDER | SWP_NOACTIVATE); EndDeferWindowPos(hdwp); - g_WinCurrentWidth = cx; + s_WinCurrentWidth = cx; UpdateToolbar(); UpdateStatusbar(false); @@ -2369,11 +2250,11 @@ LRESULT MsgDropFiles(HWND hwnd, WPARAM wParam, LPARAM lParam) if (PathIsDirectory(szBuf)) { WCHAR tchFile[MAX_PATH] = { L'\0' }; - if (OpenFileDlg(g_hwndMain, tchFile, COUNTOF(tchFile), szBuf)) - FileLoad(false, false, false, bSkipUnicodeDetection, bSkipANSICodePageDetection, tchFile); + if (OpenFileDlg(Globals.hwndMain, tchFile, COUNTOF(tchFile), szBuf)) + FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, tchFile); } else if (PathFileExists(szBuf)) { - FileLoad(false, false, false, bSkipUnicodeDetection, bSkipANSICodePageDetection, szBuf); + FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, szBuf); } else { #ifndef _EXTRA_DRAG_N_DROP_HANDLER_ @@ -2417,10 +2298,10 @@ static DWORD DropFilesProc(CLIPFORMAT cf, HGLOBAL hData, HWND hWnd, DWORD dwKeyS if (PathIsDirectory(szBuf)) { WCHAR tchFile[MAX_PATH] = { L'\0' }; if (OpenFileDlg(hWnd, tchFile, COUNTOF(tchFile), szBuf)) - FileLoad(false, false, false, bSkipUnicodeDetection, bSkipANSICodePageDetection, tchFile); + FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, tchFile); } else - FileLoad(false, false, false, bSkipUnicodeDetection, bSkipANSICodePageDetection, szBuf); + FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, szBuf); if (DragQueryFile(hDrop, (UINT)(-1), NULL, 0) > 1) MsgBoxLng(MBWARN, IDS_MUI_ERR_DROP); @@ -2458,10 +2339,10 @@ LRESULT MsgCopyData(HWND hwnd, WPARAM wParam, LPARAM lParam) CopyMemory(params, pcds->lpData, pcds->cbData); if (params->flagLexerSpecified) - g_flagLexerSpecified = 1; + s_flagLexerSpecified = 1; if (params->flagQuietCreate) - g_flagQuietCreate = 1; + s_flagQuietCreate = 1; if (params->flagFileSpecified) { @@ -2470,55 +2351,55 @@ LRESULT MsgCopyData(HWND hwnd, WPARAM wParam, LPARAM lParam) if (PathIsDirectory(¶ms->wchData)) { WCHAR tchFile[MAX_PATH] = { L'\0' }; - if (OpenFileDlg(g_hwndMain, tchFile, COUNTOF(tchFile), ¶ms->wchData)) - bOpened = FileLoad(false, false, false, bSkipUnicodeDetection, bSkipANSICodePageDetection, tchFile); + if (OpenFileDlg(Globals.hwndMain, tchFile, COUNTOF(tchFile), ¶ms->wchData)) + bOpened = FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, tchFile); } else - bOpened = FileLoad(false, false, false, bSkipUnicodeDetection, bSkipANSICodePageDetection, ¶ms->wchData); + bOpened = FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, ¶ms->wchData); if (bOpened) { if (params->flagChangeNotify == 1) { - g_iFileWatchingMode = 0; - g_bResetFileWatching = true; - InstallFileWatching(g_wchCurFile); + Settings.FileWatchingMode = 0; + Settings.ResetFileWatching = true; + InstallFileWatching(Globals.CurrentFile); } else if (params->flagChangeNotify == 2) { if (!g_bChasingDocTail) { - SendMessage(g_hwndMain, WM_COMMAND, MAKELONG(IDM_VIEW_CHASING_DOCTAIL, 1), 0); + SendMessage(Globals.hwndMain, WM_COMMAND, MAKELONG(IDM_VIEW_CHASING_DOCTAIL, 1), 0); } else { - g_iFileWatchingMode = 2; - g_bResetFileWatching = true; - InstallFileWatching(g_wchCurFile); + Settings.FileWatchingMode = 2; + Settings.ResetFileWatching = true; + InstallFileWatching(Globals.CurrentFile); } } if (0 != params->flagSetEncoding) { - g_flagSetEncoding = params->flagSetEncoding; + s_flagSetEncoding = params->flagSetEncoding; SendMessage( hwnd, WM_COMMAND, - MAKELONG(IDM_ENCODING_ANSI + g_flagSetEncoding - 1, 1), + MAKELONG(IDM_ENCODING_ANSI + s_flagSetEncoding - 1, 1), 0); - g_flagSetEncoding = 0; + s_flagSetEncoding = 0; } if (0 != params->flagSetEOLMode) { - g_flagSetEOLMode = params->flagSetEOLMode; - SendMessage(g_hwndMain, WM_COMMAND, MAKELONG(IDM_LINEENDINGS_CRLF + g_flagSetEOLMode - 1, 1), 0); - g_flagSetEOLMode = 0; + s_flagSetEOLMode = params->flagSetEOLMode; + SendMessage(Globals.hwndMain, WM_COMMAND, MAKELONG(IDM_LINEENDINGS_CRLF + s_flagSetEOLMode - 1, 1), 0); + s_flagSetEOLMode = 0; } if (params->flagLexerSpecified) { if (params->iInitialLexer < 0) { WCHAR wchExt[32] = L"."; StringCchCopyN(CharNext(wchExt), 32, StrEnd(¶ms->wchData, 0) + 1, 31); - Style_SetLexerFromName(g_hwndEdit, ¶ms->wchData, wchExt); + Style_SetLexerFromName(Globals.hwndEdit, ¶ms->wchData, wchExt); } else if (params->iInitialLexer >= 0 && params->iInitialLexer < NUMLEXERS) - Style_SetLexerFromID(g_hwndEdit, params->iInitialLexer); + Style_SetLexerFromID(Globals.hwndEdit, params->iInitialLexer); } if (params->flagTitleExcerpt) { @@ -2532,11 +2413,11 @@ LRESULT MsgCopyData(HWND hwnd, WPARAM wParam, LPARAM lParam) if (params->flagJumpTo) { if (params->iInitialLine == 0) params->iInitialLine = 1; - EditJumpTo(g_hwndEdit, params->iInitialLine, params->iInitialColumn); + EditJumpTo(Globals.hwndEdit, params->iInitialLine, params->iInitialColumn); } - g_flagLexerSpecified = 0; - g_flagQuietCreate = 0; + s_flagLexerSpecified = 0; + s_flagQuietCreate = 0; FreeMem(params); } @@ -2565,7 +2446,7 @@ LRESULT MsgContextMenu(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) (nID != IDC_REBAR) && (nID != IDC_TOOLBAR)) return DefWindowProc(hwnd, umsg, wParam, lParam); - hmenu = LoadMenu(g_hLngResContainer, MAKEINTRESOURCE(IDR_MUI_POPUPMENU)); + hmenu = LoadMenu(Globals.hLngResContainer, MAKEINTRESOURCE(IDR_MUI_POPUPMENU)); //SetMenuDefaultItem(GetSubMenu(hmenu,1),0,false); pt.x = (int)(short)LOWORD(lParam); @@ -2577,16 +2458,16 @@ LRESULT MsgContextMenu(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (SciCall_IsSelectionEmpty() && (pt.x != -1) && (pt.y != -1)) { POINT ptc; ptc.x = pt.x; ptc.y = pt.y; - ScreenToClient(g_hwndEdit, &ptc); + ScreenToClient(Globals.hwndEdit, &ptc); DocPos iNewPos = SciCall_PositionFromPoint(ptc.x, ptc.y); - EditSetSelectionEx(g_hwndEdit, iNewPos, iNewPos, -1, -1); + EditSetSelectionEx(Globals.hwndEdit, iNewPos, iNewPos, -1, -1); } if (pt.x == -1 && pt.y == -1) { DocPos iCurrentPos = SciCall_GetCurrentPos(); pt.x = (LONG)SciCall_PointXFromPosition(iCurrentPos); pt.y = (LONG)SciCall_PointYFromPosition(iCurrentPos); - ClientToScreen(g_hwndEdit, &pt); + ClientToScreen(Globals.hwndEdit, &pt); } imenu = 0; } @@ -2621,16 +2502,16 @@ LRESULT MsgChangeNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) UNUSED(wParam); UNUSED(lParam); - if (g_iFileWatchingMode == 1 || IsDocumentModified || Encoding_HasChanged(CPI_GET)) { + if (Settings.FileWatchingMode == 1 || IsDocumentModified || Encoding_HasChanged(CPI_GET)) { SetForegroundWindow(hwnd); } - if (PathFileExists(g_wchCurFile)) + if (PathFileExists(Globals.CurrentFile)) { - if ((g_iFileWatchingMode == 2 && !IsDocumentModified && !Encoding_HasChanged(CPI_GET)) || + if ((Settings.FileWatchingMode == 2 && !IsDocumentModified && !Encoding_HasChanged(CPI_GET)) || MsgBoxLng(MBYESNOWARN,IDS_MUI_FILECHANGENOTIFY) == IDYES) { - FileRevert(g_wchCurFile, Encoding_HasChanged(CPI_GET)); + FileRevert(Globals.CurrentFile, Encoding_HasChanged(CPI_GET)); if (g_bChasingDocTail) { @@ -2647,7 +2528,7 @@ LRESULT MsgChangeNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) } if (!g_bRunningWatch) { - InstallFileWatching(g_wchCurFile); + InstallFileWatching(Globals.CurrentFile); } return 0LL; @@ -2668,7 +2549,7 @@ LRESULT MsgTrayMessage(HWND hwnd, WPARAM wParam, LPARAM lParam) case WM_RBUTTONUP: { - HMENU hMenu = LoadMenu(g_hLngResContainer, MAKEINTRESOURCE(IDR_MUI_POPUPMENU)); + HMENU hMenu = LoadMenu(Globals.hLngResContainer, MAKEINTRESOURCE(IDR_MUI_POPUPMENU)); HMENU hMenuPopup = GetSubMenu(hMenu, 2); POINT pt; @@ -2730,7 +2611,7 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) DocPos const iCurPos = SciCall_GetCurrentPos(); DocLn const iCurLine = SciCall_LineFromPosition(iCurPos); - int i = (int)StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile)); + int i = (int)StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile)); EnableCmd(hmenu,IDM_FILE_REVERT,i); EnableCmd(hmenu, CMD_RELOADASCIIASUTF8, i); EnableCmd(hmenu, CMD_RELOADFORCEDETECTION, i); @@ -2773,15 +2654,15 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) i = -1; CheckMenuRadioItem(hmenu,IDM_ENCODING_ANSI,IDM_ENCODING_UTF8SIGN,i,MF_BYCOMMAND); - if (g_iEOLMode == SC_EOL_CRLF) + if (Globals.iEOLMode == SC_EOL_CRLF) i = IDM_LINEENDINGS_CRLF; - else if (g_iEOLMode == SC_EOL_LF) + else if (Globals.iEOLMode == SC_EOL_LF) i = IDM_LINEENDINGS_LF; else i = IDM_LINEENDINGS_CR; CheckMenuRadioItem(hmenu,IDM_LINEENDINGS_CRLF,IDM_LINEENDINGS_CR,i,MF_BYCOMMAND); - EnableCmd(hmenu,IDM_FILE_RECENT,(MRU_Count(g_pFileMRU) > 0)); + EnableCmd(hmenu,IDM_FILE_RECENT,(MRU_Count(Globals.pFileMRU) > 0)); EnableCmd(hmenu,IDM_EDIT_UNDO,SciCall_CanUndo() && !ro); EnableCmd(hmenu,IDM_EDIT_REDO,SciCall_CanRedo() && !ro); @@ -2866,7 +2747,7 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) EnableCmd(hmenu,IDM_VIEW_SHOWEXCERPT, !s); - i = (int)SendMessage(g_hwndEdit,SCI_GETLEXER,0,0); + i = SciCall_GetLexer(); EnableCmd(hmenu,IDM_EDIT_LINECOMMENT, !(i == SCLEX_NULL || i == SCLEX_CSS || i == SCLEX_DIFF || i == SCLEX_MARKDOWN || i == SCLEX_JSON) && !ro); @@ -2912,128 +2793,128 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) EnableCmd(hmenu, CMD_CTRLDEL, !e && !ro); EnableCmd(hmenu, CMD_TIMESTAMPS, !e && !ro); - EnableCmd(hmenu, IDM_VIEW_FONT, !IsWindow(g_hwndDlgCustomizeSchemes)); - EnableCmd(hmenu, IDM_VIEW_CURRENTSCHEME, !IsWindow(g_hwndDlgCustomizeSchemes)); + EnableCmd(hmenu, IDM_VIEW_FONT, !IsWindow(Globals.hwndDlgCustomizeSchemes)); + EnableCmd(hmenu, IDM_VIEW_CURRENTSCHEME, !IsWindow(Globals.hwndDlgCustomizeSchemes)); EnableCmd(hmenu, IDM_VIEW_FOLDING, g_bCodeFoldingAvailable); - CheckCmd(hmenu, IDM_VIEW_FOLDING, (g_bCodeFoldingAvailable && g_bShowCodeFolding)); - EnableCmd(hmenu,IDM_VIEW_TOGGLEFOLDS,!e && (g_bCodeFoldingAvailable && g_bShowCodeFolding)); + CheckCmd(hmenu, IDM_VIEW_FOLDING, (g_bCodeFoldingAvailable && Settings.ShowCodeFolding)); + EnableCmd(hmenu,IDM_VIEW_TOGGLEFOLDS,!e && (g_bCodeFoldingAvailable && Settings.ShowCodeFolding)); bool const bF = (SC_FOLDLEVELBASE < (SciCall_GetFoldLevel(iCurLine) & SC_FOLDLEVELNUMBERMASK)); bool const bH = (SciCall_GetFoldLevel(iCurLine) & SC_FOLDLEVELHEADERFLAG); - EnableCmd(hmenu,IDM_VIEW_TOGGLE_CURRENT_FOLD, !e && (g_bCodeFoldingAvailable && g_bShowCodeFolding) && (bF || bH)); + EnableCmd(hmenu,IDM_VIEW_TOGGLE_CURRENT_FOLD, !e && (g_bCodeFoldingAvailable && Settings.ShowCodeFolding) && (bF || bH)); CheckCmd(hmenu,IDM_VIEW_USE2NDDEFAULT,Style_GetUse2ndDefault()); - CheckCmd(hmenu,IDM_VIEW_WORDWRAP,g_bWordWrap); - CheckCmd(hmenu,IDM_VIEW_LONGLINEMARKER,g_bMarkLongLines); - CheckCmd(hmenu,IDM_VIEW_TABSASSPACES,g_bTabsAsSpaces); - CheckCmd(hmenu,IDM_VIEW_SHOWINDENTGUIDES,bShowIndentGuides); - CheckCmd(hmenu,IDM_VIEW_AUTOINDENTTEXT,bAutoIndent); - CheckCmd(hmenu,IDM_VIEW_LINENUMBERS,g_bShowLineNumbers); - CheckCmd(hmenu,IDM_VIEW_MARGIN,g_bShowSelectionMargin); + CheckCmd(hmenu,IDM_VIEW_WORDWRAP,Settings.WordWrap); + CheckCmd(hmenu,IDM_VIEW_LONGLINEMARKER,Settings.MarkLongLines); + CheckCmd(hmenu,IDM_VIEW_TABSASSPACES,Settings.TabsAsSpaces); + CheckCmd(hmenu,IDM_VIEW_SHOWINDENTGUIDES,Settings.ShowIndentGuides); + CheckCmd(hmenu,IDM_VIEW_AUTOINDENTTEXT,Settings.AutoIndent); + CheckCmd(hmenu,IDM_VIEW_LINENUMBERS,Settings.ShowLineNumbers); + CheckCmd(hmenu,IDM_VIEW_MARGIN,Settings.ShowSelectionMargin); CheckCmd(hmenu,IDM_VIEW_CHASING_DOCTAIL, g_bChasingDocTail); EnableCmd(hmenu,IDM_EDIT_COMPLETEWORD,!e && !ro); - CheckCmd(hmenu,IDM_VIEW_AUTOCOMPLETEWORDS,g_bAutoCompleteWords && !ro); - CheckCmd(hmenu,IDM_VIEW_AUTOCLEXKEYWORDS, g_bAutoCLexerKeyWords && !ro); + CheckCmd(hmenu,IDM_VIEW_AUTOCOMPLETEWORDS,Settings.AutoCompleteWords && !ro); + CheckCmd(hmenu,IDM_VIEW_AUTOCLEXKEYWORDS, Settings.AutoCLexerKeyWords && !ro); - CheckCmd(hmenu,IDM_VIEW_ACCELWORDNAV,g_bAccelWordNavigation); + CheckCmd(hmenu,IDM_VIEW_ACCELWORDNAV,Settings.AccelWordNavigation); - CheckCmd(hmenu, IDM_VIEW_MARKOCCUR_ONOFF, (g_iMarkOccurrences > 0)); - CheckCmd(hmenu, IDM_VIEW_MARKOCCUR_VISIBLE, g_bMarkOccurrencesMatchVisible); - CheckCmd(hmenu, IDM_VIEW_MARKOCCUR_CASE, g_bMarkOccurrencesMatchCase); + CheckCmd(hmenu, IDM_VIEW_MARKOCCUR_ONOFF, (Settings.MarkOccurrences > 0)); + CheckCmd(hmenu, IDM_VIEW_MARKOCCUR_VISIBLE, Settings.MarkOccurrencesMatchVisible); + CheckCmd(hmenu, IDM_VIEW_MARKOCCUR_CASE, Settings.MarkOccurrencesMatchCase); - EnableCmd(hmenu, IDM_VIEW_TOGGLE_VIEW, (g_iMarkOccurrences > 0) && !g_bMarkOccurrencesMatchVisible); - CheckCmd(hmenu, IDM_VIEW_TOGGLE_VIEW, EditToggleView(g_hwndEdit, false)); + EnableCmd(hmenu, IDM_VIEW_TOGGLE_VIEW, (Settings.MarkOccurrences > 0) && !Settings.MarkOccurrencesMatchVisible); + CheckCmd(hmenu, IDM_VIEW_TOGGLE_VIEW, EditToggleView(Globals.hwndEdit, false)); - if (g_bMarkOccurrencesMatchWords) + if (Settings.MarkOccurrencesMatchWholeWords) i = IDM_VIEW_MARKOCCUR_WORD; - else if (g_bMarkOccurrencesCurrentWord) + else if (Settings.MarkOccurrencesCurrentWord) i = IDM_VIEW_MARKOCCUR_CURRENT; else i = IDM_VIEW_MARKOCCUR_WNONE; CheckMenuRadioItem(hmenu, IDM_VIEW_MARKOCCUR_WNONE, IDM_VIEW_MARKOCCUR_CURRENT, i, MF_BYCOMMAND); - CheckCmdPos(GetSubMenu(GetSubMenu(GetMenu(g_hwndMain), 2), 17), 5, (i != IDM_VIEW_MARKOCCUR_WNONE)); + CheckCmdPos(GetSubMenu(GetSubMenu(GetMenu(Globals.hwndMain), 2), 17), 5, (i != IDM_VIEW_MARKOCCUR_WNONE)); - i = (int)(g_iMarkOccurrences > 0); + i = (int)(Settings.MarkOccurrences > 0); EnableCmd(hmenu, IDM_VIEW_MARKOCCUR_VISIBLE, i); EnableCmd(hmenu, IDM_VIEW_MARKOCCUR_CASE, i); EnableCmd(hmenu, IDM_VIEW_MARKOCCUR_WNONE, i); EnableCmd(hmenu,IDM_VIEW_MARKOCCUR_WORD, i); EnableCmd(hmenu, IDM_VIEW_MARKOCCUR_CURRENT, i); - EnableCmdPos(GetSubMenu(GetSubMenu(GetMenu(g_hwndMain), 2), 17), 5, i); + EnableCmdPos(GetSubMenu(GetSubMenu(GetMenu(Globals.hwndMain), 2), 17), 5, i); - CheckCmd(hmenu,IDM_VIEW_SHOWBLANKS,bViewWhiteSpace); - CheckCmd(hmenu,IDM_VIEW_SHOWEOLS,bViewEOLs); - CheckCmd(hmenu,IDM_VIEW_WORDWRAPSYMBOLS,bShowWordWrapSymbols); - CheckCmd(hmenu,IDM_VIEW_MATCHBRACES,bMatchBraces); - CheckCmd(hmenu,IDM_VIEW_TOOLBAR,bShowToolbar); - EnableCmd(hmenu,IDM_VIEW_CUSTOMIZETB,bShowToolbar); - CheckCmd(hmenu,IDM_VIEW_STATUSBAR,bShowStatusbar); + CheckCmd(hmenu,IDM_VIEW_SHOWBLANKS,Settings.ViewWhiteSpace); + CheckCmd(hmenu,IDM_VIEW_SHOWEOLS,Settings.ViewEOLs); + CheckCmd(hmenu,IDM_VIEW_WORDWRAPSYMBOLS,Settings.ShowWordWrapSymbols); + CheckCmd(hmenu,IDM_VIEW_MATCHBRACES,Settings.MatchBraces); + CheckCmd(hmenu,IDM_VIEW_TOOLBAR,Settings.ShowToolbar); + EnableCmd(hmenu,IDM_VIEW_CUSTOMIZETB, Settings.ShowToolbar); + CheckCmd(hmenu,IDM_VIEW_STATUSBAR,Settings.ShowStatusbar); - i = (int)SendMessage(g_hwndEdit,SCI_GETLEXER,0,0); + i = SciCall_GetLexer(); //EnableCmd(hmenu,IDM_VIEW_AUTOCLOSETAGS,(i == SCLEX_HTML || i == SCLEX_XML)); - CheckCmd(hmenu, IDM_VIEW_AUTOCLOSETAGS, bAutoCloseTags /*&& (i == SCLEX_HTML || i == SCLEX_XML)*/); - CheckCmd(hmenu, IDM_VIEW_HILITECURRENTLINE, bHiliteCurrentLine); - CheckCmd(hmenu, IDM_VIEW_HYPERLINKHOTSPOTS, g_bHyperlinkHotspot); - CheckCmd(hmenu, IDM_VIEW_SCROLLPASTEOF, bScrollPastEOF); + CheckCmd(hmenu, IDM_VIEW_AUTOCLOSETAGS, Settings.AutoCloseTags /*&& (i == SCLEX_HTML || i == SCLEX_XML)*/); + CheckCmd(hmenu, IDM_VIEW_HILITECURRENTLINE, Settings.HighlightCurrentLine); + CheckCmd(hmenu, IDM_VIEW_HYPERLINKHOTSPOTS, Settings.HyperlinkHotspot); + CheckCmd(hmenu, IDM_VIEW_SCROLLPASTEOF, Settings.ScrollPastEOF); - i = IniGetInt(L"Settings2",L"ReuseWindow",0); + i = Flags.ReuseWindow; CheckCmd(hmenu,IDM_VIEW_REUSEWINDOW,i); - i = IniGetInt(L"Settings2",L"SingleFileInstance",0); + i = Flags.SingleFileInstance; CheckCmd(hmenu,IDM_VIEW_SINGLEFILEINSTANCE,i); - g_bStickyWinPos = IniGetBool(L"Settings2",L"StickyWindowPosition",false); - CheckCmd(hmenu,IDM_VIEW_STICKYWINPOS,g_bStickyWinPos); - CheckCmd(hmenu,IDM_VIEW_ALWAYSONTOP,((bAlwaysOnTop || g_flagAlwaysOnTop == 2) && g_flagAlwaysOnTop != 1)); - CheckCmd(hmenu,IDM_VIEW_MINTOTRAY,bMinimizeToTray); - CheckCmd(hmenu,IDM_VIEW_TRANSPARENT,g_bTransparentMode); + i = Flags.StickyWindowPosition; + CheckCmd(hmenu,IDM_VIEW_STICKYWINPOS,i); + CheckCmd(hmenu,IDM_VIEW_ALWAYSONTOP,((Settings.AlwaysOnTop || s_flagAlwaysOnTop == 2) && s_flagAlwaysOnTop != 1)); + CheckCmd(hmenu,IDM_VIEW_MINTOTRAY,Settings.MinimizeToTray); + CheckCmd(hmenu,IDM_VIEW_TRANSPARENT,Settings.TransparentMode); - i = IDM_SET_RENDER_TECH_DEFAULT + g_iRenderingTechnology; + i = IDM_SET_RENDER_TECH_DEFAULT + Settings.RenderingTechnology; CheckMenuRadioItem(hmenu, IDM_SET_RENDER_TECH_DEFAULT, IDM_SET_RENDER_TECH_D2DDC, i, MF_BYCOMMAND); - if (g_iRenderingTechnology > 0) { - i = IDM_SET_BIDIRECTIONAL_NONE + g_iBidirectional; + if (Settings.RenderingTechnology > 0) { + i = IDM_SET_BIDIRECTIONAL_NONE + Settings.Bidirectional; CheckMenuRadioItem(hmenu, IDM_SET_BIDIRECTIONAL_NONE, IDM_SET_BIDIRECTIONAL_R2L, i, MF_BYCOMMAND); } else { i = IDM_SET_BIDIRECTIONAL_NONE; CheckMenuRadioItem(hmenu, IDM_SET_BIDIRECTIONAL_NONE, IDM_SET_BIDIRECTIONAL_R2L, i, MF_BYCOMMAND); } - EnableCmd(hmenu, IDM_SET_BIDIRECTIONAL_NONE, (g_iRenderingTechnology > 0)); - EnableCmd(hmenu, IDM_SET_BIDIRECTIONAL_L2R, (g_iRenderingTechnology > 0)); - EnableCmd(hmenu, IDM_SET_BIDIRECTIONAL_R2L, (g_iRenderingTechnology > 0)); + EnableCmd(hmenu, IDM_SET_BIDIRECTIONAL_NONE, (Settings.RenderingTechnology > 0)); + EnableCmd(hmenu, IDM_SET_BIDIRECTIONAL_L2R, (Settings.RenderingTechnology > 0)); + EnableCmd(hmenu, IDM_SET_BIDIRECTIONAL_R2L, (Settings.RenderingTechnology > 0)); - CheckCmd(hmenu,IDM_VIEW_NOSAVERECENT,g_bSaveRecentFiles); - CheckCmd(hmenu,IDM_VIEW_NOPRESERVECARET, g_bPreserveCaretPos); - CheckCmd(hmenu,IDM_VIEW_NOSAVEFINDREPL,g_bSaveFindReplace); - CheckCmd(hmenu,IDM_VIEW_SAVEBEFORERUNNINGTOOLS,bSaveBeforeRunningTools); + CheckCmd(hmenu,IDM_VIEW_NOSAVERECENT,Settings.SaveRecentFiles); + CheckCmd(hmenu,IDM_VIEW_NOPRESERVECARET, Settings.PreserveCaretPos); + CheckCmd(hmenu,IDM_VIEW_NOSAVEFINDREPL,Settings.SaveFindReplace); + CheckCmd(hmenu,IDM_VIEW_SAVEBEFORERUNNINGTOOLS,Settings.SaveBeforeRunningTools); - CheckCmd(hmenu,IDM_VIEW_CHANGENOTIFY,g_iFileWatchingMode); + CheckCmd(hmenu,IDM_VIEW_CHANGENOTIFY,Settings.FileWatchingMode); if (StringCchLenW(szTitleExcerpt,COUNTOF(szTitleExcerpt))) i = IDM_VIEW_SHOWEXCERPT; - else if (iPathNameFormat == 0) + else if (Settings.PathNameFormat == 0) i = IDM_VIEW_SHOWFILENAMEONLY; - else if (iPathNameFormat == 1) + else if (Settings.PathNameFormat == 1) i = IDM_VIEW_SHOWFILENAMEFIRST; else i = IDM_VIEW_SHOWFULLPATH; CheckMenuRadioItem(hmenu,IDM_VIEW_SHOWFILENAMEONLY,IDM_VIEW_SHOWEXCERPT,i,MF_BYCOMMAND); - if (iEscFunction == 1) + if (Settings.EscFunction == 1) i = IDM_VIEW_ESCMINIMIZE; - else if (iEscFunction == 2) + else if (Settings.EscFunction == 2) i = IDM_VIEW_ESCEXIT; else i = IDM_VIEW_NOESCFUNC; CheckMenuRadioItem(hmenu,IDM_VIEW_NOESCFUNC,IDM_VIEW_ESCEXIT,i,MF_BYCOMMAND); - i = (int)StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)); - CheckCmd(hmenu,IDM_VIEW_SAVESETTINGS,g_bSaveSettings && i); + i = (int)StringCchLenW(Globals.IniFile,COUNTOF(Globals.IniFile)); + CheckCmd(hmenu,IDM_VIEW_SAVESETTINGS,s_bSaveSettings && i); EnableCmd(hmenu,IDM_VIEW_REUSEWINDOW,i); EnableCmd(hmenu,IDM_VIEW_STICKYWINPOS,i); @@ -3041,13 +2922,13 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) EnableCmd(hmenu,IDM_VIEW_NOSAVERECENT,i); EnableCmd(hmenu,IDM_VIEW_NOPRESERVECARET,i); EnableCmd(hmenu,IDM_VIEW_NOSAVEFINDREPL,i); - EnableCmd(hmenu,IDM_VIEW_SAVESETTINGS,g_bEnableSaveSettings && i); + EnableCmd(hmenu,IDM_VIEW_SAVESETTINGS,s_bEnableSaveSettings && i); CheckCmd(hmenu, IDM_VIEW_TOGGLETB, (iHighDpiToolBar > 0)); - EnableCmd(hmenu, IDM_VIEW_TOGGLETB, !g_bExternalBitmap); + EnableCmd(hmenu, IDM_VIEW_TOGGLETB, !s_bExternalBitmap); - i = (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)) > 0 || StringCchLenW(g_wchIniFile2,COUNTOF(g_wchIniFile2)) > 0); - EnableCmd(hmenu,IDM_VIEW_SAVESETTINGSNOW,g_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(); @@ -3057,7 +2938,7 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) } EnableCmd(hmenu, CMD_OPEN_HYPERLINK, bIsHLink); - i = (int)StringCchLenW(g_tchAdministrationExe, COUNTOF(g_tchAdministrationExe)); + i = (int)StringCchLenW(Settings2.AdministrationTool, COUNTOF(Settings2.AdministrationTool)); EnableCmd(hmenu, IDM_HELP_ADMINEXE, i); return 0LL; @@ -3077,7 +2958,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) switch(LOWORD(wParam)) { case SCEN_CHANGE: - MarkAllOccurrences(iUpdateDelayMarkAllCoccurrences, false); + MarkAllOccurrences(Settings2.UpdateDelayMarkAllOccurrences, false); break; case IDT_TIMER_UPDATE_STATUSBAR: @@ -3089,20 +2970,20 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; case IDT_TIMER_MAIN_MRKALL: - EditMarkAllOccurrences(g_hwndEdit, (bool)lParam); + EditMarkAllOccurrences(Globals.hwndEdit, (bool)lParam); break; case IDT_TIMER_UPDATE_HOTSPOT: - EditUpdateVisibleUrlHotspot(g_bHyperlinkHotspot); + EditUpdateVisibleUrlHotspot(Settings.HyperlinkHotspot); break; case IDM_FILE_NEW: - FileLoad(false,true,false,bSkipUnicodeDetection,bSkipANSICodePageDetection,L""); + FileLoad(false,true,false,Settings.SkipUnicodeDetection,Settings.SkipANSICodePageDetection,L""); break; case IDM_FILE_OPEN: - FileLoad(false,false,false,bSkipUnicodeDetection,bSkipANSICodePageDetection,L""); + FileLoad(false,false,false,Settings.SkipUnicodeDetection,Settings.SkipANSICodePageDetection,L""); break; @@ -3110,7 +2991,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if ((IsDocumentModified || Encoding_HasChanged(CPI_GET)) && MsgBoxLng(MBYESNO,IDS_MUI_ASK_REVERT) != IDYES) { break; } - FileRevert(g_wchCurFile, Encoding_HasChanged(CPI_GET)); + FileRevert(Globals.CurrentFile, Encoding_HasChanged(CPI_GET)); break; @@ -3130,21 +3011,21 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_FILE_READONLY: - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { - DWORD dwFileAttributes = GetFileAttributes(g_wchCurFile); + DWORD dwFileAttributes = GetFileAttributes(Globals.CurrentFile); if (dwFileAttributes != INVALID_FILE_ATTRIBUTES) { if (g_bFileReadOnly) dwFileAttributes = (dwFileAttributes & ~FILE_ATTRIBUTE_READONLY); else dwFileAttributes |= FILE_ATTRIBUTE_READONLY; - if (!SetFileAttributes(g_wchCurFile,dwFileAttributes)) - MsgBoxLng(MBWARN,IDS_MUI_READONLY_MODIFY,g_wchCurFile); + if (!SetFileAttributes(Globals.CurrentFile,dwFileAttributes)) + MsgBoxLng(MBWARN,IDS_MUI_READONLY_MODIFY,Globals.CurrentFile); } else - MsgBoxLng(MBWARN,IDS_MUI_READONLY_MODIFY,g_wchCurFile); + MsgBoxLng(MBWARN,IDS_MUI_READONLY_MODIFY,Globals.CurrentFile); - dwFileAttributes = GetFileAttributes(g_wchCurFile); + dwFileAttributes = GetFileAttributes(Globals.CurrentFile); if (dwFileAttributes != INVALID_FILE_ATTRIBUTES) g_bFileReadOnly = (dwFileAttributes & FILE_ATTRIBUTE_READONLY); @@ -3161,20 +3042,20 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_FILE_NEWWINDOW: case IDM_FILE_NEWWINDOW2: //~SaveSettings(false); - DialogNewWindow(hwnd, bSaveBeforeRunningTools, (LOWORD(wParam) != IDM_FILE_NEWWINDOW2)); + DialogNewWindow(hwnd, Settings.SaveBeforeRunningTools, (LOWORD(wParam) != IDM_FILE_NEWWINDOW2)); break; case IDM_FILE_LAUNCH: { - if (!StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) + if (!StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) break; - if (bSaveBeforeRunningTools && !FileSave(false,true,false,false)) + if (Settings.SaveBeforeRunningTools && !FileSave(false,true,false,false)) break; - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { - StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),g_wchCurFile); + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { + StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),Globals.CurrentFile); PathRemoveFileSpec(tchMaxPathBuffer); } @@ -3184,7 +3065,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) sei.fMask = 0; sei.hwnd = hwnd; sei.lpVerb = NULL; - sei.lpFile = g_wchCurFile; + sei.lpFile = Globals.CurrentFile; sei.lpParameters = NULL; sei.lpDirectory = tchMaxPathBuffer; sei.nShow = SW_SHOWNORMAL; @@ -3195,10 +3076,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_FILE_RUN: { - if (bSaveBeforeRunningTools && !FileSave(false, true, false, false)) { + if (Settings.SaveBeforeRunningTools && !FileSave(false, true, false, false)) { break; } - StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),g_wchCurFile); + StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),Globals.CurrentFile); PathQuoteSpaces(tchMaxPathBuffer); RunDlg(hwnd,tchMaxPathBuffer); @@ -3207,14 +3088,14 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_FILE_OPENWITH: - if (bSaveBeforeRunningTools && !FileSave(false,true,false,false)) + if (Settings.SaveBeforeRunningTools && !FileSave(false,true,false,false)) break; - OpenWithDlg(hwnd,g_wchCurFile); + OpenWithDlg(hwnd,Globals.CurrentFile); break; case IDM_FILE_PAGESETUP: - EditPrintSetup(g_hwndEdit); + EditPrintSetup(Globals.hwndEdit); break; case IDM_FILE_PRINT: @@ -3226,8 +3107,8 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) WCHAR tchUntitled[32] = { L'\0' }; WCHAR tchPageFmt[32] = { L'\0' }; - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { - SHGetFileInfo2(g_wchCurFile,FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES); + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { + SHGetFileInfo2(Globals.CurrentFile,FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES); pszTitle = shfi.szDisplayName; } else { @@ -3237,7 +3118,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) GetLngString(IDS_MUI_PRINT_PAGENUM,tchPageFmt,COUNTOF(tchPageFmt)); - if (!EditPrint(g_hwndEdit,pszTitle,tchPageFmt)) + if (!EditPrint(Globals.hwndEdit,pszTitle,tchPageFmt)) MsgBoxLng(MBWARN,IDS_MUI_PRINT_ERROR,pszTitle); } break; @@ -3245,7 +3126,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_FILE_PROPERTIES: { - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile)) == 0) + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile)) == 0) break; SHELLEXECUTEINFO sei; @@ -3254,7 +3135,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) sei.fMask = SEE_MASK_INVOKEIDLIST; sei.hwnd = hwnd; sei.lpVerb = L"properties"; - sei.lpFile = g_wchCurFile; + sei.lpFile = Globals.CurrentFile; sei.nShow = SW_SHOWNORMAL; ShellExecuteEx(&sei); } @@ -3262,10 +3143,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_FILE_CREATELINK: { - if (!StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) + if (!StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) break; - if (!PathCreateDeskLnk(g_wchCurFile)) + if (!PathCreateDeskLnk(Globals.CurrentFile)) MsgBoxLng(MBWARN,IDS_MUI_ERR_CREATELINK); } break; @@ -3280,22 +3161,22 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (PathIsDirectory(tchMaxPathBuffer)) { - if (OpenFileDlg(g_hwndMain, tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),tchMaxPathBuffer)) - FileLoad(true,false,false,bSkipUnicodeDetection,bSkipANSICodePageDetection, tchMaxPathBuffer); + if (OpenFileDlg(Globals.hwndMain, tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),tchMaxPathBuffer)) + FileLoad(true,false,false,Settings.SkipUnicodeDetection,Settings.SkipANSICodePageDetection, tchMaxPathBuffer); } else - FileLoad(true,false,false,bSkipUnicodeDetection,bSkipANSICodePageDetection,tchMaxPathBuffer); + FileLoad(true,false,false,Settings.SkipUnicodeDetection,Settings.SkipANSICodePageDetection,tchMaxPathBuffer); } } break; case IDM_FILE_ADDTOFAV: - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { SHFILEINFO shfi; - SHGetFileInfo2(g_wchCurFile,FILE_ATTRIBUTE_NORMAL, + SHGetFileInfo2(Globals.CurrentFile,FILE_ATTRIBUTE_NORMAL, &shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES); - AddToFavDlg(hwnd,shfi.szDisplayName,g_wchCurFile); + AddToFavDlg(hwnd,shfi.szDisplayName,Globals.CurrentFile); } break; @@ -3308,7 +3189,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) sei.fMask = 0; sei.hwnd = hwnd; sei.lpVerb = NULL; - sei.lpFile = g_tchFavoritesDir; + sei.lpFile = Settings.FavoritesDir; sei.lpParameters = NULL; sei.lpDirectory = NULL; sei.nShow = SW_SHOWNORMAL; @@ -3319,7 +3200,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_FILE_RECENT: - if (MRU_Count(g_pFileMRU) > 0) { + if (MRU_Count(Globals.pFileMRU) > 0) { if (FileSave(false,true,false,false)) { WCHAR tchFile[MAX_PATH] = { L'\0' }; if (FileMRUDlg(hwnd,tchFile)) @@ -3356,10 +3237,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) BeginWaitCursor(NULL); _IGNORE_NOTIFY_CHANGE_; - if (EditSetNewEncoding(g_hwndEdit, iNewEncoding, g_flagSetEncoding, - StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile)) == 0)) { + if (EditSetNewEncoding(Globals.hwndEdit, iNewEncoding, s_flagSetEncoding, + StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile)) == 0)) { - if (SendMessage(g_hwndEdit,SCI_GETLENGTH,0,0) == 0) { + if (SendMessage(Globals.hwndEdit,SCI_GETLENGTH,0,0) == 0) { Encoding_Current(iNewEncoding); Encoding_HasChanged(iNewEncoding); } @@ -3378,7 +3259,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_ENCODING_RECODE: { - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { int iNewEncoding = Encoding_MapUnicode(Encoding_Current(CPI_GET)); @@ -3387,7 +3268,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (RecodeDlg(hwnd,&iNewEncoding)) { - StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),g_wchCurFile); + StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),Globals.CurrentFile); Encoding_SrcCmdLn(iNewEncoding); FileLoad(true,false,true,false,true,tchMaxPathBuffer); } @@ -3397,7 +3278,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_ENCODING_SETDEFAULT: - SelectDefEncodingDlg(hwnd,&g_iDefaultNewFileEncoding); + SelectDefEncodingDlg(hwnd,&Settings.DefaultEncoding); break; @@ -3407,10 +3288,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _IGNORE_NOTIFY_CHANGE_; - g_iEOLMode = (LOWORD(wParam)-IDM_LINEENDINGS_CRLF); // SC_EOL_CRLF(0), SC_EOL_CR(1), SC_EOL_LF(2) - SendMessage(g_hwndEdit,SCI_SETEOLMODE,g_iEOLMode,0); - SendMessage(g_hwndEdit,SCI_CONVERTEOLS,g_iEOLMode,0); - EditFixPositions(g_hwndEdit); + Globals.iEOLMode = (LOWORD(wParam)-IDM_LINEENDINGS_CRLF); // SC_EOL_CRLF(0), SC_EOL_CR(1), SC_EOL_LF(2) + SendMessage(Globals.hwndEdit,SCI_SETEOLMODE,Globals.iEOLMode,0); + SendMessage(Globals.hwndEdit,SCI_CONVERTEOLS,Globals.iEOLMode,0); + EditFixPositions(Globals.hwndEdit); _OBSERVE_NOTIFY_CHANGE_; EndWaitCursor(); UpdateStatusbar(false); @@ -3419,7 +3300,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_LINEENDINGS_SETDEFAULT: - SelectDefLineEndingDlg(hwnd,&g_iDefaultEOLMode); + SelectDefLineEndingDlg(hwnd,&Settings.DefaultEOLMode); break; @@ -3444,7 +3325,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_CUT: { - if (g_flagPasteBoard) + if (s_flagPasteBoard) bLastCopyFromMe = true; _BEGIN_UNDO_ACTION_; @@ -3464,7 +3345,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_COPY: case IDM_EDIT_COPYLINE: - if (g_flagPasteBoard) + if (s_flagPasteBoard) bLastCopyFromMe = true; SciCall_CopyAllowLine(); UpdateToolbar(); @@ -3473,7 +3354,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_COPYALL: { - if (g_flagPasteBoard) + if (s_flagPasteBoard) bLastCopyFromMe = true; SciCall_CopyRange(0, Sci_GetDocEndPosition()); UpdateToolbar(); @@ -3483,16 +3364,16 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_COPYADD: { - if (g_flagPasteBoard) + if (s_flagPasteBoard) bLastCopyFromMe = true; - EditCopyAppend(g_hwndEdit,true); + EditCopyAppend(Globals.hwndEdit,true); UpdateToolbar(); } break; case IDM_EDIT_PASTE: { - if (g_flagPasteBoard) + if (s_flagPasteBoard) bLastCopyFromMe = true; _BEGIN_UNDO_ACTION_; _IGNORE_NOTIFY_CHANGE_; @@ -3507,11 +3388,11 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_SWAP: { - if (g_flagPasteBoard) + if (s_flagPasteBoard) bLastCopyFromMe = true; _BEGIN_UNDO_ACTION_; _IGNORE_NOTIFY_CHANGE_; - EditSwapClipboard(g_hwndEdit, bSkipUnicodeDetection); + EditSwapClipboard(Globals.hwndEdit, Settings.SkipUnicodeDetection); _OBSERVE_NOTIFY_CHANGE_; _END_UNDO_ACTION_; UpdateToolbar(); @@ -3521,13 +3402,13 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; case IDM_EDIT_CLEARCLIPBOARD: - EditClearClipboard(g_hwndEdit); + EditClearClipboard(Globals.hwndEdit); UpdateToolbar(); break; case IDM_EDIT_SELECTALL: - SendMessage(g_hwndEdit,SCI_SELECTALL,0,0); + SendMessage(Globals.hwndEdit,SCI_SELECTALL,0,0); UpdateToolbar(); UpdateStatusbar(false); break; @@ -3537,7 +3418,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { DocPos iPos = SciCall_GetCurrentPos(); - if (SendMessage(g_hwndEdit, SCI_GETSELECTIONEMPTY, 0, 0)) { + if (SendMessage(Globals.hwndEdit, SCI_GETSELECTIONEMPTY, 0, 0)) { DocPos iWordStart = SciCall_WordStartPosition(iPos, true); DocPos iWordEnd = SciCall_WordEndPosition(iPos, true); @@ -3588,7 +3469,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_MOVELINEUP: { _BEGIN_UNDO_ACTION_; - EditMoveUp(g_hwndEdit); + EditMoveUp(Globals.hwndEdit); _END_UNDO_ACTION_; } break; @@ -3597,7 +3478,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_MOVELINEDOWN: { _BEGIN_UNDO_ACTION_; - EditMoveDown(g_hwndEdit); + EditMoveDown(Globals.hwndEdit); _END_UNDO_ACTION_; } break; @@ -3618,10 +3499,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_CUTLINE: { - if (g_flagPasteBoard) + if (s_flagPasteBoard) bLastCopyFromMe = true; _BEGIN_UNDO_ACTION_; - SendMessage(g_hwndEdit,SCI_LINECUT,0,0); + SendMessage(Globals.hwndEdit,SCI_LINECUT,0,0); _END_UNDO_ACTION_; UpdateToolbar(); } @@ -3658,7 +3539,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_INDENT: { _BEGIN_UNDO_ACTION_; - EditIndentBlock(g_hwndEdit, SCI_TAB, true); + EditIndentBlock(Globals.hwndEdit, SCI_TAB, true); _END_UNDO_ACTION_; } break; @@ -3666,7 +3547,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_UNINDENT: { _BEGIN_UNDO_ACTION_; - EditIndentBlock(g_hwndEdit, SCI_BACKTAB, true); + EditIndentBlock(Globals.hwndEdit, SCI_BACKTAB, true); _END_UNDO_ACTION_; } break; @@ -3674,7 +3555,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_TAB: { _BEGIN_UNDO_ACTION_; - EditIndentBlock(g_hwndEdit, SCI_TAB, false); + EditIndentBlock(Globals.hwndEdit, SCI_TAB, false); _END_UNDO_ACTION_; } break; @@ -3682,7 +3563,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_BACKTAB: { _BEGIN_UNDO_ACTION_; - EditIndentBlock(g_hwndEdit, SCI_BACKTAB, false); + EditIndentBlock(Globals.hwndEdit, SCI_BACKTAB, false); _END_UNDO_ACTION_; } break; @@ -3690,11 +3571,11 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_CTRLTAB: { _BEGIN_UNDO_ACTION_; - SendMessage(g_hwndEdit, SCI_SETUSETABS, true, 0); - SendMessage(g_hwndEdit, SCI_SETTABINDENTS, false, 0); - EditIndentBlock(g_hwndEdit, SCI_TAB, false); - SendMessage(g_hwndEdit, SCI_SETTABINDENTS, g_bTabIndents, 0); - SendMessage(g_hwndEdit, SCI_SETUSETABS, !g_bTabsAsSpaces, 0); + SendMessage(Globals.hwndEdit, SCI_SETUSETABS, true, 0); + SendMessage(Globals.hwndEdit, SCI_SETTABINDENTS, false, 0); + EditIndentBlock(Globals.hwndEdit, SCI_TAB, false); + SendMessage(Globals.hwndEdit, SCI_SETTABINDENTS, Settings.TabIndents, 0); + SendMessage(Globals.hwndEdit, SCI_SETUSETABS, !Settings.TabsAsSpaces, 0); _END_UNDO_ACTION_; } break; @@ -3702,13 +3583,13 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_DELETEBACK: { _BEGIN_UNDO_ACTION_; - SendMessage(g_hwndEdit, SCI_DELETEBACK, 0, 0); + SendMessage(Globals.hwndEdit, SCI_DELETEBACK, 0, 0); _END_UNDO_ACTION_; } break; case CMD_VK_INSERT: - SendMessage(g_hwndEdit, SCI_EDITTOGGLEOVERTYPE, 0, 0); + SendMessage(Globals.hwndEdit, SCI_EDITTOGGLEOVERTYPE, 0, 0); UpdateStatusbar(false); break; @@ -3716,7 +3597,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (EditEncloseSelectionDlg(hwnd,wchPrefixSelection,wchAppendSelection)) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditEncloseSelection(g_hwndEdit,wchPrefixSelection,wchAppendSelection); + EditEncloseSelection(Globals.hwndEdit,wchPrefixSelection,wchAppendSelection); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3726,7 +3607,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_PADWITHSPACES: { BeginWaitCursor(NULL); - EditPadWithSpaces(g_hwndEdit,false,false); + EditPadWithSpaces(Globals.hwndEdit,false,false); EndWaitCursor(); } break; @@ -3736,7 +3617,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditStripFirstCharacter(g_hwndEdit); + EditStripFirstCharacter(Globals.hwndEdit); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3747,7 +3628,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditStripLastCharacter(g_hwndEdit, false, false); + EditStripLastCharacter(Globals.hwndEdit, false, false); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3758,7 +3639,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditStripLastCharacter(g_hwndEdit, false, true); + EditStripLastCharacter(Globals.hwndEdit, false, true); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3769,7 +3650,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditCompressBlanks(g_hwndEdit); + EditCompressBlanks(Globals.hwndEdit); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3780,7 +3661,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditRemoveBlankLines(g_hwndEdit, true, true); + EditRemoveBlankLines(Globals.hwndEdit, true, true); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3790,7 +3671,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditRemoveBlankLines(g_hwndEdit, true, false); + EditRemoveBlankLines(Globals.hwndEdit, true, false); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3801,7 +3682,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditRemoveBlankLines(g_hwndEdit, false, true); + EditRemoveBlankLines(Globals.hwndEdit, false, true); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3812,7 +3693,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditRemoveBlankLines(g_hwndEdit, false, false); + EditRemoveBlankLines(Globals.hwndEdit, false, false); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3823,7 +3704,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditRemoveDuplicateLines(g_hwndEdit, false); + EditRemoveDuplicateLines(Globals.hwndEdit, false); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3835,7 +3716,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (EditModifyLinesDlg(hwnd,wchPrefixLines,wchAppendLines)) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditModifyLines(g_hwndEdit,wchPrefixLines,wchAppendLines); + EditModifyLines(Globals.hwndEdit,wchPrefixLines,wchAppendLines); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3848,7 +3729,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (EditAlignDlg(hwnd,&iAlignMode)) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditAlignText(g_hwndEdit,iAlignMode); + EditAlignText(Globals.hwndEdit,iAlignMode); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3861,7 +3742,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (EditSortDlg(hwnd,&iSortOptions)) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditSortLines(g_hwndEdit,iSortOptions); + EditSortLines(Globals.hwndEdit,iSortOptions); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3872,16 +3753,16 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_COLUMNWRAP: { if (iWrapCol == 0) { - iWrapCol = g_iLongLinesLimit; + iWrapCol = Settings.LongLinesLimit; } UINT uWrpCol = 0; if (ColumnWrapDlg(hwnd,IDD_MUI_COLUMNWRAP,&uWrpCol)) { - iWrapCol = (DocPos)clampi((int)uWrpCol, 1, g_iLongLinesLimit); + iWrapCol = (DocPos)clampi((int)uWrpCol, 1, Settings.LongLinesLimit); BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditWrapToColumn(g_hwndEdit,iWrapCol); + EditWrapToColumn(Globals.hwndEdit,iWrapCol); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3893,7 +3774,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditSplitLines(g_hwndEdit); + EditSplitLines(Globals.hwndEdit); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3904,7 +3785,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditJoinLinesEx(g_hwndEdit, false, true); + EditJoinLinesEx(Globals.hwndEdit, false, true); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3914,7 +3795,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditJoinLinesEx(g_hwndEdit, false, false); + EditJoinLinesEx(Globals.hwndEdit, false, false); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3924,7 +3805,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditJoinLinesEx(g_hwndEdit, true, true); + EditJoinLinesEx(Globals.hwndEdit, true, true); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3935,7 +3816,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - SendMessage(g_hwndEdit,SCI_UPPERCASE,0,0); + SendMessage(Globals.hwndEdit,SCI_UPPERCASE,0,0); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3946,7 +3827,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - SendMessage(g_hwndEdit,SCI_LOWERCASE,0,0); + SendMessage(Globals.hwndEdit,SCI_LOWERCASE,0,0); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3957,7 +3838,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditInvertCase(g_hwndEdit); + EditInvertCase(Globals.hwndEdit); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3968,7 +3849,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditTitleCase(g_hwndEdit); + EditTitleCase(Globals.hwndEdit); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3979,7 +3860,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditSentenceCase(g_hwndEdit); + EditSentenceCase(Globals.hwndEdit); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -3990,7 +3871,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditTabsToSpaces(g_hwndEdit, g_iTabWidth, false); + EditTabsToSpaces(Globals.hwndEdit, Settings.TabWidth, false); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -4001,7 +3882,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditSpacesToTabs(g_hwndEdit, g_iTabWidth, false); + EditSpacesToTabs(Globals.hwndEdit, Settings.TabWidth, false); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -4012,7 +3893,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditTabsToSpaces(g_hwndEdit, g_iTabWidth, true); + EditTabsToSpaces(Globals.hwndEdit, Settings.TabWidth, true); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -4023,7 +3904,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditSpacesToTabs(g_hwndEdit, g_iTabWidth, true); + EditSpacesToTabs(Globals.hwndEdit, Settings.TabWidth, true); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -4036,7 +3917,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) WCHAR wszClose[256] = { L'\0' }; if (EditInsertTagDlg(hwnd, wszOpen, wszClose)) { _BEGIN_UNDO_ACTION_; - EditEncloseSelection(g_hwndEdit, wszOpen, wszClose); + EditEncloseSelection(Globals.hwndEdit, wszOpen, wszClose); _END_UNDO_ACTION_; } } @@ -4053,7 +3934,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (p) *p = 0; _BEGIN_UNDO_ACTION_; - SendMessage(g_hwndEdit,SCI_REPLACESEL,0,(LPARAM)msz); + SendMessage(Globals.hwndEdit,SCI_REPLACESEL,0,(LPARAM)msz); _END_UNDO_ACTION_; } } @@ -4072,9 +3953,11 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) GetLocalTime(&st); - if (IniGetString(L"Settings2", - (LOWORD(wParam) == IDM_EDIT_INSERT_SHORTDATE) ? L"DateTimeShort" : L"DateTimeLong", - L"",tchTemplate,COUNTOF(tchTemplate))) { + StringCchCopyW(tchTemplate, COUNTOF(tchTemplate), + (LOWORD(wParam) == IDM_EDIT_INSERT_SHORTDATE) ? Settings2.DateTimeLong : Settings2.DateTimeLong); + + if (StringCchLenW(tchTemplate,0) > 0) + { struct tm sst; sst.tm_isdst = -1; sst.tm_sec = (int)st.wSecond; @@ -4098,7 +3981,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) char chDateTime[128] = { '\0' }; WideCharToMultiByteStrg(Encoding_SciCP,tchDateTime, chDateTime); _BEGIN_UNDO_ACTION_; - SendMessage(g_hwndEdit,SCI_REPLACESEL,0,(LPARAM)chDateTime); + SendMessage(Globals.hwndEdit,SCI_REPLACESEL,0,(LPARAM)chDateTime); _END_UNDO_ACTION_; } break; @@ -4112,14 +3995,14 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) WCHAR tchUntitled[32]; //int iSelStart; - if (StringCchLenW(g_wchCurFile, COUNTOF(g_wchCurFile))) { + if (StringCchLenW(Globals.CurrentFile, COUNTOF(Globals.CurrentFile))) { if (LOWORD(wParam) == IDM_EDIT_INSERT_FILENAME) { - SHGetFileInfo2(g_wchCurFile, FILE_ATTRIBUTE_NORMAL, &shfi, sizeof(SHFILEINFO), + SHGetFileInfo2(Globals.CurrentFile, FILE_ATTRIBUTE_NORMAL, &shfi, sizeof(SHFILEINFO), SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES); pszInsert = shfi.szDisplayName; } else - pszInsert = g_wchCurFile; + pszInsert = Globals.CurrentFile; } else { GetLngString(IDS_MUI_UNTITLED, tchUntitled, COUNTOF(tchUntitled)); @@ -4128,7 +4011,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) char chPath[MAX_PATH + 1]; WideCharToMultiByteStrg(Encoding_SciCP, pszInsert, chPath); _BEGIN_UNDO_ACTION_; - SendMessage(g_hwndEdit, SCI_REPLACESEL, 0, (LPARAM)chPath); + SendMessage(Globals.hwndEdit, SCI_REPLACESEL, 0, (LPARAM)chPath); _END_UNDO_ACTION_; } break; @@ -4142,7 +4025,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) StrTrimW(tchMaxPathBuffer, L"{}"); if (WideCharToMultiByteStrg(Encoding_SciCP, tchMaxPathBuffer, chMaxPathBuffer)) { _BEGIN_UNDO_ACTION_; - SendMessage(g_hwndEdit,SCI_REPLACESEL,0,(LPARAM)chMaxPathBuffer); + SendMessage(Globals.hwndEdit,SCI_REPLACESEL,0,(LPARAM)chMaxPathBuffer); _END_UNDO_ACTION_; } } @@ -4156,7 +4039,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - switch (SendMessage(g_hwndEdit, SCI_GETLEXER, 0, 0)) { + switch (SciCall_GetLexer()) { default: case SCLEX_NULL: case SCLEX_CSS: @@ -4168,11 +4051,11 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case SCLEX_XML: case SCLEX_CPP: case SCLEX_PASCAL: - EditToggleLineComments(g_hwndEdit, L"//", false); + EditToggleLineComments(Globals.hwndEdit, L"//", false); break; case SCLEX_VBSCRIPT: case SCLEX_VB: - EditToggleLineComments(g_hwndEdit, L"'", false); + EditToggleLineComments(Globals.hwndEdit, L"'", false); break; case SCLEX_MAKEFILE: case SCLEX_PERL: @@ -4187,7 +4070,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case SCLEX_YAML: case SCLEX_COFFEESCRIPT: case SCLEX_NIMROD: - EditToggleLineComments(g_hwndEdit, L"#", true); + EditToggleLineComments(Globals.hwndEdit, L"#", true); break; case SCLEX_ASM: case SCLEX_PROPERTIES: @@ -4196,19 +4079,19 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case SCLEX_NSIS: // # could also be used instead case SCLEX_INNOSETUP: case SCLEX_REGISTRY: - EditToggleLineComments(g_hwndEdit, L";", true); + EditToggleLineComments(Globals.hwndEdit, L";", true); break; case SCLEX_SQL: case SCLEX_LUA: case SCLEX_VHDL: - EditToggleLineComments(g_hwndEdit, L"--", true); + EditToggleLineComments(Globals.hwndEdit, L"--", true); break; case SCLEX_BATCH: - EditToggleLineComments(g_hwndEdit, L"rem ", true); + EditToggleLineComments(Globals.hwndEdit, L"rem ", true); break; case SCLEX_LATEX: case SCLEX_MATLAB: - EditToggleLineComments(g_hwndEdit, L"%", true); + EditToggleLineComments(Globals.hwndEdit, L"%", true); break; } @@ -4223,7 +4106,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - switch (SendMessage(g_hwndEdit, SCI_GETLEXER, 0, 0)) { + switch (SciCall_GetLexer()) { default: case SCLEX_NULL: case SCLEX_VBSCRIPT: @@ -4258,20 +4141,20 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case SCLEX_NSIS: case SCLEX_AVS: case SCLEX_VHDL: - EditEncloseSelection(g_hwndEdit, L"/*", L"*/"); + EditEncloseSelection(Globals.hwndEdit, L"/*", L"*/"); break; case SCLEX_PASCAL: case SCLEX_INNOSETUP: - EditEncloseSelection(g_hwndEdit, L"{", L"}"); + EditEncloseSelection(Globals.hwndEdit, L"{", L"}"); break; case SCLEX_LUA: - EditEncloseSelection(g_hwndEdit, L"--[[", L"]]"); + EditEncloseSelection(Globals.hwndEdit, L"--[[", L"]]"); break; case SCLEX_COFFEESCRIPT: - EditEncloseSelection(g_hwndEdit, L"###", L"###"); + EditEncloseSelection(Globals.hwndEdit, L"###", L"###"); break; case SCLEX_MATLAB: - EditEncloseSelection(g_hwndEdit, L"%{", L"%}"); + EditEncloseSelection(Globals.hwndEdit, L"%{", L"%}"); } _END_UNDO_ACTION_; EndWaitCursor(); @@ -4283,7 +4166,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditURLEncode(g_hwndEdit); + EditURLEncode(Globals.hwndEdit); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -4294,7 +4177,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditURLDecode(g_hwndEdit); + EditURLDecode(Globals.hwndEdit); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -4305,7 +4188,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditEscapeCChars(g_hwndEdit); + EditEscapeCChars(Globals.hwndEdit); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -4316,7 +4199,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { BeginWaitCursor(NULL); _BEGIN_UNDO_ACTION_; - EditUnescapeCChars(g_hwndEdit); + EditUnescapeCChars(Globals.hwndEdit); _END_UNDO_ACTION_; EndWaitCursor(); } @@ -4326,26 +4209,26 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_CHAR2HEX: { _BEGIN_UNDO_ACTION_; - EditChar2Hex(g_hwndEdit); + EditChar2Hex(Globals.hwndEdit); _END_UNDO_ACTION_; } break; case IDM_EDIT_HEX2CHAR: - EditHex2Char(g_hwndEdit); + EditHex2Char(Globals.hwndEdit); break; case IDM_EDIT_FINDMATCHINGBRACE: - EditFindMatchingBrace(g_hwndEdit); + EditFindMatchingBrace(Globals.hwndEdit); break; case IDM_EDIT_SELTOMATCHINGBRACE: { _BEGIN_UNDO_ACTION_; - EditSelectToMatchingBrace(g_hwndEdit); + EditSelectToMatchingBrace(Globals.hwndEdit); _END_UNDO_ACTION_; } break; @@ -4358,10 +4241,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) const DocLn iLine = SciCall_LineFromPosition(iPos); int bitmask = (1 << MARKER_NP3_BOOKMARK); - DocLn iNextLine = (DocLn)SendMessage( g_hwndEdit , SCI_MARKERNEXT , iLine+1 , bitmask ); + DocLn iNextLine = (DocLn)SendMessage( Globals.hwndEdit , SCI_MARKERNEXT , iLine+1 , bitmask ); if (iNextLine == (DocLn)-1) { - iNextLine = (DocLn)SendMessage( g_hwndEdit , SCI_MARKERNEXT , 0 , bitmask ); + iNextLine = (DocLn)SendMessage( Globals.hwndEdit , SCI_MARKERNEXT , 0 , bitmask ); } if (iNextLine != (DocLn)-1) @@ -4379,10 +4262,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) const DocLn iLine = SciCall_LineFromPosition(iPos); int bitmask = (1 << MARKER_NP3_BOOKMARK); - DocLn iNextLine = (DocLn)SendMessage( g_hwndEdit , SCI_MARKERPREVIOUS , iLine-1 , bitmask ); + DocLn iNextLine = (DocLn)SendMessage( Globals.hwndEdit , SCI_MARKERPREVIOUS , iLine-1 , bitmask ); if (iNextLine == (DocLn)-1) { - iNextLine = (DocLn)SendMessage( g_hwndEdit , SCI_MARKERPREVIOUS , SciCall_GetLineCount(), bitmask ); + iNextLine = (DocLn)SendMessage( Globals.hwndEdit , SCI_MARKERPREVIOUS , SciCall_GetLineCount(), bitmask ); } if (iNextLine != (DocLn)-1) @@ -4417,20 +4300,20 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_FIND: - if (!IsWindow(g_hwndDlgFindReplace)) { + if (!IsWindow(Globals.hwndDlgFindReplace)) { g_bFindReplCopySelOrClip = true; - g_hwndDlgFindReplace = EditFindReplaceDlg(g_hwndEdit, &g_efrData, false); + Globals.hwndDlgFindReplace = EditFindReplaceDlg(Globals.hwndEdit, &Settings.EFR_Data, false); } else { - g_bFindReplCopySelOrClip = (GetForegroundWindow() != g_hwndDlgFindReplace); - if (GetDlgItem(g_hwndDlgFindReplace, IDC_REPLACE)) { - SendMessage(g_hwndDlgFindReplace, WM_COMMAND, MAKELONG(IDMSG_SWITCHTOFIND, 1), 0); - DestroyWindow(g_hwndDlgFindReplace); - g_hwndDlgFindReplace = EditFindReplaceDlg(g_hwndEdit, &g_efrData, false); + g_bFindReplCopySelOrClip = (GetForegroundWindow() != Globals.hwndDlgFindReplace); + if (GetDlgItem(Globals.hwndDlgFindReplace, IDC_REPLACE)) { + SendMessage(Globals.hwndDlgFindReplace, WM_COMMAND, MAKELONG(IDMSG_SWITCHTOFIND, 1), 0); + DestroyWindow(Globals.hwndDlgFindReplace); + Globals.hwndDlgFindReplace = EditFindReplaceDlg(Globals.hwndEdit, &Settings.EFR_Data, false); } else { - SetForegroundWindow(g_hwndDlgFindReplace); - PostMessage(g_hwndDlgFindReplace, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(g_hwndDlgFindReplace, IDC_FINDTEXT)), 1); + SetForegroundWindow(Globals.hwndDlgFindReplace); + PostMessage(Globals.hwndDlgFindReplace, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(Globals.hwndDlgFindReplace, IDC_FINDTEXT)), 1); } UpdateStatusbar(false); } @@ -4438,20 +4321,20 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_REPLACE: - if (!IsWindow(g_hwndDlgFindReplace)) { + if (!IsWindow(Globals.hwndDlgFindReplace)) { g_bFindReplCopySelOrClip = true; - g_hwndDlgFindReplace = EditFindReplaceDlg(g_hwndEdit, &g_efrData, true); + Globals.hwndDlgFindReplace = EditFindReplaceDlg(Globals.hwndEdit, &Settings.EFR_Data, true); } else { - g_bFindReplCopySelOrClip = (GetForegroundWindow() != g_hwndDlgFindReplace); - if (!GetDlgItem(g_hwndDlgFindReplace, IDC_REPLACE)) { - SendMessage(g_hwndDlgFindReplace, WM_COMMAND, MAKELONG(IDMSG_SWITCHTOREPLACE, 1), 0); - DestroyWindow(g_hwndDlgFindReplace); - g_hwndDlgFindReplace = EditFindReplaceDlg(g_hwndEdit, &g_efrData, true); + g_bFindReplCopySelOrClip = (GetForegroundWindow() != Globals.hwndDlgFindReplace); + if (!GetDlgItem(Globals.hwndDlgFindReplace, IDC_REPLACE)) { + SendMessage(Globals.hwndDlgFindReplace, WM_COMMAND, MAKELONG(IDMSG_SWITCHTOREPLACE, 1), 0); + DestroyWindow(Globals.hwndDlgFindReplace); + Globals.hwndDlgFindReplace = EditFindReplaceDlg(Globals.hwndEdit, &Settings.EFR_Data, true); } else { - SetForegroundWindow(g_hwndDlgFindReplace); - PostMessage(g_hwndDlgFindReplace, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(g_hwndDlgFindReplace, IDC_FINDTEXT)), 1); + SetForegroundWindow(Globals.hwndDlgFindReplace); + PostMessage(Globals.hwndDlgFindReplace, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(Globals.hwndDlgFindReplace, IDC_FINDTEXT)), 1); } UpdateStatusbar(false); } @@ -4467,7 +4350,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (SciCall_GetTextLength() == 0) break; - if (IsFindPatternEmpty() && !StringCchLenA(g_efrData.szFind, COUNTOF(g_efrData.szFind))) + if (IsFindPatternEmpty() && !StringCchLenA(Settings.EFR_Data.szFind, COUNTOF(Settings.EFR_Data.szFind))) { if (LOWORD(wParam) != IDM_EDIT_REPLACENEXT) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_FIND,1),0); @@ -4480,37 +4363,37 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_FINDNEXT: if (!SciCall_IsSelectionEmpty()) { - EditJumpToSelectionEnd(g_hwndEdit); + EditJumpToSelectionEnd(Globals.hwndEdit); } - EditFindNext(g_hwndEdit,&g_efrData,false,false); + EditFindNext(Globals.hwndEdit,&Settings.EFR_Data,false,false); break; case IDM_EDIT_FINDPREV: if (!SciCall_IsSelectionEmpty()) { - EditJumpToSelectionStart(g_hwndEdit); + EditJumpToSelectionStart(Globals.hwndEdit); } - EditFindPrev(g_hwndEdit,&g_efrData,false,false); + EditFindPrev(Globals.hwndEdit,&Settings.EFR_Data,false,false); break; case IDM_EDIT_REPLACENEXT: - if (bReplaceInitialized) - EditReplace(g_hwndEdit,&g_efrData); + if (g_bReplaceInitialized) + EditReplace(Globals.hwndEdit,&Settings.EFR_Data); else SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_REPLACE,1),0); break; case IDM_EDIT_SELTONEXT: if (!SciCall_IsSelectionEmpty()) { - EditJumpToSelectionEnd(g_hwndEdit); + EditJumpToSelectionEnd(Globals.hwndEdit); } - EditFindNext(g_hwndEdit,&g_efrData,true,false); + EditFindNext(Globals.hwndEdit,&Settings.EFR_Data,true,false); break; case IDM_EDIT_SELTOPREV: if (!SciCall_IsSelectionEmpty()) { - EditJumpToSelectionStart(g_hwndEdit); + EditJumpToSelectionStart(Globals.hwndEdit); } - EditFindPrev(g_hwndEdit,&g_efrData,true,false); + EditFindPrev(Globals.hwndEdit,&Settings.EFR_Data,true,false); break; } } @@ -4541,13 +4424,13 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) lpsz = StrChrA(mszSelection, '\r'); if (lpsz) *lpsz = '\0'; - StringCchCopyA(g_efrData.szFind, COUNTOF(g_efrData.szFind), mszSelection); - g_efrData.fuFlags &= (~(SCFIND_REGEXP | SCFIND_POSIX)); - g_efrData.bTransformBS = false; + StringCchCopyA(Settings.EFR_Data.szFind, COUNTOF(Settings.EFR_Data.szFind), mszSelection); + Settings.EFR_Data.fuFlags &= (~(SCFIND_REGEXP | SCFIND_POSIX)); + Settings.EFR_Data.bTransformBS = false; WCHAR wszBuf[FNDRPL_BUFFER]; MultiByteToWideCharStrg(Encoding_SciCP, mszSelection, wszBuf); - MRU_Add(g_pMRUfind, wszBuf, 0, 0, NULL); + MRU_Add(Globals.pMRUfind, wszBuf, 0, 0, NULL); SetFindPattern(wszBuf); switch (LOWORD(wParam)) { @@ -4557,16 +4440,16 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_FINDNEXTSEL: if (!SciCall_IsSelectionEmpty()) { - EditJumpToSelectionEnd(g_hwndEdit); + EditJumpToSelectionEnd(Globals.hwndEdit); } - EditFindNext(g_hwndEdit, &g_efrData, false, false); + EditFindNext(Globals.hwndEdit, &Settings.EFR_Data, false, false); break; case CMD_FINDPREVSEL: if (!SciCall_IsSelectionEmpty()) { - EditJumpToSelectionStart(g_hwndEdit); + EditJumpToSelectionStart(Globals.hwndEdit); } - EditFindPrev(g_hwndEdit, &g_efrData, false, false); + EditFindPrev(Globals.hwndEdit, &Settings.EFR_Data, false, false); break; } } @@ -4574,40 +4457,39 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; - case IDM_EDIT_COMPLETEWORD: - EditCompleteWord(g_hwndEdit, true); + EditAutoCompleteWord(Globals.hwndEdit, true); break; case IDM_EDIT_GOTOLINE: - EditLinenumDlg(g_hwndEdit); + EditLinenumDlg(Globals.hwndEdit); UpdateStatusbar(false); break; case IDM_VIEW_SCHEME: - Style_SelectLexerDlg(g_hwndEdit); + Style_SelectLexerDlg(Globals.hwndEdit); UpdateToolbar(); UpdateStatusbar(false); break; case IDM_VIEW_USE2NDDEFAULT: - Style_ToggleUse2ndDefault(g_hwndEdit); + Style_ToggleUse2ndDefault(Globals.hwndEdit); UpdateToolbar(); UpdateStatusbar(false); break; case IDM_VIEW_SCHEMECONFIG: - if (!IsWindow(g_hwndDlgCustomizeSchemes)) { - g_hwndDlgCustomizeSchemes = Style_CustomizeSchemesDlg(g_hwndEdit); + if (!IsWindow(Globals.hwndDlgCustomizeSchemes)) { + Globals.hwndDlgCustomizeSchemes = Style_CustomizeSchemesDlg(Globals.hwndEdit); } else { - SetForegroundWindow(g_hwndDlgCustomizeSchemes); + SetForegroundWindow(Globals.hwndDlgCustomizeSchemes); } - PostMessage(g_hwndDlgCustomizeSchemes, WM_COMMAND, MAKELONG(IDC_SETCURLEXERTV, 1), 0); + PostMessage(Globals.hwndDlgCustomizeSchemes, WM_COMMAND, MAKELONG(IDC_SETCURLEXERTV, 1), 0); UpdateToolbar(); UpdateStatusbar(false); UpdateMarginWidth(); @@ -4615,16 +4497,16 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_VIEW_FONT: - if (!IsWindow(g_hwndDlgCustomizeSchemes)) - Style_SetDefaultFont(g_hwndEdit, true); + if (!IsWindow(Globals.hwndDlgCustomizeSchemes)) + Style_SetDefaultFont(Globals.hwndEdit, true); UpdateToolbar(); UpdateStatusbar(false); UpdateMarginWidth(); break; case IDM_VIEW_CURRENTSCHEME: - if (!IsWindow(g_hwndDlgCustomizeSchemes)) - Style_SetDefaultFont(g_hwndEdit, false); + if (!IsWindow(Globals.hwndDlgCustomizeSchemes)) + Style_SetDefaultFont(Globals.hwndEdit, false); UpdateToolbar(); UpdateStatusbar(false); UpdateMarginWidth(); @@ -4632,36 +4514,36 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_VIEW_WORDWRAP: - g_bWordWrap = (g_bWordWrap) ? false : true; - _SetWrapIndentMode(g_hwndEdit); - EditEnsureSelectionVisible(g_hwndEdit); - bWordWrapG = g_bWordWrap; + Settings.WordWrap = !Settings.WordWrap; + _SetWrapIndentMode(Globals.hwndEdit); + EditEnsureSelectionVisible(Globals.hwndEdit); + g_bWordWrapG = Settings.WordWrap; UpdateToolbar(); break; case IDM_VIEW_WORDWRAPSETTINGS: - if (WordWrapSettingsDlg(hwnd,IDD_MUI_WORDWRAP,&iWordWrapIndent)) { - _SetWrapIndentMode(g_hwndEdit); - _SetWrapVisualFlags(g_hwndEdit); + if (WordWrapSettingsDlg(hwnd,IDD_MUI_WORDWRAP, &Settings.WordWrapIndent)) { + _SetWrapIndentMode(Globals.hwndEdit); + _SetWrapVisualFlags(Globals.hwndEdit); } break; case IDM_VIEW_WORDWRAPSYMBOLS: - bShowWordWrapSymbols = (bShowWordWrapSymbols) ? false : true; - _SetWrapVisualFlags(g_hwndEdit); + Settings.ShowWordWrapSymbols = !Settings.ShowWordWrapSymbols; + _SetWrapVisualFlags(Globals.hwndEdit); break; case IDM_VIEW_LONGLINEMARKER: - g_bMarkLongLines = (g_bMarkLongLines) ? false: true; - if (g_bMarkLongLines) { - SendMessage(g_hwndEdit,SCI_SETEDGEMODE,(iLongLineMode == EDGE_LINE)?EDGE_LINE:EDGE_BACKGROUND,0); - Style_SetLongLineColors(g_hwndEdit); + Settings.MarkLongLines = !Settings.MarkLongLines; + if (Settings.MarkLongLines) { + SendMessage(Globals.hwndEdit,SCI_SETEDGEMODE,(Settings.LongLineMode == EDGE_LINE)?EDGE_LINE:EDGE_BACKGROUND,0); + Style_SetLongLineColors(Globals.hwndEdit); } else - SendMessage(g_hwndEdit,SCI_SETEDGEMODE,EDGE_NONE,0); + SendMessage(Globals.hwndEdit,SCI_SETEDGEMODE,EDGE_NONE,0); UpdateToolbar(); UpdateStatusbar(false); @@ -4669,13 +4551,13 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_VIEW_LONGLINESETTINGS: - if (LongLineSettingsDlg(hwnd,IDD_MUI_LONGLINES,&g_iLongLinesLimit)) { - g_bMarkLongLines = true; - SendMessage(g_hwndEdit, SCI_SETEDGEMODE, (iLongLineMode == EDGE_LINE) ? EDGE_LINE : EDGE_BACKGROUND, 0); - Style_SetLongLineColors(g_hwndEdit); - g_iLongLinesLimit = clampi(g_iLongLinesLimit, 0, LONG_LINES_MARKER_LIMIT); - SendMessage(g_hwndEdit,SCI_SETEDGECOLUMN,g_iLongLinesLimit,0); - iLongLinesLimitG = g_iLongLinesLimit; + if (LongLineSettingsDlg(hwnd,IDD_MUI_LONGLINES,&Settings.LongLinesLimit)) { + Settings.MarkLongLines = true; + SendMessage(Globals.hwndEdit, SCI_SETEDGEMODE, (Settings.LongLineMode == EDGE_LINE) ? EDGE_LINE : EDGE_BACKGROUND, 0); + Style_SetLongLineColors(Globals.hwndEdit); + Settings.LongLinesLimit = clampi(Settings.LongLinesLimit, 0, LONG_LINES_MARKER_LIMIT); + SendMessage(Globals.hwndEdit,SCI_SETEDGECOLUMN,Settings.LongLinesLimit,0); + g_iLongLinesLimitG = Settings.LongLinesLimit; UpdateToolbar(); UpdateStatusbar(false); } @@ -4683,122 +4565,122 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_VIEW_TABSASSPACES: - g_bTabsAsSpaces = (g_bTabsAsSpaces) ? false : true; - SendMessage(g_hwndEdit,SCI_SETUSETABS,!g_bTabsAsSpaces,0); - bTabsAsSpacesG = g_bTabsAsSpaces; + Settings.TabsAsSpaces = !Settings.TabsAsSpaces; + SendMessage(Globals.hwndEdit,SCI_SETUSETABS,!Settings.TabsAsSpaces,0); + g_bTabsAsSpacesG = Settings.TabsAsSpaces; break; case IDM_VIEW_TABSETTINGS: if (TabSettingsDlg(hwnd,IDD_MUI_TABSETTINGS,NULL)) { - SendMessage(g_hwndEdit,SCI_SETUSETABS,!g_bTabsAsSpaces,0); - SendMessage(g_hwndEdit,SCI_SETTABINDENTS,g_bTabIndents,0); - SendMessage(g_hwndEdit,SCI_SETBACKSPACEUNINDENTS,bBackspaceUnindents,0); - g_iTabWidth = clampi(g_iTabWidth, 1, 256); - g_iIndentWidth = clampi(g_iIndentWidth, 0, 256); - SendMessage(g_hwndEdit,SCI_SETTABWIDTH,g_iTabWidth,0); - SendMessage(g_hwndEdit,SCI_SETINDENT,g_iIndentWidth,0); - bTabsAsSpacesG = g_bTabsAsSpaces; - bTabIndentsG = g_bTabIndents; - iTabWidthG = g_iTabWidth; - iIndentWidthG = g_iIndentWidth; - if (SendMessage(g_hwndEdit, SCI_GETWRAPINDENTMODE, 0, 0) == SC_WRAPINDENT_FIXED) { - _SetWrapStartIndent(g_hwndEdit); + SendMessage(Globals.hwndEdit,SCI_SETUSETABS,!Settings.TabsAsSpaces,0); + SendMessage(Globals.hwndEdit,SCI_SETTABINDENTS,Settings.TabIndents,0); + SendMessage(Globals.hwndEdit,SCI_SETBACKSPACEUNINDENTS,Settings.BackspaceUnindents,0); + Settings.TabWidth = clampi(Settings.TabWidth, 1, 256); + Settings.IndentWidth = clampi(Settings.IndentWidth, 0, 256); + SendMessage(Globals.hwndEdit,SCI_SETTABWIDTH,Settings.TabWidth,0); + SendMessage(Globals.hwndEdit,SCI_SETINDENT,Settings.IndentWidth,0); + g_bTabsAsSpacesG = Settings.TabsAsSpaces; + g_bTabIndentsG = Settings.TabIndents; + g_iTabWidthG = Settings.TabWidth; + g_iIndentWidthG = Settings.IndentWidth; + if (SendMessage(Globals.hwndEdit, SCI_GETWRAPINDENTMODE, 0, 0) == SC_WRAPINDENT_FIXED) { + _SetWrapStartIndent(Globals.hwndEdit); } } break; case IDM_VIEW_SHOWINDENTGUIDES: - bShowIndentGuides = (bShowIndentGuides) ? false : true; - Style_SetIndentGuides(g_hwndEdit,bShowIndentGuides); + Settings.ShowIndentGuides = !Settings.ShowIndentGuides; + Style_SetIndentGuides(Globals.hwndEdit,Settings.ShowIndentGuides); break; case IDM_VIEW_AUTOINDENTTEXT: - bAutoIndent = (bAutoIndent) ? false : true; + Settings.AutoIndent = !Settings.AutoIndent; break; case IDM_VIEW_LINENUMBERS: - g_bShowLineNumbers = (g_bShowLineNumbers) ? false : true; + Settings.ShowLineNumbers = !Settings.ShowLineNumbers; UpdateMarginWidth(); break; case IDM_VIEW_MARGIN: - g_bShowSelectionMargin = (g_bShowSelectionMargin) ? false : true; + Settings.ShowSelectionMargin = !Settings.ShowSelectionMargin; UpdateMarginWidth(); break; case IDM_VIEW_AUTOCOMPLETEWORDS: - g_bAutoCompleteWords = (g_bAutoCompleteWords) ? false : true; // toggle + Settings.AutoCompleteWords = !Settings.AutoCompleteWords; SciCall_AutoCCancel(); break; case IDM_VIEW_AUTOCLEXKEYWORDS: - g_bAutoCLexerKeyWords = (g_bAutoCLexerKeyWords) ? false : true; // toggle + Settings.AutoCLexerKeyWords = !Settings.AutoCLexerKeyWords; SciCall_AutoCCancel(); break; case IDM_VIEW_ACCELWORDNAV: - g_bAccelWordNavigation = (g_bAccelWordNavigation) ? false : true; // toggle - EditSetAccelWordNav(g_hwndEdit,g_bAccelWordNavigation); - MarkAllOccurrences(iUpdateDelayMarkAllCoccurrences, true); + Settings.AccelWordNavigation = !Settings.AccelWordNavigation; + EditSetAccelWordNav(Globals.hwndEdit,Settings.AccelWordNavigation); + MarkAllOccurrences(Settings2.UpdateDelayMarkAllOccurrences, true); break; case IDM_VIEW_MARKOCCUR_ONOFF: - g_iMarkOccurrences = (g_iMarkOccurrences == 0) ? max_i(1, IniGetInt(L"Settings", L"MarkOccurrences", 1)) : 0; + Settings.MarkOccurrences = (Settings.MarkOccurrences == 0) ? max_i(1, IniGetInt(L"Settings", L"MarkOccurrences", 1)) : 0; MarkAllOccurrences(0, true); - EnableCmd(GetMenu(hwnd), IDM_VIEW_TOGGLE_VIEW, (g_iMarkOccurrences > 0) && !g_bMarkOccurrencesMatchVisible); + EnableCmd(GetMenu(hwnd), IDM_VIEW_TOGGLE_VIEW, (Settings.MarkOccurrences > 0) && !Settings.MarkOccurrencesMatchVisible); break; case IDM_VIEW_MARKOCCUR_VISIBLE: - g_bMarkOccurrencesMatchVisible = (g_bMarkOccurrencesMatchVisible) ? false : true; + Settings.MarkOccurrencesMatchVisible = !Settings.MarkOccurrencesMatchVisible; MarkAllOccurrences(0, true); - EnableCmd(GetMenu(hwnd), IDM_VIEW_TOGGLE_VIEW, (g_iMarkOccurrences > 0) && !g_bMarkOccurrencesMatchVisible); + EnableCmd(GetMenu(hwnd), IDM_VIEW_TOGGLE_VIEW, (Settings.MarkOccurrences > 0) && !Settings.MarkOccurrencesMatchVisible); break; case IDM_VIEW_TOGGLE_VIEW: - if (EditToggleView(g_hwndEdit, false)) { - EditToggleView(g_hwndEdit, true); + if (EditToggleView(Globals.hwndEdit, false)) { + EditToggleView(Globals.hwndEdit, true); MarkAllOccurrences(0, true); } else { - EditToggleView(g_hwndEdit, true); + EditToggleView(Globals.hwndEdit, true); } - CheckCmd(GetMenu(hwnd), IDM_VIEW_TOGGLE_VIEW, EditToggleView(g_hwndEdit, false)); + CheckCmd(GetMenu(hwnd), IDM_VIEW_TOGGLE_VIEW, EditToggleView(Globals.hwndEdit, false)); UpdateToolbar(); break; case IDM_VIEW_MARKOCCUR_CASE: - g_bMarkOccurrencesMatchCase = (g_bMarkOccurrencesMatchCase) ? false : true; - MarkAllOccurrences(iUpdateDelayMarkAllCoccurrences, true); + Settings.MarkOccurrencesMatchCase = !Settings.MarkOccurrencesMatchCase; + MarkAllOccurrences(Settings2.UpdateDelayMarkAllOccurrences, true); break; case IDM_VIEW_MARKOCCUR_WNONE: - g_bMarkOccurrencesMatchWords = false; - g_bMarkOccurrencesCurrentWord = false; - MarkAllOccurrences(iUpdateDelayMarkAllCoccurrences, true); + Settings.MarkOccurrencesMatchWholeWords = false; + Settings.MarkOccurrencesCurrentWord = false; + MarkAllOccurrences(Settings2.UpdateDelayMarkAllOccurrences, true); break; case IDM_VIEW_MARKOCCUR_WORD: - g_bMarkOccurrencesMatchWords = true; - g_bMarkOccurrencesCurrentWord = false; - MarkAllOccurrences(iUpdateDelayMarkAllCoccurrences, true); + Settings.MarkOccurrencesMatchWholeWords = true; + Settings.MarkOccurrencesCurrentWord = false; + MarkAllOccurrences(Settings2.UpdateDelayMarkAllOccurrences, true); break; case IDM_VIEW_MARKOCCUR_CURRENT: - g_bMarkOccurrencesMatchWords = false; - g_bMarkOccurrencesCurrentWord = true; - MarkAllOccurrences(iUpdateDelayMarkAllCoccurrences, true); + Settings.MarkOccurrencesMatchWholeWords = false; + Settings.MarkOccurrencesCurrentWord = true; + MarkAllOccurrences(Settings2.UpdateDelayMarkAllOccurrences, true); break; case IDM_VIEW_FOLDING: - g_bShowCodeFolding = (g_bShowCodeFolding) ? false : true; - Style_SetFolding(g_hwndEdit, g_bShowCodeFolding); - if (!g_bShowCodeFolding) { EditToggleFolds(EXPAND, true); } + Settings.ShowCodeFolding = !Settings.ShowCodeFolding; + Style_SetFolding(Globals.hwndEdit, Settings.ShowCodeFolding); + if (!Settings.ShowCodeFolding) { EditToggleFolds(EXPAND, true); } UpdateToolbar(); break; @@ -4812,44 +4694,44 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; case IDM_VIEW_SHOWBLANKS: - bViewWhiteSpace = (bViewWhiteSpace) ? false : true; - SendMessage(g_hwndEdit,SCI_SETVIEWWS,(bViewWhiteSpace)?SCWS_VISIBLEALWAYS:SCWS_INVISIBLE,0); + Settings.ViewWhiteSpace = !Settings.ViewWhiteSpace; + SendMessage(Globals.hwndEdit,SCI_SETVIEWWS,(Settings.ViewWhiteSpace)?SCWS_VISIBLEALWAYS:SCWS_INVISIBLE,0); break; case IDM_VIEW_SHOWEOLS: - bViewEOLs = (bViewEOLs) ? false : true; - SendMessage(g_hwndEdit,SCI_SETVIEWEOL,bViewEOLs,0); + Settings.ViewEOLs = !Settings.ViewEOLs; + SendMessage(Globals.hwndEdit,SCI_SETVIEWEOL,Settings.ViewEOLs,0); break; case IDM_VIEW_MATCHBRACES: - bMatchBraces = (bMatchBraces) ? false : true; - if (bMatchBraces) - EditMatchBrace(g_hwndEdit); + Settings.MatchBraces = !Settings.MatchBraces; + if (Settings.MatchBraces) + EditMatchBrace(Globals.hwndEdit); else SciCall_BraceHighLight(INVALID_POSITION, INVALID_POSITION); break; case IDM_VIEW_AUTOCLOSETAGS: - bAutoCloseTags = (bAutoCloseTags) ? false : true; + Settings.AutoCloseTags = !Settings.AutoCloseTags; break; case IDM_VIEW_HILITECURRENTLINE: - bHiliteCurrentLine = (bHiliteCurrentLine) ? false : true; - Style_SetCurrentLineBackground(g_hwndEdit, bHiliteCurrentLine); + Settings.HighlightCurrentLine = !Settings.HighlightCurrentLine; + Style_SetCurrentLineBackground(Globals.hwndEdit, Settings.HighlightCurrentLine); break; case IDM_VIEW_HYPERLINKHOTSPOTS: - g_bHyperlinkHotspot = (g_bHyperlinkHotspot) ? false : true; - Style_SetUrlHotSpot(g_hwndEdit, g_bHyperlinkHotspot); - if (g_bHyperlinkHotspot) { + Settings.HyperlinkHotspot = !Settings.HyperlinkHotspot; + Style_SetUrlHotSpot(Globals.hwndEdit, Settings.HyperlinkHotspot); + if (Settings.HyperlinkHotspot) { UpdateVisibleUrlHotspot(0); } else { SciCall_StartStyling(0); - Style_ResetCurrentLexer(g_hwndEdit); + Style_ResetCurrentLexer(Globals.hwndEdit); } break; @@ -4857,7 +4739,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { SciCall_ZoomIn(); UpdateMarginWidth(); - EditShowZoomCallTip(g_hwndEdit); + EditShowZoomCallTip(Globals.hwndEdit); } break; @@ -4865,7 +4747,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { SciCall_ZoomOut(); UpdateMarginWidth(); - EditShowZoomCallTip(g_hwndEdit); + EditShowZoomCallTip(Globals.hwndEdit); } break; @@ -4873,7 +4755,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { SciCall_SetZoom(100); UpdateMarginWidth(); - EditShowZoomCallTip(g_hwndEdit); + EditShowZoomCallTip(Globals.hwndEdit); } break; @@ -4883,39 +4765,39 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) static int iPrevFileWatchingMode = 0; static bool bPrevResetFileWatching = false; - g_bChasingDocTail = (g_bChasingDocTail) ? false : true; + g_bChasingDocTail = !g_bChasingDocTail; SciCall_SetReadOnly(g_bChasingDocTail); if (g_bChasingDocTail) { SetForegroundWindow(hwnd); - flagPrevChangeNotify = g_flagChangeNotify; - iPrevFileWatchingMode = g_iFileWatchingMode; - bPrevResetFileWatching = g_bResetFileWatching; - g_flagChangeNotify = 2; - g_iFileWatchingMode = 2; - g_bResetFileWatching = true; + flagPrevChangeNotify = s_flagChangeNotify; + iPrevFileWatchingMode = Settings.FileWatchingMode; + bPrevResetFileWatching = Settings.ResetFileWatching; + s_flagChangeNotify = 2; + Settings.FileWatchingMode = 2; + Settings.ResetFileWatching = true; } else { - g_flagChangeNotify = flagPrevChangeNotify; - g_iFileWatchingMode = iPrevFileWatchingMode; - g_bResetFileWatching = bPrevResetFileWatching; + s_flagChangeNotify = flagPrevChangeNotify; + Settings.FileWatchingMode = iPrevFileWatchingMode; + Settings.ResetFileWatching = bPrevResetFileWatching; } - if (!g_bRunningWatch) { InstallFileWatching(g_wchCurFile); } + if (!g_bRunningWatch) { InstallFileWatching(Globals.CurrentFile); } - CheckCmd(GetMenu(g_hwndMain), IDM_VIEW_CHASING_DOCTAIL, g_bChasingDocTail); + CheckCmd(GetMenu(Globals.hwndMain), IDM_VIEW_CHASING_DOCTAIL, g_bChasingDocTail); UpdateToolbar(); } break; case IDM_VIEW_SCROLLPASTEOF: - bScrollPastEOF = (bScrollPastEOF) ? false : true; - SciCall_SetEndAtLastLine(!bScrollPastEOF); + Settings.ScrollPastEOF = !Settings.ScrollPastEOF; + SciCall_SetEndAtLastLine(!Settings.ScrollPastEOF); break; case IDM_VIEW_TOOLBAR: - bShowToolbar = !bShowToolbar; - ShowWindow(g_hwndReBar, (bShowToolbar ? SW_SHOW : SW_HIDE)); + Settings.ShowToolbar = !Settings.ShowToolbar; + ShowWindow(s_hwndReBar, (Settings.ShowToolbar ? SW_SHOW : SW_HIDE)); UpdateToolbar(); SendWMSize(hwnd, NULL); break; @@ -4926,20 +4808,20 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; case IDM_VIEW_CUSTOMIZETB: - SendMessage(g_hwndToolbar,TB_CUSTOMIZE,0,0); + SendMessage(s_hwndToolbar,TB_CUSTOMIZE,0,0); break; case IDM_VIEW_STATUSBAR: - bShowStatusbar = !bShowStatusbar; - ShowWindow(g_hwndStatus, (bShowStatusbar ? SW_SHOW : SW_HIDE)); - UpdateStatusbar(bShowStatusbar); + Settings.ShowStatusbar = !Settings.ShowStatusbar; + ShowWindow(Globals.hwndStatus, (Settings.ShowStatusbar ? SW_SHOW : SW_HIDE)); + UpdateStatusbar(Settings.ShowStatusbar); SendWMSize(hwnd, NULL); break; case IDM_VIEW_STICKYWINPOS: - g_bStickyWinPos = IniGetBool(L"Settings2",L"StickyWindowPosition",g_bStickyWinPos); - if (!g_bStickyWinPos) + + if (Flags.StickyWindowPosition == 0) { WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32], tchZoom[32]; @@ -4953,11 +4835,8 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) StringCchPrintf(tchMaximized,COUNTOF(tchMaximized),L"%ix%i Maximized",ResX,ResY); StringCchPrintf(tchZoom, COUNTOF(tchZoom), L"%ix%i Zoom", ResX, ResY); - g_bStickyWinPos = true; - IniSetInt(L"Settings2",L"StickyWindowPosition",1); - // GetWindowPlacement - WININFO wi = GetMyWindowPlacement(g_hwndMain,NULL); + WININFO wi = GetMyWindowPlacement(Globals.hwndMain,NULL); IniSetInt(L"Window",tchPosX,wi.x); IniSetInt(L"Window",tchPosY,wi.y); IniSetInt(L"Window",tchSizeX,wi.cx); @@ -4965,131 +4844,142 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) IniSetBool(L"Window",tchMaximized,wi.max); IniSetInt(L"Window", tchZoom, wi.zoom); + Flags.StickyWindowPosition = 1; InfoBoxLng(0,L"MsgStickyWinPos",IDS_MUI_STICKYWINPOS); } else { - g_bStickyWinPos = false; - IniSetInt(L"Settings2",L"StickyWindowPosition",0); + Flags.StickyWindowPosition = 0; } + + if (Flags.StickyWindowPosition != DefaultFlags.StickyWindowPosition) + IniSetInt(L"Settings2", L"StickyWindowPosition", Flags.StickyWindowPosition); + else + IniSetString(L"Settings2", L"StickyWindowPosition", NULL); + break; case IDM_VIEW_REUSEWINDOW: - if (IniGetInt(L"Settings2",L"ReuseWindow",0)) - IniSetInt(L"Settings2",L"ReuseWindow",0); + Flags.ReuseWindow = (Flags.ReuseWindow != 0) ? 0 : 1; // reverse + if (Flags.ReuseWindow != DefaultFlags.ReuseWindow) + IniSetInt(L"Settings2", L"ReuseWindow", Flags.ReuseWindow); else - IniSetInt(L"Settings2",L"ReuseWindow",1); + IniSetString(L"Settings2", L"ReuseWindow", NULL); break; case IDM_VIEW_SINGLEFILEINSTANCE: - if (IniGetInt(L"Settings2",L"SingleFileInstance",0)) - IniSetInt(L"Settings2",L"SingleFileInstance",0); + Flags.SingleFileInstance = (Flags.SingleFileInstance != 0) ? 0 : 1; // reverse + if (Flags.SingleFileInstance != DefaultFlags.SingleFileInstance) + IniSetInt(L"Settings2", L"SingleFileInstance", Flags.SingleFileInstance); else - IniSetInt(L"Settings2",L"SingleFileInstance",1); + IniSetString(L"Settings2", L"SingleFileInstance", NULL); break; case IDM_VIEW_ALWAYSONTOP: - if ((bAlwaysOnTop || g_flagAlwaysOnTop == 2) && g_flagAlwaysOnTop != 1) { - bAlwaysOnTop = 0; - g_flagAlwaysOnTop = 0; + if ((Settings.AlwaysOnTop || s_flagAlwaysOnTop == 2) && s_flagAlwaysOnTop != 1) { + Settings.AlwaysOnTop = false; + s_flagAlwaysOnTop = 0; SetWindowPos(hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); } else { - bAlwaysOnTop = 1; - g_flagAlwaysOnTop = 0; + Settings.AlwaysOnTop = true; + s_flagAlwaysOnTop = 0; SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); } break; case IDM_VIEW_MINTOTRAY: - bMinimizeToTray =(bMinimizeToTray) ? false : true; + Settings.MinimizeToTray = !Settings.MinimizeToTray; break; case IDM_VIEW_TRANSPARENT: - g_bTransparentMode =(g_bTransparentMode) ? false : true; - SetWindowTransparentMode(hwnd,g_bTransparentMode); + Settings.TransparentMode = !Settings.TransparentMode; + SetWindowTransparentMode(hwnd,Settings.TransparentMode); break; case IDM_SET_RENDER_TECH_DEFAULT: case IDM_SET_RENDER_TECH_D2D: case IDM_SET_RENDER_TECH_D2DRETAIN: case IDM_SET_RENDER_TECH_D2DDC: - g_iRenderingTechnology = (int)LOWORD(wParam) - IDM_SET_RENDER_TECH_DEFAULT; - if (g_iRenderingTechnology == 0) { + Settings.RenderingTechnology = (int)LOWORD(wParam) - IDM_SET_RENDER_TECH_DEFAULT; + if (Settings.RenderingTechnology == 0) { SciCall_SetBidirectional(SciBidirectional[0]); } - SciCall_SetBufferedDraw((g_iRenderingTechnology == 0)); - SciCall_SetTechnology(DirectWriteTechnology[g_iRenderingTechnology]); + SciCall_SetBufferedDraw((Settings.RenderingTechnology == 0)); + SciCall_SetTechnology(DirectWriteTechnology[Settings.RenderingTechnology]); break; case IDM_SET_BIDIRECTIONAL_NONE: case IDM_SET_BIDIRECTIONAL_L2R: case IDM_SET_BIDIRECTIONAL_R2L: - g_iBidirectional = (int)LOWORD(wParam) - IDM_SET_BIDIRECTIONAL_NONE; - SciCall_SetBidirectional(SciBidirectional[g_iBidirectional]); + Settings.Bidirectional = (int)LOWORD(wParam) - IDM_SET_BIDIRECTIONAL_NONE; + SciCall_SetBidirectional(SciBidirectional[Settings.Bidirectional]); break; //case IDM_SET_INLINE_IME: - // g_IMEInteraction = (g_IMEInteraction == SC_IME_WINDOWED) ? SC_IME_INLINE : SC_IME_WINDOWED; - // SciCall_SetIMEInteraction(g_IMEInteraction); + // Settings2.IMEInteraction = (Settings2.IMEInteraction == SC_IME_WINDOWED) ? SC_IME_INLINE : SC_IME_WINDOWED; + // SciCall_SetIMEInteraction(Settings2.IMEInteraction); // break; case IDM_VIEW_SHOWFILENAMEONLY: case IDM_VIEW_SHOWFILENAMEFIRST: case IDM_VIEW_SHOWFULLPATH: - iPathNameFormat = (int)LOWORD(wParam) - IDM_VIEW_SHOWFILENAMEONLY; + Settings.PathNameFormat = (int)LOWORD(wParam) - IDM_VIEW_SHOWFILENAMEONLY; StringCchCopy(szTitleExcerpt,COUNTOF(szTitleExcerpt),L""); UpdateToolbar(); break; case IDM_VIEW_SHOWEXCERPT: - EditGetExcerpt(g_hwndEdit,szTitleExcerpt,COUNTOF(szTitleExcerpt)); + EditGetExcerpt(Globals.hwndEdit,szTitleExcerpt,COUNTOF(szTitleExcerpt)); UpdateToolbar(); break; case IDM_VIEW_NOSAVERECENT: - g_bSaveRecentFiles = (g_bSaveRecentFiles) ? false : true; + Settings.SaveRecentFiles = !Settings.SaveRecentFiles; break; case IDM_VIEW_NOPRESERVECARET: - g_bPreserveCaretPos = (g_bPreserveCaretPos) ? false : true; + Settings.PreserveCaretPos = !Settings.PreserveCaretPos; break; case IDM_VIEW_NOSAVEFINDREPL: - g_bSaveFindReplace = (g_bSaveFindReplace) ? false : true; + Settings.SaveFindReplace = !Settings.SaveFindReplace; break; case IDM_VIEW_SAVEBEFORERUNNINGTOOLS: - bSaveBeforeRunningTools = (bSaveBeforeRunningTools) ? false : true; + Settings.SaveBeforeRunningTools = !Settings.SaveBeforeRunningTools; break; case IDM_VIEW_CHANGENOTIFY: if (ChangeNotifyDlg(hwnd)) - InstallFileWatching(g_wchCurFile); + InstallFileWatching(Globals.CurrentFile); break; case IDM_VIEW_NOESCFUNC: case IDM_VIEW_ESCMINIMIZE: case IDM_VIEW_ESCEXIT: - iEscFunction = (int)LOWORD(wParam) - IDM_VIEW_NOESCFUNC; + Settings.EscFunction = (int)LOWORD(wParam) - IDM_VIEW_NOESCFUNC; break; case IDM_VIEW_SAVESETTINGS: if (IsCmdEnabled(hwnd, IDM_VIEW_SAVESETTINGS)) { - g_bSaveSettings = (g_bSaveSettings) ? false : true; - IniSetInt(L"Settings", L"SaveSettings", g_bSaveSettings); + s_bSaveSettings = !s_bSaveSettings; + if (s_bSaveSettings) + IniSetString(L"Settings", L"SaveSettings", NULL); + else + IniSetBool(L"Settings", L"SaveSettings", s_bSaveSettings); } break; @@ -5099,12 +4989,12 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) bool bCreateFailure = false; - if (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)) == 0) { + if (StringCchLenW(Globals.IniFile,COUNTOF(Globals.IniFile)) == 0) { - 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""); + if (StringCchLenW(s_wchIniFile2,COUNTOF(s_wchIniFile2)) > 0) { + if (CreateIniFileEx(s_wchIniFile2)) { + StringCchCopy(Globals.IniFile,COUNTOF(Globals.IniFile),s_wchIniFile2); + StringCchCopy(s_wchIniFile2,COUNTOF(s_wchIniFile2),L""); } else bCreateFailure = true; @@ -5114,14 +5004,14 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; } - if (!bCreateFailure) { - - if (WritePrivateProfileString(L"Settings",L"WriteTest",L"ok",g_wchIniFile)) { + if (!bCreateFailure) + { + if (WritePrivateProfileString(L"Settings", L"WriteTest", L"ok", Globals.IniFile)) { SaveSettings(true); MsgBoxLng(MBINFO,IDS_MUI_SAVEDSETTINGS); } else { - dwLastIOError = GetLastError(); + g_dwLastIOError = GetLastError(); MsgBoxLng(MBWARN,IDS_MUI_WRITEINI_FAIL); } } @@ -5136,11 +5026,11 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; case IDM_HELP_ABOUT: - ThemedDialogBox(g_hLngResContainer, MAKEINTRESOURCE(IDD_MUI_ABOUT), hwnd, AboutDlgProc); + ThemedDialogBox(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_ABOUT), hwnd, AboutDlgProc); break; case IDM_SETPASS: - if (GetFileKey(g_hwndEdit)) { + if (GetFileKey(Globals.hwndEdit)) { _SetDocumentModified(true); } break; @@ -5161,13 +5051,13 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) } if (!SciCall_IsSelectionEmpty()) { DocPos const iCurPos = SciCall_GetCurrentPos(); - EditSetSelectionEx(g_hwndEdit, iCurPos, iCurPos, -1, -1); + EditSetSelectionEx(Globals.hwndEdit, iCurPos, iCurPos, -1, -1); break; } - if (iEscFunction == 1) { + if (Settings.EscFunction == 1) { SendMessage(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); } - else if (iEscFunction == 2) { + else if (Settings.EscFunction == 2) { PostMessage(hwnd, WM_CLOSE, 0, 0); } else { @@ -5204,9 +5094,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) // Newline with toggled auto indent setting case CMD_SHIFTCTRLENTER: - bAutoIndent = (bAutoIndent) ? 0 : 1; + Settings.AutoIndent = !Settings.AutoIndent; SciCall_NewLine(); - bAutoIndent = (bAutoIndent) ? 0 : 1; + Settings.AutoIndent = !Settings.AutoIndent; break; @@ -5221,12 +5111,12 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_CTRLLEFT: - SendMessage(g_hwndEdit, SCI_WORDLEFT, 0, 0); + SendMessage(Globals.hwndEdit, SCI_WORDLEFT, 0, 0); break; case CMD_CTRLRIGHT: - SendMessage(g_hwndEdit, SCI_WORDRIGHT, 0, 0); + SendMessage(Globals.hwndEdit, SCI_WORDRIGHT, 0, 0); break; @@ -5280,9 +5170,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_RECODEDEFAULT: { - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { - Encoding_SrcCmdLn(Encoding_MapUnicode(g_iDefaultNewFileEncoding)); - StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),g_wchCurFile); + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { + Encoding_SrcCmdLn(Encoding_MapUnicode(Settings.DefaultEncoding)); + StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),Globals.CurrentFile); FileLoad(false,false,true,true,true,tchMaxPathBuffer); } } @@ -5291,10 +5181,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_RECODEANSI: { - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { Encoding_SrcCmdLn(CPI_ANSI_DEFAULT); - StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),g_wchCurFile); - FileLoad(false,false,true,true,bSkipANSICodePageDetection,tchMaxPathBuffer); + StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),Globals.CurrentFile); + FileLoad(false,false,true,true,Settings.SkipANSICodePageDetection,tchMaxPathBuffer); } } break; @@ -5302,9 +5192,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_RECODEOEM: { - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { Encoding_SrcCmdLn(CPI_OEM); - StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),g_wchCurFile); + StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),Globals.CurrentFile); FileLoad(false,false,true,true,true,tchMaxPathBuffer); } } @@ -5313,9 +5203,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_RELOADASCIIASUTF8: { - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { g_bForceLoadASCIIasUTF8 = true; - StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),g_wchCurFile); + StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),Globals.CurrentFile); FileLoad(false, false, true, true, true, tchMaxPathBuffer); g_bForceLoadASCIIasUTF8 = false; } @@ -5326,9 +5216,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_RELOADFORCEDETECTION: { g_bForceCompEncDetection = true; - if (StringCchLenW(g_wchCurFile, COUNTOF(g_wchCurFile))) { + if (StringCchLenW(Globals.CurrentFile, COUNTOF(Globals.CurrentFile))) { g_bForceLoadASCIIasUTF8 = false; - StringCchCopy(tchMaxPathBuffer, COUNTOF(tchMaxPathBuffer), g_wchCurFile); + StringCchCopy(tchMaxPathBuffer, COUNTOF(tchMaxPathBuffer), Globals.CurrentFile); FileLoad(false, false, true, false, false, tchMaxPathBuffer); } g_bForceCompEncDetection = false; @@ -5337,32 +5227,32 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_RELOADNOFILEVARS: { - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { - int _fNoFileVariables = g_flagNoFileVariables; - bool _bNoEncodingTags = g_bNoEncodingTags; - g_flagNoFileVariables = 1; - g_bNoEncodingTags = 1; - StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),g_wchCurFile); - FileLoad(false,false,true, bSkipUnicodeDetection, bSkipANSICodePageDetection, tchMaxPathBuffer); - g_flagNoFileVariables = _fNoFileVariables; - g_bNoEncodingTags = _bNoEncodingTags; + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { + int _fNoFileVariables = Flags.NoFileVariables; + bool _bNoEncodingTags = Settings.NoEncodingTags; + Flags.NoFileVariables = 1; + Settings.NoEncodingTags = true; + StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),Globals.CurrentFile); + FileLoad(false,false,true, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, tchMaxPathBuffer); + Flags.NoFileVariables = _fNoFileVariables; + Settings.NoEncodingTags = _bNoEncodingTags; } } break; case CMD_LEXDEFAULT: - Style_SetDefaultLexer(g_hwndEdit); + Style_SetDefaultLexer(Globals.hwndEdit); break; //case CMD_LEXHTML: - // Style_SetHTMLLexer(g_hwndEdit); + // Style_SetHTMLLexer(Globals.hwndEdit); // break; //case CMD_LEXXML: - // Style_SetXMLLexer(g_hwndEdit); + // Style_SetXMLLexer(Globals.hwndEdit); // break; @@ -5376,10 +5266,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) struct tm sst; EDITFINDREPLACE efrTS = EFR_INIT_DATA; - efrTS.hwnd = g_hwndEdit; + efrTS.hwnd = Globals.hwndEdit; efrTS.fuFlags = SCFIND_REGEXP; - IniGetString(L"Settings2",L"TimeStamp",L"\\$Date:[^\\$]+\\$ | $Date: %Y/%m/%d %H:%M:%S $",wchFind,COUNTOF(wchFind)); + StringCchCopyW(wchFind, COUNTOF(wchFind), Settings2.TimeStamp); WCHAR *pwchSep = StrChr(wchFind, L'|'); if (pwchSep) { @@ -5408,10 +5298,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) WideCharToMultiByteStrg(Encoding_SciCP,wchFind,efrTS.szFind); WideCharToMultiByteStrg(Encoding_SciCP,wchReplace,efrTS.szReplace); - if (!SendMessage(g_hwndEdit, SCI_GETSELECTIONEMPTY, 0, 0)) - EditReplaceAllInSelection(g_hwndEdit, &efrTS, true); + if (!SendMessage(Globals.hwndEdit, SCI_GETSELECTIONEMPTY, 0, 0)) + EditReplaceAllInSelection(Globals.hwndEdit, &efrTS, true); else - EditReplaceAll(g_hwndEdit,&efrTS,true); + EditReplaceAll(Globals.hwndEdit,&efrTS,true); } break; @@ -5427,11 +5317,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_WEBACTION1: case CMD_WEBACTION2: { - LPWSTR lpszTemplateName = (LOWORD(wParam) == CMD_WEBACTION1) ? L"WebTemplate1" : L"WebTemplate2"; - - bool bCmdEnabled = IniGetString(L"Settings2",lpszTemplateName,L"",tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer)); + StringCchCopyW(tchMaxPathBuffer, COUNTOF(tchMaxPathBuffer), + (LOWORD(wParam) == CMD_WEBACTION1) ? Settings2.WebTemplate1 : Settings2.WebTemplate1); - if (bCmdEnabled) { + if (StringCchLenW(tchMaxPathBuffer,0) > 0) { DocPos const cchSelection = SciCall_GetSelText(NULL); @@ -5461,8 +5350,8 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) ExpandEnvironmentStringsEx(lpszCommand, cmdsz); WCHAR wchDirectory[MAX_PATH] = { L'\0' }; - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { - StringCchCopy(wchDirectory,COUNTOF(wchDirectory),g_wchCurFile); + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { + StringCchCopy(wchDirectory,COUNTOF(wchDirectory),Globals.CurrentFile); PathRemoveFileSpec(wchDirectory); } @@ -5488,25 +5377,25 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_INCLINELIMIT: case CMD_DECLINELIMIT: - if (!g_bMarkLongLines) + if (!Settings.MarkLongLines) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_VIEW_LONGLINEMARKER,1),0); else { if (LOWORD(wParam) == CMD_INCLINELIMIT) - g_iLongLinesLimit++; + Settings.LongLinesLimit++; else - g_iLongLinesLimit--; - g_iLongLinesLimit = clampi(g_iLongLinesLimit, 0, LONG_LINES_MARKER_LIMIT); - SendMessage(g_hwndEdit,SCI_SETEDGECOLUMN,g_iLongLinesLimit,0); + Settings.LongLinesLimit--; + Settings.LongLinesLimit = clampi(Settings.LongLinesLimit, 0, LONG_LINES_MARKER_LIMIT); + SendMessage(Globals.hwndEdit,SCI_SETEDGECOLUMN,Settings.LongLinesLimit,0); UpdateToolbar(); UpdateStatusbar(false); - iLongLinesLimitG = g_iLongLinesLimit; + g_iLongLinesLimitG = Settings.LongLinesLimit; } break; case CMD_STRINGIFY: { _BEGIN_UNDO_ACTION_; - EditEncloseSelection(g_hwndEdit, L"'", L"'"); + EditEncloseSelection(Globals.hwndEdit, L"'", L"'"); _END_UNDO_ACTION_; } break; @@ -5515,7 +5404,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_STRINGIFY2: { _BEGIN_UNDO_ACTION_; - EditEncloseSelection(g_hwndEdit, L"\"", L"\""); + EditEncloseSelection(Globals.hwndEdit, L"\"", L"\""); _END_UNDO_ACTION_; } break; @@ -5524,7 +5413,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_EMBRACE: { _BEGIN_UNDO_ACTION_; - EditEncloseSelection(g_hwndEdit, L"(", L")"); + EditEncloseSelection(Globals.hwndEdit, L"(", L")"); _END_UNDO_ACTION_; } break; @@ -5533,7 +5422,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_EMBRACE2: { _BEGIN_UNDO_ACTION_; - EditEncloseSelection(g_hwndEdit, L"[", L"]"); + EditEncloseSelection(Globals.hwndEdit, L"[", L"]"); _END_UNDO_ACTION_; } break; @@ -5542,7 +5431,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_EMBRACE3: { _BEGIN_UNDO_ACTION_; - EditEncloseSelection(g_hwndEdit, L"{", L"}"); + EditEncloseSelection(Globals.hwndEdit, L"{", L"}"); _END_UNDO_ACTION_; } break; @@ -5551,35 +5440,35 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_EMBRACE4: { _BEGIN_UNDO_ACTION_; - EditEncloseSelection(g_hwndEdit, L"`", L"`"); + EditEncloseSelection(Globals.hwndEdit, L"`", L"`"); _END_UNDO_ACTION_; } break; case CMD_INCREASENUM: - EditModifyNumber(g_hwndEdit,true); + EditModifyNumber(Globals.hwndEdit,true); break; case CMD_DECREASENUM: - EditModifyNumber(g_hwndEdit,false); + EditModifyNumber(Globals.hwndEdit,false); break; case CMD_TOGGLETITLE: - EditGetExcerpt(g_hwndEdit,szTitleExcerpt,COUNTOF(szTitleExcerpt)); + EditGetExcerpt(Globals.hwndEdit,szTitleExcerpt,COUNTOF(szTitleExcerpt)); UpdateToolbar(); break; case CMD_JUMP2SELSTART: - EditJumpToSelectionStart(g_hwndEdit); + EditJumpToSelectionStart(Globals.hwndEdit); SciCall_ChooseCaretX(); break; case CMD_JUMP2SELEND: - EditJumpToSelectionEnd(g_hwndEdit); + EditJumpToSelectionEnd(Globals.hwndEdit); SciCall_ChooseCaretX(); break; @@ -5588,8 +5477,8 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) WCHAR *pszCopy; WCHAR tchUntitled[32] = { L'\0' }; - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) - pszCopy = g_wchCurFile; + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) + pszCopy = Globals.CurrentFile; else { GetLngString(IDS_MUI_UNTITLED, tchUntitled, COUNTOF(tchUntitled)); pszCopy = tchUntitled; @@ -5601,7 +5490,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_COPYWINPOS: { - WININFO wi = GetMyWindowPlacement(g_hwndMain,NULL); + WININFO wi = GetMyWindowPlacement(Globals.hwndMain,NULL); StringCchPrintf(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),L"/pos %i,%i,%i,%i,%i",wi.x,wi.y,wi.cx,wi.cy,wi.max); SetClipboardTextW(hwnd, tchMaxPathBuffer, StringCchLen(tchMaxPathBuffer, 0)); UpdateToolbar(); @@ -5610,23 +5499,23 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_INITIALWINPOS: - SnapToWinInfoPos(hwnd, &g_WinInfo, false); + SnapToWinInfoPos(hwnd, &s_WinInfo, false); break; case CMD_FULLSCRWINPOS: { - WININFO const wi = GetMyWindowPlacement(g_hwndMain, NULL); + WININFO const wi = GetMyWindowPlacement(Globals.hwndMain, NULL); SnapToWinInfoPos(hwnd, &wi, true); } break; case CMD_DEFAULTWINPOS: - SnapToWinInfoPos(hwnd, &g_DefWinInfo, false); + SnapToWinInfoPos(hwnd, &s_DefWinInfo, false); break; case CMD_SAVEASDEFWINPOS: { - WININFO const wi = GetMyWindowPlacement(g_hwndMain, NULL); + WININFO const wi = GetMyWindowPlacement(Globals.hwndMain, NULL); WCHAR tchDefWinPos[80]; StringCchPrintf(tchDefWinPos, COUNTOF(tchDefWinPos), L"%i,%i,%i,%i,%i", wi.x, wi.y, wi.cx, wi.cy, wi.max); IniSetString(L"Settings2", L"DefaultWindowPosition", tchDefWinPos); @@ -5634,9 +5523,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; case CMD_OPENINIFILE: - if (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile))) { + if (StringCchLenW(Globals.IniFile,COUNTOF(Globals.IniFile))) { SaveSettings(false); - FileLoad(false,false,false,false,true,g_wchIniFile); + FileLoad(false,false,false,false,true,Globals.IniFile); } break; @@ -5825,7 +5714,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (IsCmdEnabled(hwnd,IDM_EDIT_CLEAR)) SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CLEAR,1),0); else - SendMessage(g_hwndEdit,SCI_CLEARALL,0,0); + SendMessage(Globals.hwndEdit,SCI_CLEARALL,0,0); break; @@ -5894,7 +5783,7 @@ LRESULT MsgSysCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) switch (wParam) { case SC_MINIMIZE: ShowOwnedPopups(hwnd, false); - if (bMinimizeToTray) { + if (Settings.MinimizeToTray) { MinimizeWndToTray(hwnd); ShowNotifyIcon(hwnd, true); SetNotifyIconTitle(hwnd); @@ -5972,18 +5861,18 @@ void OpenHotSpotURL(DocPos position, bool bForceBrowser) { WCHAR tchFile[MAX_PATH + 1] = { L'\0' }; - if (OpenFileDlg(g_hwndMain, tchFile, COUNTOF(tchFile), szFileName)) - FileLoad(false, false, false, bSkipUnicodeDetection, bSkipANSICodePageDetection, tchFile); + if (OpenFileDlg(Globals.hwndMain, tchFile, COUNTOF(tchFile), szFileName)) + FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, tchFile); } else - FileLoad(false, false, false, bSkipUnicodeDetection, bSkipANSICodePageDetection, szFileName); + FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, szFileName); } else { // open in web browser WCHAR wchDirectory[MAX_PATH+1] = { L'\0' }; - if (StringCchLenW(g_wchCurFile, COUNTOF(g_wchCurFile))) { - StringCchCopy(wchDirectory, COUNTOF(wchDirectory), g_wchCurFile); + if (StringCchLenW(Globals.CurrentFile, COUNTOF(Globals.CurrentFile))) { + StringCchCopy(wchDirectory, COUNTOF(wchDirectory), Globals.CurrentFile); PathRemoveFileSpec(wchDirectory); } @@ -6010,11 +5899,11 @@ void OpenHotSpotURL(DocPos position, bool bForceBrowser) // // _HandleAutoIndent() // -static void __fastcall _HandleAutoIndent(int const charAdded) +static void _HandleAutoIndent(int const charAdded) { // TODO: handle indent after '{' and un-indent on '}' in C/C++ ? // in CRLF mode handle LF only... - if (((SC_EOL_CRLF == g_iEOLMode) && (charAdded != '\r')) || (SC_EOL_CRLF != g_iEOLMode)) + if (((SC_EOL_CRLF == Globals.iEOLMode) && (charAdded != '\r')) || (SC_EOL_CRLF != Globals.iEOLMode)) { DocPos const iCurPos = SciCall_GetCurrentPos(); DocLn const iCurLine = SciCall_LineFromPosition(iCurPos); @@ -6064,9 +5953,9 @@ static void __fastcall _HandleAutoIndent(int const charAdded) // // _HandleAutoCloseTags() // -static void __fastcall _HandleAutoCloseTags() +static void _HandleAutoCloseTags() { - ///int lexerID = (int)SendMessage(g_hwndEdit,SCI_GETLEXER,0,0); + ///int lexerID = SciCall_GetLexer(); ///if (lexerID == SCLEX_HTML || lexerID == SCLEX_XML) DocPos const maxSearchBackward = 4096; { @@ -6122,7 +6011,7 @@ static void __fastcall _HandleAutoCloseTags() // // _HandleTinyExpr() - called on '?' insert // -static void __fastcall _HandleTinyExpr() +static void _HandleTinyExpr() { DocPos const iCurPos = SciCall_GetCurrentPos(); DocPos const iPosBefore = SciCall_PositionBefore(iCurPos); @@ -6158,10 +6047,10 @@ static void __fastcall _HandleTinyExpr() // // _IsIMEOpenInNoNativeMode() // -static bool __fastcall _IsIMEOpenInNoNativeMode() +static bool _IsIMEOpenInNoNativeMode() { bool result = false; - HIMC const himc = ImmGetContext(g_hwndEdit); + HIMC const himc = ImmGetContext(Globals.hwndEdit); if (himc) { if (ImmGetOpenStatus(himc)) { DWORD dwConversion = IME_CMODE_ALPHANUMERIC, dwSentence = 0; @@ -6169,7 +6058,7 @@ static bool __fastcall _IsIMEOpenInNoNativeMode() result = (dwConversion != IME_CMODE_ALPHANUMERIC); } } - ImmReleaseContext(g_hwndEdit, himc); + ImmReleaseContext(Globals.hwndEdit, himc); } return result; } @@ -6221,8 +6110,8 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) _SetDocumentModified(true); } else if (pnmh->code == SCN_MODIFYATTEMPTRO) { - if (EditToggleView(g_hwndEdit, false)) { - EditToggleView(g_hwndEdit, true); + if (EditToggleView(Globals.hwndEdit, false)) { + EditToggleView(Globals.hwndEdit, true); } } } @@ -6256,8 +6145,8 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) } } if (bModified) { - if (g_iMarkOccurrences > 0) { - MarkAllOccurrences(iUpdateDelayMarkAllCoccurrences, true); + if (Settings.MarkOccurrences > 0) { + MarkAllOccurrences(Settings2.UpdateDelayMarkAllOccurrences, true); } if (scn->linesAdded != 0) { UpdateMarginWidth(); @@ -6273,8 +6162,8 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) //case SCN_STYLENEEDED: // this event needs SCI_SETLEXER(SCLEX_CONTAINER) // { // int lineNumber = SciCall_LineFromPosition(SciCall_GetEndStyled()); - // EditUpdateUrlHotspots(g_hwndEdit, SciCall_PositionFromLine(lineNumber), (int)scn->position, bHyperlinkHotspot); - // EditUpdateHiddenLineRange(hwnd, &g_efrData, 0, SciCall_GetLineCount()); + // EditUpdateUrlHotspots(Globals.hwndEdit, SciCall_PositionFromLine(lineNumber), (int)scn->position, bHyperlinkHotspot); + // EditUpdateHiddenLineRange(hwnd, &Settings.EFR_Data, 0, SciCall_GetLineCount()); // } // break; @@ -6291,41 +6180,41 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) //~InvalidateSelections(); // fixed in SCI ? // Brace Match - if (bMatchBraces) { - EditMatchBrace(g_hwndEdit); + if (Settings.MatchBraces) { + EditMatchBrace(Globals.hwndEdit); } - if (g_iMarkOccurrences > 0) { + if (Settings.MarkOccurrences > 0) { // clear marks only, if selection changed if (iUpd & SC_UPDATE_SELECTION) { if (!SciCall_IsSelectionEmpty()) { - MarkAllOccurrences(iUpdateDelayMarkAllCoccurrences, true); + MarkAllOccurrences(Settings2.UpdateDelayMarkAllOccurrences, true); } else { - EditClearAllOccurrenceMarkers(g_hwndEdit); + EditClearAllOccurrenceMarkers(Globals.hwndEdit); } } else if (iUpd & SC_UPDATE_CONTENT) { // ignoring SC_UPDATE_CONTENT cause Style and Marker are out of scope here // using WM_COMMAND -> SCEN_CHANGE instead! - //~MarkAllOccurrences(iUpdateDelayMarkAllCoccurrences, false); + //~MarkAllOccurrences(Settings2.UpdateDelayMarkAllCoccurrences, false); } } - if (g_bHyperlinkHotspot) { - UpdateVisibleUrlHotspot(iUpdateDelayHyperlinkStyling); + if (Settings.HyperlinkHotspot) { + UpdateVisibleUrlHotspot(Settings2.UpdateDelayHyperlinkStyling); } UpdateToolbar(); UpdateStatusbar(false); } else if (iUpd & SC_UPDATE_V_SCROLL) { - if ((g_iMarkOccurrences > 0) && g_bMarkOccurrencesMatchVisible) { - MarkAllOccurrences(iUpdateDelayMarkAllCoccurrences, false); + if ((Settings.MarkOccurrences > 0) && Settings.MarkOccurrencesMatchVisible) { + MarkAllOccurrences(Settings2.UpdateDelayMarkAllOccurrences, false); } - if (g_bHyperlinkHotspot) { - UpdateVisibleUrlHotspot(iUpdateDelayHyperlinkStyling); + if (Settings.HyperlinkHotspot) { + UpdateVisibleUrlHotspot(Settings2.UpdateDelayHyperlinkStyling); } } } @@ -6358,10 +6247,10 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) switch (ich) { case '\r': case '\n': - if (bAutoIndent) { _HandleAutoIndent(ich); } + if (Settings.AutoIndent) { _HandleAutoIndent(ich); } break; case '>': - if (bAutoCloseTags) { _HandleAutoCloseTags(); } + if (Settings.AutoCloseTags) { _HandleAutoCloseTags(); } break; case '?': _HandleTinyExpr(); @@ -6370,18 +6259,19 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) break; } - if ((g_bAutoCompleteWords || g_bAutoCLexerKeyWords)) + if ((Settings.AutoCompleteWords || Settings.AutoCLexerKeyWords)) { - if (SciCall_IsIMEModeCJK()) - { - SciCall_AutoCCancel(); - return 0; - } - if (!SciCall_AutoCActive()) { EditCompleteWord(g_hwndEdit, false); } + if (!EditAutoCompleteWord(Globals.hwndEdit, false)) { return 0; } } } break; + case SCN_AUTOCCHARDELETED: + if ((Settings.AutoCompleteWords || Settings.AutoCLexerKeyWords)) + { + if (!EditAutoCompleteWord(Globals.hwndEdit, false)) { return 0; } + } + break; case SCN_NEEDSHOWN: { @@ -6433,12 +6323,12 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) //SetForegroundWindow(hwnd); if (PathIsDirectory(szBuf)) { WCHAR tchFile[MAX_PATH]; - if (OpenFileDlg(g_hwndMain, tchFile, COUNTOF(tchFile), szBuf)) { - FileLoad(false, false, false, bSkipUnicodeDetection, bSkipANSICodePageDetection, tchFile); + if (OpenFileDlg(Globals.hwndMain, tchFile, COUNTOF(tchFile), szBuf)) { + FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, tchFile); } } else if (PathFileExists(szBuf)) { - FileLoad(false, false, false, bSkipUnicodeDetection, bSkipANSICodePageDetection, szBuf); + FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, szBuf); } } } @@ -6448,8 +6338,8 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) return 0LL; } // in any case - if (g_bMarkOccurrencesCurrentWord && (g_iMarkOccurrences > 0)) { - MarkAllOccurrences(iUpdateDelayMarkAllCoccurrences, false); + if (Settings.MarkOccurrencesCurrentWord && (Settings.MarkOccurrences > 0)) { + MarkAllOccurrences(Settings2.UpdateDelayMarkAllOccurrences, false); } return -1LL; @@ -6482,11 +6372,11 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) case TBN_RESET: { - int i; int c = (int)SendMessage(g_hwndToolbar,TB_BUTTONCOUNT,0,0); + int i; int c = (int)SendMessage(s_hwndToolbar,TB_BUTTONCOUNT,0,0); for (i = 0; i < c; i++) { - SendMessage(g_hwndToolbar, TB_DELETEBUTTON, 0, 0); + SendMessage(s_hwndToolbar, TB_DELETEBUTTON, 0, 0); } - SendMessage(g_hwndToolbar,TB_ADDBUTTONS,NUMINITIALTOOLS,(LPARAM)tbbMainWnd); + SendMessage(s_hwndToolbar,TB_ADDBUTTONS,NUMINITIALTOOLS,(LPARAM)tbbMainWnd); } return 0LL; @@ -6509,8 +6399,8 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) switch (pnmm->dwItemSpec) { case STATUS_EOLMODE: - SendMessage(g_hwndEdit,SCI_CONVERTEOLS, SciCall_GetEOLMode(),0); - EditFixPositions(g_hwndEdit); + SendMessage(Globals.hwndEdit,SCI_CONVERTEOLS, SciCall_GetEOLMode(),0); + EditFixPositions(Globals.hwndEdit); return 1LL; default: @@ -6523,7 +6413,7 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) { LPNMMOUSE pnmm = (LPNMMOUSE)lParam; - switch (g_vSBSOrder[pnmm->dwItemSpec]) + switch (s_vSBSOrder[pnmm->dwItemSpec]) { case STATUS_DOCLINE: case STATUS_DOCCOLUMN: @@ -6537,9 +6427,9 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) case STATUS_EOLMODE: { int i; - if (g_iEOLMode == SC_EOL_CRLF) + if (Globals.iEOLMode == SC_EOL_CRLF) i = IDM_LINEENDINGS_CRLF; - else if (g_iEOLMode == SC_EOL_LF) + else if (Globals.iEOLMode == SC_EOL_LF) i = IDM_LINEENDINGS_LF; else i = IDM_LINEENDINGS_CR; @@ -6676,309 +6566,297 @@ void LoadSettings() if (pIniSection) { - g_iSettingsVersion = IniGetInt(L"Settings", L"SettingsVersion", CFG_VER_NONE); - - g_bEnableSaveSettings = true; // false: if settings-file is loaded in editor - g_bSaveSettings = IniGetBool(L"Settings", L"SaveSettings", true); - + // prerequisites + s_bSaveSettings = IniGetBool(L"Settings", L"SaveSettings", true); + s_iSettingsVersion = IniGetInt(L"Settings", L"SettingsVersion", CFG_VER_NONE); // first load "hard coded" .ini-Settings // -------------------------------------------------------------------------- LoadIniSection(L"Settings2", pIniSection, cchIniSection); // -------------------------------------------------------------------------- - IniSectionGetString(pIniSection, L"PreferredLanguageLocaleName", L"", - g_tchPrefLngLocName, COUNTOF(g_tchPrefLngLocName)); + Defaults2.PreferredLanguageLocaleName[0] = L'\0'; + IniSectionGetString(pIniSection, L"PreferredLanguageLocaleName", Defaults2.PreferredLanguageLocaleName, + Settings2.PreferredLanguageLocaleName, COUNTOF(Settings2.PreferredLanguageLocaleName)); - g_bStickyWinPos = IniSectionGetBool(pIniSection, L"StickyWindowPosition", false); + StringCchCopyW(Defaults2.DefaultExtension, COUNTOF(Defaults2.DefaultExtension), L"txt"); + IniSectionGetString(pIniSection, L"DefaultExtension", Defaults2.DefaultExtension, + Settings2.DefaultExtension, COUNTOF(Settings2.DefaultExtension)); + StrTrim(Settings2.DefaultExtension, L" \t.\""); - IniSectionGetString(pIniSection, L"DefaultExtension", L"txt", g_tchDefaultExtension, COUNTOF(g_tchDefaultExtension)); - StrTrim(g_tchDefaultExtension, L" \t.\""); + Defaults2.DefaultDirectory[0] = L'\0'; + IniSectionGetString(pIniSection, L"DefaultDirectory", Defaults2.DefaultDirectory, + Settings2.DefaultDirectory, COUNTOF(Settings2.DefaultDirectory)); - IniSectionGetString(pIniSection, L"DefaultDirectory", L"", g_tchDefaultDir, COUNTOF(g_tchDefaultDir)); + Defaults2.FileDlgFilters[0] = L'\0'; + IniSectionGetString(pIniSection, L"FileDlgFilters", Defaults2.FileDlgFilters, + Settings2.FileDlgFilters, COUNTOF(Settings2.FileDlgFilters) - 2); - ZeroMemory(g_tchFileDlgFilters, sizeof(WCHAR)*COUNTOF(g_tchFileDlgFilters)); - IniSectionGetString(pIniSection, L"FileDlgFilters", L"", g_tchFileDlgFilters, COUNTOF(g_tchFileDlgFilters) - 2); - - dwFileCheckInverval = IniSectionGetInt(pIniSection, L"FileCheckInverval", 2000); - dwFileCheckInverval = clampul(dwFileCheckInverval, 250, 300000); - - dwAutoReloadTimeout = IniSectionGetInt(pIniSection, L"AutoReloadTimeout", 2000); - dwAutoReloadTimeout = clampul(dwAutoReloadTimeout, 250, 300000); + Defaults2.FileCheckInverval = 2000UL; + Settings2.FileCheckInverval = clampul(IniSectionGetInt(pIniSection, L"FileCheckInverval", + Defaults2.FileCheckInverval), 250UL, 300000UL); + Defaults2.AutoReloadTimeout = 2000UL; + Settings2.AutoReloadTimeout = clampul(IniSectionGetInt(pIniSection, L"AutoReloadTimeout", + Defaults2.AutoReloadTimeout), 250UL, 300000UL); // deprecated - g_iRenderingTechnology = IniSectionGetInt(pIniSection, L"SciDirectWriteTech", -111); - if ((g_iRenderingTechnology != -111) && g_bSaveSettings) { + Defaults.RenderingTechnology = IniSectionGetInt(pIniSection, L"SciDirectWriteTech", -111); + if ((Defaults.RenderingTechnology != -111) && s_bSaveSettings) { // cleanup IniSetString(L"Settings2", L"SciDirectWriteTech", NULL); - IniSetInt(L"Settings", L"RenderingTechnology", g_iRenderingTechnology); } - g_iRenderingTechnology = clampi(g_iRenderingTechnology, 0, 3); + Defaults.RenderingTechnology = clampi(Defaults.RenderingTechnology, 0, 3); // Settings2 deprecated - g_iBidirectional = IniSectionGetInt(pIniSection, L"EnableBidirectionalSupport", -111); - if ((g_iBidirectional != -111) && g_bSaveSettings) { + Defaults.Bidirectional = IniSectionGetInt(pIniSection, L"EnableBidirectionalSupport", -111); + if ((Defaults.Bidirectional != -111) && s_bSaveSettings) { // cleanup IniSetString(L"Settings2", L"EnableBidirectionalSupport", NULL); - IniSetInt(L"Settings", L"Bidirectional", g_iBidirectional); } - g_iBidirectional = (clampi(g_iBidirectional, SC_BIDIRECTIONAL_DISABLED, SC_BIDIRECTIONAL_R2L) > 0) ? SC_BIDIRECTIONAL_R2L : 0; + Defaults.Bidirectional = (clampi(Defaults.Bidirectional, SC_BIDIRECTIONAL_DISABLED, SC_BIDIRECTIONAL_R2L) > 0) ? SC_BIDIRECTIONAL_R2L : 0; - g_IMEInteraction = clampi(IniSectionGetInt(pIniSection, L"IMEInteraction", -1), -1, SC_IME_INLINE); + Defaults2.IMEInteraction = -1; + Settings2.IMEInteraction = clampi(IniSectionGetInt(pIniSection, L"IMEInteraction", Defaults2.IMEInteraction), -1, SC_IME_INLINE); // Korean IME use inline mode by default - if (g_IMEInteraction == -1) { // auto detection once + if (Settings2.IMEInteraction == -1) { // auto detection once // ScintillaWin::KoreanIME() int const codePage = Scintilla_InputCodePage(); - g_IMEInteraction = ((codePage == 949 || codePage == 1361) ? SC_IME_INLINE : SC_IME_WINDOWED); + Settings2.IMEInteraction = ((codePage == 949 || codePage == 1361) ? SC_IME_INLINE : SC_IME_WINDOWED); } - g_iSciFontQuality = clampi(IniSectionGetInt(pIniSection, L"SciFontQuality", FontQuality[3]), 0, 3); + Defaults2.SciFontQuality = FontQuality[3]; + Settings2.SciFontQuality = clampi(IniSectionGetInt(pIniSection, L"SciFontQuality", Defaults2.SciFontQuality), 0, 3); + + Defaults2.MarkOccurrencesMaxCount = 2000; + Settings2.MarkOccurrencesMaxCount = IniSectionGetInt(pIniSection, L"MarkOccurrencesMaxCount", Defaults2.MarkOccurrencesMaxCount); + if (Settings2.MarkOccurrencesMaxCount <= 0) { Settings2.MarkOccurrencesMaxCount = INT_MAX; } - g_iMarkOccurrencesMaxCount = IniSectionGetInt(pIniSection, L"MarkOccurrencesMaxCount", 2000); - g_iMarkOccurrencesMaxCount = (g_iMarkOccurrencesMaxCount <= 0) ? INT_MAX : g_iMarkOccurrencesMaxCount; + Defaults2.UpdateDelayHyperlinkStyling = 100; + Settings2.UpdateDelayHyperlinkStyling = clampi(IniSectionGetInt(pIniSection, L"UpdateDelayHyperlinkStyling", + Defaults2.UpdateDelayHyperlinkStyling), USER_TIMER_MINIMUM, 10000); - iUpdateDelayHyperlinkStyling = clampi(IniSectionGetInt(pIniSection, L"UpdateDelayHyperlinkStyling", 100), USER_TIMER_MINIMUM, 10000); + Defaults2.UpdateDelayMarkAllOccurrences = 50; + Settings2.UpdateDelayMarkAllOccurrences = clampi(IniSectionGetInt(pIniSection, L"UpdateDelayMarkAllOccurrences", + Defaults2.UpdateDelayMarkAllOccurrences), USER_TIMER_MINIMUM, 10000); - iUpdateDelayMarkAllCoccurrences = clampi(IniSectionGetInt(pIniSection, L"UpdateDelayMarkAllCoccurrences", 50), USER_TIMER_MINIMUM, 10000); + Defaults2.DenyVirtualSpaceAccess = false; + Settings2.DenyVirtualSpaceAccess = IniSectionGetBool(pIniSection, L"DenyVirtualSpaceAccess", Defaults2.DenyVirtualSpaceAccess); - g_bDenyVirtualSpaceAccess = IniSectionGetBool(pIniSection, L"DenyVirtualSpaceAccess", false); - g_bUseOldStyleBraceMatching = IniSectionGetBool(pIniSection, L"UseOldStyleBraceMatching", false); + Defaults2.UseOldStyleBraceMatching = false; + Settings2.UseOldStyleBraceMatching = IniSectionGetBool(pIniSection, L"UseOldStyleBraceMatching", Defaults2.UseOldStyleBraceMatching); - iCurrentLineHorizontalSlop = clampi(IniSectionGetInt(pIniSection, L"CurrentLineHorizontalSlop", 40), 0, 240); + Defaults2.CurrentLineHorizontalSlop = 40; + Settings2.CurrentLineHorizontalSlop = clampi(IniSectionGetInt(pIniSection, L"CurrentLineHorizontalSlop", Defaults2.CurrentLineHorizontalSlop), 0, 240); - iCurrentLineVerticalSlop = clampi(IniSectionGetInt(pIniSection, L"CurrentLineVerticalSlop", 5), 0, 25); + Defaults2.CurrentLineVerticalSlop = 5; + Settings2.CurrentLineVerticalSlop = clampi(IniSectionGetInt(pIniSection, L"CurrentLineVerticalSlop", Defaults2.CurrentLineVerticalSlop), 0, 25); - IniSectionGetString(pIniSection, L"AdministrationTool.exe", L"", g_tchAdministrationExe, COUNTOF(g_tchAdministrationExe)); + Defaults2.AdministrationTool[0] = L'\0'; + IniSectionGetString(pIniSection, L"AdministrationTool.exe", Defaults2.AdministrationTool, + Settings2.AdministrationTool, COUNTOF(Settings2.AdministrationTool)); + + Defaults2.DefaultWindowPosition[0] = L'\0'; + IniSectionGetString(pIniSection, L"DefaultWindowPosition", Defaults2.DefaultWindowPosition, + Settings2.DefaultWindowPosition, COUNTOF(Settings2.DefaultWindowPosition)); + bool const bExplicitDefaultWinPos = (StringCchLenW(Settings2.DefaultWindowPosition, 0) != 0); + + Defaults2.FileLoadWarningMB = 1; + Settings2.FileLoadWarningMB = clampi(IniSectionGetInt(pIniSection, L"FileLoadWarningMB", Defaults2.FileLoadWarningMB), 0, 2048); + + Defaults2.OpacityLevel = 75; + Settings2.OpacityLevel = clampi(IniSectionGetInt(pIniSection, L"OpacityLevel", Defaults2.OpacityLevel), 0, 100); + + Defaults2.FileBrowserPath[0] = L'\0'; + IniSectionGetString(pIniSection, L"filebrowser.exe", Defaults2.FileBrowserPath, Settings2.FileBrowserPath, COUNTOF(Settings2.FileBrowserPath)); + + StringCchCopyW(Defaults2.AppUserModelID, COUNTOF(Defaults2.AppUserModelID), MKWCS(APPNAME)); + IniSectionGetString(pIniSection, L"ShellAppUserModelID", Defaults2.AppUserModelID, Settings2.AppUserModelID, COUNTOF(Settings2.AppUserModelID)); + + Defaults2.ExtendedWhiteSpaceChars[0] = L'\0'; + IniSectionGetString(pIniSection, L"ExtendedWhiteSpaceChars", Defaults2.ExtendedWhiteSpaceChars, + Settings2.ExtendedWhiteSpaceChars, COUNTOF(Settings2.ExtendedWhiteSpaceChars)); + + Defaults2.AutoCompleteWordCharSet[0] = L'\0'; + IniSectionGetString(pIniSection, L"AutoCompleteWordCharSet", Defaults2.AutoCompleteWordCharSet, + Settings2.AutoCompleteWordCharSet, COUNTOF(Settings2.AutoCompleteWordCharSet)); + + StringCchCopyW(Defaults2.TimeStamp, COUNTOF(Defaults2.TimeStamp), L"\\$Date:[^\\$]+\\$ | $Date: %Y/%m/%d %H:%M:%S $"); + IniSectionGetString(pIniSection, L"TimeStamp", Defaults2.TimeStamp, Settings2.TimeStamp, COUNTOF(Settings2.TimeStamp)); + + Defaults2.DateTimeShort[0] = L'\0'; + IniSectionGetString(pIniSection, L"DateTimeShort", Defaults2.DateTimeShort, Settings2.DateTimeShort, COUNTOF(Settings2.DateTimeShort)); + + Defaults2.DateTimeLong[0] = L'\0'; + IniSectionGetString(pIniSection, L"DateTimeLong", Defaults2.DateTimeLong, Settings2.DateTimeLong, COUNTOF(Settings2.DateTimeLong)); + + StringCchCopyW(Defaults2.WebTemplate1, COUNTOF(Defaults2.WebTemplate1), L"https://google.com/search?q=%s"); + IniSectionGetString(pIniSection, L"WebTemplate1", Defaults2.WebTemplate1, Settings2.WebTemplate1, COUNTOF(Settings2.WebTemplate1)); + + StringCchCopyW(Defaults2.WebTemplate2, COUNTOF(Defaults2.WebTemplate2), L"https ://en.wikipedia.org/w/index.php?search=%s"); + IniSectionGetString(pIniSection, L"WebTemplate2", Defaults2.WebTemplate2, Settings2.WebTemplate2, COUNTOF(Settings2.WebTemplate2)); - WCHAR tchDefWinPos[80]; - IniSectionGetString(pIniSection, L"DefaultWindowPosition", L"", tchDefWinPos, COUNTOF(tchDefWinPos)); - int bMaxi = 0; - int const itok = swscanf_s(tchDefWinPos, L"%i,%i,%i,%i,%i", - &g_DefWinInfo.x, &g_DefWinInfo.y, &g_DefWinInfo.cx, &g_DefWinInfo.cy, &bMaxi); - if (itok == 4 || itok == 5) { // scan successful - if (g_DefWinInfo.cx < 1) g_DefWinInfo.cx = CW_USEDEFAULT; - if (g_DefWinInfo.cy < 1) g_DefWinInfo.cy = CW_USEDEFAULT; - if (bMaxi) g_DefWinInfo.max = true; - if (itok == 4) g_DefWinInfo.max = false; - _InitWindowPosition(&g_DefWinInfo, 0); - } - else { - g_DefWinInfo = _InitDefaultWndPos(2); - } // -------------------------------------------------------------------------- LoadIniSection(L"Settings", pIniSection, cchIniSection); // -------------------------------------------------------------------------- - g_bSaveRecentFiles = IniSectionGetBool(pIniSection, L"SaveRecentFiles", true); - g_bPreserveCaretPos = IniSectionGetBool(pIniSection, L"PreserveCaretPos", false); - g_bSaveFindReplace = IniSectionGetBool(pIniSection, L"SaveFindReplace", false); - - g_efrData.bFindClose = IniSectionGetBool(pIniSection, L"CloseFind", false); - g_efrData.bReplaceClose = IniSectionGetBool(pIniSection, L"CloseReplace", false); - g_efrData.bNoFindWrap = IniSectionGetBool(pIniSection, L"NoFindWrap", false); - g_efrData.bTransformBS = IniSectionGetBool(pIniSection, L"FindTransformBS", false); - g_efrData.bWildcardSearch = IniSectionGetBool(pIniSection, L"WildcardSearch", false); - g_efrData.bMarkOccurences = IniSectionGetBool(pIniSection, L"FindMarkAllOccurrences", false); - g_efrData.bHideNonMatchedLines = IniSectionGetBool(pIniSection, L"HideNonMatchedLines", false); - g_efrData.bDotMatchAll = IniSectionGetBool(pIniSection, L"RegexDotMatchesAll", false); - g_efrData.fuFlags = IniSectionGetUInt(pIniSection, L"efrData_fuFlags", 0); - - if (!IniSectionGetString(pIniSection, L"OpenWithDir", L"", g_tchOpenWithDir, COUNTOF(g_tchOpenWithDir))) { - //SHGetSpecialFolderPath(NULL, g_tchOpenWithDir, CSIDL_DESKTOPDIRECTORY, true); - GetKnownFolderPath(&FOLDERID_Desktop, g_tchOpenWithDir, COUNTOF(g_tchOpenWithDir)); +#define GET_BOOL_VALUE_FROM_INISECTION(VARNAME,DEFAULT) \ + Defaults.##VARNAME = DEFAULT; \ + Settings.##VARNAME = IniSectionGetBool(pIniSection, STRGW(VARNAME), Defaults.##VARNAME) + +#define GET_INT_VALUE_FROM_INISECTION(VARNAME,DEFAULT,MIN,MAX) \ + Defaults.##VARNAME = DEFAULT; \ + Settings.##VARNAME = clampi(IniSectionGetInt(pIniSection, STRGW(VARNAME), Defaults.##VARNAME),MIN,MAX) + + GET_BOOL_VALUE_FROM_INISECTION(SaveRecentFiles, true); + GET_BOOL_VALUE_FROM_INISECTION(PreserveCaretPos, false); + GET_BOOL_VALUE_FROM_INISECTION(SaveFindReplace, false); + + Defaults.EFR_Data.bFindClose = false; + Settings.EFR_Data.bFindClose = IniSectionGetBool(pIniSection, L"CloseFind", Defaults.EFR_Data.bFindClose); + Defaults.EFR_Data.bReplaceClose = false; + Settings.EFR_Data.bReplaceClose = IniSectionGetBool(pIniSection, L"CloseReplace", Defaults.EFR_Data.bReplaceClose); + Defaults.EFR_Data.bNoFindWrap = false; + Settings.EFR_Data.bNoFindWrap = IniSectionGetBool(pIniSection, L"NoFindWrap", Defaults.EFR_Data.bNoFindWrap); + Defaults.EFR_Data.bTransformBS = false; + Settings.EFR_Data.bTransformBS = IniSectionGetBool(pIniSection, L"FindTransformBS", Defaults.EFR_Data.bTransformBS); + Defaults.EFR_Data.bWildcardSearch = false; + Settings.EFR_Data.bWildcardSearch = IniSectionGetBool(pIniSection, L"WildcardSearch", Defaults.EFR_Data.bWildcardSearch); + Defaults.EFR_Data.bMarkOccurences = false; + Settings.EFR_Data.bMarkOccurences = IniSectionGetBool(pIniSection, L"FindMarkAllOccurrences", Defaults.EFR_Data.bMarkOccurences); + Defaults.EFR_Data.bHideNonMatchedLines = false; + Settings.EFR_Data.bHideNonMatchedLines = IniSectionGetBool(pIniSection, L"HideNonMatchedLines", Defaults.EFR_Data.bHideNonMatchedLines); + Defaults.EFR_Data.bDotMatchAll = false; + Settings.EFR_Data.bDotMatchAll = IniSectionGetBool(pIniSection, L"RegexDotMatchesAll", Defaults.EFR_Data.bDotMatchAll); + Defaults.EFR_Data.fuFlags = 0; + Settings.EFR_Data.fuFlags = IniSectionGetUInt(pIniSection, L"efrData_fuFlags", Defaults.EFR_Data.fuFlags); + + Defaults.OpenWithDir[0] = L'\0'; + if (!IniSectionGetString(pIniSection, L"OpenWithDir", Defaults.OpenWithDir, Settings.OpenWithDir, COUNTOF(Settings.OpenWithDir))) { + //SHGetSpecialFolderPath(NULL, Settings.OpenWithDir, CSIDL_DESKTOPDIRECTORY, true); + GetKnownFolderPath(&FOLDERID_Desktop, Settings.OpenWithDir, COUNTOF(Settings.OpenWithDir)); } else { - PathAbsoluteFromApp(g_tchOpenWithDir, NULL, COUNTOF(g_tchOpenWithDir), true); + PathAbsoluteFromApp(Settings.OpenWithDir, NULL, COUNTOF(Settings.OpenWithDir), true); } - if (!IniSectionGetString(pIniSection, L"Favorites", L"", g_tchFavoritesDir, COUNTOF(g_tchFavoritesDir))) { - //SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,g_tchFavoritesDir); - GetKnownFolderPath(&FOLDERID_Favorites, g_tchFavoritesDir, COUNTOF(g_tchFavoritesDir)); + + Defaults.FavoritesDir[0] = L'\0'; + //StringCchCopyW(Defaults.FavoritesDir, COUNTOF(Defaults.FavoritesDir), L"%USERPROFILE%"); + if (!IniSectionGetString(pIniSection, L"Favorites", Defaults.FavoritesDir, Settings.FavoritesDir, COUNTOF(Settings.FavoritesDir))) { + //SHGetFolderPath(NULL,CSIDL_PERSONAL,NULL,SHGFP_TYPE_CURRENT,Settings.FavoritesDir); + GetKnownFolderPath(&FOLDERID_Favorites, Settings.FavoritesDir, COUNTOF(Settings.FavoritesDir)); } else { - PathAbsoluteFromApp(g_tchFavoritesDir, NULL, COUNTOF(g_tchFavoritesDir), true); + PathAbsoluteFromApp(Settings.FavoritesDir, NULL, COUNTOF(Settings.FavoritesDir), true); } - iPathNameFormat = clampi(IniSectionGetInt(pIniSection, L"PathNameFormat", 1), 0, 2); + GET_INT_VALUE_FROM_INISECTION(PathNameFormat, 1, 0, 2); + GET_BOOL_VALUE_FROM_INISECTION(WordWrap, false); g_bWordWrapG = Settings.WordWrap; + GET_INT_VALUE_FROM_INISECTION(WordWrapMode, 0, 0, 1); + GET_INT_VALUE_FROM_INISECTION(WordWrapIndent, 0, 0, 6); - g_bWordWrap = IniSectionGetBool(pIniSection, L"WordWrap", false); - bWordWrapG = g_bWordWrap; - - iWordWrapMode = clampi(IniSectionGetInt(pIniSection, L"WordWrapMode", 0), 0, 1); - - iWordWrapIndent = clampi(IniSectionGetInt(pIniSection, L"WordWrapIndent", 0), 0, 6); - - iWordWrapSymbols = IniSectionGetInt(pIniSection, L"WordWrapSymbols", 22); - iWordWrapSymbols = clampi(iWordWrapSymbols % 10, 0, 2) + - clampi((iWordWrapSymbols % 100 - iWordWrapSymbols % 10) / 10, 0, 2) * 10; - - bShowWordWrapSymbols = IniSectionGetBool(pIniSection, L"ShowWordWrapSymbols", 0); - - bMatchBraces = IniSectionGetBool(pIniSection, L"MatchBraces", true); - - bAutoCloseTags = IniSectionGetBool(pIniSection, L"AutoCloseTags", false); - - bHiliteCurrentLine = IniSectionGetBool(pIniSection, L"HighlightCurrentLine", false); - - g_bHyperlinkHotspot = IniSectionGetBool(pIniSection, L"HyperlinkHotspot", false); - - bScrollPastEOF = IniSectionGetBool(pIniSection, L"ScrollPastEOF", false); - - bAutoIndent = IniSectionGetBool(pIniSection, L"AutoIndent", true); - - g_bAutoCompleteWords = IniSectionGetBool(pIniSection, L"AutoCompleteWords", false); + Defaults.WordWrapSymbols = 22; + int iWS = IniSectionGetInt(pIniSection, L"WordWrapSymbols", Defaults.WordWrapSymbols); + Settings.WordWrapSymbols = clampi(iWS % 10, 0, 2) + clampi((iWS % 100 - iWS % 10) / 10, 0, 2) * 10; - g_bAutoCLexerKeyWords = IniSectionGetBool(pIniSection, L"AutoCLexerKeyWords", false); - - g_bAccelWordNavigation = IniSectionGetBool(pIniSection, L"AccelWordNavigation", false); - - bShowIndentGuides = IniSectionGetBool(pIniSection, L"ShowIndentGuides", false); - - g_bTabsAsSpaces = IniSectionGetBool(pIniSection, L"TabsAsSpaces", false); - bTabsAsSpacesG = g_bTabsAsSpaces; - - g_bTabIndents = IniSectionGetBool(pIniSection, L"TabIndents", true); - bTabIndentsG = g_bTabIndents; - - bBackspaceUnindents = IniSectionGetBool(pIniSection, L"BackspaceUnindents", false); - - g_iTabWidth = clampi(IniSectionGetInt(pIniSection, L"TabWidth", 4), 1, 256); - iTabWidthG = g_iTabWidth; - - g_iIndentWidth = clampi(IniSectionGetInt(pIniSection, L"IndentWidth", 0), 0, 256); - iIndentWidthG = g_iIndentWidth; - - g_bMarkLongLines = IniSectionGetBool(pIniSection, L"MarkLongLines", true); - - g_iLongLinesLimit = clampi(IniSectionGetInt(pIniSection, L"LongLinesLimit", 80), 0, LONG_LINES_MARKER_LIMIT); - iLongLinesLimitG = g_iLongLinesLimit; - - iLongLineMode = clampi(IniSectionGetInt(pIniSection, L"LongLineMode", EDGE_LINE), EDGE_LINE, EDGE_BACKGROUND); - - g_bShowSelectionMargin = IniSectionGetBool(pIniSection, L"ShowSelectionMargin", false); - - g_bShowLineNumbers = IniSectionGetBool(pIniSection, L"ShowLineNumbers", true); - - g_bShowCodeFolding = IniSectionGetBool(pIniSection, L"ShowCodeFolding", true); - - g_iMarkOccurrences = clampi(IniSectionGetInt(pIniSection, L"MarkOccurrences", 1), 0, 3); - - g_bMarkOccurrencesMatchVisible = IniSectionGetBool(pIniSection, L"MarkOccurrencesMatchVisible", false); - g_bMarkOccurrencesMatchCase = IniSectionGetBool(pIniSection, L"MarkOccurrencesMatchCase", false); - g_bMarkOccurrencesMatchWords = IniSectionGetBool(pIniSection, L"MarkOccurrencesMatchWholeWords", true); - g_bMarkOccurrencesCurrentWord = IniSectionGetBool(pIniSection, L"MarkOccurrencesCurrentWord", !g_bMarkOccurrencesMatchWords); - g_bMarkOccurrencesCurrentWord = g_bMarkOccurrencesCurrentWord && !g_bMarkOccurrencesMatchWords; - - bViewWhiteSpace = IniSectionGetBool(pIniSection, L"ViewWhiteSpace", false); - - bViewEOLs = IniSectionGetBool(pIniSection, L"ViewEOLs", false); - - g_iDefaultNewFileEncoding = IniSectionGetInt(pIniSection, L"DefaultEncoding", CPI_NONE); + GET_BOOL_VALUE_FROM_INISECTION(ShowWordWrapSymbols, false); + GET_BOOL_VALUE_FROM_INISECTION(MatchBraces, true); + GET_BOOL_VALUE_FROM_INISECTION(AutoCloseTags, false); + GET_BOOL_VALUE_FROM_INISECTION(HighlightCurrentLine, false); + GET_BOOL_VALUE_FROM_INISECTION(HyperlinkHotspot, false); + GET_BOOL_VALUE_FROM_INISECTION(ScrollPastEOF, false); + GET_BOOL_VALUE_FROM_INISECTION(AutoIndent, true); + GET_BOOL_VALUE_FROM_INISECTION(AutoCompleteWords, false); + GET_BOOL_VALUE_FROM_INISECTION(AutoCLexerKeyWords, false); + GET_BOOL_VALUE_FROM_INISECTION(AccelWordNavigation, false); + GET_BOOL_VALUE_FROM_INISECTION(ShowIndentGuides, false); + GET_BOOL_VALUE_FROM_INISECTION(TabsAsSpaces, false); g_bTabsAsSpacesG = Settings.TabsAsSpaces; + GET_BOOL_VALUE_FROM_INISECTION(TabIndents, true); g_bTabIndentsG = Settings.TabIndents; + GET_BOOL_VALUE_FROM_INISECTION(BackspaceUnindents, false); + GET_INT_VALUE_FROM_INISECTION(TabWidth, 4, 1, 256); g_iTabWidthG = Settings.TabWidth; + GET_INT_VALUE_FROM_INISECTION(IndentWidth, 4, 0, 256); g_iIndentWidthG = Settings.IndentWidth; + GET_BOOL_VALUE_FROM_INISECTION(MarkLongLines, true); + GET_INT_VALUE_FROM_INISECTION(LongLinesLimit, 80, 0, LONG_LINES_MARKER_LIMIT); g_iLongLinesLimitG = Settings.LongLinesLimit; + GET_INT_VALUE_FROM_INISECTION(LongLineMode, EDGE_LINE, EDGE_LINE, EDGE_BACKGROUND); + GET_BOOL_VALUE_FROM_INISECTION(ShowSelectionMargin, true); + GET_BOOL_VALUE_FROM_INISECTION(ShowLineNumbers, true); + GET_BOOL_VALUE_FROM_INISECTION(ShowCodeFolding, true); + GET_INT_VALUE_FROM_INISECTION(MarkOccurrences, 1, 0, 3); + GET_BOOL_VALUE_FROM_INISECTION(MarkOccurrencesMatchVisible, false); + GET_BOOL_VALUE_FROM_INISECTION(MarkOccurrencesMatchCase, false); + GET_BOOL_VALUE_FROM_INISECTION(MarkOccurrencesMatchWholeWords, false); + + Defaults.MarkOccurrencesCurrentWord = !Defaults.MarkOccurrencesMatchWholeWords; + Settings.MarkOccurrencesCurrentWord = IniSectionGetBool(pIniSection, L"MarkOccurrencesCurrentWord", Defaults.MarkOccurrencesCurrentWord); + Settings.MarkOccurrencesCurrentWord = Settings.MarkOccurrencesCurrentWord && !Settings.MarkOccurrencesMatchWholeWords; + + GET_BOOL_VALUE_FROM_INISECTION(ViewWhiteSpace, false); + GET_BOOL_VALUE_FROM_INISECTION(ViewEOLs, false); + + GET_INT_VALUE_FROM_INISECTION(DefaultEncoding, CPI_ANSI_DEFAULT, CED_NO_MAPPING, INT_MAX); // if DefaultEncoding is not defined set to system's current code-page - g_iDefaultNewFileEncoding = (g_iDefaultNewFileEncoding == CPI_NONE) ? - Encoding_MapIniSetting(true, (int)GetACP()) : Encoding_MapIniSetting(true, g_iDefaultNewFileEncoding); - - bUseDefaultForFileEncoding = IniSectionGetBool(pIniSection, L"UseDefaultForFileEncoding", false); - - bSkipUnicodeDetection = IniSectionGetBool(pIniSection, L"SkipUnicodeDetection", false); - - bSkipANSICodePageDetection = IniSectionGetBool(pIniSection, L"SkipANSICodePageDetection", true); - - g_bLoadASCIIasUTF8 = IniSectionGetBool(pIniSection, L"LoadASCIIasUTF8", false); - - g_bLoadNFOasOEM = IniSectionGetBool(pIniSection, L"LoadNFOasOEM", true); - - g_bNoEncodingTags = IniSectionGetBool(pIniSection, L"NoEncodingTags", false); - - g_iDefaultEOLMode = clampi(IniSectionGetInt(pIniSection, L"DefaultEOLMode", 0), 0, 2); - - bFixLineEndings = IniSectionGetBool(pIniSection, L"FixLineEndings", false); - - bAutoStripBlanks = IniSectionGetBool(pIniSection, L"FixTrailingBlanks", false); - - iPrintHeader = clampi(IniSectionGetInt(pIniSection, L"PrintHeader", 1), 0, 3); - - iPrintFooter = clampi(IniSectionGetInt(pIniSection, L"PrintFooter", 0), 0, 1); - - iPrintColor = clampi(IniSectionGetInt(pIniSection, L"PrintColorMode", 3), 0, 4); - - iPrintZoom = IniSectionGetInt(pIniSection, L"PrintZoom", (g_iSettingsVersion < CFG_VER_0001) ? 10 : 100); - if (g_iSettingsVersion < CFG_VER_0001) { iPrintZoom = 100 + (iPrintZoom-10) * 10; } - iPrintZoom = clampi(iPrintZoom, SC_MIN_ZOOM_LEVEL, SC_MAX_ZOOM_LEVEL); - - pagesetupMargin.left = IniSectionGetInt(pIniSection, L"PrintMarginLeft", -1); - pagesetupMargin.left = max_l(pagesetupMargin.left, -1); - - pagesetupMargin.top = IniSectionGetInt(pIniSection, L"PrintMarginTop", -1); - pagesetupMargin.top = max_l(pagesetupMargin.top, -1); - - pagesetupMargin.right = IniSectionGetInt(pIniSection, L"PrintMarginRight", -1); - pagesetupMargin.right = max_l(pagesetupMargin.right, -1); - - pagesetupMargin.bottom = IniSectionGetInt(pIniSection, L"PrintMarginBottom", -1); - pagesetupMargin.bottom = max_l(pagesetupMargin.bottom, -1); - - bSaveBeforeRunningTools = IniSectionGetBool(pIniSection, L"SaveBeforeRunningTools", false); - - g_iFileWatchingMode = clampi(IniSectionGetInt(pIniSection, L"FileWatchingMode", 0), 0, 2); - - g_bResetFileWatching = IniSectionGetBool(pIniSection, L"ResetFileWatching", true); - - iEscFunction = clampi(IniSectionGetInt(pIniSection, L"EscFunction", 0), 0, 2); - - bAlwaysOnTop = IniSectionGetBool(pIniSection, L"AlwaysOnTop", false); - - bMinimizeToTray = IniSectionGetBool(pIniSection, L"MinimizeToTray", false); - - g_bTransparentMode = IniSectionGetBool(pIniSection, L"TransparentMode", false); - - g_iRenderingTechnology = clampi(IniSectionGetInt(pIniSection, L"RenderingTechnology", g_iRenderingTechnology), 0, 3); - - g_iBidirectional = clampi(IniSectionGetInt(pIniSection, L"Bidirectional", g_iBidirectional), 0, 2); - - ///~g_IMEInteraction = clampi(IniSectionGetInt(pIniSection, L"IMEInteraction", g_IMEInteraction), SC_IME_WINDOWED, SC_IME_INLINE); + Settings.DefaultEncoding = ((Settings.DefaultEncoding == CPI_NONE) ? + Encoding_MapIniSetting(true, (int)GetACP()) : Encoding_MapIniSetting(true, Settings.DefaultEncoding)); + + GET_BOOL_VALUE_FROM_INISECTION(UseDefaultForFileEncoding, false); + GET_BOOL_VALUE_FROM_INISECTION(SkipUnicodeDetection, false); + GET_BOOL_VALUE_FROM_INISECTION(SkipANSICodePageDetection, false); + GET_BOOL_VALUE_FROM_INISECTION(LoadASCIIasUTF8, false); + GET_BOOL_VALUE_FROM_INISECTION(LoadNFOasOEM, true); + GET_BOOL_VALUE_FROM_INISECTION(NoEncodingTags, false); + GET_INT_VALUE_FROM_INISECTION(DefaultEOLMode, SC_EOL_CRLF, SC_EOL_CRLF, SC_EOL_LF); Globals.iEOLMode = Settings.DefaultEOLMode; + GET_BOOL_VALUE_FROM_INISECTION(FixLineEndings, false); + GET_BOOL_VALUE_FROM_INISECTION(FixTrailingBlanks, false); + GET_INT_VALUE_FROM_INISECTION(PrintHeader, 1, 0, 3); + GET_INT_VALUE_FROM_INISECTION(PrintFooter, 0, 0, 1); + GET_INT_VALUE_FROM_INISECTION(PrintColorMode, 3, 0, 4); + + Defaults.PrintZoom = (s_iSettingsVersion < CFG_VER_0001) ? 10 : 100; + int iPrintZoom = clampi(IniSectionGetInt(pIniSection, L"PrintZoom", Defaults.PrintZoom), 0, SC_MAX_ZOOM_LEVEL); + if (s_iSettingsVersion < CFG_VER_0001) { iPrintZoom = 100 + (iPrintZoom - 10) * 10; } + Settings.PrintZoom = clampi(iPrintZoom, SC_MIN_ZOOM_LEVEL, SC_MAX_ZOOM_LEVEL); + + Defaults.PrintMargin.left = -1; + Settings.PrintMargin.left = clampi(IniSectionGetInt(pIniSection, L"PrintMarginLeft", Defaults.PrintMargin.left), -1, 40000); + Defaults.PrintMargin.top = -1; + Settings.PrintMargin.top = clampi(IniSectionGetInt(pIniSection, L"PrintMarginTop", Defaults.PrintMargin.top), -1, 40000); + Defaults.PrintMargin.right = -1; + Settings.PrintMargin.right = clampi(IniSectionGetInt(pIniSection, L"PrintMarginRight", Defaults.PrintMargin.right), -1, 40000); + Defaults.PrintMargin.bottom = -1; + Settings.PrintMargin.bottom = clampi(IniSectionGetInt(pIniSection, L"PrintMarginBottom", Defaults.PrintMargin.bottom), -1, 40000); + + GET_BOOL_VALUE_FROM_INISECTION(SaveBeforeRunningTools, false); + GET_INT_VALUE_FROM_INISECTION(FileWatchingMode, 0, 0, 2); + GET_BOOL_VALUE_FROM_INISECTION(ResetFileWatching, true); + GET_INT_VALUE_FROM_INISECTION(EscFunction, 0, 0, 2); + GET_BOOL_VALUE_FROM_INISECTION(AlwaysOnTop, false); + GET_BOOL_VALUE_FROM_INISECTION(MinimizeToTray, false); + GET_BOOL_VALUE_FROM_INISECTION(TransparentMode, false); + GET_INT_VALUE_FROM_INISECTION(RenderingTechnology, Defaults.RenderingTechnology, 0, 3); // set before + GET_INT_VALUE_FROM_INISECTION(Bidirectional, Defaults.Bidirectional, 0, 2); // set before + ///~Settings2.IMEInteraction = clampi(IniSectionGetInt(pIniSection, L"IMEInteraction", Settings2.IMEInteraction), SC_IME_WINDOWED, SC_IME_INLINE); // see TBBUTTON tbbMainWnd[] for initial/reset set of buttons - IniSectionGetString(pIniSection, L"ToolbarButtons", L"", g_tchToolbarButtons, COUNTOF(g_tchToolbarButtons)); - - bShowToolbar = IniSectionGetBool(pIniSection, L"ShowToolbar", true); - bShowStatusbar = IniSectionGetBool(pIniSection, L"ShowStatusbar", true); - - cxEncodingDlg = IniSectionGetInt(pIniSection, L"EncodingDlgSizeX", 256); - cxEncodingDlg = max_i(cxEncodingDlg, 0); - - cyEncodingDlg = IniSectionGetInt(pIniSection, L"EncodingDlgSizeY", 262); - cyEncodingDlg = max_i(cyEncodingDlg, 0); - - cxRecodeDlg = IniSectionGetInt(pIniSection, L"RecodeDlgSizeX", 256); - cxRecodeDlg = max_i(cxRecodeDlg, 0); - - cyRecodeDlg = IniSectionGetInt(pIniSection, L"RecodeDlgSizeY", 262); - cyRecodeDlg = max_i(cyRecodeDlg, 0); - - cxFileMRUDlg = IniSectionGetInt(pIniSection, L"FileMRUDlgSizeX", 412); - cxFileMRUDlg = max_i(cxFileMRUDlg, 0); - - cyFileMRUDlg = IniSectionGetInt(pIniSection, L"FileMRUDlgSizeY", 376); - cyFileMRUDlg = max_i(cyFileMRUDlg, 0); - - cxOpenWithDlg = IniSectionGetInt(pIniSection, L"OpenWithDlgSizeX", 384); - cxOpenWithDlg = max_i(cxOpenWithDlg, 0); - - cyOpenWithDlg = IniSectionGetInt(pIniSection, L"OpenWithDlgSizeY", 386); - cyOpenWithDlg = max_i(cyOpenWithDlg, 0); - - cxFavoritesDlg = IniSectionGetInt(pIniSection, L"FavoritesDlgSizeX", 334); - cxFavoritesDlg = max_i(cxFavoritesDlg, 0); - - cyFavoritesDlg = IniSectionGetInt(pIniSection, L"FavoritesDlgSizeY", 316); - cyFavoritesDlg = max_i(cyFavoritesDlg, 0); - - xFindReplaceDlg = IniSectionGetInt(pIniSection, L"FindReplaceDlgPosX", 0); - yFindReplaceDlg = IniSectionGetInt(pIniSection, L"FindReplaceDlgPosY", 0); - - xCustomSchemesDlg = IniSectionGetInt(pIniSection, L"CustomSchemesDlgPosX", 0); - yCustomSchemesDlg = IniSectionGetInt(pIniSection, L"CustomSchemesDlgPosY", 0); + StringCchCopyW(Defaults.ToolbarButtons, COUNTOF(Defaults.ToolbarButtons), TBBUTTON_DEFAULT_IDS); + IniSectionGetString(pIniSection, L"ToolbarButtons", Defaults.ToolbarButtons, Settings.ToolbarButtons, COUNTOF(Settings.ToolbarButtons)); + + GET_BOOL_VALUE_FROM_INISECTION(ShowToolbar, true); + GET_BOOL_VALUE_FROM_INISECTION(ShowStatusbar, true); + + GET_INT_VALUE_FROM_INISECTION(EncodingDlgSizeX, 256, 0, 8192); + GET_INT_VALUE_FROM_INISECTION(EncodingDlgSizeY, 262, 0, 8192); + GET_INT_VALUE_FROM_INISECTION(RecodeDlgSizeX, 256, 0, 8192); + GET_INT_VALUE_FROM_INISECTION(RecodeDlgSizeY, 262, 0, 8192); + GET_INT_VALUE_FROM_INISECTION(FileMRUDlgSizeX, 412, 0, 8192); + GET_INT_VALUE_FROM_INISECTION(FileMRUDlgSizeY, 376, 0, 8192); + GET_INT_VALUE_FROM_INISECTION(OpenWithDlgSizeX, 384, 0, 8192); + GET_INT_VALUE_FROM_INISECTION(OpenWithDlgSizeX, 384, 0, 8192); + GET_INT_VALUE_FROM_INISECTION(FavoritesDlgSizeX, 334, 0, 8192); + GET_INT_VALUE_FROM_INISECTION(FavoritesDlgSizeX, 334, 0, 8192); + GET_INT_VALUE_FROM_INISECTION(FindReplaceDlgPosX, 0, 0, 8192); + GET_INT_VALUE_FROM_INISECTION(FindReplaceDlgPosY, 0, 0, 8192); + GET_INT_VALUE_FROM_INISECTION(CustomSchemesDlgPosX, 0, 0, 8192); + GET_INT_VALUE_FROM_INISECTION(CustomSchemesDlgPosY, 0, 0, 8192); // -------------------------------------------------------------------------- LoadIniSection(L"Statusbar Settings", pIniSection, cchIniSection); @@ -6987,29 +6865,29 @@ void LoadSettings() WCHAR tchStatusBar[MIDSZ_BUFFER] = { L'\0' }; IniSectionGetString(pIniSection, L"SectionPrefixes", STATUSBAR_SECTION_PREFIXES, tchStatusBar, COUNTOF(tchStatusBar)); - ReadStrgsFromCSV(tchStatusBar, g_mxSBPrefix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L"_PRFX_"); + ReadStrgsFromCSV(tchStatusBar, s_mxSBPrefix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L"_PRFX_"); IniSectionGetString(pIniSection, L"SectionPostfixes", STATUSBAR_SECTION_POSTFIXES, tchStatusBar, COUNTOF(tchStatusBar)); - ReadStrgsFromCSV(tchStatusBar, g_mxSBPostfix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L"_POFX_"); + ReadStrgsFromCSV(tchStatusBar, s_mxSBPostfix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L"_POFX_"); IniSectionGetString(pIniSection, L"VisibleSections", STATUSBAR_DEFAULT_IDS, tchStatusBar, COUNTOF(tchStatusBar)); - ReadVectorFromString(tchStatusBar, g_iStatusbarSections, STATUS_SECTOR_COUNT, 0, (STATUS_SECTOR_COUNT - 1), -1); + ReadVectorFromString(tchStatusBar, s_iStatusbarSections, STATUS_SECTOR_COUNT, 0, (STATUS_SECTOR_COUNT - 1), -1); for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) { - g_iStatusbarVisible[i] = false; + s_iStatusbarVisible[i] = false; } int cnt = 0; for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) { - g_vSBSOrder[i] = -1; - int const id = g_iStatusbarSections[i]; + s_vSBSOrder[i] = -1; + int const id = s_iStatusbarSections[i]; if (id >= 0) { - g_vSBSOrder[cnt++] = id; - g_iStatusbarVisible[id] = true; + s_vSBSOrder[cnt++] = id; + s_iStatusbarVisible[id] = true; } } IniSectionGetString(pIniSection, L"SectionWidthSpecs", STATUSBAR_SECTION_WIDTH_SPECS, tchStatusBar, COUNTOF(tchStatusBar)); - ReadVectorFromString(tchStatusBar, g_iStatusbarWidthSpec, STATUS_SECTOR_COUNT, -4096, 4096, 0); + ReadVectorFromString(tchStatusBar, s_iStatusbarWidthSpec, STATUS_SECTOR_COUNT, -4096, 4096, 0); g_bZeroBasedColumnIndex = IniSectionGetBool(pIniSection, L"ZeroBasedColumnIndex", false); g_bZeroBasedCharacterCount = IniSectionGetBool(pIniSection, L"ZeroBasedCharacterCount", false); @@ -7020,11 +6898,11 @@ void LoadSettings() // -------------------------------------------------------------------------- IniSectionGetString(pIniSection, L"BitmapDefault", L"", - g_tchToolbarBitmap, COUNTOF(g_tchToolbarBitmap)); + s_tchToolbarBitmap, COUNTOF(s_tchToolbarBitmap)); IniSectionGetString(pIniSection, L"BitmapHot", L"", - g_tchToolbarBitmapHot, COUNTOF(g_tchToolbarBitmap)); + s_tchToolbarBitmapHot, COUNTOF(s_tchToolbarBitmap)); IniSectionGetString(pIniSection, L"BitmapDisabled", L"", - g_tchToolbarBitmapDisabled, COUNTOF(g_tchToolbarBitmap)); + s_tchToolbarBitmapDisabled, COUNTOF(s_tchToolbarBitmap)); int ResX = GetSystemMetrics(SM_CXSCREEN); int ResY = GetSystemMetrics(SM_CYSCREEN); @@ -7042,7 +6920,38 @@ void LoadSettings() iHighDpiToolBar = ((ResX > 1920) && (ResY > 1080)) ? 1 : 0; } - if (!g_flagPosParam /*|| g_bStickyWinPos*/) { // ignore window position if /p was specified + // -------------------------------------------------------------- + // startup window (ignore window position if /p was specified) + // -------------------------------------------------------------- + + // 1st set default window position + + s_DefWinInfo = _InitDefaultWndPos(2); // std. default position + + if (bExplicitDefaultWinPos) { + int bMaxi = 0; + int const itok = swscanf_s(Settings2.DefaultWindowPosition, L"%i,%i,%i,%i,%i", + &s_DefWinInfo.x, &s_DefWinInfo.y, &s_DefWinInfo.cx, &s_DefWinInfo.cy, &bMaxi); + if (itok == 4 || itok == 5) { // scan successful + if (s_DefWinInfo.cx < 1) s_DefWinInfo.cx = CW_USEDEFAULT; + if (s_DefWinInfo.cy < 1) s_DefWinInfo.cy = CW_USEDEFAULT; + if (bMaxi) s_DefWinInfo.max = true; + if (itok == 4) s_DefWinInfo.max = false; + _InitWindowPosition(&s_DefWinInfo, 0); + } + else { + // overwrite bad defined default position + StringCchPrintf(Settings2.DefaultWindowPosition, COUNTOF(Settings2.DefaultWindowPosition), + L"%i,%i,%i,%i,%i", s_DefWinInfo.x, s_DefWinInfo.y, s_DefWinInfo.cx, s_DefWinInfo.cy, s_DefWinInfo.max); + IniSetString(L"Settings2", L"DefaultWindowPosition", Settings2.DefaultWindowPosition); + } + } + + // 2nd set initial window position + + s_WinInfo = s_DefWinInfo; + + if (!s_flagPosParam /*|| g_bStickyWinPos*/) { WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32], tchZoom[32]; @@ -7053,35 +6962,35 @@ void LoadSettings() StringCchPrintf(tchMaximized, COUNTOF(tchMaximized), L"%ix%i Maximized", ResX, ResY); StringCchPrintf(tchZoom, COUNTOF(tchZoom), L"%ix%i Zoom", ResX, ResY); - g_WinInfo.x = IniSectionGetInt(pIniSection, tchPosX, CW_USEDEFAULT); - g_WinInfo.y = IniSectionGetInt(pIniSection, tchPosY, CW_USEDEFAULT); - g_WinInfo.cx = IniSectionGetInt(pIniSection, tchSizeX, CW_USEDEFAULT); - g_WinInfo.cy = IniSectionGetInt(pIniSection, tchSizeY, CW_USEDEFAULT); - g_WinInfo.max = IniSectionGetBool(pIniSection, tchMaximized, false); - g_WinInfo.max = clampi(g_WinInfo.max, 0, 1); - g_WinInfo.zoom = IniSectionGetInt(pIniSection, tchZoom, (g_iSettingsVersion < CFG_VER_0001) ? 0 : 100); - if (g_iSettingsVersion < CFG_VER_0001) { g_WinInfo.zoom = (g_WinInfo.zoom + 10) * 10; } - g_WinInfo.zoom = clampi(g_WinInfo.zoom, SC_MIN_ZOOM_LEVEL, SC_MAX_ZOOM_LEVEL); - - if ((g_WinInfo.x == CW_USEDEFAULT) || (g_WinInfo.y == CW_USEDEFAULT) || - (g_WinInfo.cx == CW_USEDEFAULT) || (g_WinInfo.cy == CW_USEDEFAULT)) + s_WinInfo.x = IniSectionGetInt(pIniSection, tchPosX, CW_USEDEFAULT); + s_WinInfo.y = IniSectionGetInt(pIniSection, tchPosY, CW_USEDEFAULT); + s_WinInfo.cx = IniSectionGetInt(pIniSection, tchSizeX, CW_USEDEFAULT); + s_WinInfo.cy = IniSectionGetInt(pIniSection, tchSizeY, CW_USEDEFAULT); + s_WinInfo.max = IniSectionGetBool(pIniSection, tchMaximized, false); + s_WinInfo.max = clampi(s_WinInfo.max, 0, 1); + s_WinInfo.zoom = IniSectionGetInt(pIniSection, tchZoom, (s_iSettingsVersion < CFG_VER_0001) ? 0 : 100); + if (s_iSettingsVersion < CFG_VER_0001) { s_WinInfo.zoom = (s_WinInfo.zoom + 10) * 10; } + s_WinInfo.zoom = clampi(s_WinInfo.zoom, SC_MIN_ZOOM_LEVEL, SC_MAX_ZOOM_LEVEL); + + if ((s_WinInfo.x == CW_USEDEFAULT) || (s_WinInfo.y == CW_USEDEFAULT) || + (s_WinInfo.cx == CW_USEDEFAULT) || (s_WinInfo.cy == CW_USEDEFAULT)) { - g_flagWindowPos = 2; // std. default position (CmdLn: /pd) + s_flagWindowPos = 2; // std. default position (CmdLn: /pd) } else - g_flagWindowPos = 0; // init to g_WinInfo + s_flagWindowPos = 0; // init to g_WinInfo } + // ------------------------------------------------------------------------ + // --- override by resolution specific settings --- WCHAR tchSciDirectWriteTech[64]; StringCchPrintf(tchSciDirectWriteTech, COUNTOF(tchSciDirectWriteTech), L"%ix%i RenderingTechnology", ResX, ResY); - g_iRenderingTechnology = IniSectionGetInt(pIniSection, tchSciDirectWriteTech, g_iRenderingTechnology); - g_iRenderingTechnology = clampi(g_iRenderingTechnology, 0, 3); + Settings.RenderingTechnology = clampi(IniSectionGetInt(pIniSection, tchSciDirectWriteTech, Settings.RenderingTechnology), 0, 3); WCHAR tchSciFontQuality[64]; StringCchPrintf(tchSciFontQuality, COUNTOF(tchSciFontQuality), L"%ix%i SciFontQuality", ResX, ResY); - g_iSciFontQuality = IniSectionGetInt(pIniSection, tchSciFontQuality, g_iSciFontQuality); - g_iSciFontQuality = clampi(g_iSciFontQuality, 0, 3); + Settings2.SciFontQuality = clampi(IniSectionGetInt(pIniSection, tchSciFontQuality, Settings2.SciFontQuality), 0, 3); FreeMem(pIniSection); } @@ -7091,19 +7000,19 @@ void LoadSettings() // remove internal support for Chinese, Japan, Korean DBCS use UTF-8 instead /* - if (g_iDefaultNewFileEncoding == CPI_ANSI_DEFAULT) + if (Settings.DefaultEncoding == CPI_ANSI_DEFAULT) { // check for Chinese, Japan, Korean DBCS code pages and switch accordingly int acp = (int)GetACP(); if (acp == 932 || acp == 936 || acp == 949 || acp == 950) { iSciDefaultCodePage = acp; } - g_iDefaultNewFileEncoding = Encoding_GetByCodePage(iSciDefaultCodePage); + Settings.DefaultEncoding = Encoding_GetByCodePage(iSciDefaultCodePage); } */ // set flag for encoding default - Encoding_SetDefaultFlag(g_iDefaultNewFileEncoding); + Encoding_SetDefaultFlag(Settings.DefaultEncoding); // define default charset g_iDefaultCharSet = (int)CharSetFromCodePage((UINT)iSciDefaultCodePage); @@ -7118,18 +7027,27 @@ void LoadSettings() // // SaveSettings() // + +#define SAVE_VALUE_IF_NOT_EQ_DEFAULT(TYPE,VARNAME) \ + if (Settings.##VARNAME != Defaults.##VARNAME) { \ + IniSectionSet##TYPE(pIniSection, STRGW(VARNAME), Settings.##VARNAME); \ + } + +// ---------------------------------------------------------------------------- + + void SaveSettings(bool bSaveSettingsNow) { WCHAR wchTmp[MAX_PATH] = { L'\0' }; - if (StringCchLenW(g_wchIniFile, COUNTOF(g_wchIniFile)) == 0) { return; } + if (StringCchLenW(Globals.IniFile, COUNTOF(Globals.IniFile)) == 0) { return; } - if (!g_bEnableSaveSettings) { return; } + if (!s_bEnableSaveSettings) { return; } CreateIniFile(); - if (!g_bSaveSettings && !bSaveSettingsNow) { - IniSetBool(L"Settings", L"SaveSettings", g_bSaveSettings); + if (!s_bSaveSettings && !bSaveSettingsNow) { + IniSetBool(L"Settings", L"SaveSettings", s_bSaveSettings); return; } @@ -7142,105 +7060,158 @@ void SaveSettings(bool bSaveSettingsNow) if (pIniSection) { IniSectionSetInt(pIniSection, L"SettingsVersion", CFG_VER_CURRENT); - IniSectionSetBool(pIniSection, L"SaveSettings", g_bSaveSettings); - IniSectionSetBool(pIniSection, L"SaveRecentFiles", g_bSaveRecentFiles); - IniSectionSetBool(pIniSection, L"PreserveCaretPos", g_bPreserveCaretPos); - IniSectionSetBool(pIniSection, L"SaveFindReplace", g_bSaveFindReplace); - IniSectionSetBool(pIniSection, L"CloseFind", g_efrData.bFindClose); - IniSectionSetBool(pIniSection, L"CloseReplace", g_efrData.bReplaceClose); - IniSectionSetBool(pIniSection, L"NoFindWrap", g_efrData.bNoFindWrap); - IniSectionSetBool(pIniSection, L"FindTransformBS", g_efrData.bTransformBS); - IniSectionSetBool(pIniSection, L"WildcardSearch", g_efrData.bWildcardSearch); - IniSectionSetBool(pIniSection, L"FindMarkAllOccurrences", g_efrData.bMarkOccurences); - IniSectionSetBool(pIniSection, L"HideNonMatchedLines", g_efrData.bHideNonMatchedLines); - IniSectionSetBool(pIniSection, L"RegexDotMatchesAll", g_efrData.bDotMatchAll); - IniSectionSetInt(pIniSection, L"efrData_fuFlags", g_efrData.fuFlags); - PathRelativeToApp(g_tchOpenWithDir, wchTmp, COUNTOF(wchTmp), false, true, g_flagPortableMyDocs); - IniSectionSetString(pIniSection, L"OpenWithDir", wchTmp); - PathRelativeToApp(g_tchFavoritesDir, wchTmp, COUNTOF(wchTmp), false, true, g_flagPortableMyDocs); - IniSectionSetString(pIniSection, L"Favorites", wchTmp); - IniSectionSetInt(pIniSection, L"PathNameFormat", iPathNameFormat); - IniSectionSetBool(pIniSection, L"WordWrap", bWordWrapG); - IniSectionSetInt(pIniSection, L"WordWrapMode", iWordWrapMode); - IniSectionSetInt(pIniSection, L"WordWrapIndent", iWordWrapIndent); - IniSectionSetInt(pIniSection, L"WordWrapSymbols", iWordWrapSymbols); - IniSectionSetBool(pIniSection, L"ShowWordWrapSymbols", bShowWordWrapSymbols); - IniSectionSetBool(pIniSection, L"MatchBraces", bMatchBraces); - IniSectionSetBool(pIniSection, L"AutoCloseTags", bAutoCloseTags); - IniSectionSetBool(pIniSection, L"HighlightCurrentLine", bHiliteCurrentLine); - IniSectionSetBool(pIniSection, L"HyperlinkHotspot", g_bHyperlinkHotspot); - IniSectionSetBool(pIniSection, L"ScrollPastEOF", bScrollPastEOF); - IniSectionSetBool(pIniSection, L"AutoIndent", bAutoIndent); - IniSectionSetBool(pIniSection, L"AutoCompleteWords", g_bAutoCompleteWords); - IniSectionSetBool(pIniSection, L"AutoCLexerKeyWords", g_bAutoCLexerKeyWords); - IniSectionSetBool(pIniSection, L"AccelWordNavigation", g_bAccelWordNavigation); - IniSectionSetBool(pIniSection, L"ShowIndentGuides", bShowIndentGuides); - IniSectionSetBool(pIniSection, L"TabsAsSpaces", bTabsAsSpacesG); - IniSectionSetBool(pIniSection, L"TabIndents", bTabIndentsG); - IniSectionSetBool(pIniSection, L"BackspaceUnindents", bBackspaceUnindents); - IniSectionSetInt(pIniSection, L"TabWidth", iTabWidthG); - IniSectionSetInt(pIniSection, L"IndentWidth", iIndentWidthG); - IniSectionSetBool(pIniSection, L"MarkLongLines", g_bMarkLongLines); - IniSectionSetPos(pIniSection, L"LongLinesLimit", iLongLinesLimitG); - IniSectionSetInt(pIniSection, L"LongLineMode", iLongLineMode); - IniSectionSetBool(pIniSection, L"ShowSelectionMargin", g_bShowSelectionMargin); - IniSectionSetBool(pIniSection, L"ShowLineNumbers", g_bShowLineNumbers); - IniSectionSetBool(pIniSection, L"ShowCodeFolding", g_bShowCodeFolding); - IniSectionSetInt(pIniSection, L"MarkOccurrences", g_iMarkOccurrences); - IniSectionSetBool(pIniSection, L"MarkOccurrencesMatchVisible", g_bMarkOccurrencesMatchVisible); - IniSectionSetBool(pIniSection, L"MarkOccurrencesMatchCase", g_bMarkOccurrencesMatchCase); - IniSectionSetBool(pIniSection, L"MarkOccurrencesMatchWholeWords", g_bMarkOccurrencesMatchWords); - IniSectionSetBool(pIniSection, L"MarkOccurrencesCurrentWord", g_bMarkOccurrencesCurrentWord); - IniSectionSetBool(pIniSection, L"ViewWhiteSpace", bViewWhiteSpace); - IniSectionSetBool(pIniSection, L"ViewEOLs", bViewEOLs); - IniSectionSetInt(pIniSection, L"DefaultEncoding", Encoding_MapIniSetting(false, g_iDefaultNewFileEncoding)); - IniSectionSetBool(pIniSection, L"UseDefaultForFileEncoding", bUseDefaultForFileEncoding); - IniSectionSetBool(pIniSection, L"SkipUnicodeDetection", bSkipUnicodeDetection); - IniSectionSetBool(pIniSection, L"SkipANSICodePageDetection", bSkipANSICodePageDetection); - IniSectionSetInt(pIniSection, L"LoadASCIIasUTF8", g_bLoadASCIIasUTF8); - IniSectionSetBool(pIniSection, L"LoadNFOasOEM", g_bLoadNFOasOEM); - IniSectionSetBool(pIniSection, L"NoEncodingTags", g_bNoEncodingTags); - IniSectionSetInt(pIniSection, L"DefaultEOLMode", g_iDefaultEOLMode); - IniSectionSetBool(pIniSection, L"FixLineEndings", bFixLineEndings); - IniSectionSetBool(pIniSection, L"FixTrailingBlanks", bAutoStripBlanks); - IniSectionSetInt(pIniSection, L"PrintHeader", iPrintHeader); - IniSectionSetInt(pIniSection, L"PrintFooter", iPrintFooter); - IniSectionSetInt(pIniSection, L"PrintColorMode", iPrintColor); - IniSectionSetInt(pIniSection, L"PrintZoom", iPrintZoom); - IniSectionSetInt(pIniSection, L"PrintMarginLeft", pagesetupMargin.left); - IniSectionSetInt(pIniSection, L"PrintMarginTop", pagesetupMargin.top); - IniSectionSetInt(pIniSection, L"PrintMarginRight", pagesetupMargin.right); - IniSectionSetInt(pIniSection, L"PrintMarginBottom", pagesetupMargin.bottom); - IniSectionSetBool(pIniSection, L"SaveBeforeRunningTools", bSaveBeforeRunningTools); - IniSectionSetInt(pIniSection, L"FileWatchingMode", g_iFileWatchingMode); - IniSectionSetBool(pIniSection, L"ResetFileWatching", g_bResetFileWatching); - IniSectionSetInt(pIniSection, L"EscFunction", iEscFunction); - IniSectionSetBool(pIniSection, L"AlwaysOnTop", bAlwaysOnTop); - IniSectionSetBool(pIniSection, L"MinimizeToTray", bMinimizeToTray); - IniSectionSetBool(pIniSection, L"TransparentMode", g_bTransparentMode); - IniSectionSetInt(pIniSection, L"RenderingTechnology", g_iRenderingTechnology); - IniSectionSetInt(pIniSection, L"Bidirectional", g_iBidirectional); - ///~IniSectionSetInt(pIniSection, L"IMEInteraction", g_IMEInteraction); - IniSectionSetBool(pIniSection, L"ShowToolbar", bShowToolbar); - IniSectionSetBool(pIniSection, L"ShowStatusbar", bShowStatusbar); - IniSectionSetInt(pIniSection, L"EncodingDlgSizeX", cxEncodingDlg); - IniSectionSetInt(pIniSection, L"EncodingDlgSizeY", cyEncodingDlg); - IniSectionSetInt(pIniSection, L"RecodeDlgSizeX", cxRecodeDlg); - IniSectionSetInt(pIniSection, L"RecodeDlgSizeY", cyRecodeDlg); - IniSectionSetInt(pIniSection, L"FileMRUDlgSizeX", cxFileMRUDlg); - IniSectionSetInt(pIniSection, L"FileMRUDlgSizeY", cyFileMRUDlg); - IniSectionSetInt(pIniSection, L"OpenWithDlgSizeX", cxOpenWithDlg); - IniSectionSetInt(pIniSection, L"OpenWithDlgSizeY", cyOpenWithDlg); - IniSectionSetInt(pIniSection, L"FavoritesDlgSizeX", cxFavoritesDlg); - IniSectionSetInt(pIniSection, L"FavoritesDlgSizeY", cyFavoritesDlg); - IniSectionSetInt(pIniSection, L"FindReplaceDlgPosX", xFindReplaceDlg); - IniSectionSetInt(pIniSection, L"FindReplaceDlgPosY", yFindReplaceDlg); - IniSectionSetInt(pIniSection, L"CustomSchemesDlgPosX", xCustomSchemesDlg); - IniSectionSetInt(pIniSection, L"CustomSchemesDlgPosY", yCustomSchemesDlg); - - Toolbar_GetButtons(g_hwndToolbar, IDT_FILE_NEW, g_tchToolbarButtons, COUNTOF(g_tchToolbarButtons)); - if (StringCchCompareX(g_tchToolbarButtons, TBBUTTON_DEFAULT_IDS) == 0) { g_tchToolbarButtons[0] = L'\0'; } - IniSectionSetString(pIniSection, L"ToolbarButtons", g_tchToolbarButtons); + IniSectionSetBool(pIniSection, L"SaveSettings", s_bSaveSettings); + + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, SaveRecentFiles); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, PreserveCaretPos); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, SaveFindReplace); + + if (Settings.EFR_Data.bFindClose != Defaults.EFR_Data.bFindClose) { + IniSectionSetBool(pIniSection, L"CloseFind", Settings.EFR_Data.bFindClose); + } + if (Settings.EFR_Data.bReplaceClose != Defaults.EFR_Data.bReplaceClose) { + IniSectionSetBool(pIniSection, L"CloseReplace", Settings.EFR_Data.bReplaceClose); + } + if (Settings.EFR_Data.bNoFindWrap != Defaults.EFR_Data.bNoFindWrap) { + IniSectionSetBool(pIniSection, L"NoFindWrap", Settings.EFR_Data.bNoFindWrap); + } + if (Settings.EFR_Data.bTransformBS != Defaults.EFR_Data.bTransformBS) { + IniSectionSetBool(pIniSection, L"FindTransformBS", Settings.EFR_Data.bTransformBS); + } + if (Settings.EFR_Data.bWildcardSearch != Defaults.EFR_Data.bWildcardSearch) { + IniSectionSetBool(pIniSection, L"WildcardSearch", Settings.EFR_Data.bWildcardSearch); + } + if (Settings.EFR_Data.bMarkOccurences != Defaults.EFR_Data.bMarkOccurences) { + IniSectionSetBool(pIniSection, L"FindMarkAllOccurrences", Settings.EFR_Data.bMarkOccurences); + } + if (Settings.EFR_Data.bHideNonMatchedLines != Defaults.EFR_Data.bHideNonMatchedLines) { + IniSectionSetBool(pIniSection, L"HideNonMatchedLines", Settings.EFR_Data.bHideNonMatchedLines); + } + if (Settings.EFR_Data.bDotMatchAll != Defaults.EFR_Data.bDotMatchAll) { + IniSectionSetBool(pIniSection, L"RegexDotMatchesAll", Settings.EFR_Data.bDotMatchAll); + } + if (Settings.EFR_Data.fuFlags != Defaults.EFR_Data.fuFlags) { + IniSectionSetInt(pIniSection, L"efrData_fuFlags", Settings.EFR_Data.fuFlags); + } + if (StringCchCompareXIW(Settings.OpenWithDir, Defaults.OpenWithDir) != 0) { + PathRelativeToApp(Settings.OpenWithDir, wchTmp, COUNTOF(wchTmp), false, true, Flags.PortableMyDocs); + IniSectionSetString(pIniSection, L"OpenWithDir", wchTmp); + } + if (StringCchCompareXIW(Settings.FavoritesDir, Defaults.FavoritesDir) != 0) { + PathRelativeToApp(Settings.FavoritesDir, wchTmp, COUNTOF(wchTmp), false, true, Flags.PortableMyDocs); + IniSectionSetString(pIniSection, L"Favorites", wchTmp); + } + + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, PathNameFormat); + + if (g_bWordWrapG != Defaults.WordWrap) { + IniSectionSetBool(pIniSection, L"WordWrap", g_bWordWrapG); + } + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, WordWrapMode); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, WordWrapIndent); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, WordWrapSymbols); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ShowWordWrapSymbols); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, MatchBraces); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, AutoCloseTags); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, HighlightCurrentLine); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, HyperlinkHotspot); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ScrollPastEOF); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, AutoIndent); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, AutoCompleteWords); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, AutoCLexerKeyWords); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, AccelWordNavigation); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ShowIndentGuides); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, TabsAsSpaces); + + if (g_bTabIndentsG != Defaults.TabIndents) { + IniSectionSetBool(pIniSection, L"", g_bTabIndentsG); + } + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, BackspaceUnindents); + + if (g_iTabWidthG != Defaults.TabWidth) { + IniSectionSetInt(pIniSection, L"TabWidth", g_iTabWidthG); + } + if (g_iIndentWidthG != Defaults.TabWidth) { + IniSectionSetInt(pIniSection, L"IndentWidth", g_iIndentWidthG); + } + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, MarkLongLines); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, LongLinesLimit); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, LongLineMode); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ShowSelectionMargin); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ShowLineNumbers); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ShowCodeFolding); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, MarkOccurrences); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, MarkOccurrencesMatchVisible); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, MarkOccurrencesMatchCase); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, MarkOccurrencesMatchWholeWords); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, MarkOccurrencesCurrentWord); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ViewWhiteSpace); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ViewEOLs); + + if (Settings.DefaultEncoding != Defaults.DefaultEncoding) { + IniSectionSetInt(pIniSection, L"DefaultEncoding", Encoding_MapIniSetting(false, Settings.DefaultEncoding)); + } + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, UseDefaultForFileEncoding); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, SkipUnicodeDetection); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, SkipANSICodePageDetection); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, LoadASCIIasUTF8); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, LoadNFOasOEM); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, NoEncodingTags); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, DefaultEOLMode); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, FixLineEndings); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, FixTrailingBlanks); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, PrintHeader); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, PrintFooter); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, PrintColorMode); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, PrintZoom); + + if (Settings.PrintMargin.left != Defaults.PrintMargin.left) { + IniSectionSetInt(pIniSection, L"PrintMarginLeft", Settings.PrintMargin.left); + } + if (Settings.PrintMargin.top != Defaults.PrintMargin.top) { + IniSectionSetInt(pIniSection, L"PrintMarginTop", Settings.PrintMargin.top); + } + if (Settings.PrintMargin.right != Defaults.PrintMargin.right) { + IniSectionSetInt(pIniSection, L"PrintMarginRight", Settings.PrintMargin.right); + } + if (Settings.PrintMargin.bottom != Defaults.PrintMargin.bottom) { + IniSectionSetInt(pIniSection, L"PrintMarginBottom", Settings.PrintMargin.bottom); + } + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, SaveBeforeRunningTools); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, FileWatchingMode); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ResetFileWatching); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, EscFunction); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, AlwaysOnTop); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, MinimizeToTray); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, TransparentMode); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, RenderingTechnology); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, Bidirectional); + ///~IniSectionSetInt(pIniSection, L"IMEInteraction", Settings2.IMEInteraction); + + Toolbar_GetButtons(s_hwndToolbar, IDT_FILE_NEW, Settings.ToolbarButtons, COUNTOF(Settings.ToolbarButtons)); + if (StringCchCompareX(Settings.ToolbarButtons, Defaults.ToolbarButtons) == 0) { + IniSectionSetString(pIniSection, L"ToolbarButtons", NULL); + } else { + IniSectionSetString(pIniSection, L"ToolbarButtons", Settings.ToolbarButtons); + } + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ShowToolbar); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ShowStatusbar); + + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, EncodingDlgSizeX); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, EncodingDlgSizeY); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, RecodeDlgSizeX); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, RecodeDlgSizeY); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, FileMRUDlgSizeX); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, FileMRUDlgSizeY); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, OpenWithDlgSizeX); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, OpenWithDlgSizeY); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, FavoritesDlgSizeX); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, FavoritesDlgSizeY); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, FindReplaceDlgPosX); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, FindReplaceDlgPosY); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, CustomSchemesDlgPosX); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, CustomSchemesDlgPosY); + SaveIniSection(L"Settings", pIniSection); @@ -7250,13 +7221,9 @@ void SaveSettings(bool bSaveSettingsNow) // Scintilla Styles Style_Save(); - /* - SaveSettingsNow(): query Window Dimensions - */ - + // update window placement if (bSaveSettingsNow) { - // GetWindowPlacement - g_WinInfo = GetMyWindowPlacement(g_hwndMain,NULL); + s_WinInfo = GetMyWindowPlacement(Globals.hwndMain, NULL); } int ResX = GetSystemMetrics(SM_CXSCREEN); @@ -7266,7 +7233,7 @@ void SaveSettings(bool bSaveSettingsNow) StringCchPrintf(tchHighDpiToolBar,COUNTOF(tchHighDpiToolBar),L"%ix%i HighDpiToolBar", ResX, ResY); IniSetInt(L"Window", tchHighDpiToolBar, iHighDpiToolBar); - if (!IniGetInt(L"Settings2",L"StickyWindowPosition",0)) { + if (Flags.StickyWindowPosition == 0) { WCHAR tchPosX[32], tchPosY[32], tchSizeX[32], tchSizeY[32], tchMaximized[32], tchZoom[32]; @@ -7277,12 +7244,12 @@ void SaveSettings(bool bSaveSettingsNow) StringCchPrintf(tchMaximized,COUNTOF(tchMaximized),L"%ix%i Maximized",ResX,ResY); StringCchPrintf(tchZoom, COUNTOF(tchMaximized), L"%ix%i Zoom", ResX, ResY); - IniSetInt(L"Window",tchPosX,g_WinInfo.x); - IniSetInt(L"Window",tchPosY,g_WinInfo.y); - IniSetInt(L"Window",tchSizeX,g_WinInfo.cx); - IniSetInt(L"Window",tchSizeY,g_WinInfo.cy); - IniSetBool(L"Window",tchMaximized,g_WinInfo.max); - IniSetInt(L"Window",tchZoom, g_WinInfo.zoom); + IniSetInt(L"Window",tchPosX,s_WinInfo.x); + IniSetInt(L"Window",tchPosY,s_WinInfo.y); + IniSetInt(L"Window",tchSizeX,s_WinInfo.cx); + IniSetInt(L"Window",tchSizeY,s_WinInfo.cy); + IniSetBool(L"Window",tchMaximized,s_WinInfo.max); + IniSetInt(L"Window",tchZoom, s_WinInfo.zoom); } EndWaitCursor(); @@ -7321,12 +7288,12 @@ void ParseCommandLine() // options if (lp1[1] == L'\0') { if (!bIsFileArg && (lp1[0] == L'+')) { - g_flagMultiFileArg = 2; + Flags.MultiFileArg = 2; bIsFileArg = true; } else if (!bIsFileArg && (lp1[0] == L'-')) { - g_flagMultiFileArg = 1; + Flags.MultiFileArg = 1; bIsFileArg = true; } } @@ -7337,33 +7304,33 @@ void ParseCommandLine() // Encoding if (StringCchCompareXI(lp1, L"ANSI") == 0 || StringCchCompareXI(lp1, L"A") == 0 || StringCchCompareXI(lp1, L"MBCS") == 0) - g_flagSetEncoding = IDM_ENCODING_ANSI - IDM_ENCODING_ANSI + 1; + s_flagSetEncoding = IDM_ENCODING_ANSI - IDM_ENCODING_ANSI + 1; else if (StringCchCompareXI(lp1, L"UNICODE") == 0 || StringCchCompareXI(lp1, L"W") == 0) - g_flagSetEncoding = IDM_ENCODING_UNICODE - IDM_ENCODING_ANSI + 1; + s_flagSetEncoding = IDM_ENCODING_UNICODE - IDM_ENCODING_ANSI + 1; else if (StringCchCompareXI(lp1, L"UNICODEBE") == 0 || StringCchCompareXI(lp1, L"UNICODE-BE") == 0) - g_flagSetEncoding = IDM_ENCODING_UNICODEREV - IDM_ENCODING_ANSI + 1; + s_flagSetEncoding = IDM_ENCODING_UNICODEREV - IDM_ENCODING_ANSI + 1; else if (StringCchCompareXI(lp1, L"UTF8") == 0 || StringCchCompareXI(lp1, L"UTF-8") == 0) - g_flagSetEncoding = IDM_ENCODING_UTF8 - IDM_ENCODING_ANSI + 1; + s_flagSetEncoding = IDM_ENCODING_UTF8 - IDM_ENCODING_ANSI + 1; else if (StringCchCompareXI(lp1, L"UTF8SIG") == 0 || StringCchCompareXI(lp1, L"UTF-8SIG") == 0 || StringCchCompareXI(lp1, L"UTF8SIGNATURE") == 0 || StringCchCompareXI(lp1, L"UTF-8SIGNATURE") == 0 || StringCchCompareXI(lp1, L"UTF8-SIGNATURE") == 0 || StringCchCompareXI(lp1, L"UTF-8-SIGNATURE") == 0) - g_flagSetEncoding = IDM_ENCODING_UTF8SIGN - IDM_ENCODING_ANSI + 1; + s_flagSetEncoding = IDM_ENCODING_UTF8SIGN - IDM_ENCODING_ANSI + 1; // EOL Mode else if (StringCchCompareXI(lp1, L"CRLF") == 0 || StringCchCompareXI(lp1, L"CR+LF") == 0) - g_flagSetEOLMode = IDM_LINEENDINGS_CRLF - IDM_LINEENDINGS_CRLF + 1; + s_flagSetEOLMode = IDM_LINEENDINGS_CRLF - IDM_LINEENDINGS_CRLF + 1; else if (StringCchCompareXI(lp1, L"LF") == 0) - g_flagSetEOLMode = IDM_LINEENDINGS_LF - IDM_LINEENDINGS_CRLF + 1; + s_flagSetEOLMode = IDM_LINEENDINGS_LF - IDM_LINEENDINGS_CRLF + 1; else if (StringCchCompareXI(lp1, L"CR") == 0) - g_flagSetEOLMode = IDM_LINEENDINGS_CR - IDM_LINEENDINGS_CRLF + 1; + s_flagSetEOLMode = IDM_LINEENDINGS_CR - IDM_LINEENDINGS_CRLF + 1; // Shell integration else if (StrCmpNI(lp1, L"appid=", CSTRLEN(L"appid=")) == 0) { - StringCchCopyN(g_wchAppUserModelID, COUNTOF(g_wchAppUserModelID), + StringCchCopyN(Settings2.AppUserModelID, COUNTOF(Settings2.AppUserModelID), lp1 + CSTRLEN(L"appid="), len - CSTRLEN(L"appid=")); - StrTrim(g_wchAppUserModelID, L" "); - if (StringCchLenW(g_wchAppUserModelID, COUNTOF(g_wchAppUserModelID)) == 0) - StringCchCopy(g_wchAppUserModelID, COUNTOF(g_wchAppUserModelID), L"" APPNAME); + StrTrim(Settings2.AppUserModelID, L" "); + if (StringCchLenW(Settings2.AppUserModelID, COUNTOF(Settings2.AppUserModelID)) == 0) + StringCchCopy(Settings2.AppUserModelID, COUNTOF(Settings2.AppUserModelID), MKWCS(APPNAME)); } else if (StrCmpNI(lp1, L"sysmru=", CSTRLEN(L"sysmru=")) == 0) { @@ -7371,61 +7338,61 @@ void ParseCommandLine() StringCchCopyN(wch, COUNTOF(wch), lp1 + CSTRLEN(L"sysmru="), COUNTOF(wch)); StrTrim(wch, L" "); if (*wch == L'1') - g_flagUseSystemMRU = 2; + Flags.ShellUseSystemMRU = 2; else - g_flagUseSystemMRU = 1; + Flags.ShellUseSystemMRU = 1; } // Relaunch elevated else if (StrCmpNI(lp1, L"tmpfbuf=", CSTRLEN(L"tmpfbuf=")) == 0) { - StringCchCopyN(g_szTmpFilePath, COUNTOF(g_szTmpFilePath), + StringCchCopyN(s_wchTmpFilePath, COUNTOF(s_wchTmpFilePath), lp1 + CSTRLEN(L"tmpfbuf="), len - CSTRLEN(L"tmpfbuf=")); - TrimStringW(g_szTmpFilePath); - PathUnquoteSpaces(g_szTmpFilePath); - NormalizePathEx(g_szTmpFilePath, COUNTOF(g_szTmpFilePath)); - g_flagBufferFile = 1; + TrimStringW(s_wchTmpFilePath); + PathUnquoteSpaces(s_wchTmpFilePath); + NormalizePathEx(s_wchTmpFilePath, COUNTOF(s_wchTmpFilePath)); + s_flagBufferFile = 1; } else switch (*CharUpper(lp1)) { case L'N': - g_flagReuseWindow = 0; - g_flagNoReuseWindow = 1; + Flags.ReuseWindow = 0; + Flags.NoReuseWindow = 1; if (*CharUpper(lp1 + 1) == L'S') - g_flagSingleFileInstance = 1; + Flags.SingleFileInstance = 1; else - g_flagSingleFileInstance = 0; + Flags.SingleFileInstance = 0; break; case L'R': - g_flagReuseWindow = 1; - g_flagNoReuseWindow = 0; + Flags.ReuseWindow = 1; + Flags.NoReuseWindow = 0; if (*CharUpper(lp1 + 1) == L'S') - g_flagSingleFileInstance = 1; + Flags.SingleFileInstance = 1; else - g_flagSingleFileInstance = 0; + Flags.SingleFileInstance = 0; break; case L'F': if (*(lp1 + 1) == L'0' || *CharUpper(lp1 + 1) == L'O') - StringCchCopy(g_wchIniFile, COUNTOF(g_wchIniFile), L"*?"); + StringCchCopy(Globals.IniFile, COUNTOF(Globals.IniFile), L"*?"); else if (ExtractFirstArgument(lp2, lp1, lp2, (int)len)) { - StringCchCopyN(g_wchIniFile, COUNTOF(g_wchIniFile), lp1, len); - TrimStringW(g_wchIniFile); - PathUnquoteSpaces(g_wchIniFile); - NormalizePathEx(g_wchIniFile, COUNTOF(g_wchIniFile)); + StringCchCopyN(Globals.IniFile, COUNTOF(Globals.IniFile), lp1, len); + TrimStringW(Globals.IniFile); + PathUnquoteSpaces(Globals.IniFile); + NormalizePathEx(Globals.IniFile, COUNTOF(Globals.IniFile)); } break; case L'I': - g_flagStartAsTrayIcon = 1; + s_flagStartAsTrayIcon = 1; break; case L'O': if (*(lp1 + 1) == L'0' || *(lp1 + 1) == L'-' || *CharUpper(lp1 + 1) == L'O') - g_flagAlwaysOnTop = 1; + s_flagAlwaysOnTop = 1; else - g_flagAlwaysOnTop = 2; + s_flagAlwaysOnTop = 2; break; case L'P': @@ -7443,58 +7410,60 @@ void ParseCommandLine() break; } if (*(lp + 1) == L'0' || *CharUpper(lp + 1) == L'O') { - g_flagPosParam = 1; - g_flagWindowPos = 1; + s_flagPosParam = 1; + s_flagWindowPos = 1; } else if (*CharUpper(lp + 1) == L'D' || *CharUpper(lp + 1) == L'S') { - g_flagPosParam = 1; - g_flagWindowPos = (StrChrI((lp + 1), L'L')) ? 3 : 2; + s_flagPosParam = 1; + s_flagWindowPos = (StrChrI((lp + 1), L'L')) ? 3 : 2; } else if (StrChrI(L"FLTRBM", *(lp + 1))) { WCHAR *p = (lp + 1); - g_flagPosParam = 1; - g_flagWindowPos = 0; + s_flagPosParam = 1; + s_flagWindowPos = 0; while (*p) { switch (*CharUpper(p)) { case L'F': - g_flagWindowPos &= ~(4 | 8 | 16 | 32); - g_flagWindowPos |= 64; + s_flagWindowPos &= ~(4 | 8 | 16 | 32); + s_flagWindowPos |= 64; break; case L'L': - g_flagWindowPos &= ~(8 | 64); - g_flagWindowPos |= 4; + s_flagWindowPos &= ~(8 | 64); + s_flagWindowPos |= 4; break; case L'R': - g_flagWindowPos &= ~(4 | 64); - g_flagWindowPos |= 8; + s_flagWindowPos &= ~(4 | 64); + s_flagWindowPos |= 8; break; case L'T': - g_flagWindowPos &= ~(32 | 64); - g_flagWindowPos |= 16; + s_flagWindowPos &= ~(32 | 64); + s_flagWindowPos |= 16; break; case L'B': - g_flagWindowPos &= ~(16 | 64); - g_flagWindowPos |= 32; + s_flagWindowPos &= ~(16 | 64); + s_flagWindowPos |= 32; break; case L'M': - if (g_flagWindowPos == 0) - g_flagWindowPos |= 64; - g_flagWindowPos |= 128; + if (s_flagWindowPos == 0) + s_flagWindowPos |= 64; + s_flagWindowPos |= 128; break; } p = CharNext(p); } } else if (ExtractFirstArgument(lp2, lp1, lp2, (int)len)) { + WININFO wi; int bMaximize = 0; - int itok = swscanf_s(lp1, L"%i,%i,%i,%i,%i", &g_WinInfo.x, &g_WinInfo.y, &g_WinInfo.cx, &g_WinInfo.cy, &bMaximize); + int itok = swscanf_s(lp1, L"%i,%i,%i,%i,%i", &wi.x, &wi.y, &wi.cx, &wi.cy, &bMaximize); if (itok == 4 || itok == 5) { // scan successful - g_flagPosParam = 1; - g_flagWindowPos = 0; - if (g_WinInfo.cx < 1) g_WinInfo.cx = CW_USEDEFAULT; - if (g_WinInfo.cy < 1) g_WinInfo.cy = CW_USEDEFAULT; - if (bMaximize) g_WinInfo.max = true; - if (itok == 4) g_WinInfo.max = false; + s_flagPosParam = 1; + s_flagWindowPos = 0; + if (wi.cx < 1) wi.cx = CW_USEDEFAULT; + if (wi.cy < 1) wi.cy = CW_USEDEFAULT; + if (bMaximize) wi.max = true; + if (itok == 4) wi.max = false; + s_WinInfo = wi; // set window placement } } } @@ -7508,11 +7477,11 @@ void ParseCommandLine() break; case L'C': - g_flagNewFromClipboard = 1; + s_flagNewFromClipboard = 1; break; case L'B': - g_flagPasteBoard = 1; + s_flagPasteBoard = 1; break; case L'E': @@ -7528,7 +7497,7 @@ void ParseCommandLine() int itok = swscanf_s(lp1, L"%i,%i", &iInitialLine, &iInitialColumn); if (itok == 1 || itok == 2) { // scan successful - g_flagJumpTo = 1; + s_flagJumpTo = 1; } } break; @@ -7549,19 +7518,19 @@ void ParseCommandLine() if (ExtractFirstArgument(lp2, lp1, lp2, (int)len)) { if (lpMatchArg) { LocalFree(lpMatchArg); } // StrDup() lpMatchArg = StrDup(lp1); - g_flagMatchText = 1; + s_flagMatchText = 1; if (bFindUp) - g_flagMatchText |= 2; + s_flagMatchText |= 2; if (bRegex) { - g_flagMatchText &= ~8; - g_flagMatchText |= 4; + s_flagMatchText &= ~8; + s_flagMatchText |= 4; } if (bTransBS) { - g_flagMatchText &= ~4; - g_flagMatchText |= 8; + s_flagMatchText &= ~4; + s_flagMatchText |= 8; } } } @@ -7569,20 +7538,20 @@ void ParseCommandLine() case L'L': if (*(lp1 + 1) == L'0' || *(lp1 + 1) == L'-' || *CharUpper(lp1 + 1) == L'O') - g_flagChangeNotify = 1; + s_flagChangeNotify = 1; else - g_flagChangeNotify = 2; + s_flagChangeNotify = 2; break; case L'Q': - g_flagQuietCreate = 1; + s_flagQuietCreate = 1; break; case L'S': if (ExtractFirstArgument(lp2, lp1, lp2, (int)len)) { if (lpSchemeArg) { LocalFree(lpSchemeArg); } // StrDup() lpSchemeArg = StrDup(lp1); - g_flagLexerSpecified = 1; + s_flagLexerSpecified = 1; } break; @@ -7592,7 +7561,7 @@ void ParseCommandLine() lpSchemeArg = NULL; } iInitialLexer = 0; - g_flagLexerSpecified = 1; + s_flagLexerSpecified = 1; break; case L'H': @@ -7601,7 +7570,7 @@ void ParseCommandLine() lpSchemeArg = NULL; } iInitialLexer = 35; - g_flagLexerSpecified = 1; + s_flagLexerSpecified = 1; break; case L'X': @@ -7610,27 +7579,27 @@ void ParseCommandLine() lpSchemeArg = NULL; } iInitialLexer = 36; - g_flagLexerSpecified = 1; + s_flagLexerSpecified = 1; break; case L'U': - g_flagRelaunchElevated = 1; + s_flagRelaunchElevated = 1; break; case L'Z': ExtractFirstArgument(lp2, lp1, lp2, (int)len); - g_flagMultiFileArg = 1; + Flags.MultiFileArg = 1; bIsNotepadReplacement = true; break; case L'?': - g_flagDisplayHelp = 1; + s_flagDisplayHelp = 1; break; case L'V': - g_flagPrintFileAndLeave = 1; + Flags.PrintFileAndLeave = 1; if (*CharUpper(lp1 + 1) == L'D') - g_flagPrintFileAndLeave = 2; // open printer dialog + Flags.PrintFileAndLeave = 2; // open printer dialog break; default: @@ -7650,19 +7619,19 @@ void ParseCommandLine() FreeMem(lpFileArg); //lpFileArg = NULL; } - lpFileArg = AllocMem(sizeof(WCHAR)*FILE_ARG_BUF, HEAP_ZERO_MEMORY); // changed for ActivatePrevInst() needs - StringCchCopy(lpFileArg, FILE_ARG_BUF, lp3); + lpFileArg = AllocMem(sizeof(WCHAR)*(MAX_PATH+1), HEAP_ZERO_MEMORY); // changed for ActivatePrevInst() needs + StringCchCopy(lpFileArg, (MAX_PATH+1), lp3); PathFixBackslashes(lpFileArg); if (!PathIsRelative(lpFileArg) && !PathIsUNC(lpFileArg) && - PathGetDriveNumber(lpFileArg) == -1 /*&& PathGetDriveNumber(g_wchWorkingDirectory) != -1*/) { + PathGetDriveNumber(lpFileArg) == -1 /*&& PathGetDriveNumber(Globals.WorkingDirectory) != -1*/) { - WCHAR wchPath[FILE_ARG_BUF] = { L'\0' }; - StringCchCopy(wchPath, COUNTOF(wchPath), g_wchWorkingDirectory); + WCHAR wchPath[(MAX_PATH+1)] = { L'\0' }; + StringCchCopy(wchPath, COUNTOF(wchPath), Globals.WorkingDirectory); PathStripToRoot(wchPath); PathCchAppend(wchPath, COUNTOF(wchPath), lpFileArg); - StringCchCopy(lpFileArg, FILE_ARG_BUF, wchPath); + StringCchCopy(lpFileArg, (MAX_PATH+1), wchPath); } StrTrim(lpFileArg, L" \""); @@ -7695,6 +7664,24 @@ void ParseCommandLine() // void LoadFlags() { + DefaultFlags.StickyWindowPosition = 0; + DefaultFlags.ReuseWindow = 0; + DefaultFlags.NoReuseWindow = 1; + DefaultFlags.SingleFileInstance = 1; + DefaultFlags.MultiFileArg = 0; + DefaultFlags.RelativeFileMRU = 1; + DefaultFlags.PortableMyDocs = DefaultFlags.RelativeFileMRU; + DefaultFlags.NoFadeHidden = 0; + DefaultFlags.ToolbarLook = IsXP() ? 1 : 2; + DefaultFlags.SimpleIndentGuides = 0; + DefaultFlags.NoHTMLGuess = 0; + DefaultFlags.NoCGIGuess = 0; + DefaultFlags.NoFileVariables = 0; + DefaultFlags.ShellUseSystemMRU = 1; + DefaultFlags.PrintFileAndLeave = 0; + + // -------------------------------------------------------------------------- + int const cchIniSection = INISECTIONBUFCNT * HUGE_BUFFER; WCHAR *pIniSection = AllocMem(sizeof(WCHAR) * cchIniSection, HEAP_ZERO_MEMORY); @@ -7703,55 +7690,60 @@ void LoadFlags() { LoadIniSection(L"Settings2", pIniSection, cchIniSection); - if (!g_flagReuseWindow && !g_flagNoReuseWindow) { + if (IniSectionGetInt(pIniSection, L"StickyWindowPosition", DefaultFlags.StickyWindowPosition)) + Flags.StickyWindowPosition = 1; - if (!IniSectionGetInt(pIniSection, L"ReuseWindow", 0)) - g_flagNoReuseWindow = 1; + if (!Flags.ReuseWindow && !Flags.NoReuseWindow) { - if (IniSectionGetInt(pIniSection, L"SingleFileInstance", 0)) - g_flagSingleFileInstance = 1; - } + if (!IniSectionGetInt(pIniSection, L"ReuseWindow", DefaultFlags.ReuseWindow)) + Flags.NoReuseWindow = 1; - if (g_flagMultiFileArg == 0) { - if (IniSectionGetInt(pIniSection, L"MultiFileArg", 0)) - g_flagMultiFileArg = 2; + if (IniSectionGetInt(pIniSection, L"SingleFileInstance", DefaultFlags.SingleFileInstance)) + Flags.SingleFileInstance = 1; } - if (IniSectionGetInt(pIniSection, L"RelativeFileMRU", 1)) - g_flagRelativeFileMRU = 1; + if (Flags.MultiFileArg == 0) { + if (IniSectionGetInt(pIniSection, L"MultiFileArg", DefaultFlags.MultiFileArg)) + Flags.MultiFileArg = 2; + } - if (IniSectionGetInt(pIniSection, L"PortableMyDocs", g_flagRelativeFileMRU)) - g_flagPortableMyDocs = 1; + if (IniSectionGetInt(pIniSection, L"RelativeFileMRU", DefaultFlags.RelativeFileMRU)) + Flags.RelativeFileMRU = 1; - if (IniSectionGetInt(pIniSection, L"NoFadeHidden", 0)) - g_flagNoFadeHidden = 1; + if (IniSectionGetInt(pIniSection, L"PortableMyDocs", DefaultFlags.PortableMyDocs)) + Flags.PortableMyDocs = 1; - g_flagToolbarLook = IniSectionGetInt(pIniSection, L"ToolbarLook", IsXP() ? 1 : 2); - g_flagToolbarLook = clampi(g_flagToolbarLook, 0, 2); + if (IniSectionGetInt(pIniSection, L"NoFadeHidden", DefaultFlags.NoFadeHidden)) + Flags.NoFadeHidden = 1; - if (IniSectionGetInt(pIniSection, L"SimpleIndentGuides", 0)) - g_flagSimpleIndentGuides = 1; + Flags.ToolbarLook = IniSectionGetInt(pIniSection, L"ToolbarLook", DefaultFlags.ToolbarLook); + Flags.ToolbarLook = clampi(Flags.ToolbarLook, 0, 2); - if (IniSectionGetInt(pIniSection, L"NoHTMLGuess", 0)) - g_flagNoHTMLGuess = 1; + if (IniSectionGetInt(pIniSection, L"SimpleIndentGuides", DefaultFlags.SimpleIndentGuides)) + Flags.SimpleIndentGuides = 1; - if (IniSectionGetInt(pIniSection, L"NoCGIGuess", 0)) - g_flagNoCGIGuess = 1; + if (IniSectionGetInt(pIniSection, L"NoHTMLGuess", DefaultFlags.NoHTMLGuess)) + Flags.NoHTMLGuess = 1; - if (IniSectionGetInt(pIniSection, L"NoFileVariables", 0)) - g_flagNoFileVariables = 1; + if (IniSectionGetInt(pIniSection, L"NoCGIGuess", DefaultFlags.NoCGIGuess)) + Flags.NoCGIGuess = 1; - if (StringCchLenW(g_wchAppUserModelID, COUNTOF(g_wchAppUserModelID)) == 0) { - IniSectionGetString(pIniSection, L"ShellAppUserModelID", L"" APPNAME, - g_wchAppUserModelID, COUNTOF(g_wchAppUserModelID)); - } + if (IniSectionGetInt(pIniSection, L"NoFileVariables", DefaultFlags.NoFileVariables)) + Flags.NoFileVariables = 1; - if (g_flagUseSystemMRU == 0) { - if (IniSectionGetInt(pIniSection, L"ShellUseSystemMRU", 0)) { - g_flagUseSystemMRU = 2; + if (Flags.ShellUseSystemMRU == 0) { + if (IniSectionGetInt(pIniSection, L"ShellUseSystemMRU", DefaultFlags.ShellUseSystemMRU)) { + Flags.ShellUseSystemMRU = 2; } } + FreeMem(pIniSection); + + // ------------------------- + // non-settings global flags + // ------------------------- + Flags.PrintFileAndLeave = DefaultFlags.PrintFileAndLeave = 0; + } } @@ -7761,7 +7753,7 @@ void LoadFlags() // FindIniFile() // // -static bool __fastcall _CheckIniFile(LPWSTR lpszFile,LPCWSTR lpszModule) +static bool _CheckIniFile(LPWSTR lpszFile,LPCWSTR lpszModule) { WCHAR tchFileExpanded[MAX_PATH] = { L'\0' }; WCHAR tchBuild[MAX_PATH] = { L'\0' }; @@ -7807,7 +7799,7 @@ static bool __fastcall _CheckIniFile(LPWSTR lpszFile,LPCWSTR lpszModule) } -static bool __fastcall _CheckIniFileRedirect(LPWSTR lpszAppName, LPWSTR lpszKeyName, LPWSTR lpszFile,LPCWSTR lpszModule) +static bool _CheckIniFileRedirect(LPWSTR lpszAppName, LPWSTR lpszKeyName, LPWSTR lpszFile,LPCWSTR lpszModule) { WCHAR tch[MAX_PATH] = { L'\0' }; if (GetPrivateProfileString(lpszAppName, lpszKeyName, L"", tch, COUNTOF(tch), lpszFile)) { @@ -7845,17 +7837,17 @@ int FindIniFile() { PathRemoveFileSpec(tchPath); SetEnvironmentVariable(L"NOTEPAD3MODULEDIR", tchPath); - if (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile))) { - if (StringCchCompareXI(g_wchIniFile,L"*?") == 0) + if (StringCchLenW(Globals.IniFile,COUNTOF(Globals.IniFile))) { + if (StringCchCompareXI(Globals.IniFile,L"*?") == 0) return(0); else { - if (!_CheckIniFile(g_wchIniFile,tchModule)) { - ExpandEnvironmentStringsEx(g_wchIniFile,COUNTOF(g_wchIniFile)); - if (PathIsRelative(g_wchIniFile)) { + if (!_CheckIniFile(Globals.IniFile,tchModule)) { + ExpandEnvironmentStringsEx(Globals.IniFile,COUNTOF(Globals.IniFile)); + if (PathIsRelative(Globals.IniFile)) { StringCchCopy(tchPath,COUNTOF(tchPath),tchModule); PathRemoveFileSpec(tchPath); - PathCchAppend(tchPath,COUNTOF(tchPath),g_wchIniFile); - StringCchCopy(g_wchIniFile,COUNTOF(g_wchIniFile),tchPath); + PathCchAppend(tchPath,COUNTOF(tchPath),Globals.IniFile); + StringCchCopy(Globals.IniFile,COUNTOF(Globals.IniFile),tchPath); } } } @@ -7873,18 +7865,18 @@ int FindIniFile() { if (bFound) { // allow two redirections: administrator -> user -> custom - if (_CheckIniFileRedirect(L"" APPNAME, L"" APPNAME ".ini", tchPath, tchModule)) { - _CheckIniFileRedirect(L"" APPNAME, L"" APPNAME ".ini", tchPath, tchModule); + if (_CheckIniFileRedirect(MKWCS(APPNAME), MKWCS(APPNAME) L".ini", tchPath, tchModule)) { + _CheckIniFileRedirect(MKWCS(APPNAME), MKWCS(APPNAME) L".ini", tchPath, tchModule); } - StringCchCopy(g_wchIniFile,COUNTOF(g_wchIniFile),tchPath); + StringCchCopy(Globals.IniFile,COUNTOF(Globals.IniFile),tchPath); } else { - StringCchCopy(g_wchIniFile,COUNTOF(g_wchIniFile),tchModule); - PathCchRenameExtension(g_wchIniFile,COUNTOF(g_wchIniFile),L".ini"); + StringCchCopy(Globals.IniFile,COUNTOF(Globals.IniFile),tchModule); + PathCchRenameExtension(Globals.IniFile,COUNTOF(Globals.IniFile),L".ini"); } } - NormalizePathEx(g_wchIniFile,COUNTOF(g_wchIniFile)); + NormalizePathEx(Globals.IniFile,COUNTOF(Globals.IniFile)); return(1); } @@ -7892,31 +7884,31 @@ int FindIniFile() { int TestIniFile() { - if (StringCchCompareXI(g_wchIniFile,L"*?") == 0) { - StringCchCopy(g_wchIniFile2,COUNTOF(g_wchIniFile2),L""); - StringCchCopy(g_wchIniFile,COUNTOF(g_wchIniFile),L""); + if (StringCchCompareXI(Globals.IniFile,L"*?") == 0) { + StringCchCopy(s_wchIniFile2,COUNTOF(s_wchIniFile2),L""); + StringCchCopy(Globals.IniFile,COUNTOF(Globals.IniFile),L""); return(0); } - if (PathIsDirectory(g_wchIniFile) || *CharPrev(g_wchIniFile,StrEnd(g_wchIniFile, COUNTOF(g_wchIniFile))) == L'\\') { + if (PathIsDirectory(Globals.IniFile) || *CharPrev(Globals.IniFile,StrEnd(Globals.IniFile, COUNTOF(Globals.IniFile))) == L'\\') { WCHAR wchModule[MAX_PATH] = { L'\0' }; GetModuleFileName(NULL,wchModule,COUNTOF(wchModule)); - 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"); + PathCchAppend(Globals.IniFile,COUNTOF(Globals.IniFile),PathFindFileName(wchModule)); + PathCchRenameExtension(Globals.IniFile,COUNTOF(Globals.IniFile),L".ini"); + if (!PathFileExists(Globals.IniFile)) { + StringCchCopy(PathFindFileName(Globals.IniFile),COUNTOF(Globals.IniFile),L"Notepad3.ini"); + if (!PathFileExists(Globals.IniFile)) { + StringCchCopy(PathFindFileName(Globals.IniFile),COUNTOF(Globals.IniFile),PathFindFileName(wchModule)); + PathCchRenameExtension(Globals.IniFile,COUNTOF(Globals.IniFile),L".ini"); } } } - NormalizePathEx(g_wchIniFile,COUNTOF(g_wchIniFile)); + NormalizePathEx(Globals.IniFile,COUNTOF(Globals.IniFile)); - if (!PathFileExists(g_wchIniFile) || PathIsDirectory(g_wchIniFile)) { - StringCchCopy(g_wchIniFile2,COUNTOF(g_wchIniFile2),g_wchIniFile); - StringCchCopy(g_wchIniFile,COUNTOF(g_wchIniFile),L""); + if (!PathFileExists(Globals.IniFile) || PathIsDirectory(Globals.IniFile)) { + StringCchCopy(s_wchIniFile2,COUNTOF(s_wchIniFile2),Globals.IniFile); + StringCchCopy(Globals.IniFile,COUNTOF(Globals.IniFile),L""); return(0); } else @@ -7926,7 +7918,7 @@ int TestIniFile() { int CreateIniFile() { - return(CreateIniFileEx(g_wchIniFile)); + return(CreateIniFileEx(Globals.IniFile)); } @@ -7944,7 +7936,7 @@ int CreateIniFileEx(LPCWSTR lpszIniFile) HANDLE hFile = CreateFile(lpszIniFile, GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); - dwLastIOError = GetLastError(); + g_dwLastIOError = GetLastError(); if (hFile != INVALID_HANDLE_VALUE) { if (GetFileSize(hFile,NULL) == 0) { DWORD dw; @@ -7968,10 +7960,10 @@ int CreateIniFileEx(LPCWSTR lpszIniFile) // DelayUpdateStatusbar() // // -static void __fastcall DelayUpdateStatusbar(int delay, bool bForceRedraw) +static void DelayUpdateStatusbar(int delay, bool bForceRedraw) { static CmdMessageQueue_t mqc = { NULL, WM_COMMAND, (WPARAM)MAKELONG(IDT_TIMER_UPDATE_STATUSBAR, 1), (LPARAM)0, 0 }; - mqc.hwnd = g_hwndMain; + mqc.hwnd = Globals.hwndMain; mqc.lparam = (LPARAM)bForceRedraw; _MQ_AppendCmd(&mqc, (UINT)(delay <= 0 ? 0 : _MQ_ms(delay))); } @@ -7982,10 +7974,10 @@ static void __fastcall DelayUpdateStatusbar(int delay, bool bForceRedraw) // DelayUpdateToolbar() // // -static void __fastcall DelayUpdateToolbar(int delay) +static void DelayUpdateToolbar(int delay) { static CmdMessageQueue_t mqc = { NULL, WM_COMMAND, (WPARAM)MAKELONG(IDT_TIMER_UPDATE_TOOLBAR, 1), (LPARAM)0, 0 }; - mqc.hwnd = g_hwndMain; + mqc.hwnd = Globals.hwndMain; //mqc.lparam = (LPARAM)bForceRedraw; _MQ_AppendCmd(&mqc, (UINT)(delay <= 0 ? 0 : _MQ_ms(delay))); } @@ -7998,7 +7990,7 @@ static void __fastcall DelayUpdateToolbar(int delay) void MarkAllOccurrences(int delay, bool bForceClear) { static CmdMessageQueue_t mqc = { NULL, WM_COMMAND, (WPARAM)MAKELONG(IDT_TIMER_MAIN_MRKALL, 1), (LPARAM)0 , 0 }; - mqc.hwnd = g_hwndMain; + mqc.hwnd = Globals.hwndMain; mqc.lparam = (LPARAM)bForceClear; _MQ_AppendCmd(&mqc, (UINT)(delay <= 0 ? 0 : _MQ_ms(delay))); } @@ -8011,7 +8003,7 @@ void MarkAllOccurrences(int delay, bool bForceClear) void UpdateVisibleUrlHotspot(int delay) { static CmdMessageQueue_t mqc = { NULL, WM_COMMAND, (WPARAM)MAKELONG(IDT_TIMER_UPDATE_HOTSPOT, 1), (LPARAM)0 , 0 }; - mqc.hwnd = g_hwndMain; + mqc.hwnd = Globals.hwndMain; _MQ_AppendCmd(&mqc, (UINT)(delay <= 0 ? 0 : _MQ_ms(delay))); } @@ -8030,26 +8022,26 @@ void UpdateToolbar() //============================================================================= -#define EnableTool(id,b) SendMessage(g_hwndToolbar,TB_ENABLEBUTTON,id, MAKELONG(((b) ? 1 : 0), 0)) -#define CheckTool(id,b) SendMessage(g_hwndToolbar,TB_CHECKBUTTON,id, MAKELONG((b),0)) +#define EnableTool(id,b) SendMessage(s_hwndToolbar,TB_ENABLEBUTTON,id, MAKELONG(((b) ? 1 : 0), 0)) +#define CheckTool(id,b) SendMessage(s_hwndToolbar,TB_CHECKBUTTON,id, MAKELONG((b),0)) -static void __fastcall _UpdateToolbarDelayed() +static void _UpdateToolbarDelayed() { - SetWindowTitle(g_hwndMain, uidsAppTitle, flagIsElevated, IDS_MUI_UNTITLED, g_wchCurFile, - iPathNameFormat, IsDocumentModified || Encoding_HasChanged(CPI_GET), + SetWindowTitle(Globals.hwndMain, uidsAppTitle, flagIsElevated, IDS_MUI_UNTITLED, Globals.CurrentFile, + Settings.PathNameFormat, IsDocumentModified || Encoding_HasChanged(CPI_GET), IDS_MUI_READONLY, g_bFileReadOnly, szTitleExcerpt); - if (!bShowToolbar) { return; } + if (!Settings.ShowToolbar) { return; } - EnableTool(IDT_FILE_ADDTOFAV, StringCchLenW(g_wchCurFile, COUNTOF(g_wchCurFile))); + EnableTool(IDT_FILE_ADDTOFAV, StringCchLenW(Globals.CurrentFile, COUNTOF(Globals.CurrentFile))); EnableTool(IDT_FILE_SAVE, (IsDocumentModified || Encoding_HasChanged(CPI_GET)) /*&& !bReadOnly*/); - CheckTool(IDT_VIEW_WORDWRAP, g_bWordWrap); + CheckTool(IDT_VIEW_WORDWRAP, Settings.WordWrap); CheckTool(IDT_VIEW_CHASING_DOCTAIL, g_bChasingDocTail); bool b1 = SciCall_IsSelectionEmpty(); bool b2 = (bool)(SciCall_GetTextLength() > 0); bool ro = SciCall_GetReadOnly(); - bool tv = EditToggleView(g_hwndEdit, false); + bool tv = EditToggleView(Globals.hwndEdit, false); EnableTool(IDT_EDIT_UNDO, SciCall_CanUndo() && !ro); EnableTool(IDT_EDIT_REDO, SciCall_CanRedo() && !ro); @@ -8060,16 +8052,16 @@ static void __fastcall _UpdateToolbarDelayed() EnableTool(IDT_EDIT_FIND, b2); //EnableTool(IDT_EDIT_FINDNEXT,b2); - //EnableTool(IDT_EDIT_FINDPREV,b2 && StringCchLenA(g_efrData.szFind,0)); + //EnableTool(IDT_EDIT_FINDPREV,b2 && StringCchLenA(Settings.EFR_Data.szFind,0)); EnableTool(IDT_EDIT_REPLACE, b2 && !ro); EnableTool(IDT_EDIT_CUT, !b1 && !ro); EnableTool(IDT_EDIT_COPY, !b1 && !ro); EnableTool(IDT_EDIT_CLEAR, !b1 && !ro); - EnableTool(IDT_VIEW_TOGGLEFOLDS, b2 && (g_bCodeFoldingAvailable && g_bShowCodeFolding)); + EnableTool(IDT_VIEW_TOGGLEFOLDS, b2 && (g_bCodeFoldingAvailable && Settings.ShowCodeFolding)); - EnableTool(IDT_VIEW_TOGGLE_VIEW, b2 && ((g_iMarkOccurrences > 0) && !g_bMarkOccurrencesMatchVisible)); + EnableTool(IDT_VIEW_TOGGLE_VIEW, b2 && ((Settings.MarkOccurrences > 0) && !Settings.MarkOccurrencesMatchVisible)); CheckTool(IDT_VIEW_TOGGLE_VIEW, tv); } @@ -8079,7 +8071,7 @@ static void __fastcall _UpdateToolbarDelayed() // // _StatusCalcPaneWidth() // -static LONG __fastcall _StatusCalcPaneWidth(HWND hwnd, LPCWSTR lpsz) +static LONG _StatusCalcPaneWidth(HWND hwnd, LPCWSTR lpsz) { HDC const hdc = GetDC(hwnd); HGDIOBJ const hfont = (HGDIOBJ)SendMessage(hwnd, WM_GETFONT, 0, 0); @@ -8106,24 +8098,24 @@ static LONG __fastcall _StatusCalcPaneWidth(HWND hwnd, LPCWSTR lpsz) #define txtWidth 80 typedef WCHAR sectionTxt_t[txtWidth]; -static void __fastcall _CalculateStatusbarSections(int vSectionWidth[], sectionTxt_t tchStatusBar[], bool* bIsUpdNeeded) +static void _CalculateStatusbarSections(int vSectionWidth[], sectionTxt_t tchStatusBar[], bool* bIsUpdNeeded) { static int s_iWinFormerWidth = -1; - if (s_iWinFormerWidth != g_WinCurrentWidth) { + if (s_iWinFormerWidth != s_WinCurrentWidth) { *bIsUpdNeeded = true; - s_iWinFormerWidth = g_WinCurrentWidth; + s_iWinFormerWidth = s_WinCurrentWidth; } if (!(*bIsUpdNeeded)) { return; } // count fixed and dynamic optimized pixels int pxCount = 0; for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) { - if (g_iStatusbarVisible[i]) { - if (g_iStatusbarWidthSpec[i] == 0) { // dynamic optimized - vSectionWidth[i] = _StatusCalcPaneWidth(g_hwndStatus, tchStatusBar[i]); + if (s_iStatusbarVisible[i]) { + if (s_iStatusbarWidthSpec[i] == 0) { // dynamic optimized + vSectionWidth[i] = _StatusCalcPaneWidth(Globals.hwndStatus, tchStatusBar[i]); } - else if (g_iStatusbarWidthSpec[i] < -1) { // fixed pixel count - vSectionWidth[i] = -(g_iStatusbarWidthSpec[i]); + else if (s_iStatusbarWidthSpec[i] < -1) { // fixed pixel count + vSectionWidth[i] = -(s_iStatusbarWidthSpec[i]); } //else { /* 0,-1 : relative counts */ } // accumulate @@ -8131,13 +8123,13 @@ static void __fastcall _CalculateStatusbarSections(int vSectionWidth[], sectionT } } - int const iPropSectTotalWidth = g_WinCurrentWidth - pxCount - STAUSBAR_RIGHT_MARGIN; + int const iPropSectTotalWidth = s_WinCurrentWidth - pxCount - STAUSBAR_RIGHT_MARGIN; // init proportional section checker bool bIsPropSection[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO; for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) { - if ((g_iStatusbarVisible[i]) && (vSectionWidth[i] < 0)) { - assert(g_iStatusbarWidthSpec[i] > 0); + if ((s_iStatusbarVisible[i]) && (vSectionWidth[i] < 0)) { + assert(s_iStatusbarWidthSpec[i] > 0); bIsPropSection[i] = true; } } @@ -8147,7 +8139,7 @@ static void __fastcall _CalculateStatusbarSections(int vSectionWidth[], sectionT int iTotalMinWidth = 0; for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) { if (bIsPropSection[i]) { - int const iMinWidth = _StatusCalcPaneWidth(g_hwndStatus, tchStatusBar[i]); + int const iMinWidth = _StatusCalcPaneWidth(Globals.hwndStatus, tchStatusBar[i]); vMinWidth[i] = iMinWidth; iTotalMinWidth += iMinWidth; } @@ -8167,8 +8159,8 @@ static void __fastcall _CalculateStatusbarSections(int vSectionWidth[], sectionT int totalCnt = 0; for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) { if (bIsPropSection[i]) { - vPropWidth[i] = iPropSectTotalWidth * g_iStatusbarWidthSpec[i]; - totalCnt += g_iStatusbarWidthSpec[i]; + vPropWidth[i] = iPropSectTotalWidth * s_iStatusbarWidthSpec[i]; + totalCnt += s_iStatusbarWidthSpec[i]; } } // normalize @@ -8235,7 +8227,7 @@ static void __fastcall _CalculateStatusbarSections(int vSectionWidth[], sectionT // _InterpRectSelTinyExpr() // // -static double __fastcall _InterpRectSelTinyExpr(int* piExprError) +static double _InterpRectSelTinyExpr(int* piExprError) { #define _tmpBufCnt 128 char tmpRectSelN[_tmpBufCnt] = { '\0' }; @@ -8282,9 +8274,9 @@ const static WCHAR* FR_Status[] = { L"[>--<]", L"[>>--]", L"[>>-+]", L"[+->]>", FR_STATES g_FindReplaceMatchFoundState = FND_NOP; -static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) +static void _UpdateStatusbarDelayed(bool bForceRedraw) { - if (!bShowStatusbar) { return; } + if (!Settings.ShowStatusbar) { return; } bool bIsUpdateNeeded = bForceRedraw; @@ -8314,7 +8306,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) static WCHAR tchLines[32] = { L'\0' }; static DocLn s_iLnCnt = -1; - if (g_iStatusbarVisible[STATUS_DOCLINE] || g_hwndDlgFindReplace) + if (s_iStatusbarVisible[STATUS_DOCLINE] || Globals.hwndDlgFindReplace) { if (s_iLnFromPos != iLnFromPos) { StringCchPrintf(tchLn, COUNTOF(tchLn), DOCPOSFMTW, iLnFromPos + 1); @@ -8330,7 +8322,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) if ((s_iLnFromPos != iLnFromPos) || (s_iLnCnt != iLnCnt)) { StringCchPrintf(tchStatusBar[STATUS_DOCLINE], txtWidth, L"%s%s / %s%s", - g_mxSBPrefix[STATUS_DOCLINE], tchLn, tchLines, g_mxSBPostfix[STATUS_DOCLINE]); + s_mxSBPrefix[STATUS_DOCLINE], tchLn, tchLines, s_mxSBPostfix[STATUS_DOCLINE]); s_iLnFromPos = iLnFromPos; s_iLnCnt = iLnCnt; bIsUpdateNeeded = true; @@ -8341,7 +8333,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) static WCHAR tchCol[32] = { L'\0' }; static WCHAR tchCols[32] = { L'\0' }; - if (g_iStatusbarVisible[STATUS_DOCCOLUMN] || g_hwndDlgFindReplace) + if (s_iStatusbarVisible[STATUS_DOCCOLUMN] || Globals.hwndDlgFindReplace) { DocPos const colOffset = g_bZeroBasedColumnIndex ? 0 : 1; @@ -8361,7 +8353,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) if ((s_iCol != iCol) || (s_iCols != iCols)) { StringCchPrintf(tchStatusBar[STATUS_DOCCOLUMN], txtWidth, L"%s%s / %s%s", - g_mxSBPrefix[STATUS_DOCCOLUMN], tchCol, tchCols, g_mxSBPostfix[STATUS_DOCCOLUMN]); + s_mxSBPrefix[STATUS_DOCCOLUMN], tchCol, tchCols, s_mxSBPostfix[STATUS_DOCCOLUMN]); s_iCol = iCol; s_iCols = iCols; @@ -8373,7 +8365,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) static WCHAR tchChr[32] = { L'\0' }; static WCHAR tchChrs[32] = { L'\0' }; - if (g_iStatusbarVisible[STATUS_DOCCHAR]) + if (s_iStatusbarVisible[STATUS_DOCCHAR]) { DocPos const chrOffset = g_bZeroBasedCharacterCount ? 0 : 1; @@ -8393,7 +8385,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) if ((s_iChr != iChr) || (s_iChrs != iChrs)) { StringCchPrintf(tchStatusBar[STATUS_DOCCHAR], txtWidth, L"%s%s / %s%s", - g_mxSBPrefix[STATUS_DOCCHAR], tchChr, tchChrs, g_mxSBPostfix[STATUS_DOCCHAR]); + s_mxSBPrefix[STATUS_DOCCHAR], tchChr, tchChrs, s_mxSBPostfix[STATUS_DOCCHAR]); s_iChr = iChr; s_iChrs = iChrs; @@ -8409,13 +8401,13 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) static DocPos s_iSelStart = -1; static DocPos s_iSelEnd = -1; - if (g_iStatusbarVisible[STATUS_SELECTION] || g_iStatusbarVisible[STATUS_SELCTBYTES] || g_hwndDlgFindReplace) + if (s_iStatusbarVisible[STATUS_SELECTION] || s_iStatusbarVisible[STATUS_SELCTBYTES] || Globals.hwndDlgFindReplace) { if ((s_bIsSelCountable != bIsSelCountable) || (s_iSelStart != iSelStart) || (s_iSelEnd != iSelEnd)) { if (bIsSelCountable) { - const DocPos iSel = (DocPos)SendMessage(g_hwndEdit, SCI_COUNTCHARACTERS, iSelStart, iSelEnd); + const DocPos iSel = (DocPos)SendMessage(Globals.hwndEdit, SCI_COUNTCHARACTERS, iSelStart, iSelEnd); StringCchPrintf(tchSel, COUNTOF(tchSel), DOCPOSFMTW, iSel); FormatNumberStr(tchSel); StrFormatByteSize((iSelEnd - iSelStart), tchSelB, COUNTOF(tchSelB)); @@ -8425,10 +8417,10 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) tchSelB[0] = L'0'; tchSelB[1] = L'\0'; } StringCchPrintf(tchStatusBar[STATUS_SELECTION], txtWidth, L"%s%s%s", - g_mxSBPrefix[STATUS_SELECTION], tchSel, g_mxSBPostfix[STATUS_SELECTION]); + s_mxSBPrefix[STATUS_SELECTION], tchSel, s_mxSBPostfix[STATUS_SELECTION]); StringCchPrintf(tchStatusBar[STATUS_SELCTBYTES], txtWidth, L"%s%s%s", - g_mxSBPrefix[STATUS_SELCTBYTES], tchSelB, g_mxSBPostfix[STATUS_SELCTBYTES]); + s_mxSBPrefix[STATUS_SELCTBYTES], tchSelB, s_mxSBPostfix[STATUS_SELCTBYTES]); s_bIsSelCountable = bIsSelCountable; s_iSelStart = iSelStart; @@ -8443,7 +8435,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) static bool s_bIsSelectionEmpty = true; static DocLn s_iLinesSelected = -1; - if (g_iStatusbarVisible[STATUS_SELCTLINES]) + if (s_iStatusbarVisible[STATUS_SELCTLINES]) { DocLn const iLineStart = SciCall_LineFromPosition(iSelStart); DocLn const iLineEnd = SciCall_LineFromPosition(iSelEnd); @@ -8463,7 +8455,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) FormatNumberStr(tchLinesSelected); } StringCchPrintf(tchStatusBar[STATUS_SELCTLINES], txtWidth, L"%s%s%s", - g_mxSBPrefix[STATUS_SELCTLINES], tchLinesSelected, g_mxSBPostfix[STATUS_SELCTLINES]); + s_mxSBPrefix[STATUS_SELCTLINES], tchLinesSelected, s_mxSBPostfix[STATUS_SELCTLINES]); s_bIsSelectionEmpty = bIsSelectionEmpty; s_iLinesSelected = iLinesSelected; @@ -8476,7 +8468,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) static WCHAR tchExpression[32] = { L'\0' }; static int s_iExprError = -3; - if (g_iStatusbarVisible[STATUS_TINYEXPR]) + if (s_iStatusbarVisible[STATUS_TINYEXPR]) { g_dExpression = 0.0; tchExpression[0] = L'-'; @@ -8522,7 +8514,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) if (!g_iExprError || (s_iExprError != g_iExprError)) { StringCchPrintf(tchStatusBar[STATUS_TINYEXPR], txtWidth, L"%s%s%s ", - g_mxSBPrefix[STATUS_TINYEXPR], tchExpression, g_mxSBPostfix[STATUS_TINYEXPR]); + s_mxSBPrefix[STATUS_TINYEXPR], tchExpression, s_mxSBPostfix[STATUS_TINYEXPR]); s_iExprError = g_iExprError; bIsUpdateNeeded = true; @@ -8535,13 +8527,13 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) static int s_iMarkOccurrencesCount = -111; static bool s_bMOVisible = false; - if (g_iStatusbarVisible[STATUS_OCCURRENCE] || g_hwndDlgFindReplace) + if (s_iStatusbarVisible[STATUS_OCCURRENCE] || Globals.hwndDlgFindReplace) { - if ((s_bMOVisible != g_bMarkOccurrencesMatchVisible) || (s_iMarkOccurrencesCount != g_iMarkOccurrencesCount)) + if ((s_bMOVisible != Settings.MarkOccurrencesMatchVisible) || (s_iMarkOccurrencesCount != g_iMarkOccurrencesCount)) { - if ((g_iMarkOccurrencesCount >= 0) && !g_bMarkOccurrencesMatchVisible) + if ((g_iMarkOccurrencesCount >= 0) && !Settings.MarkOccurrencesMatchVisible) { - if ((g_iMarkOccurrencesMaxCount < 0) || (g_iMarkOccurrencesCount < g_iMarkOccurrencesMaxCount)) + if ((Settings2.MarkOccurrencesMaxCount < 0) || (g_iMarkOccurrencesCount < Settings2.MarkOccurrencesMaxCount)) { StringCchPrintf(tchOcc, COUNTOF(tchOcc), L"%i", g_iMarkOccurrencesCount); FormatNumberStr(tchOcc); @@ -8557,9 +8549,9 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) } StringCchPrintf(tchStatusBar[STATUS_OCCURRENCE], txtWidth, L"%s%s%s", - g_mxSBPrefix[STATUS_OCCURRENCE], tchOcc, g_mxSBPostfix[STATUS_OCCURRENCE]); + s_mxSBPrefix[STATUS_OCCURRENCE], tchOcc, s_mxSBPostfix[STATUS_OCCURRENCE]); - s_bMOVisible = g_bMarkOccurrencesMatchVisible; + s_bMOVisible = Settings.MarkOccurrencesMatchVisible; s_iMarkOccurrencesCount = g_iMarkOccurrencesCount; bIsUpdateNeeded = true; } @@ -8570,7 +8562,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) static WCHAR tchRepl[32] = { L'\0' }; static int s_iReplacedOccurrences = -1; - if (g_iStatusbarVisible[STATUS_OCCREPLACE] || g_hwndDlgFindReplace) + if (s_iStatusbarVisible[STATUS_OCCREPLACE] || Globals.hwndDlgFindReplace) { if (s_iReplacedOccurrences != g_iReplacedOccurrences) { @@ -8584,7 +8576,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) } StringCchPrintf(tchStatusBar[STATUS_OCCREPLACE], txtWidth, L"%s%s%s", - g_mxSBPrefix[STATUS_OCCREPLACE], tchRepl, g_mxSBPostfix[STATUS_OCCREPLACE]); + s_mxSBPrefix[STATUS_OCCREPLACE], tchRepl, s_mxSBPostfix[STATUS_OCCREPLACE]); s_iReplacedOccurrences = g_iReplacedOccurrences; bIsUpdateNeeded = true; @@ -8596,14 +8588,14 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) static WCHAR tchBytes[32] = { L'\0' }; static DocPos s_iTextLength = -1; - if (g_iStatusbarVisible[STATUS_DOCSIZE]) + if (s_iStatusbarVisible[STATUS_DOCSIZE]) { DocPos const iTextLength = SciCall_GetTextLength(); if (s_iTextLength != iTextLength) { StrFormatByteSize(iTextLength, tchBytes, COUNTOF(tchBytes)); StringCchPrintf(tchStatusBar[STATUS_DOCSIZE], txtWidth, L"%s%s%s", - g_mxSBPrefix[STATUS_DOCSIZE], tchBytes, g_mxSBPostfix[STATUS_DOCSIZE]); + s_mxSBPrefix[STATUS_DOCSIZE], tchBytes, s_mxSBPostfix[STATUS_DOCSIZE]); s_iTextLength = iTextLength; bIsUpdateNeeded = true; @@ -8613,14 +8605,14 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) static int s_iEncoding = -1; - if (g_iStatusbarVisible[STATUS_CODEPAGE]) + if (s_iStatusbarVisible[STATUS_CODEPAGE]) { int const iEncoding = Encoding_Current(CPI_GET); if (s_iEncoding != iEncoding) { Encoding_SetLabel(iEncoding); StringCchPrintf(tchStatusBar[STATUS_CODEPAGE], txtWidth, L"%s%s%s", - g_mxSBPrefix[STATUS_CODEPAGE], Encoding_GetLabel(iEncoding), g_mxSBPostfix[STATUS_CODEPAGE]); + s_mxSBPrefix[STATUS_CODEPAGE], Encoding_GetLabel(iEncoding), s_mxSBPostfix[STATUS_CODEPAGE]); s_iEncoding = iEncoding; bIsUpdateNeeded = true; @@ -8630,24 +8622,24 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) static int s_iEOLMode = -1; - if (g_iStatusbarVisible[STATUS_EOLMODE]) + if (s_iStatusbarVisible[STATUS_EOLMODE]) { - if (s_iEOLMode != g_iEOLMode) { - if (g_iEOLMode == SC_EOL_CR) + if (s_iEOLMode != Globals.iEOLMode) { + if (Globals.iEOLMode == SC_EOL_CR) { StringCchPrintf(tchStatusBar[STATUS_EOLMODE], txtWidth, L"%sCR%s", - g_mxSBPrefix[STATUS_EOLMODE], g_mxSBPostfix[STATUS_EOLMODE]); + s_mxSBPrefix[STATUS_EOLMODE], s_mxSBPostfix[STATUS_EOLMODE]); } - else if (g_iEOLMode == SC_EOL_LF) + else if (Globals.iEOLMode == SC_EOL_LF) { StringCchPrintf(tchStatusBar[STATUS_EOLMODE], txtWidth, L"%sLF%s", - g_mxSBPrefix[STATUS_EOLMODE], g_mxSBPostfix[STATUS_EOLMODE]); + s_mxSBPrefix[STATUS_EOLMODE], s_mxSBPostfix[STATUS_EOLMODE]); } else { StringCchPrintf(tchStatusBar[STATUS_EOLMODE], txtWidth, L"%sCR+LF%s", - g_mxSBPrefix[STATUS_EOLMODE], g_mxSBPostfix[STATUS_EOLMODE]); + s_mxSBPrefix[STATUS_EOLMODE], s_mxSBPostfix[STATUS_EOLMODE]); } - s_iEOLMode = g_iEOLMode; + s_iEOLMode = Globals.iEOLMode; bIsUpdateNeeded = true; } } @@ -8655,18 +8647,18 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) static bool s_bIsOVR = -1; - if (g_iStatusbarVisible[STATUS_OVRMODE]) + if (s_iStatusbarVisible[STATUS_OVRMODE]) { - bool const bIsOVR = (bool)SendMessage(g_hwndEdit, SCI_GETOVERTYPE, 0, 0); + bool const bIsOVR = (bool)SendMessage(Globals.hwndEdit, SCI_GETOVERTYPE, 0, 0); if (s_bIsOVR != bIsOVR) { if (bIsOVR) { StringCchPrintf(tchStatusBar[STATUS_OVRMODE], txtWidth, L"%sOVR%s", - g_mxSBPrefix[STATUS_OVRMODE], g_mxSBPostfix[STATUS_OVRMODE]); + s_mxSBPrefix[STATUS_OVRMODE], s_mxSBPostfix[STATUS_OVRMODE]); } else { StringCchPrintf(tchStatusBar[STATUS_OVRMODE], txtWidth, L"%sINS%s", - g_mxSBPrefix[STATUS_OVRMODE], g_mxSBPostfix[STATUS_OVRMODE]); + s_mxSBPrefix[STATUS_OVRMODE], s_mxSBPostfix[STATUS_OVRMODE]); } s_bIsOVR = bIsOVR; bIsUpdateNeeded = true; @@ -8676,17 +8668,17 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) static bool s_bUse2ndDefault = -1; - if (g_iStatusbarVisible[STATUS_2ND_DEF]) + if (s_iStatusbarVisible[STATUS_2ND_DEF]) { bool const bUse2ndDefault = Style_GetUse2ndDefault(); if (s_bUse2ndDefault != bUse2ndDefault) { if (bUse2ndDefault) StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%s2ND%s", - g_mxSBPrefix[STATUS_2ND_DEF], g_mxSBPostfix[STATUS_2ND_DEF]); + s_mxSBPrefix[STATUS_2ND_DEF], s_mxSBPostfix[STATUS_2ND_DEF]); else StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%sSTD%s", - g_mxSBPrefix[STATUS_2ND_DEF], g_mxSBPostfix[STATUS_2ND_DEF]); + s_mxSBPrefix[STATUS_2ND_DEF], s_mxSBPostfix[STATUS_2ND_DEF]); s_bUse2ndDefault = bUse2ndDefault; bIsUpdateNeeded = true; @@ -8697,7 +8689,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) static int s_iCurLexer = -1; static WCHAR tchLexerName[MINI_BUFFER]; - if (g_iStatusbarVisible[STATUS_LEXER]) + if (s_iStatusbarVisible[STATUS_LEXER]) { int const iCurLexer = Style_GetCurrentLexerRID(); @@ -8709,7 +8701,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) Style_GetLexerDisplayName(Style_GetCurrentLexerPtr(), tchLexerName, MINI_BUFFER); StringCchPrintf(tchStatusBar[STATUS_LEXER], txtWidth, L"%s%s%s", - g_mxSBPrefix[STATUS_LEXER], tchLexerName, g_mxSBPostfix[STATUS_LEXER]); + s_mxSBPrefix[STATUS_LEXER], tchLexerName, s_mxSBPostfix[STATUS_LEXER]); s_iCurLexer = iCurLexer; bIsUpdateNeeded = true; @@ -8728,7 +8720,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) int cnt = 0; int totalWidth = 0; for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) { - int const id = g_vSBSOrder[i]; + int const id = s_vSBSOrder[i]; if ((id >= 0) && (g_vStatusbarSectionWidth[id] >= 0)) { totalWidth += g_vStatusbarSectionWidth[id]; @@ -8737,24 +8729,24 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) } if (cnt > 0) { aStatusbarSections[cnt - 1] = -1; } - else { aStatusbarSections[0] = -1; bShowStatusbar = false; } + else { aStatusbarSections[0] = -1; Settings.ShowStatusbar = false; } - SendMessage(g_hwndStatus, SB_SETPARTS, (WPARAM)cnt, (LPARAM)aStatusbarSections); + SendMessage(Globals.hwndStatus, SB_SETPARTS, (WPARAM)cnt, (LPARAM)aStatusbarSections); cnt = 0; for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) { - int const id = g_vSBSOrder[i]; + int const id = s_vSBSOrder[i]; if ((id >= 0) && (g_vStatusbarSectionWidth[id] >= 0)) { - StatusSetText(g_hwndStatus, cnt++, tchStatusBar[id]); + StatusSetText(Globals.hwndStatus, cnt++, tchStatusBar[id]); } } - //InvalidateRect(g_hwndStatus,NULL,true); + //InvalidateRect(Globals.hwndStatus,NULL,true); } // -------------------------------------------------------------------------- // update Find/Replace dialog (if any) static WCHAR tchReplOccs[32] = { L'\0' }; - if (g_hwndDlgFindReplace) { + if (Globals.hwndDlgFindReplace) { if (g_iReplacedOccurrences > 0) StringCchPrintf(tchReplOccs, COUNTOF(tchReplOccs), L"%i", g_iReplacedOccurrences); else @@ -8763,14 +8755,14 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) const WCHAR* SBFMT = L" %s%s / %s %s%s %s%s %s%s %s%s ( %s ) "; StringCchPrintf(tchFRStatus, COUNTOF(tchFRStatus), SBFMT, - g_mxSBPrefix[STATUS_DOCLINE], tchLn, tchLines, - g_mxSBPrefix[STATUS_DOCCOLUMN], tchCol, - g_mxSBPrefix[STATUS_SELECTION], tchSel, - g_mxSBPrefix[STATUS_OCCURRENCE], tchOcc, - g_mxSBPrefix[STATUS_OCCREPLACE], tchReplOccs, + s_mxSBPrefix[STATUS_DOCLINE], tchLn, tchLines, + s_mxSBPrefix[STATUS_DOCCOLUMN], tchCol, + s_mxSBPrefix[STATUS_SELECTION], tchSel, + s_mxSBPrefix[STATUS_OCCURRENCE], tchOcc, + s_mxSBPrefix[STATUS_OCCREPLACE], tchReplOccs, FR_Status[g_FindReplaceMatchFoundState]); - SetWindowText(GetDlgItem(g_hwndDlgFindReplace, IDS_FR_STATUS_TEXT), tchFRStatus); + SetWindowText(GetDlgItem(Globals.hwndDlgFindReplace, IDS_FR_STATUS_TEXT), tchFRStatus); } } @@ -8783,7 +8775,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) // void UpdateMarginWidth() { - if (g_bShowLineNumbers) + if (Settings.ShowLineNumbers) { char chLines[32] = { '\0' }; StringCchPrintfA(chLines, COUNTOF(chLines), "_%td", (size_t)SciCall_GetLineCount()); @@ -8799,8 +8791,8 @@ void UpdateMarginWidth() SciCall_SetMarginWidthN(MARGIN_SCI_LINENUM, 0); } - Style_SetFolding(g_hwndEdit, (g_bCodeFoldingAvailable && g_bShowCodeFolding)); - Style_SetBookmark(g_hwndEdit, g_bShowSelectionMargin); + Style_SetFolding(Globals.hwndEdit, (g_bCodeFoldingAvailable && Settings.ShowCodeFolding)); + Style_SetBookmark(Globals.hwndEdit, Settings.ShowSelectionMargin); } @@ -8812,12 +8804,12 @@ void UpdateMarginWidth() // void UpdateSettingsCmds() { - HMENU hmenu = GetSystemMenu(g_hwndMain, false); - bool hasIniFile = (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)) > 0 || StringCchLenW(g_wchIniFile2,COUNTOF(g_wchIniFile2)) > 0); - CheckCmd(hmenu, IDM_VIEW_SAVESETTINGS, g_bSaveSettings && g_bEnableSaveSettings); - EnableCmd(hmenu, IDM_VIEW_SAVESETTINGS, hasIniFile && g_bEnableSaveSettings); - EnableCmd(hmenu, IDM_VIEW_SAVESETTINGSNOW, hasIniFile && g_bEnableSaveSettings); - if (SciCall_GetZoom() != 100) { EditShowZoomCallTip(g_hwndEdit); } + 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, s_bSaveSettings && s_bEnableSaveSettings); + EnableCmd(hmenu, IDM_VIEW_SAVESETTINGS, hasIniFile && s_bEnableSaveSettings); + EnableCmd(hmenu, IDM_VIEW_SAVESETTINGSNOW, hasIniFile && s_bEnableSaveSettings); + if (SciCall_GetZoom() != 100) { EditShowZoomCallTip(Globals.hwndEdit); } } @@ -8828,12 +8820,12 @@ void UpdateSettingsCmds() void UpdateUI() { struct SCNotification scn; - scn.nmhdr.hwndFrom = g_hwndEdit; + scn.nmhdr.hwndFrom = Globals.hwndEdit; scn.nmhdr.idFrom = IDC_EDIT; scn.nmhdr.code = SCN_UPDATEUI; scn.updated = (SC_UPDATE_CONTENT | SC_UPDATE_NP3_INTERNAL_NOTIFY); - SendMessage(g_hwndMain, WM_NOTIFY, IDC_EDIT, (LPARAM)&scn); - //PostMessage(g_hwndMain, WM_NOTIFY, IDC_EDIT, (LPARAM)&scn); + SendMessage(Globals.hwndMain, WM_NOTIFY, IDC_EDIT, (LPARAM)&scn); + //PostMessage(Globals.hwndMain, WM_NOTIFY, IDC_EDIT, (LPARAM)&scn); } @@ -8846,7 +8838,7 @@ static volatile LONG UndoActionToken = UNDOREDO_BLOCKED; // block //============================================================================= -static bool __fastcall _InUndoRedoTransaction() { +static bool _InUndoRedoTransaction() { return (InterlockedOr(&UndoActionToken, 0L) != UNDOREDO_FREE); } @@ -8883,28 +8875,28 @@ void UndoRedoRecordingStop() // _SaveUndoSelection() // // -static int __fastcall _SaveUndoSelection() +static int _SaveUndoSelection() { UndoRedoSelection_t sel = INIT_UNDOREDOSEL; - sel.selMode_undo = (int)SendMessage(g_hwndEdit, SCI_GETSELECTIONMODE, 0, 0); + sel.selMode_undo = (int)SendMessage(Globals.hwndEdit, SCI_GETSELECTIONMODE, 0, 0); switch (sel.selMode_undo) { case SC_SEL_RECTANGLE: case SC_SEL_THIN: - sel.anchorPos_undo = (DocPos)SendMessage(g_hwndEdit, SCI_GETRECTANGULARSELECTIONANCHOR, 0, 0); - sel.curPos_undo = (DocPos)SendMessage(g_hwndEdit, SCI_GETRECTANGULARSELECTIONCARET, 0, 0); - if (!g_bDenyVirtualSpaceAccess) { - sel.anchorVS_undo = (DocPos)SendMessage(g_hwndEdit, SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE, 0, 0); - sel.curVS_undo = (DocPos)SendMessage(g_hwndEdit, SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE, 0, 0); + sel.anchorPos_undo = (DocPos)SendMessage(Globals.hwndEdit, SCI_GETRECTANGULARSELECTIONANCHOR, 0, 0); + sel.curPos_undo = (DocPos)SendMessage(Globals.hwndEdit, SCI_GETRECTANGULARSELECTIONCARET, 0, 0); + if (!Settings2.DenyVirtualSpaceAccess) { + sel.anchorVS_undo = (DocPos)SendMessage(Globals.hwndEdit, SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE, 0, 0); + sel.curVS_undo = (DocPos)SendMessage(Globals.hwndEdit, SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE, 0, 0); } break; case SC_SEL_LINES: case SC_SEL_STREAM: default: - sel.anchorPos_undo = (DocPos)SendMessage(g_hwndEdit, SCI_GETANCHOR, 0, 0); - sel.curPos_undo = (DocPos)SendMessage(g_hwndEdit, SCI_GETCURRENTPOS, 0, 0); + sel.anchorPos_undo = (DocPos)SendMessage(Globals.hwndEdit, SCI_GETANCHOR, 0, 0); + sel.curPos_undo = (DocPos)SendMessage(Globals.hwndEdit, SCI_GETCURRENTPOS, 0, 0); break; } @@ -8923,31 +8915,31 @@ static int __fastcall _SaveUndoSelection() // _SaveRedoSelection() // // -static void __fastcall _SaveRedoSelection(int token) +static void _SaveRedoSelection(int token) { if (token >= 0) { UndoRedoSelection_t sel = INIT_UNDOREDOSEL; if (_UndoRedoActionMap(token, &sel) >= 0) { - sel.selMode_redo = (int)SendMessage(g_hwndEdit, SCI_GETSELECTIONMODE, 0, 0); + sel.selMode_redo = (int)SendMessage(Globals.hwndEdit, SCI_GETSELECTIONMODE, 0, 0); switch (sel.selMode_redo) { case SC_SEL_RECTANGLE: case SC_SEL_THIN: - sel.anchorPos_redo = (DocPos)SendMessage(g_hwndEdit, SCI_GETRECTANGULARSELECTIONANCHOR, 0, 0); - sel.curPos_redo = (DocPos)SendMessage(g_hwndEdit, SCI_GETRECTANGULARSELECTIONCARET, 0, 0); - if (!g_bDenyVirtualSpaceAccess) { - sel.anchorVS_redo = (DocPos)SendMessage(g_hwndEdit, SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE, 0, 0); + sel.anchorPos_redo = (DocPos)SendMessage(Globals.hwndEdit, SCI_GETRECTANGULARSELECTIONANCHOR, 0, 0); + sel.curPos_redo = (DocPos)SendMessage(Globals.hwndEdit, SCI_GETRECTANGULARSELECTIONCARET, 0, 0); + if (!Settings2.DenyVirtualSpaceAccess) { + sel.anchorVS_redo = (DocPos)SendMessage(Globals.hwndEdit, SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE, 0, 0); } break; case SC_SEL_LINES: case SC_SEL_STREAM: default: - sel.anchorPos_redo = (DocPos)SendMessage(g_hwndEdit, SCI_GETANCHOR, 0, 0); - sel.curPos_redo = (DocPos)SendMessage(g_hwndEdit, SCI_GETCURRENTPOS, 0, 0); + sel.anchorPos_redo = (DocPos)SendMessage(Globals.hwndEdit, SCI_GETANCHOR, 0, 0); + sel.curPos_redo = (DocPos)SendMessage(Globals.hwndEdit, SCI_GETCURRENTPOS, 0, 0); break; } @@ -9018,22 +9010,22 @@ void RestoreAction(int token, DoAction doAct) // This needs to be done _before_ the SCI_SETSEL message DocLn const anchorPosLine = SciCall_LineFromPosition(_anchorPos); DocLn const currPosLine = SciCall_LineFromPosition(_curPos); - ISSUE_MESSAGE(g_hwndEdit, SCI_ENSUREVISIBLE, anchorPosLine, 0); - if (anchorPosLine != currPosLine) { ISSUE_MESSAGE(g_hwndEdit, SCI_ENSUREVISIBLE, currPosLine, 0); } + ISSUE_MESSAGE(Globals.hwndEdit, SCI_ENSUREVISIBLE, anchorPosLine, 0); + if (anchorPosLine != currPosLine) { ISSUE_MESSAGE(Globals.hwndEdit, SCI_ENSUREVISIBLE, currPosLine, 0); } int const selectionMode = (doAct == UNDO ? sel.selMode_undo : sel.selMode_redo); - ISSUE_MESSAGE(g_hwndEdit, SCI_SETSELECTIONMODE, (WPARAM)selectionMode, 0); + ISSUE_MESSAGE(Globals.hwndEdit, SCI_SETSELECTIONMODE, (WPARAM)selectionMode, 0); // independent from selection mode - ISSUE_MESSAGE(g_hwndEdit, SCI_SETANCHOR, (WPARAM)_anchorPos, 0); - ISSUE_MESSAGE(g_hwndEdit, SCI_SETCURRENTPOS, (WPARAM)_curPos, 0); + ISSUE_MESSAGE(Globals.hwndEdit, SCI_SETANCHOR, (WPARAM)_anchorPos, 0); + ISSUE_MESSAGE(Globals.hwndEdit, SCI_SETCURRENTPOS, (WPARAM)_curPos, 0); switch (selectionMode) { case SC_SEL_RECTANGLE: - ISSUE_MESSAGE(g_hwndEdit, SCI_SETRECTANGULARSELECTIONANCHOR, (WPARAM)_anchorPos, 0); - ISSUE_MESSAGE(g_hwndEdit, SCI_SETRECTANGULARSELECTIONCARET, (WPARAM)_curPos, 0); + ISSUE_MESSAGE(Globals.hwndEdit, SCI_SETRECTANGULARSELECTIONANCHOR, (WPARAM)_anchorPos, 0); + ISSUE_MESSAGE(Globals.hwndEdit, SCI_SETRECTANGULARSELECTIONCARET, (WPARAM)_curPos, 0); // fall-through case SC_SEL_THIN: @@ -9041,8 +9033,8 @@ void RestoreAction(int token, DoAction doAct) DocPos const anchorVS = (doAct == UNDO ? sel.anchorVS_undo : sel.anchorVS_redo); DocPos const currVS = (doAct == UNDO ? sel.curVS_undo : sel.curVS_redo); if ((anchorVS != 0) || (currVS != 0)) { - ISSUE_MESSAGE(g_hwndEdit, SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE, (WPARAM)anchorVS, 0); - ISSUE_MESSAGE(g_hwndEdit, SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE, (WPARAM)currVS, 0); + ISSUE_MESSAGE(Globals.hwndEdit, SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE, (WPARAM)anchorVS, 0); + ISSUE_MESSAGE(Globals.hwndEdit, SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE, (WPARAM)currVS, 0); } } break; @@ -9053,9 +9045,9 @@ void RestoreAction(int token, DoAction doAct) // nothing to do here break; } - ISSUE_MESSAGE(g_hwndEdit, SCI_SCROLLCARET, 0, 0); - ISSUE_MESSAGE(g_hwndEdit, SCI_CHOOSECARETX, 0, 0); - ISSUE_MESSAGE(g_hwndEdit, SCI_CANCEL, 0, 0); + ISSUE_MESSAGE(Globals.hwndEdit, SCI_SCROLLCARET, 0, 0); + ISSUE_MESSAGE(Globals.hwndEdit, SCI_CHOOSECARETX, 0, 0); + ISSUE_MESSAGE(Globals.hwndEdit, SCI_CANCEL, 0, 0); #undef ISSUE_MASSAGE } @@ -9067,7 +9059,7 @@ void RestoreAction(int token, DoAction doAct) // _UndoSelectionMap() // // -static int __fastcall _UndoRedoActionMap(int token, UndoRedoSelection_t* const selection) +static int _UndoRedoActionMap(int token, UndoRedoSelection_t* const selection) { if (UndoRedoSelectionUTArray == NULL) { return -1; } @@ -9131,20 +9123,20 @@ bool FileIO(bool fLoad,LPWSTR pszFileName,bool bSkipUnicodeDetect,bool bSkipANSI BeginWaitCursor(tch); if (fLoad) { - fSuccess = EditLoadFile(g_hwndEdit,pszFileName,bSkipUnicodeDetect,bSkipANSICPDetection,ienc,ieol,pbUnicodeErr,pbFileTooBig,pbUnknownExt); + fSuccess = EditLoadFile(Globals.hwndEdit,pszFileName,bSkipUnicodeDetect,bSkipANSICPDetection,ienc,ieol,pbUnicodeErr,pbFileTooBig,pbUnknownExt); } else { int idx; - if (MRU_FindFile(g_pFileMRU,pszFileName,&idx)) { - g_pFileMRU->iEncoding[idx] = *ienc; - g_pFileMRU->iCaretPos[idx] = (g_bPreserveCaretPos ? SciCall_GetCurrentPos() : 0); + if (MRU_FindFile(Globals.pFileMRU,pszFileName,&idx)) { + Globals.pFileMRU->iEncoding[idx] = *ienc; + Globals.pFileMRU->iCaretPos[idx] = (Settings.PreserveCaretPos ? SciCall_GetCurrentPos() : 0); WCHAR wchBookMarks[MRU_BMRK_SIZE] = { L'\0' }; - EditGetBookmarkList(g_hwndEdit, wchBookMarks, COUNTOF(wchBookMarks)); - if (g_pFileMRU->pszBookMarks[idx]) - LocalFree(g_pFileMRU->pszBookMarks[idx]); // StrDup() - g_pFileMRU->pszBookMarks[idx] = StrDup(wchBookMarks); + EditGetBookmarkList(Globals.hwndEdit, wchBookMarks, COUNTOF(wchBookMarks)); + if (Globals.pFileMRU->pszBookMarks[idx]) + LocalFree(Globals.pFileMRU->pszBookMarks[idx]); // StrDup() + Globals.pFileMRU->pszBookMarks[idx] = StrDup(wchBookMarks); } - fSuccess = EditSaveFile(g_hwndEdit,pszFileName,*ienc,pbCancelDataLoss,bSaveCopy); + fSuccess = EditSaveFile(Globals.hwndEdit,pszFileName,*ienc,pbCancelDataLoss,bSaveCopy); } dwFileAttributes = GetFileAttributes(pszFileName); @@ -9172,8 +9164,8 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload, bool bSkipUnicodeDetect, int fileEncoding = CPI_ANSI_DEFAULT; if (bNew || bReload) { - if (EditToggleView(g_hwndEdit, false)) { - EditToggleView(g_hwndEdit, true); + if (EditToggleView(Globals.hwndEdit, false)) { + EditToggleView(Globals.hwndEdit, true); } } @@ -9186,20 +9178,20 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload, bool bSkipUnicodeDetect, if (!bReload) { ResetEncryption(); } if (bNew) { - StringCchCopy(g_wchCurFile,COUNTOF(g_wchCurFile),L""); - SetDlgItemText(g_hwndMain,IDC_FILENAME,g_wchCurFile); - SetDlgItemInt(g_hwndMain,IDC_REUSELOCK,GetTickCount(),false); + StringCchCopy(Globals.CurrentFile,COUNTOF(Globals.CurrentFile),L""); + SetDlgItemText(Globals.hwndMain,IDC_FILENAME,Globals.CurrentFile); + SetDlgItemInt(Globals.hwndMain,IDC_REUSELOCK,GetTickCount(),false); if (!fKeepTitleExcerpt) { StringCchCopy(szTitleExcerpt, COUNTOF(szTitleExcerpt), L""); } FileVars_Init(NULL,0,&fvCurFile); - EditSetNewText(g_hwndEdit, "", 0); + EditSetNewText(Globals.hwndEdit, "", 0); - g_iEOLMode = g_iDefaultEOLMode; - SendMessage(g_hwndEdit,SCI_SETEOLMODE,g_iEOLMode,0); - Encoding_Current(g_iDefaultNewFileEncoding); - Encoding_HasChanged(g_iDefaultNewFileEncoding); + Globals.iEOLMode = Settings.DefaultEOLMode; + SendMessage(Globals.hwndEdit,SCI_SETEOLMODE,Globals.iEOLMode,0); + Encoding_Current(Settings.DefaultEncoding); + Encoding_HasChanged(Settings.DefaultEncoding); - EditSetNewText(g_hwndEdit, "", 0); - Style_SetDefaultLexer(g_hwndEdit); + EditSetNewText(Globals.hwndEdit, "", 0); + Style_SetDefaultLexer(Globals.hwndEdit); g_bFileReadOnly = false; _SetDocumentModified(false); @@ -9209,20 +9201,20 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload, bool bSkipUnicodeDetect, UpdateMarginWidth(); // Terminate file watching - if (g_bResetFileWatching) { + if (Settings.ResetFileWatching) { if (g_bChasingDocTail) { - SendMessage(g_hwndMain, WM_COMMAND, MAKELONG(IDM_VIEW_CHASING_DOCTAIL, 1), 0); + SendMessage(Globals.hwndMain, WM_COMMAND, MAKELONG(IDM_VIEW_CHASING_DOCTAIL, 1), 0); } - g_iFileWatchingMode = 0; + Settings.FileWatchingMode = 0; } InstallFileWatching(NULL); - g_bEnableSaveSettings = true; + s_bEnableSaveSettings = true; UpdateSettingsCmds(); return true; } if (StrIsEmpty(lpszFile)) { - if (!OpenFileDlg(g_hwndMain,tch,COUNTOF(tch),NULL)) + if (!OpenFileDlg(Globals.hwndMain,tch,COUNTOF(tch),NULL)) return false; } else @@ -9231,7 +9223,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload, bool bSkipUnicodeDetect, ExpandEnvironmentStringsEx(tch,COUNTOF(tch)); if (PathIsRelative(tch)) { - StringCchCopyN(szFileName,COUNTOF(szFileName),g_wchWorkingDirectory,COUNTOF(g_wchWorkingDirectory)); + StringCchCopyN(szFileName,COUNTOF(szFileName),Globals.WorkingDirectory,COUNTOF(Globals.WorkingDirectory)); PathCchAppend(szFileName,COUNTOF(szFileName),tch); if (!PathFileExists(szFileName)) { WCHAR wchFullPath[MAX_PATH] = { L'\0' }; @@ -9259,29 +9251,29 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload, bool bSkipUnicodeDetect, // Ask to create a new file... if (!bReload && !PathFileExists(szFileName)) { - if (g_flagQuietCreate || MsgBoxLng(MBYESNO,IDS_MUI_ASK_CREATE,szFileName) == IDYES) { + if (s_flagQuietCreate || MsgBoxLng(MBYESNO,IDS_MUI_ASK_CREATE,szFileName) == IDYES) { HANDLE hFile = CreateFile(szFileName, GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL); - dwLastIOError = GetLastError(); + g_dwLastIOError = GetLastError(); fSuccess = (hFile != INVALID_HANDLE_VALUE); if (fSuccess) { FileVars_Init(NULL,0,&fvCurFile); - EditSetNewText(g_hwndEdit,"",0); - Style_SetDefaultLexer(g_hwndEdit); - g_iEOLMode = g_iDefaultEOLMode; - SendMessage(g_hwndEdit,SCI_SETEOLMODE,g_iEOLMode,0); + EditSetNewText(Globals.hwndEdit,"",0); + Style_SetDefaultLexer(Globals.hwndEdit); + Globals.iEOLMode = Settings.DefaultEOLMode; + SendMessage(Globals.hwndEdit,SCI_SETEOLMODE,Globals.iEOLMode,0); if (Encoding_SrcCmdLn(CPI_GET) != CPI_NONE) { fileEncoding = Encoding_SrcCmdLn(CPI_GET); Encoding_Current(fileEncoding); Encoding_HasChanged(fileEncoding); } else { - Encoding_Current(g_iDefaultNewFileEncoding); - Encoding_HasChanged(g_iDefaultNewFileEncoding); + Encoding_Current(Settings.DefaultEncoding); + Encoding_HasChanged(Settings.DefaultEncoding); } g_bFileReadOnly = false; - EditSetNewText(g_hwndEdit,"",0); + EditSetNewText(Globals.hwndEdit,"",0); } if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE)) { CloseHandle(hFile); @@ -9292,78 +9284,78 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload, bool bSkipUnicodeDetect, } else { int idx; - if (!bReload && MRU_FindFile(g_pFileMRU,szFileName,&idx)) { - fileEncoding = g_pFileMRU->iEncoding[idx]; + if (!bReload && MRU_FindFile(Globals.pFileMRU,szFileName,&idx)) { + fileEncoding = Globals.pFileMRU->iEncoding[idx]; if (fileEncoding > 0) Encoding_SrcCmdLn(Encoding_MapUnicode(fileEncoding)); } else fileEncoding = Encoding_Current(CPI_GET); - fSuccess = FileIO(true,szFileName,bSkipUnicodeDetect,bSkipANSICPDetection,&fileEncoding,&g_iEOLMode,&bUnicodeErr,&bFileTooBig,&bUnknownExt,NULL,false); + fSuccess = FileIO(true,szFileName,bSkipUnicodeDetect,bSkipANSICPDetection,&fileEncoding,&Globals.iEOLMode,&bUnicodeErr,&bFileTooBig,&bUnknownExt,NULL,false); if (fSuccess) Encoding_Current(fileEncoding); // load may change encoding } if (fSuccess) { - StringCchCopy(g_wchCurFile,COUNTOF(g_wchCurFile),szFileName); - SetDlgItemText(g_hwndMain,IDC_FILENAME,g_wchCurFile); - SetDlgItemInt(g_hwndMain,IDC_REUSELOCK,GetTickCount(),false); + StringCchCopy(Globals.CurrentFile,COUNTOF(Globals.CurrentFile),szFileName); + SetDlgItemText(Globals.hwndMain,IDC_FILENAME,Globals.CurrentFile); + SetDlgItemInt(Globals.hwndMain,IDC_REUSELOCK,GetTickCount(),false); if (!fKeepTitleExcerpt) StringCchCopy(szTitleExcerpt,COUNTOF(szTitleExcerpt),L""); - if (!g_flagLexerSpecified) // flag will be cleared - Style_SetLexerFromFile(g_hwndEdit,g_wchCurFile); + if (!s_flagLexerSpecified) // flag will be cleared + Style_SetLexerFromFile(Globals.hwndEdit,Globals.CurrentFile); - SendMessage(g_hwndEdit,SCI_SETEOLMODE,g_iEOLMode,0); + SendMessage(Globals.hwndEdit,SCI_SETEOLMODE,Globals.iEOLMode,0); fileEncoding = Encoding_Current(CPI_GET); Encoding_HasChanged(fileEncoding); int idx = 0; DocPos iCaretPos = 0; LPCWSTR pszBookMarks = L""; - if (!bReload && MRU_FindFile(g_pFileMRU,szFileName,&idx)) { - iCaretPos = g_pFileMRU->iCaretPos[idx]; - pszBookMarks = g_pFileMRU->pszBookMarks[idx]; + if (!bReload && MRU_FindFile(Globals.pFileMRU,szFileName,&idx)) { + iCaretPos = Globals.pFileMRU->iCaretPos[idx]; + pszBookMarks = Globals.pFileMRU->pszBookMarks[idx]; } - MRU_AddFile(g_pFileMRU,szFileName,g_flagRelativeFileMRU,g_flagPortableMyDocs,fileEncoding,iCaretPos,pszBookMarks); + MRU_AddFile(Globals.pFileMRU,szFileName,Flags.RelativeFileMRU,Flags.PortableMyDocs,fileEncoding,iCaretPos,pszBookMarks); - EditSetBookmarkList(g_hwndEdit, pszBookMarks); - SetFindPattern((g_pMRUfind ? g_pMRUfind->pszItems[0] : L"")); + EditSetBookmarkList(Globals.hwndEdit, pszBookMarks); + SetFindPattern((Globals.pMRUfind ? Globals.pMRUfind->pszItems[0] : L"")); - if (g_flagUseSystemMRU == 2) + if (Flags.ShellUseSystemMRU == 2) SHAddToRecentDocs(SHARD_PATHW,szFileName); // Install watching of the current file - if (!bReload && g_bResetFileWatching) { + if (!bReload && Settings.ResetFileWatching) { if (g_bChasingDocTail) { - SendMessage(g_hwndMain, WM_COMMAND, MAKELONG(IDM_VIEW_CHASING_DOCTAIL, 1), 0); + SendMessage(Globals.hwndMain, WM_COMMAND, MAKELONG(IDM_VIEW_CHASING_DOCTAIL, 1), 0); } - g_iFileWatchingMode = 0; + Settings.FileWatchingMode = 0; } - InstallFileWatching(g_wchCurFile); + InstallFileWatching(Globals.CurrentFile); // the .LOG feature ... if (SciCall_GetTextLength() >= 4) { char tchLog[6] = { '\0','\0','\0','\0','\0','\0' }; SciCall_GetText(5, tchLog); if (StringCchCompareXA(tchLog,".LOG") == 0) { - EditJumpTo(g_hwndEdit,-1,0); + EditJumpTo(Globals.hwndEdit,-1,0); _BEGIN_UNDO_ACTION_; - SendMessage(g_hwndEdit,SCI_NEWLINE,0,0); - SendMessage(g_hwndMain,WM_COMMAND,MAKELONG(IDM_EDIT_INSERT_SHORTDATE,1),0); - EditJumpTo(g_hwndEdit,-1,0); - SendMessage(g_hwndEdit,SCI_NEWLINE,0,0); + SendMessage(Globals.hwndEdit,SCI_NEWLINE,0,0); + SendMessage(Globals.hwndMain,WM_COMMAND,MAKELONG(IDM_EDIT_INSERT_SHORTDATE,1),0); + EditJumpTo(Globals.hwndEdit,-1,0); + SendMessage(Globals.hwndEdit,SCI_NEWLINE,0,0); _END_UNDO_ACTION_; - SendMessage(g_hwndEdit, SCI_DOCUMENTEND, 0, 0); - EditEnsureSelectionVisible(g_hwndEdit); + SendMessage(Globals.hwndEdit, SCI_DOCUMENTEND, 0, 0); + EditEnsureSelectionVisible(Globals.hwndEdit); } // set historic caret pos else if (iCaretPos > 0) { - SendMessage(g_hwndEdit, SCI_GOTOPOS, (WPARAM)iCaretPos, 0); + SendMessage(Globals.hwndEdit, SCI_GOTOPOS, (WPARAM)iCaretPos, 0); // adjust view const DocPos iCurPos = SciCall_GetCurrentPos(); - EditJumpTo(g_hwndEdit, SciCall_LineFromPosition(iCurPos) + 1, SciCall_GetColumn(iCurPos) + 1); + EditJumpTo(Globals.hwndEdit, SciCall_LineFromPosition(iCurPos) + 1, SciCall_GetColumn(iCurPos) + 1); } } @@ -9375,7 +9367,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload, bool bSkipUnicodeDetect, UpdateVisibleUrlHotspot(0); // consistent settings file handling (if loaded in editor) - g_bEnableSaveSettings = (StringCchCompareNIW(g_wchCurFile, COUNTOF(g_wchCurFile), g_wchIniFile, COUNTOF(g_wchIniFile)) == 0) ? false : true; + s_bEnableSaveSettings = (StringCchCompareNIW(Globals.CurrentFile, COUNTOF(Globals.CurrentFile), Globals.IniFile, COUNTOF(Globals.IniFile)) == 0) ? false : true; UpdateSettingsCmds(); // Show warning: Unicode file loaded as ANSI @@ -9422,9 +9414,9 @@ bool FileRevert(LPCWSTR szFileName, bool bIgnoreCmdLnEnc) if (FileLoad(true,false,true,false,true,tchFileName2)) { - if (bIsTail && g_iFileWatchingMode == 2) { - SendMessage(g_hwndEdit, SCI_DOCUMENTEND, 0, 0); - EditEnsureSelectionVisible(g_hwndEdit); + if (bIsTail && Settings.FileWatchingMode == 2) { + SendMessage(Globals.hwndEdit, SCI_DOCUMENTEND, 0, 0); + EditEnsureSelectionVisible(Globals.hwndEdit); } else if (SciCall_GetTextLength() >= 4) { @@ -9432,8 +9424,8 @@ bool FileRevert(LPCWSTR szFileName, bool bIgnoreCmdLnEnc) SciCall_GetText(5, tch); if (StringCchCompareXA(tch,".LOG") != 0) { SciCall_ClearSelections(); - //~EditSetSelectionEx(g_hwndEdit, iAnchorPos, iCurPos, vSpcAnchorPos, vSpcCaretPos); - EditJumpTo(g_hwndEdit, iCurrLine+1, iCurColumn+1); + //~EditSetSelectionEx(Globals.hwndEdit, iAnchorPos, iCurPos, vSpcAnchorPos, vSpcCaretPos); + EditJumpTo(Globals.hwndEdit, iCurrLine+1, iCurColumn+1); SciCall_EnsureVisible(iDocTopLine); const DocLn iNewTopLine = SciCall_GetFirstVisibleLine(); SciCall_LineScroll(0,iVisTopLine - iNewTopLine); @@ -9460,7 +9452,7 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy) bool bCancelDataLoss = false; bool bIsEmptyNewFile = false; - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile)) == 0) { + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile)) == 0) { const DocPos cchText = SciCall_GetTextLength(); if (cchText == 0) bIsEmptyNewFile = true; @@ -9475,14 +9467,14 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy) if (!bSaveAlways && (!IsDocumentModified && !Encoding_HasChanged(CPI_GET) || bIsEmptyNewFile) && !bSaveAs) { int idx; - if (MRU_FindFile(g_pFileMRU,g_wchCurFile,&idx)) { - g_pFileMRU->iEncoding[idx] = Encoding_Current(CPI_GET); - g_pFileMRU->iCaretPos[idx] = (g_bPreserveCaretPos) ? SciCall_GetCurrentPos() : 0; + if (MRU_FindFile(Globals.pFileMRU,Globals.CurrentFile,&idx)) { + Globals.pFileMRU->iEncoding[idx] = Encoding_Current(CPI_GET); + Globals.pFileMRU->iCaretPos[idx] = (Settings.PreserveCaretPos) ? SciCall_GetCurrentPos() : 0; WCHAR wchBookMarks[MRU_BMRK_SIZE] = { L'\0' }; - EditGetBookmarkList(g_hwndEdit, wchBookMarks, COUNTOF(wchBookMarks)); - if (g_pFileMRU->pszBookMarks[idx]) - LocalFree(g_pFileMRU->pszBookMarks[idx]); // StrDup() - g_pFileMRU->pszBookMarks[idx] = StrDup(wchBookMarks); + EditGetBookmarkList(Globals.hwndEdit, wchBookMarks, COUNTOF(wchBookMarks)); + if (Globals.pFileMRU->pszBookMarks[idx]) + LocalFree(Globals.pFileMRU->pszBookMarks[idx]); // StrDup() + Globals.pFileMRU->pszBookMarks[idx] = StrDup(wchBookMarks); } return true; } @@ -9491,8 +9483,8 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy) { // File or "Untitled" ... WCHAR tch[MAX_PATH] = { L'\0' }; - if (StringCchLenW(g_wchCurFile, COUNTOF(g_wchCurFile))) { - StringCchCopy(tch, COUNTOF(tch), g_wchCurFile); + if (StringCchLenW(Globals.CurrentFile, COUNTOF(Globals.CurrentFile))) { + StringCchCopy(tch, COUNTOF(tch), Globals.CurrentFile); } else { GetLngString(IDS_MUI_UNTITLED, tch, COUNTOF(tch)); @@ -9506,14 +9498,14 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy) } // Read only... - if (!bSaveAs && !bSaveCopy && StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) + if (!bSaveAs && !bSaveCopy && StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { - DWORD dwFileAttributes = GetFileAttributes(g_wchCurFile); + DWORD dwFileAttributes = GetFileAttributes(Globals.CurrentFile); if (dwFileAttributes != INVALID_FILE_ATTRIBUTES) g_bFileReadOnly = (dwFileAttributes & FILE_ATTRIBUTE_READONLY); if (g_bFileReadOnly) { UpdateToolbar(); - if (MsgBoxLng(MBYESNOWARN,IDS_MUI_READONLY_SAVE,g_wchCurFile) == IDYES) + if (MsgBoxLng(MBYESNOWARN,IDS_MUI_READONLY_SAVE,Globals.CurrentFile) == IDYES) bSaveAs = true; else return false; @@ -9521,36 +9513,36 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy) } // Save As... - if (bSaveAs || bSaveCopy || StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile)) == 0) + if (bSaveAs || bSaveCopy || StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile)) == 0) { WCHAR tchInitialDir[MAX_PATH] = { L'\0' }; - if (bSaveCopy && StringCchLenW(g_tchLastSaveCopyDir,COUNTOF(g_tchLastSaveCopyDir))) { - StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),g_tchLastSaveCopyDir); - StringCchCopy(tchFile,COUNTOF(tchFile),g_tchLastSaveCopyDir); - PathCchAppend(tchFile,COUNTOF(tchFile),PathFindFileName(g_wchCurFile)); + if (bSaveCopy && StringCchLenW(s_tchLastSaveCopyDir,COUNTOF(s_tchLastSaveCopyDir))) { + StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),s_tchLastSaveCopyDir); + StringCchCopy(tchFile,COUNTOF(tchFile),s_tchLastSaveCopyDir); + PathCchAppend(tchFile,COUNTOF(tchFile),PathFindFileName(Globals.CurrentFile)); } else - StringCchCopy(tchFile,COUNTOF(tchFile),g_wchCurFile); + StringCchCopy(tchFile,COUNTOF(tchFile),Globals.CurrentFile); - if (SaveFileDlg(g_hwndMain,tchFile,COUNTOF(tchFile),tchInitialDir)) + if (SaveFileDlg(Globals.hwndMain,tchFile,COUNTOF(tchFile),tchInitialDir)) { int fileEncoding = Encoding_Current(CPI_GET); - fSuccess = FileIO(false, tchFile, false, true, &fileEncoding, &g_iEOLMode, NULL, NULL, NULL, &bCancelDataLoss, bSaveCopy); + fSuccess = FileIO(false, tchFile, false, true, &fileEncoding, &Globals.iEOLMode, NULL, NULL, NULL, &bCancelDataLoss, bSaveCopy); //~if (fSuccess) Encoding_Current(fileEncoding); // save should not change encoding if (fSuccess) { if (!bSaveCopy) { - StringCchCopy(g_wchCurFile,COUNTOF(g_wchCurFile),tchFile); - SetDlgItemText(g_hwndMain,IDC_FILENAME,g_wchCurFile); - SetDlgItemInt(g_hwndMain,IDC_REUSELOCK,GetTickCount(),false); + StringCchCopy(Globals.CurrentFile,COUNTOF(Globals.CurrentFile),tchFile); + SetDlgItemText(Globals.hwndMain,IDC_FILENAME,Globals.CurrentFile); + SetDlgItemInt(Globals.hwndMain,IDC_REUSELOCK,GetTickCount(),false); if (!fKeepTitleExcerpt) StringCchCopy(szTitleExcerpt,COUNTOF(szTitleExcerpt),L""); - Style_SetLexerFromFile(g_hwndEdit,g_wchCurFile); + Style_SetLexerFromFile(Globals.hwndEdit,Globals.CurrentFile); } else { - StringCchCopy(g_tchLastSaveCopyDir,COUNTOF(g_tchLastSaveCopyDir),tchFile); - PathRemoveFileSpec(g_tchLastSaveCopyDir); + StringCchCopy(s_tchLastSaveCopyDir,COUNTOF(s_tchLastSaveCopyDir),tchFile); + PathRemoveFileSpec(s_tchLastSaveCopyDir); } } } @@ -9559,7 +9551,7 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy) } else { int fileEncoding = Encoding_Current(CPI_GET); - fSuccess = FileIO(false, g_wchCurFile, false, true, &fileEncoding, &g_iEOLMode, NULL, NULL, NULL, &bCancelDataLoss, false); + fSuccess = FileIO(false, Globals.CurrentFile, false, true, &fileEncoding, &Globals.iEOLMode, NULL, NULL, NULL, &bCancelDataLoss, false); //~if (fSuccess) Encoding_Current(fileEncoding); // save should not change encoding } @@ -9571,31 +9563,31 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy) Encoding_HasChanged(iCurrEnc); const DocPos iCaretPos = SciCall_GetCurrentPos(); WCHAR wchBookMarks[MRU_BMRK_SIZE] = { L'\0' }; - EditGetBookmarkList(g_hwndEdit, wchBookMarks, COUNTOF(wchBookMarks)); - MRU_AddFile(g_pFileMRU,g_wchCurFile,g_flagRelativeFileMRU,g_flagPortableMyDocs,iCurrEnc,iCaretPos,wchBookMarks); - if (g_flagUseSystemMRU == 2) { - SHAddToRecentDocs(SHARD_PATHW, g_wchCurFile); + EditGetBookmarkList(Globals.hwndEdit, wchBookMarks, COUNTOF(wchBookMarks)); + MRU_AddFile(Globals.pFileMRU,Globals.CurrentFile,Flags.RelativeFileMRU,Flags.PortableMyDocs,iCurrEnc,iCaretPos,wchBookMarks); + if (Flags.ShellUseSystemMRU == 2) { + SHAddToRecentDocs(SHARD_PATHW, Globals.CurrentFile); } _SetDocumentModified(false); // Install watching of the current file - if (bSaveAs && g_bResetFileWatching) { + if (bSaveAs && Settings.ResetFileWatching) { if (g_bChasingDocTail) { - SendMessage(g_hwndMain, WM_COMMAND, MAKELONG(IDM_VIEW_CHASING_DOCTAIL, 1), 0); + SendMessage(Globals.hwndMain, WM_COMMAND, MAKELONG(IDM_VIEW_CHASING_DOCTAIL, 1), 0); } - g_iFileWatchingMode = 0; + Settings.FileWatchingMode = 0; } - InstallFileWatching(g_wchCurFile); + InstallFileWatching(Globals.CurrentFile); } } else if (!bCancelDataLoss) { - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile)) > 0) { - StringCchCopy(tchFile,COUNTOF(tchFile),g_wchCurFile); - StringCchCopy(tchBase,COUNTOF(tchBase),g_wchCurFile); + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile)) > 0) { + StringCchCopy(tchFile,COUNTOF(tchFile),Globals.CurrentFile); + StringCchCopy(tchBase,COUNTOF(tchBase),Globals.CurrentFile); PathStripPath(tchBase); } - if (!flagIsElevated && dwLastIOError == ERROR_ACCESS_DENIED) { + if (!flagIsElevated && g_dwLastIOError == ERROR_ACCESS_DENIED) { if (IDYES == MsgBoxLng(MBYESNOWARN,IDS_MUI_ERR_ACCESSDENIED,tchFile)) { WCHAR lpTempPathBuffer[MAX_PATH]; WCHAR szTempFileName[MAX_PATH]; @@ -9603,7 +9595,7 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy) if (GetTempPath(MAX_PATH,lpTempPathBuffer) && GetTempFileName(lpTempPathBuffer,TEXT("NP3"),0,szTempFileName)) { int fileEncoding = Encoding_Current(CPI_GET); - if (FileIO(false,szTempFileName,false,true,&fileEncoding,&g_iEOLMode,NULL,NULL,NULL,&bCancelDataLoss,true)) { + if (FileIO(false,szTempFileName,false,true,&fileEncoding,&Globals.iEOLMode,NULL,NULL,NULL,&bCancelDataLoss,true)) { //~Encoding_Current(fileEncoding); // save should not change encoding WCHAR szArguments[2048] = { L'\0' }; LPWSTR lpCmdLine = GetCommandLine(); @@ -9614,7 +9606,7 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy) // remove relaunch elevated, we are doing this here already lpArgs = StrCutI(lpArgs,L"/u "); lpArgs = StrCutI(lpArgs,L"-u "); - WININFO wi = GetMyWindowPlacement(g_hwndMain,NULL); + WININFO wi = GetMyWindowPlacement(Globals.hwndMain,NULL); StringCchPrintf(szArguments,COUNTOF(szArguments), L"/pos %i,%i,%i,%i,%i /tmpfbuf=\"%s\" %s",wi.x,wi.y,wi.cx,wi.cy,wi.max,szTempFileName,lpArgs); if (StringCchLenW(tchFile,COUNTOF(tchFile))) { @@ -9622,12 +9614,12 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy) StringCchPrintf(szArguments,COUNTOF(szArguments),L"%s \"%s\"",szArguments,tchFile); } } - g_flagRelaunchElevated = 1; + s_flagRelaunchElevated = 1; if (RelaunchElevated(szArguments)) { // set no change and quit Encoding_HasChanged(Encoding_Current(CPI_GET)); _SetDocumentModified(false); - PostMessage(g_hwndMain,WM_CLOSE,0,0); + PostMessage(Globals.hwndMain,WM_CLOSE,0,0); } else { if (PathFileExists(szTempFileName)) { @@ -9647,7 +9639,7 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy) MsgBoxLng(MBWARN,IDS_MUI_ERR_SAVEFILE,tchFile); } } - //???EditEnsureSelectionVisible(g_hwndEdit); + //???EditEnsureSelectionVisible(Globals.hwndEdit); return(fSuccess); } @@ -9668,12 +9660,12 @@ bool OpenFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir) Style_GetOpenDlgFilterStr(s_szFilter,COUNTOF(s_szFilter)); if (!lpstrInitialDir) { - if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { - StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),g_wchCurFile); + if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { + StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),Globals.CurrentFile); PathRemoveFileSpec(tchInitialDir); } - else if (StringCchLenW(g_tchDefaultDir,COUNTOF(g_tchDefaultDir))) { - ExpandEnvironmentStrings(g_tchDefaultDir,tchInitialDir,COUNTOF(tchInitialDir)); + else if (StringCchLenW(Settings2.DefaultDirectory,COUNTOF(Settings2.DefaultDirectory))) { + ExpandEnvironmentStrings(Settings2.DefaultDirectory,tchInitialDir,COUNTOF(tchInitialDir)); if (PathIsRelative(tchInitialDir)) { WCHAR tchModule[MAX_PATH] = { L'\0' }; GetModuleFileName(NULL,tchModule,COUNTOF(tchModule)); @@ -9683,7 +9675,7 @@ bool OpenFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir) } } else - StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),g_wchWorkingDirectory); + StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),Globals.WorkingDirectory); } ZeroMemory(&ofn,sizeof(OPENFILENAME)); @@ -9696,7 +9688,7 @@ bool OpenFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir) ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | /* OFN_NOCHANGEDIR |*/ OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST | OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/; - ofn.lpstrDefExt = (StringCchLenW(g_tchDefaultExtension,COUNTOF(g_tchDefaultExtension))) ? g_tchDefaultExtension : NULL; + ofn.lpstrDefExt = (StringCchLenW(Settings2.DefaultExtension,COUNTOF(Settings2.DefaultExtension))) ? Settings2.DefaultExtension : NULL; if (GetOpenFileName(&ofn)) { StringCchCopyN(lpstrFile,cchFile,szFile,COUNTOF(szFile)); @@ -9724,12 +9716,12 @@ bool SaveFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir) if (StrIsNotEmpty(lpstrInitialDir)) StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),lpstrInitialDir); - else if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { - StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),g_wchCurFile); + else if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { + StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),Globals.CurrentFile); PathRemoveFileSpec(tchInitialDir); } - else if (StringCchLenW(g_tchDefaultDir,COUNTOF(g_tchDefaultDir))) { - ExpandEnvironmentStrings(g_tchDefaultDir,tchInitialDir,COUNTOF(tchInitialDir)); + else if (StringCchLenW(Settings2.DefaultDirectory,COUNTOF(Settings2.DefaultDirectory))) { + ExpandEnvironmentStrings(Settings2.DefaultDirectory,tchInitialDir,COUNTOF(tchInitialDir)); if (PathIsRelative(tchInitialDir)) { WCHAR tchModule[MAX_PATH] = { L'\0' }; GetModuleFileName(NULL,tchModule,COUNTOF(tchModule)); @@ -9739,7 +9731,7 @@ bool SaveFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir) } } else - StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),g_wchWorkingDirectory); + StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),Globals.WorkingDirectory); ZeroMemory(&ofn,sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); @@ -9751,7 +9743,7 @@ bool SaveFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir) ofn.Flags = OFN_HIDEREADONLY /*| OFN_NOCHANGEDIR*/ | /*OFN_NODEREFERENCELINKS |*/ OFN_OVERWRITEPROMPT | OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST; - ofn.lpstrDefExt = (StringCchLenW(g_tchDefaultExtension,COUNTOF(g_tchDefaultExtension))) ? g_tchDefaultExtension : NULL; + ofn.lpstrDefExt = (StringCchLenW(Settings2.DefaultExtension,COUNTOF(Settings2.DefaultExtension))) ? Settings2.DefaultExtension : NULL; if (GetSaveFileName(&ofn)) { StringCchCopyN(lpstrFile,cchFile,szNewFile,COUNTOF(szNewFile)); @@ -9824,37 +9816,37 @@ bool ActivatePrevInst() HWND hwnd = NULL; COPYDATASTRUCT cds; - if ((g_flagNoReuseWindow && !g_flagSingleFileInstance) || g_flagStartAsTrayIcon || g_flagNewFromClipboard || g_flagPasteBoard) + if ((Flags.NoReuseWindow && !Flags.SingleFileInstance) || s_flagStartAsTrayIcon || s_flagNewFromClipboard || s_flagPasteBoard) return(false); - if (g_flagSingleFileInstance && lpFileArg) { + if (Flags.SingleFileInstance && lpFileArg) { // Search working directory from second instance, first! // lpFileArg is at least MAX_PATH+4 WCHARS - WCHAR tchTmp[FILE_ARG_BUF] = { L'\0' }; + WCHAR tchTmp[(MAX_PATH+1)] = { L'\0' }; ExpandEnvironmentStringsEx(lpFileArg,(DWORD)SizeOfMem(lpFileArg)/sizeof(WCHAR)); if (PathIsRelative(lpFileArg)) { - StringCchCopyN(tchTmp,COUNTOF(tchTmp),g_wchWorkingDirectory,COUNTOF(g_wchWorkingDirectory)); + StringCchCopyN(tchTmp,COUNTOF(tchTmp),Globals.WorkingDirectory,COUNTOF(Globals.WorkingDirectory)); PathCchAppend(tchTmp,COUNTOF(tchTmp),lpFileArg); if (PathFileExists(tchTmp)) - StringCchCopy(lpFileArg,FILE_ARG_BUF,tchTmp); + StringCchCopy(lpFileArg,(MAX_PATH+1),tchTmp); else { if (SearchPath(NULL,lpFileArg,NULL,COUNTOF(tchTmp),tchTmp,NULL)) - StringCchCopy(lpFileArg,FILE_ARG_BUF,tchTmp); + StringCchCopy(lpFileArg,(MAX_PATH+1),tchTmp); else { - StringCchCopyN(tchTmp,COUNTOF(tchTmp),g_wchWorkingDirectory,COUNTOF(g_wchWorkingDirectory)); + StringCchCopyN(tchTmp,COUNTOF(tchTmp),Globals.WorkingDirectory,COUNTOF(Globals.WorkingDirectory)); PathCchAppend(tchTmp,COUNTOF(tchTmp),lpFileArg); - StringCchCopy(lpFileArg,FILE_ARG_BUF,tchTmp); + StringCchCopy(lpFileArg,(MAX_PATH+1),tchTmp); } } } else if (SearchPath(NULL,lpFileArg,NULL,COUNTOF(tchTmp),tchTmp,NULL)) - StringCchCopy(lpFileArg,FILE_ARG_BUF,tchTmp); + StringCchCopy(lpFileArg,(MAX_PATH+1),tchTmp); - NormalizePathEx(lpFileArg,FILE_ARG_BUF); + NormalizePathEx(lpFileArg,(MAX_PATH+1)); EnumWindows(EnumWndProc2,(LPARAM)&hwnd); @@ -9884,20 +9876,20 @@ bool ActivatePrevInst() params->flagFileSpecified = false; params->flagChangeNotify = 0; params->flagQuietCreate = false; - params->flagLexerSpecified = g_flagLexerSpecified; - if (g_flagLexerSpecified && lpSchemeArg) { + params->flagLexerSpecified = s_flagLexerSpecified; + if (s_flagLexerSpecified && lpSchemeArg) { StringCchCopy(StrEnd(¶ms->wchData,0)+1,(StringCchLen(lpSchemeArg,0)+1),lpSchemeArg); params->iInitialLexer = -1; } else params->iInitialLexer = iInitialLexer; - params->flagJumpTo = g_flagJumpTo; + params->flagJumpTo = s_flagJumpTo; params->iInitialLine = iInitialLine; params->iInitialColumn = iInitialColumn; params->iSrcEncoding = (lpEncodingArg) ? Encoding_MatchW(lpEncodingArg) : CPI_NONE; - params->flagSetEncoding = g_flagSetEncoding; - params->flagSetEOLMode = g_flagSetEOLMode; + params->flagSetEncoding = s_flagSetEncoding; + params->flagSetEOLMode = s_flagSetEOLMode; params->flagTitleExcerpt = 0; cds.dwData = DATA_NOTEPAD3_PARAMS; @@ -9921,7 +9913,7 @@ bool ActivatePrevInst() } } - if (g_flagNoReuseWindow) + if (Flags.NoReuseWindow) return(false); hwnd = NULL; @@ -9950,24 +9942,24 @@ bool ActivatePrevInst() { // Search working directory from second instance, first! // lpFileArg is at least MAX_PATH+4 WCHAR - WCHAR tchTmp[FILE_ARG_BUF] = { L'\0' }; + WCHAR tchTmp[(MAX_PATH+1)] = { L'\0' }; ExpandEnvironmentStringsEx(lpFileArg,(DWORD)SizeOfMem(lpFileArg)/sizeof(WCHAR)); if (PathIsRelative(lpFileArg)) { - StringCchCopyN(tchTmp,COUNTOF(tchTmp),g_wchWorkingDirectory,COUNTOF(g_wchWorkingDirectory)); + StringCchCopyN(tchTmp,COUNTOF(tchTmp),Globals.WorkingDirectory,COUNTOF(Globals.WorkingDirectory)); PathCchAppend(tchTmp,COUNTOF(tchTmp),lpFileArg); if (PathFileExists(tchTmp)) { - StringCchCopy(lpFileArg, FILE_ARG_BUF, tchTmp); + StringCchCopy(lpFileArg, (MAX_PATH+1), tchTmp); } else { if (SearchPath(NULL, lpFileArg, NULL, COUNTOF(tchTmp), tchTmp, NULL)) { - StringCchCopy(lpFileArg, FILE_ARG_BUF, tchTmp); + StringCchCopy(lpFileArg, (MAX_PATH+1), tchTmp); } } } else if (SearchPath(NULL, lpFileArg, NULL, COUNTOF(tchTmp), tchTmp, NULL)) { - StringCchCopy(lpFileArg, FILE_ARG_BUF, tchTmp); + StringCchCopy(lpFileArg, (MAX_PATH+1), tchTmp); } size_t cb = sizeof(np3params); @@ -9983,23 +9975,23 @@ bool ActivatePrevInst() LPnp3params params = AllocMem(cb, HEAP_ZERO_MEMORY); params->flagFileSpecified = true; StringCchCopy(¶ms->wchData, StringCchLenW(lpFileArg,0)+1,lpFileArg); - params->flagChangeNotify = g_flagChangeNotify; - params->flagQuietCreate = g_flagQuietCreate; - params->flagLexerSpecified = g_flagLexerSpecified; - if (g_flagLexerSpecified && lpSchemeArg) { + params->flagChangeNotify = s_flagChangeNotify; + params->flagQuietCreate = s_flagQuietCreate; + params->flagLexerSpecified = s_flagLexerSpecified; + if (s_flagLexerSpecified && lpSchemeArg) { StringCchCopy(StrEnd(¶ms->wchData,0)+1, StringCchLen(lpSchemeArg,0)+1,lpSchemeArg); params->iInitialLexer = -1; } else { params->iInitialLexer = iInitialLexer; } - params->flagJumpTo = g_flagJumpTo; + params->flagJumpTo = s_flagJumpTo; params->iInitialLine = iInitialLine; params->iInitialColumn = iInitialColumn; params->iSrcEncoding = (lpEncodingArg) ? Encoding_MatchW(lpEncodingArg) : CPI_NONE; - params->flagSetEncoding = g_flagSetEncoding; - params->flagSetEOLMode = g_flagSetEOLMode; + params->flagSetEncoding = s_flagSetEncoding; + params->flagSetEOLMode = s_flagSetEOLMode; if (cchTitleExcerpt) { StringCchCopy(StrEnd(¶ms->wchData,0)+1,cchTitleExcerpt+1,szTitleExcerpt); @@ -10036,7 +10028,7 @@ bool ActivatePrevInst() // bool RelaunchMultiInst() { - if (g_flagMultiFileArg == 2 && cFileList > 1) { + if (Flags.MultiFileArg == 2 && cFileList > 1) { LPWSTR lpCmdLineNew = StrDup(GetCommandLine()); size_t len = StringCchLen(lpCmdLineNew,0) + 1UL; @@ -10068,7 +10060,7 @@ bool RelaunchMultiInst() { PROCESS_INFORMATION pi; ZeroMemory(&pi,sizeof(PROCESS_INFORMATION)); - CreateProcess(NULL,lpCmdLineNew,NULL,NULL,false,0,NULL,g_wchWorkingDirectory,&si,&pi); + CreateProcess(NULL,lpCmdLineNew,NULL,NULL,false,0,NULL,Globals.WorkingDirectory,&si,&pi); } LocalFree(lpCmdLineNew); // StrDup() @@ -10097,7 +10089,7 @@ bool RelaunchElevated(LPWSTR lpArgs) { bool result = false; - if (!IsVista() || flagIsElevated || !g_flagRelaunchElevated || g_flagDisplayHelp) + if (!IsVista() || flagIsElevated || !s_flagRelaunchElevated || s_flagDisplayHelp) return result; STARTUPINFO si; @@ -10121,8 +10113,8 @@ bool RelaunchElevated(LPWSTR lpArgs) { StringCchCopy(szArguments,COUNTOF(szArguments),szArgs); } else { - if (StringCchLenW(g_wchIniFile,COUNTOF(g_wchIniFile)) > 0) - StringCchPrintf(szArguments,COUNTOF(szArguments),L"/f \"%s\" %s",g_wchIniFile,szArgs); + if (StringCchLenW(Globals.IniFile,COUNTOF(Globals.IniFile)) > 0) + StringCchPrintf(szArguments,COUNTOF(szArguments),L"/f \"%s\" %s",Globals.IniFile,szArgs); else StringCchCopy(szArguments,COUNTOF(szArguments),szArgs); } @@ -10136,7 +10128,7 @@ bool RelaunchElevated(LPWSTR lpArgs) { sei.lpVerb = L"runas"; sei.lpFile = lpExe; sei.lpParameters = szArguments; - sei.lpDirectory = g_wchWorkingDirectory; + sei.lpDirectory = Globals.WorkingDirectory; sei.nShow = si.wShowWindow ? si.wShowWindow : SW_SHOWNORMAL; result = ShellExecuteEx(&sei); } @@ -10162,15 +10154,15 @@ void SnapToWinInfoPos(HWND hwnd, const WININFO* const pWinInfo, bool bFullWorkAr if (bFullWorkArea) { if (s_bPrevFullWAFlag) { // snap to previous rect - bShowToolbar = s_bPrevShowToolbar; - bShowStatusbar = s_bPrevShowStatusbar; + Settings.ShowToolbar = s_bPrevShowToolbar; + Settings.ShowStatusbar = s_bPrevShowStatusbar; wndpl = s_wndplPrev; } else { GetWindowPlacement(hwnd, &s_wndplPrev); - s_bPrevShowToolbar = bShowToolbar; - s_bPrevShowStatusbar = bShowStatusbar; - bShowToolbar = bShowStatusbar = false; + s_bPrevShowToolbar = Settings.ShowToolbar; + s_bPrevShowStatusbar = Settings.ShowStatusbar; + Settings.ShowToolbar = Settings.ShowStatusbar = false; wndpl = WindowPlacementFromInfo(hwnd, NULL); } s_bPrevFullWAFlag = !s_bPrevFullWAFlag; @@ -10178,8 +10170,8 @@ void SnapToWinInfoPos(HWND hwnd, const WININFO* const pWinInfo, bool bFullWorkAr else { wndpl = WindowPlacementFromInfo(hwnd, pWinInfo); if (s_bPrevFullWAFlag) { - bShowToolbar = s_bPrevShowToolbar; - bShowStatusbar = s_bPrevShowStatusbar; + Settings.ShowToolbar = s_bPrevShowToolbar; + Settings.ShowStatusbar = s_bPrevShowStatusbar; } s_bPrevFullWAFlag = false; } @@ -10207,7 +10199,7 @@ void ShowNotifyIcon(HWND hwnd,bool bAdd) { static HICON hIcon = NULL; if (!hIcon) { - hIcon = LoadImage(g_hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, + hIcon = LoadImage(Globals.hInstance, MAKEINTRESOURCE(IDR_MAINWND), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); } NOTIFYICONDATA nid; @@ -10218,7 +10210,7 @@ void ShowNotifyIcon(HWND hwnd,bool bAdd) nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; nid.uCallbackMessage = WM_TRAYMESSAGE; nid.hIcon = hIcon; - StringCchCopy(nid.szTip,COUNTOF(nid.szTip), L"" APPNAME); + StringCchCopy(nid.szTip,COUNTOF(nid.szTip), MKWCS(APPNAME)); if(bAdd) Shell_NotifyIcon(NIM_ADD,&nid); @@ -10252,8 +10244,8 @@ void SetNotifyIconTitle(HWND hwnd) StringCchPrintf(tchTitle,COUNTOF(tchTitle),tchFormat,szTitleExcerpt); } - else if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) { - SHGetFileInfo2(g_wchCurFile,FILE_ATTRIBUTE_NORMAL, + else if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { + SHGetFileInfo2(Globals.CurrentFile,FILE_ATTRIBUTE_NORMAL, &shfi,sizeof(SHFILEINFO),SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES); PathCompactPathEx(tchTitle,shfi.szDisplayName,COUNTOF(tchTitle)-4,0); } @@ -10283,7 +10275,7 @@ void InstallFileWatching(LPCWSTR lpszFile) HANDLE hFind; // Terminate - if (!g_iFileWatchingMode || !lpszFile || StringCchLen(lpszFile,MAX_PATH) == 0) + if (!Settings.FileWatchingMode || !lpszFile || StringCchLen(lpszFile,MAX_PATH) == 0) { if (g_bRunningWatch) { @@ -10309,13 +10301,13 @@ void InstallFileWatching(LPCWSTR lpszFile) // No previous watching installed, so launch the timer first else - SetTimer(NULL,ID_WATCHTIMER,dwFileCheckInverval,WatchTimerProc); + SetTimer(NULL,ID_WATCHTIMER,Settings2.FileCheckInverval,WatchTimerProc); StringCchCopy(tchDirectory,COUNTOF(tchDirectory),lpszFile); PathRemoveFileSpec(tchDirectory); // Save data of current file - hFind = FindFirstFile(g_wchCurFile,&fdCurFile); + hFind = FindFirstFile(Globals.CurrentFile,&fdCurFile); if (hFind != INVALID_HANDLE_VALUE) FindClose(hFind); else @@ -10344,7 +10336,7 @@ void CALLBACK WatchTimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) { if (g_bRunningWatch) { - if (dwChangeNotifyTime > 0 && GetTickCount() - dwChangeNotifyTime > dwAutoReloadTimeout) + if (dwChangeNotifyTime > 0 && GetTickCount() - dwChangeNotifyTime > Settings2.AutoReloadTimeout) { if (hChangeHandle) { FindCloseChangeNotification(hChangeHandle); @@ -10353,7 +10345,7 @@ void CALLBACK WatchTimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) KillTimer(NULL,ID_WATCHTIMER); g_bRunningWatch = false; dwChangeNotifyTime = 0; - SendMessage(g_hwndMain,WM_CHANGENOTIFY,0,0); + SendMessage(Globals.hwndMain,WM_CHANGENOTIFY,0,0); } // Check Change Notification Handle @@ -10361,7 +10353,7 @@ void CALLBACK WatchTimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) { // Check if the changes affect the current file WIN32_FIND_DATA fdUpdated; - HANDLE hFind = FindFirstFile(g_wchCurFile,&fdUpdated); + HANDLE hFind = FindFirstFile(Globals.CurrentFile,&fdUpdated); if (INVALID_HANDLE_VALUE != hFind) FindClose(hFind); else @@ -10378,7 +10370,7 @@ void CALLBACK WatchTimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) FindCloseChangeNotification(hChangeHandle); hChangeHandle = NULL; } - if (g_iFileWatchingMode == 2) { + if (Settings.FileWatchingMode == 2) { g_bRunningWatch = true; /* ! */ dwChangeNotifyTime = GetTickCount(); } @@ -10386,7 +10378,7 @@ void CALLBACK WatchTimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) KillTimer(NULL,ID_WATCHTIMER); g_bRunningWatch = false; dwChangeNotifyTime = 0; - SendMessage(g_hwndMain,WM_CHANGENOTIFY,0,0); + SendMessage(Globals.hwndMain,WM_CHANGENOTIFY,0,0); } } @@ -10411,20 +10403,20 @@ void CALLBACK PasteBoardTimer(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) { if ((dwLastCopyTime > 0) && ((GetTickCount() - dwLastCopyTime) > 200)) { - if (SendMessage(g_hwndEdit,SCI_CANPASTE,0,0)) { + if (SendMessage(Globals.hwndEdit,SCI_CANPASTE,0,0)) { - bool bAutoIndent2 = bAutoIndent; - bAutoIndent = 0; - EditJumpTo(g_hwndEdit,-1,0); + bool bAutoIndent2 = Settings.AutoIndent; + Settings.AutoIndent = 0; + EditJumpTo(Globals.hwndEdit,-1,0); _BEGIN_UNDO_ACTION_; - if (SendMessage(g_hwndEdit, SCI_GETLENGTH, 0, 0) > 0) { - SendMessage(g_hwndEdit, SCI_NEWLINE, 0, 0); + if (SendMessage(Globals.hwndEdit, SCI_GETLENGTH, 0, 0) > 0) { + SendMessage(Globals.hwndEdit, SCI_NEWLINE, 0, 0); } - SendMessage(g_hwndEdit,SCI_PASTE,0,0); - SendMessage(g_hwndEdit,SCI_NEWLINE,0,0); + SendMessage(Globals.hwndEdit,SCI_PASTE,0,0); + SendMessage(Globals.hwndEdit,SCI_NEWLINE,0,0); _END_UNDO_ACTION_; - EditEnsureSelectionVisible(g_hwndEdit); - bAutoIndent = bAutoIndent2; + EditEnsureSelectionVisible(Globals.hwndEdit); + Settings.AutoIndent = bAutoIndent2; } dwLastCopyTime = 0; } @@ -10435,6 +10427,4 @@ void CALLBACK PasteBoardTimer(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) UNUSED(hwnd); } - - /// End of Notepad3.c \\\ diff --git a/src/Print.cpp b/src/Print.cpp index c54c181d1..79ddf6881 100644 --- a/src/Print.cpp +++ b/src/Print.cpp @@ -42,24 +42,12 @@ extern "C" { #include "dialogs.h" #include "helpers.h" +#include "TypeDefs.h" } -extern "C" HINSTANCE g_hInstance; -extern "C" HMODULE g_hLngResContainer; -extern "C" HICON g_hDlgIcon; - -extern "C" HWND g_hwndEdit; // Global settings... -extern "C" int iPrintHeader; -extern "C" int iPrintFooter; -extern "C" int iPrintColor; -extern "C" int iPrintZoom; -extern "C" RECT pagesetupMargin; -extern "C" int g_flagPrintFileAndLeave; - -extern "C" HWND g_hwndStatus; - +extern "C" SETTINGS_T Settings; // Stored objects... HGLOBAL hDevMode = nullptr; @@ -77,11 +65,11 @@ void StatusUpdatePrintPage(int iPageNum) FormatLngStringW(tch,COUNTOF(tch),IDS_MUI_PRINTFILE,iPageNum); - StatusSetText(g_hwndStatus,255,tch); - StatusSetSimple(g_hwndStatus,true); + StatusSetText(Globals.hwndStatus,255,tch); + StatusSetSimple(Globals.hwndStatus,true); - InvalidateRect(g_hwndStatus,nullptr,true); - UpdateWindow(g_hwndStatus); + InvalidateRect(Globals.hwndStatus,nullptr,true); + UpdateWindow(Globals.hwndStatus); } @@ -136,7 +124,7 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) PRINTDLG pdlg = { sizeof(PRINTDLG), nullptr, nullptr, nullptr, nullptr, 0, 0, 0, 0, 0, 0, nullptr, 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }; pdlg.hwndOwner = GetParent(hwnd); - pdlg.hInstance = g_hInstance; + pdlg.hInstance = Globals.hInstance; pdlg.Flags = PD_USEDEVMODECOPIES | PD_ALLPAGES | PD_RETURNDC; pdlg.nFromPage = 1; pdlg.nToPage = 1; @@ -157,7 +145,7 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) } // |= 0 - Don't display dialog box, just use the default printer and options - pdlg.Flags |= (g_flagPrintFileAndLeave == 1) ? PD_RETURNDEFAULT : 0; + pdlg.Flags |= (Flags.PrintFileAndLeave == 1) ? PD_RETURNDEFAULT : 0; if (!PrintDlg(&pdlg)) { return true; // False means error... @@ -198,8 +186,8 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) EditPrintInit(); // Take in account the page setup given by the user (if one value is not null) - if (pagesetupMargin.left != 0 || pagesetupMargin.right != 0 || - pagesetupMargin.top != 0 || pagesetupMargin.bottom != 0) { + if (Settings.PrintMargin.left != 0 || Settings.PrintMargin.right != 0 || + Settings.PrintMargin.top != 0 || Settings.PrintMargin.bottom != 0) { // Convert the hundredths of millimeters (HiMetric) or // thousandths of inches (HiEnglish) margin values @@ -210,15 +198,15 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, localeInfo, 3); if (localeInfo[0] == L'0') { // Metric system. L'1' is US System - rectSetup.left = MulDiv (pagesetupMargin.left, ptDpi.x, 2540); - rectSetup.top = MulDiv (pagesetupMargin.top, ptDpi.y, 2540); - rectSetup.right = MulDiv(pagesetupMargin.right, ptDpi.x, 2540); - rectSetup.bottom = MulDiv(pagesetupMargin.bottom, ptDpi.y, 2540); + rectSetup.left = MulDiv (Settings.PrintMargin.left, ptDpi.x, 2540); + rectSetup.top = MulDiv (Settings.PrintMargin.top, ptDpi.y, 2540); + rectSetup.right = MulDiv(Settings.PrintMargin.right, ptDpi.x, 2540); + rectSetup.bottom = MulDiv(Settings.PrintMargin.bottom, ptDpi.y, 2540); } else { - rectSetup.left = MulDiv(pagesetupMargin.left, ptDpi.x, 1000); - rectSetup.top = MulDiv(pagesetupMargin.top, ptDpi.y, 1000); - rectSetup.right = MulDiv(pagesetupMargin.right, ptDpi.x, 1000); - rectSetup.bottom = MulDiv(pagesetupMargin.bottom, ptDpi.y, 1000); + rectSetup.left = MulDiv(Settings.PrintMargin.left, ptDpi.x, 1000); + rectSetup.top = MulDiv(Settings.PrintMargin.top, ptDpi.y, 1000); + rectSetup.right = MulDiv(Settings.PrintMargin.right, ptDpi.x, 1000); + rectSetup.bottom = MulDiv(Settings.PrintMargin.bottom, ptDpi.y, 1000); } // Dont reduce margins below the minimum printable area @@ -256,7 +244,7 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) GetTextMetrics(hdc, &tm); headerLineHeight = tm.tmHeight + tm.tmExternalLeading; - if (iPrintHeader == 3) + if (Settings.PrintHeader == 3) headerLineHeight = 0; footerLineHeight = MulDiv(7,ptDpi.y, 72); @@ -272,7 +260,7 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) GetTextMetrics(hdc, &tm); footerLineHeight = tm.tmHeight + tm.tmExternalLeading; - if (iPrintFooter == 1) + if (Settings.PrintFooter == 1) footerLineHeight = 0; di.lpszDocName = pszDocTitle; @@ -294,7 +282,7 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&st,nullptr,dateString,MIDSZ_BUFFER); // Get current time... - if (iPrintHeader == 0) + if (Settings.PrintHeader == 0) { WCHAR timeString[SMALL_BUFFER] = { L'\0' }; GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&st,nullptr,timeString,SMALL_BUFFER); @@ -311,10 +299,10 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) SC_PRINT_COLOURONWHITEDEFAULTBG, SC_PRINT_SCREENCOLOURS }; - SendMessage(hwnd,SCI_SETPRINTCOLOURMODE,printColorModes[iPrintColor],0); + SendMessage(hwnd,SCI_SETPRINTCOLOURMODE,printColorModes[Settings.PrintColorMode],0); // Set print zoom... - SendMessage(hwnd,SCI_SETPRINTMAGNIFICATION,(WPARAM)iPrintZoom,0); + SendMessage(hwnd,SCI_SETPRINTMAGNIFICATION,(WPARAM)Settings.PrintZoom,0); lengthDoc = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0); lengthDocMax = lengthDoc; @@ -361,7 +349,7 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) if (printPage) { // Show wait cursor... - SendMessage(g_hwndEdit, SCI_SETCURSOR, (WPARAM)SC_CURSORWAIT, 0); + SendMessage(Globals.hwndEdit, SCI_SETCURSOR, (WPARAM)SC_CURSORWAIT, 0); // Display current page number in Statusbar StatusUpdatePrintPage(pageNum); @@ -376,7 +364,7 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) frPrint.rc.right, frPrint.rc.top - headerLineHeight / 2}; rcw.bottom = rcw.top + headerLineHeight; - if (iPrintHeader < 3) + if (Settings.PrintHeader < 3) { ExtTextOut(hdc, frPrint.rc.left + 5, frPrint.rc.top - headerLineHeight / 2, /*ETO_OPAQUE*/0, &rcw, pszDocTitle, @@ -384,7 +372,7 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) } // Print date in header - if (iPrintHeader == 0 || iPrintHeader == 1) + if (Settings.PrintHeader == 0 || Settings.PrintHeader == 1) { SIZE sizeInfo; SelectObject(hdc,fontFooter); @@ -394,7 +382,7 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) (UINT)StringCchLenW(dateString,COUNTOF(dateString)), nullptr); } - if (iPrintHeader < 3) + if (Settings.PrintHeader < 3) { SetTextAlign(hdc, ta); pen = CreatePen(0, 1, RGB(0,0,0)); @@ -419,7 +407,7 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) RECT rcw = {frPrint.rc.left, frPrint.rc.bottom + footerLineHeight / 2, frPrint.rc.right, frPrint.rc.bottom + footerLineHeight + footerLineHeight / 2}; - if (iPrintFooter == 0) + if (Settings.PrintFooter == 0) { SIZE sizeFooter; GetTextExtentPoint32(hdc,pageString,(int)StringCchLenW(pageString,COUNTOF(pageString)),&sizeFooter); @@ -455,10 +443,10 @@ extern "C" bool EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat) DeleteObject(fontFooter); // Reset Statusbar to default mode - StatusSetSimple(g_hwndStatus,false); + StatusSetSimple(Globals.hwndStatus,false); // Remove wait cursor... - { POINT pt; SendMessage(g_hwndEdit, SCI_SETCURSOR, (WPARAM)SC_CURSORNORMAL, 0); GetCursorPos(&pt); SetCursorPos(pt.x, pt.y); } + { POINT pt; SendMessage(Globals.hwndEdit, SCI_SETCURSOR, (WPARAM)SC_CURSORNORMAL, 0); GetCursorPos(&pt); SetCursorPos(pt.x, pt.y); } return true; } @@ -483,14 +471,14 @@ extern "C" UINT_PTR CALLBACK PageSetupHook(HWND hwnd, UINT uiMsg, WPARAM wParam, WCHAR tch[512]; WCHAR *p1,*p2; - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } SendDlgItemMessage(hwnd,30,EM_LIMITTEXT,32,0); UDACCEL const acc[1] = { { 0, 10 } }; SendDlgItemMessage(hwnd,31,UDM_SETACCEL,1,(WPARAM)acc); SendDlgItemMessage(hwnd,31,UDM_SETRANGE32,SC_MIN_ZOOM_LEVEL,SC_MAX_ZOOM_LEVEL); - SendDlgItemMessage(hwnd,31,UDM_SETPOS32,0,iPrintZoom); + SendDlgItemMessage(hwnd,31,UDM_SETPOS32,0,Settings.PrintZoom); // Set header options GetLngString(IDS_MUI_PRINT_HEADER,tch,COUNTOF(tch)); @@ -504,7 +492,7 @@ extern "C" UINT_PTR CALLBACK PageSetupHook(HWND hwnd, UINT uiMsg, WPARAM wParam, p1 = p2; p2 = StrChr(p1, L'|'); // next } - SendDlgItemMessage(hwnd,32,CB_SETCURSEL,(WPARAM)iPrintHeader,0); + SendDlgItemMessage(hwnd,32,CB_SETCURSEL,(WPARAM)Settings.PrintHeader,0); // Set footer options GetLngString(IDS_MUI_PRINT_FOOTER,tch,COUNTOF(tch)); @@ -518,7 +506,7 @@ extern "C" UINT_PTR CALLBACK PageSetupHook(HWND hwnd, UINT uiMsg, WPARAM wParam, p1 = p2; p2 = StrChr(p1, L'|'); // next } - SendDlgItemMessage(hwnd,33,CB_SETCURSEL,(WPARAM)iPrintFooter,0); + SendDlgItemMessage(hwnd,33,CB_SETCURSEL,(WPARAM)Settings.PrintFooter,0); // Set color options GetLngString(IDS_MUI_PRINT_COLOR,tch,COUNTOF(tch)); @@ -532,7 +520,7 @@ extern "C" UINT_PTR CALLBACK PageSetupHook(HWND hwnd, UINT uiMsg, WPARAM wParam, p1 = p2; p2 = StrChr(p1, L'|'); // next } - SendDlgItemMessage(hwnd,34,CB_SETCURSEL,(LPARAM)iPrintColor,0); + SendDlgItemMessage(hwnd,34,CB_SETCURSEL,(LPARAM)Settings.PrintColorMode,0); // Make combos handier SendDlgItemMessage(hwnd,32,CB_SETEXTENDEDUI,true,0); @@ -548,11 +536,11 @@ extern "C" UINT_PTR CALLBACK PageSetupHook(HWND hwnd, UINT uiMsg, WPARAM wParam, { BOOL bError = FALSE; int const iPos = (int)SendDlgItemMessage(hwnd,31,UDM_GETPOS32,0,(LPARAM)&bError); - iPrintZoom = bError ? 100 : iPos; + Settings.PrintZoom = bError ? 100 : iPos; - iPrintHeader = (int)SendDlgItemMessage(hwnd, 32, CB_GETCURSEL, 0, 0); - iPrintFooter = (int)SendDlgItemMessage(hwnd, 33, CB_GETCURSEL, 0, 0); - iPrintColor = (int)SendDlgItemMessage(hwnd, 34, CB_GETCURSEL, 0, 0); + Settings.PrintHeader = (int)SendDlgItemMessage(hwnd, 32, CB_GETCURSEL, 0, 0); + Settings.PrintFooter = (int)SendDlgItemMessage(hwnd, 33, CB_GETCURSEL, 0, 0); + Settings.PrintColorMode = (int)SendDlgItemMessage(hwnd, 34, CB_GETCURSEL, 0, 0); } else if (LOWORD(wParam) == IDC_PRINTER) { @@ -572,7 +560,7 @@ extern "C" UINT_PTR CALLBACK PageSetupHook(HWND hwnd, UINT uiMsg, WPARAM wParam, extern "C" void EditPrintSetup(HWND hwnd) { - DLGTEMPLATE* pDlgTemplate = LoadThemedDialogTemplate(MAKEINTRESOURCE(IDD_MUI_PAGESETUP),g_hLngResContainer); + DLGTEMPLATE* pDlgTemplate = LoadThemedDialogTemplate(MAKEINTRESOURCE(IDD_MUI_PAGESETUP),Globals.hLngResContainer); PAGESETUPDLG pdlg; ZeroMemory(&pdlg,sizeof(PAGESETUPDLG)); @@ -581,18 +569,18 @@ extern "C" void EditPrintSetup(HWND hwnd) pdlg.lpfnPageSetupHook = PageSetupHook; pdlg.hPageSetupTemplate = pDlgTemplate; pdlg.hwndOwner = GetParent(hwnd); - pdlg.hInstance = g_hInstance; + pdlg.hInstance = Globals.hInstance; EditPrintInit(); - if (pagesetupMargin.left != 0 || pagesetupMargin.right != 0 || - pagesetupMargin.top != 0 || pagesetupMargin.bottom != 0) { + if (Settings.PrintMargin.left != 0 || Settings.PrintMargin.right != 0 || + Settings.PrintMargin.top != 0 || Settings.PrintMargin.bottom != 0) { pdlg.Flags |= PSD_MARGINS; - pdlg.rtMargin.left = pagesetupMargin.left; - pdlg.rtMargin.top = pagesetupMargin.top; - pdlg.rtMargin.right = pagesetupMargin.right; - pdlg.rtMargin.bottom = pagesetupMargin.bottom; + pdlg.rtMargin.left = Settings.PrintMargin.left; + pdlg.rtMargin.top = Settings.PrintMargin.top; + pdlg.rtMargin.right = Settings.PrintMargin.right; + pdlg.rtMargin.bottom = Settings.PrintMargin.bottom; } pdlg.hDevMode = hDevMode; @@ -600,10 +588,10 @@ extern "C" void EditPrintSetup(HWND hwnd) if (PageSetupDlg(&pdlg)) { - pagesetupMargin.left = pdlg.rtMargin.left; - pagesetupMargin.top = pdlg.rtMargin.top; - pagesetupMargin.right = pdlg.rtMargin.right; - pagesetupMargin.bottom = pdlg.rtMargin.bottom; + Settings.PrintMargin.left = pdlg.rtMargin.left; + Settings.PrintMargin.top = pdlg.rtMargin.top; + Settings.PrintMargin.right = pdlg.rtMargin.right; + Settings.PrintMargin.bottom = pdlg.rtMargin.bottom; hDevMode = pdlg.hDevMode; hDevNames = pdlg.hDevNames; @@ -619,23 +607,23 @@ extern "C" void EditPrintSetup(HWND hwnd) // static void EditPrintInit() { - if (pagesetupMargin.left == -1 || pagesetupMargin.top == -1 || - pagesetupMargin.right == -1 || pagesetupMargin.bottom == -1) + if (Settings.PrintMargin.left == -1 || Settings.PrintMargin.top == -1 || + Settings.PrintMargin.right == -1 || Settings.PrintMargin.bottom == -1) { WCHAR localeInfo[3]; GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, localeInfo, 3); if (localeInfo[0] == L'0') { // Metric system. L'1' is US System - pagesetupMargin.left = 2000; - pagesetupMargin.top = 2000; - pagesetupMargin.right = 2000; - pagesetupMargin.bottom = 2000; } + Settings.PrintMargin.left = 2000; + Settings.PrintMargin.top = 2000; + Settings.PrintMargin.right = 2000; + Settings.PrintMargin.bottom = 2000; } else { - pagesetupMargin.left = 1000; - pagesetupMargin.top = 1000; - pagesetupMargin.right = 1000; - pagesetupMargin.bottom = 1000; } + Settings.PrintMargin.left = 1000; + Settings.PrintMargin.top = 1000; + Settings.PrintMargin.right = 1000; + Settings.PrintMargin.bottom = 1000; } } } diff --git a/src/SciCall.h b/src/SciCall.h index af4a0b406..7a405349a 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -56,20 +56,17 @@ #include "Scintilla.h" #include "TypeDefs.h" -extern HANDLE g_hScintilla; -extern HANDLE g_hwndEdit; - //============================================================================= // // Sci_SendMessage() short version // -#define Sci_SendMsgV0(CMD) SendMessage(g_hwndEdit, SCI_##CMD, (WPARAM)0, (LPARAM)0) -#define Sci_SendMsgV1(CMD,WP) SendMessage(g_hwndEdit, SCI_##CMD, (WPARAM)(WP), (LPARAM)0) -#define Sci_SendMsgV2(CMD,WP,LP) SendMessage(g_hwndEdit, SCI_##CMD, (WPARAM)(WP), (LPARAM)(LP)) +#define Sci_SendMsgV0(CMD) SendMessage(Globals.hwndEdit, SCI_##CMD, (WPARAM)0, (LPARAM)0) +#define Sci_SendMsgV1(CMD,WP) SendMessage(Globals.hwndEdit, SCI_##CMD, (WPARAM)(WP), (LPARAM)0) +#define Sci_SendMsgV2(CMD,WP,LP) SendMessage(Globals.hwndEdit, SCI_##CMD, (WPARAM)(WP), (LPARAM)(LP)) -#define Sci_PostMsgV0(CMD) PostMessage(g_hwndEdit, SCI_##CMD, (WPARAM)0, (LPARAM)0) -#define Sci_PostMsgV1(CMD,WP) PostMessage(g_hwndEdit, SCI_##CMD, (WPARAM)(WP), (LPARAM)0) -#define Sci_PostMsgV2(CMD,WP,LP) PostMessage(g_hwndEdit, SCI_##CMD, (WPARAM)(WP), (LPARAM)(LP)) +#define Sci_PostMsgV0(CMD) PostMessage(Globals.hwndEdit, SCI_##CMD, (WPARAM)0, (LPARAM)0) +#define Sci_PostMsgV1(CMD,WP) PostMessage(Globals.hwndEdit, SCI_##CMD, (WPARAM)(WP), (LPARAM)0) +#define Sci_PostMsgV2(CMD,WP,LP) PostMessage(Globals.hwndEdit, SCI_##CMD, (WPARAM)(WP), (LPARAM)(LP)) //============================================================================= // @@ -78,11 +75,11 @@ extern HANDLE g_hwndEdit; #ifdef SCI_DIRECTFUNCTION_INTERFACE LRESULT WINAPI Scintilla_DirectFunction(HANDLE, UINT, WPARAM, LPARAM); -#define SciCall(m, w, l) Scintilla_DirectFunction(g_hScintilla, (m), (w), (l)) +#define SciCall(m, w, l) Scintilla_DirectFunction(Globals.hndlScintilla, (m), (w), (l)) #else -#define SciCall(m, w, l) SendMessage(g_hwndEdit, m, w, l) +#define SciCall(m, w, l) SendMessage(Globals.hwndEdit, m, w, l) #endif // SCI_DIRECTFUNCTION_INTERFACE @@ -231,6 +228,11 @@ DeclareSciCallR1(PositionAfter, POSITIONAFTER, DocPos, DocPos, position) DeclareSciCallR1(GetCharAt, GETCHARAT, char, DocPos, position) DeclareSciCallR0(GetEOLMode, GETEOLMODE, int) +DeclareSciCallV0(SetCharsDefault, SETCHARSDEFAULT) +DeclareSciCallV01(SetWordChars, SETWORDCHARS, const char*, chrs) +DeclareSciCallV01(SetWhitespaceChars, SETWHITESPACECHARS, const char*, chrs) +DeclareSciCallV01(SetPunctuationChars, SETPUNCTUATIONCHARS, const char*, chrs) + DeclareSciCallR0(GetLineCount, GETLINECOUNT, DocLn) DeclareSciCallR0(GetTextLength, GETTEXTLENGTH, DocPos) DeclareSciCallR1(LineLength, LINELENGTH, DocPos, DocLn, line) @@ -289,7 +291,7 @@ DeclareSciCallV0(LineDelete, LINEDELETE) DeclareSciCallV0(DelLineLeft, DELLINELEFT) DeclareSciCallV0(DelLineRight, DELLINERIGHT) - +DeclareSciCallR0(GetLexer, GETLEXER, int) DeclareSciCallR2(FindText, FINDTEXT, DocPos, int, flags, struct Sci_TextToFind*, text) @@ -342,6 +344,7 @@ DeclareSciCallV2(BraceHighLightIndicator, BRACEHIGHLIGHTINDICATOR, bool, use, in DeclareSciCallV2(BraceBadLightIndicator, BRACEBADLIGHTINDICATOR, bool, use, int, indic) DeclareSciCallV1(SetHighLightGuide, SETHIGHLIGHTGUIDE, int, column) DeclareSciCallV2(SetLineIndentation, SETLINEINDENTATION, DocLn, line, DocPos, pos) +DeclareSciCallV1(SetIndentationGuides, SETINDENTATIONGUIDES, int, iview) //============================================================================= @@ -460,8 +463,6 @@ DeclareSciCallR0(IsIMEModeCJK, ISIMEMODECJK, bool) DeclareSciCallR0(IsSelectionEmpty, GETSELECTIONEMPTY, bool) DeclareSciCallR0(IsSelectionRectangle, SELECTIONISRECTANGLE, bool) -#define Sci_GetLine_Safe(ln, bu) - #define Sci_IsSingleLineSelection() (SciCall_LineFromPosition(SciCall_GetCurrentPos()) == SciCall_LineFromPosition(SciCall_GetAnchor())) #define Sci_IsForwardSelection() (SciCall_GetAnchor() <= SciCall_GetCurrentPos()) diff --git a/src/StyleLexers/EditLexer.h b/src/StyleLexers/EditLexer.h index 3ea7e5d15..5144f89db 100644 --- a/src/StyleLexers/EditLexer.h +++ b/src/StyleLexers/EditLexer.h @@ -6,6 +6,7 @@ #define WIN32_LEAN_AND_MEAN 1 #define NOMINMAX 1 #include + #include "Scintilla.h" // ----------------------------------------------------------------------------- @@ -15,6 +16,18 @@ #define BUFZIZE_STYLE_EXTENTIONS 512 #define BUFSIZE_STYLE_VALUE 256 +// ----------------------------------------------------------------------------- + +typedef enum +{ + FCT_SETTING_CHANGE, // value -b: rest style bit, 0: get bit-set, +b: set style bit + FCT_PASS +} +LexFunctionType; + +typedef __int64 (*LexFunctionPtr_t)(LexFunctionType type, int value); + + // ----------------------------------------------------------------------------- typedef struct _editstyle @@ -48,6 +61,7 @@ typedef struct _editlexer LPCWSTR pszName; LPCWSTR pszDefExt; WCHAR szExtensions[BUFZIZE_STYLE_EXTENTIONS]; + LexFunctionPtr_t pFctPtr; PKEYWORDLIST pKeyWords; EDITSTYLE Styles[]; diff --git a/src/StyleLexers/StyleLexers.h b/src/StyleLexers/StyleLexers.h index d9d59fac7..46563f64b 100644 --- a/src/StyleLexers/StyleLexers.h +++ b/src/StyleLexers/StyleLexers.h @@ -3,6 +3,8 @@ // ---------------------------------------------------------------------------- +#include + #include "Scintilla.h" #include "SciLexer.h" #include "../sciXlexers/SciXLexer.h" @@ -15,8 +17,41 @@ #define MULTI_STYLE(a,b,c,d) ((a)|(b<<8)|(c<<16)|(d<<24)) + +#define EMPTY_KEYWORDLIST { "", "", "", "", "", "", "", "", "" } + #define EDITLEXER_SENTINEL { -1, 00000, L"", L"", L"" } // ---------------------------------------------------------------------------- +#define LEX_FUNCTION_BODY(type, value) \ + \ + static __int64 iStyleChanged = 0LL; \ + \ + assert(((value) > -63) && ((value) < 63)); \ + \ + switch (type) { \ + case FCT_SETTING_CHANGE: \ + if ((value) == 0) { \ + return iStyleChanged; \ + } \ + else if ((value) > 0) { \ + iStyleChanged |= (((__int64)1) << (value)); \ + } \ + else { /* (value) < 0 */ \ + iStyleChanged &= ~(((__int64)1) << (0 - (value))); \ + } \ + break; \ + \ + default: \ + break; \ + } \ + +// ---------------------------------------------------------------------------- + +// clamp +inline int clampi(int x, int lower, int upper) { return (x < lower) ? lower : ((x > upper) ? upper : x); } + +// ---------------------------------------------------------------------------- + #endif // _STYLE_LEXERS_H_ diff --git a/src/StyleLexers/styleLexAHK.c b/src/StyleLexers/styleLexAHK.c index c69570af9..d09bb49ec 100644 --- a/src/StyleLexers/styleLexAHK.c +++ b/src/StyleLexers/styleLexAHK.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_AHK = { "break continue else exit exitapp gosub goto if ifequal ifexist ifgreater ifgreaterorequal " "ifinstring ifless iflessorequal ifmsgbox ifnotequal ifnotexist ifnotinstring ifwinactive " @@ -106,9 +116,11 @@ KEYWORDLIST KeyWords_AHK = { "useunsetlocal useunsetglobal useenv localsameasglobal", "", "" }; +// ---------------------------------------------------------------------------- EDITLEXER lexAHK = { -SCLEX_AHK, IDS_LEX_AHK, L"AutoHotkey Script", L"", L"", +SCLEX_AHK, IDS_LEX_AHK, L"AutoHotkey Script", L"", L"", +&LexFunction, // static &KeyWords_AHK, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_AHK_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexAHKL.c b/src/StyleLexers/styleLexAHKL.c index 43eacd1d6..61d013fc1 100644 --- a/src/StyleLexers/styleLexAHKL.c +++ b/src/StyleLexers/styleLexAHKL.c @@ -1,5 +1,14 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- KEYWORDLIST KeyWords_AHKL = { // Directives @@ -120,6 +129,7 @@ KEYWORDLIST KeyWords_AHKL = { EDITLEXER lexAHKL = { SCLEX_AHKL, IDS_LEX_AHKL, L"AutoHotkey_L Script", L"ahkl; ahk; ia; scriptlet", L"", +&LexFunction, // static &KeyWords_AHKL, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_AHK_NEUTRAL, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexASM.c b/src/StyleLexers/styleLexASM.c index f206216e2..e9d925a0b 100644 --- a/src/StyleLexers/styleLexASM.c +++ b/src/StyleLexers/styleLexASM.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_ASM = { "aaa aad aam aas adc add and arpl bound bsf bsr bswap bt btc btr bts call cbw cdq cflush clc cld " "cli clts cmc cmova cmovae cmovb cmovbe cmovc cmove cmovg cmovge cmovl cmovle cmovna cmovnae " @@ -92,6 +102,7 @@ KEYWORDLIST KeyWords_ASM = { EDITLEXER lexASM = { SCLEX_ASM, IDS_LEX_ASM_SCR, L"Assembly Script", L"asm", L"", +&LexFunction, // static &KeyWords_ASM, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_ASM_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexAU3.c b/src/StyleLexers/styleLexAU3.c index fc2ace669..f920cbee4 100644 --- a/src/StyleLexers/styleLexAU3.c +++ b/src/StyleLexers/styleLexAU3.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_AU3 = { "and byref case const continuecase continueloop default dim do else elseif endfunc endif " "endselect endswitch endwith enum exit exitloop false for func global if in local next not " @@ -648,6 +658,7 @@ KEYWORDLIST KeyWords_AU3 = { EDITLEXER lexAU3 = { SCLEX_AU3, IDS_LEX_AUTOIT3, L"AutoIt3 Script", L"au3", L"", +&LexFunction, // static &KeyWords_AU3, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_AU3_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexAVS.c b/src/StyleLexers/styleLexAVS.c index 9e90460a0..32e544834 100644 --- a/src/StyleLexers/styleLexAVS.c +++ b/src/StyleLexers/styleLexAVS.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_AVS = { "true false return global", "addborders alignedsplice amplify amplifydb animate applyrange assumebff assumefieldbased assumefps " @@ -77,6 +87,7 @@ KEYWORDLIST KeyWords_AVS = { EDITLEXER lexAVS = { SCLEX_AVS, IDS_LEX_AVI_SYNTH, L"AviSynth Script", L"avs; avsi", L"", +&LexFunction, // static &KeyWords_AVS, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_AVS_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexAwk.c b/src/StyleLexers/styleLexAwk.c index a1b481e19..6e6bf94de 100644 --- a/src/StyleLexers/styleLexAwk.c +++ b/src/StyleLexers/styleLexAwk.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_Awk = { // Keywords "break case continue default do else exit function for if in next return switch while " @@ -19,6 +29,7 @@ KEYWORDLIST KeyWords_Awk = { EDITLEXER lexAwk = { SCLEX_PYTHON, IDS_LEX_AWK_SCR, L"Awk Script", L"awk", L"", +&LexFunction, // static &KeyWords_Awk,{ { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_P_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexBASH.c b/src/StyleLexers/styleLexBASH.c index fc5739d77..1fb9fbbae 100644 --- a/src/StyleLexers/styleLexBASH.c +++ b/src/StyleLexers/styleLexBASH.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_BASH = { "alias ar asa awk banner basename bash bc bdiff break bunzip2 bzip2 cal calendar case cat " "cc cd chmod cksum clear cmp col comm compress continue cp cpio crypt csplit ctags cut date " @@ -19,6 +29,7 @@ KEYWORDLIST KeyWords_BASH = { EDITLEXER lexBASH = { SCLEX_BASH, IDS_LEX_SHELL_SCR, L"Shell Script", L"sh", L"", +&LexFunction, // static &KeyWords_BASH, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_SH_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexBAT.c b/src/StyleLexers/styleLexBAT.c index 704518726..6e968d047 100644 --- a/src/StyleLexers/styleLexBAT.c +++ b/src/StyleLexers/styleLexBAT.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_BAT = { "arp assoc attrib bcdedit bootcfg break cacls call cd change chcp chdir chkdsk chkntfs choice cipher " "cleanmgr cls cmd cmdkey color com comp compact con convert copy country ctty date defined defrag del " @@ -16,6 +26,7 @@ KEYWORDLIST KeyWords_BAT = { EDITLEXER lexBAT = { SCLEX_BATCH, IDS_LEX_BATCH, L"Batch Files", L"bat; cmd", L"", +&LexFunction, // static &KeyWords_BAT, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_BAT_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexCMAKE.c b/src/StyleLexers/styleLexCMAKE.c index 44219cf38..8fd23cf38 100644 --- a/src/StyleLexers/styleLexCMAKE.c +++ b/src/StyleLexers/styleLexCMAKE.c @@ -1,5 +1,14 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- KEYWORDLIST KeyWords_CMAKE = { "add_custom_command add_custom_target add_definitions add_dependencies add_executable add_library " "add_subdirectory add_test aux_source_directory build_command build_name cmake_minimum_required " @@ -31,6 +40,7 @@ KEYWORDLIST KeyWords_CMAKE = { EDITLEXER lexCmake = { SCLEX_CMAKE, IDS_LEX_CMAKE, L"Cmake Script", L"cmake; ctest", L"", +&LexFunction, // static &KeyWords_CMAKE, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_CMAKE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexCOFFEESCRIPT.c b/src/StyleLexers/styleLexCOFFEESCRIPT.c index 5aa9d68a3..d2e2ab5a3 100644 --- a/src/StyleLexers/styleLexCOFFEESCRIPT.c +++ b/src/StyleLexers/styleLexCOFFEESCRIPT.c @@ -1,22 +1,34 @@ #include "StyleLexers.h" -KEYWORDLIST KeyWords_COFFEESCRIPT = { -"", "", "", "", "", "", "", "", "" }; +// ---------------------------------------------------------------------------- +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; -EDITLEXER lexCOFFEESCRIPT = { SCLEX_COFFEESCRIPT, IDS_LEX_COFFEE_SCR, L"Coffeescript", L"coffee; Cakefile", L"", &KeyWords_COFFEESCRIPT, { - { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, - //{ SCE_COFFEESCRIPT_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_COFFEESCRIPT_COMMENT,SCE_COFFEESCRIPT_COMMENTLINE,SCE_COFFEESCRIPT_COMMENTDOC,SCE_COFFEESCRIPT_COMMENTBLOCK), IDS_LEX_STR_63127, L"Comment", L"fore:#646464", L"" }, - { MULTI_STYLE(SCE_COFFEESCRIPT_STRING,SCE_COFFEESCRIPT_STRINGEOL,SCE_COFFEESCRIPT_STRINGRAW,0), IDS_LEX_STR_63131, L"String", L"fore:#008000", L"" }, - { SCE_COFFEESCRIPT_PREPROCESSOR, IDS_LEX_STR_63133, L"Preprocessor", L"fore:#FF8000", L"" }, - { SCE_COFFEESCRIPT_IDENTIFIER, IDS_LEX_STR_63129, L"Identifier", L"bold; fore:#0A246A", L"" }, - { SCE_COFFEESCRIPT_OPERATOR, IDS_LEX_STR_63132, L"Operator", L"fore:#B000B0", L"" }, - { SCE_COFFEESCRIPT_NUMBER, IDS_LEX_STR_63130, L"Number", L"fore:#FF0000", L"" }, - //{ SCE_COFFEESCRIPT_CHARACTER, IDS_LEX_STR_63376, L"Character", L"", L"" }, - { MULTI_STYLE(SCE_COFFEESCRIPT_REGEX,SCE_COFFEESCRIPT_VERBOSE_REGEX,SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT,0), IDS_LEX_STR_63315, L"Regex", L"fore:#006633; back:#FFF1A8", L"" }, - { SCE_COFFEESCRIPT_GLOBALCLASS, IDS_LEX_STR_63304, L"Global Class", L"", L"" }, - //{ MULTI_STYLE(SCE_COFFEESCRIPT_COMMENTLINEDOC,SCE_COFFEESCRIPT_COMMENTDOCKEYWORD,SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR,0), IDS_LEX_STR_63379, L"Comment line", L"fore:#646464", L"" }, - { MULTI_STYLE(SCE_COFFEESCRIPT_WORD,SCE_COFFEESCRIPT_WORD2,0,0), IDS_LEX_STR_63341, L"Word", L"", L"" }, - { MULTI_STYLE(SCE_COFFEESCRIPT_VERBATIM,SCE_COFFEESCRIPT_TRIPLEVERBATIM,0,0), IDS_LEX_STR_63342, L"Verbatim", L"", L"" }, - EDITLEXER_SENTINEL } }; +// ---------------------------------------------------------------------------- + +KEYWORDLIST KeyWords_COFFEESCRIPT = EMPTY_KEYWORDLIST; + + +EDITLEXER lexCOFFEESCRIPT = { +SCLEX_COFFEESCRIPT, IDS_LEX_COFFEE_SCR, L"Coffeescript", L"coffee; Cakefile", L"", +&LexFunction, // static +&KeyWords_COFFEESCRIPT, { + { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, + //{ SCE_COFFEESCRIPT_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_COFFEESCRIPT_COMMENT,SCE_COFFEESCRIPT_COMMENTLINE,SCE_COFFEESCRIPT_COMMENTDOC,SCE_COFFEESCRIPT_COMMENTBLOCK), IDS_LEX_STR_63127, L"Comment", L"fore:#646464", L"" }, + { MULTI_STYLE(SCE_COFFEESCRIPT_STRING,SCE_COFFEESCRIPT_STRINGEOL,SCE_COFFEESCRIPT_STRINGRAW,0), IDS_LEX_STR_63131, L"String", L"fore:#008000", L"" }, + { SCE_COFFEESCRIPT_PREPROCESSOR, IDS_LEX_STR_63133, L"Preprocessor", L"fore:#FF8000", L"" }, + { SCE_COFFEESCRIPT_IDENTIFIER, IDS_LEX_STR_63129, L"Identifier", L"bold; fore:#0A246A", L"" }, + { SCE_COFFEESCRIPT_OPERATOR, IDS_LEX_STR_63132, L"Operator", L"fore:#B000B0", L"" }, + { SCE_COFFEESCRIPT_NUMBER, IDS_LEX_STR_63130, L"Number", L"fore:#FF0000", L"" }, + //{ SCE_COFFEESCRIPT_CHARACTER, IDS_LEX_STR_63376, L"Character", L"", L"" }, + { MULTI_STYLE(SCE_COFFEESCRIPT_REGEX,SCE_COFFEESCRIPT_VERBOSE_REGEX,SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT,0), IDS_LEX_STR_63315, L"Regex", L"fore:#006633; back:#FFF1A8", L"" }, + { SCE_COFFEESCRIPT_GLOBALCLASS, IDS_LEX_STR_63304, L"Global Class", L"", L"" }, + //{ MULTI_STYLE(SCE_COFFEESCRIPT_COMMENTLINEDOC,SCE_COFFEESCRIPT_COMMENTDOCKEYWORD,SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR,0), IDS_LEX_STR_63379, L"Comment line", L"fore:#646464", L"" }, + { MULTI_STYLE(SCE_COFFEESCRIPT_WORD,SCE_COFFEESCRIPT_WORD2,0,0), IDS_LEX_STR_63341, L"Word", L"", L"" }, + { MULTI_STYLE(SCE_COFFEESCRIPT_VERBATIM,SCE_COFFEESCRIPT_TRIPLEVERBATIM,0,0), IDS_LEX_STR_63342, L"Verbatim", L"", L"" }, + EDITLEXER_SENTINEL } }; diff --git a/src/StyleLexers/styleLexCONF.c b/src/StyleLexers/styleLexCONF.c index 1d0f6b1d0..19086a4dc 100644 --- a/src/StyleLexers/styleLexCONF.c +++ b/src/StyleLexers/styleLexCONF.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_CONF = { "acceptfilter acceptmutex acceptpathinfo accessconfig accessfilename action addalt addaltbyencoding " "addaltbytype addcharset adddefaultcharset adddescription addencoding addhandler addicon addiconbyencoding " @@ -115,6 +125,7 @@ KEYWORDLIST KeyWords_CONF = { EDITLEXER lexCONF = { SCLEX_CONF, IDS_LEX_APC_CFG, L"Apache Config Files", L"conf; htaccess", L"", +&LexFunction, // static &KeyWords_CONF, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_CONF_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexCPP.c b/src/StyleLexers/styleLexCPP.c index 7efa91029..dde3b604b 100644 --- a/src/StyleLexers/styleLexCPP.c +++ b/src/StyleLexers/styleLexCPP.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_CPP = { // Primary keywords "alignas auto bool break case catch char char16_t char32_t class const constexpr const_cast " @@ -39,6 +49,7 @@ KEYWORDLIST KeyWords_CPP = { EDITLEXER lexCPP = { SCLEX_CPP, IDS_LEX_CPP_SRC, L"C/C++ Source Code", L"c; cpp; cxx; cc; h; hpp; hxx; hh; m; mm; idl; inl; odl", L"", +&LexFunction, // static &KeyWords_CPP, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_C_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexCS.c b/src/StyleLexers/styleLexCS.c index b7bc16a6d..048e58815 100644 --- a/src/StyleLexers/styleLexCS.c +++ b/src/StyleLexers/styleLexCS.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_CS = { "abstract add alias as ascending async await base bool break by byte case catch char checked " "class const continue decimal default delegate descending do double dynamic else " @@ -137,6 +147,7 @@ KEYWORDLIST KeyWords_CS = { EDITLEXER lexCS = { SCLEX_CPP, IDS_LEX_CSHARP_SRC, L"C# Source Code", L"cs", L"", +&LexFunction, // static &KeyWords_CS, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_C_DEFAULT, IDS_LEX_STR_63126, L"C Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexCSS.c b/src/StyleLexers/styleLexCSS.c index 10c95aa95..06e8a6882 100644 --- a/src/StyleLexers/styleLexCSS.c +++ b/src/StyleLexers/styleLexCSS.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_CSS = { "align-content align-items align-self alignment-adjust alignment-baseline animation animation-delay " "animation-direction animation-duration animation-fill-mode animation-iteration-count animation-name " @@ -64,6 +74,7 @@ KEYWORDLIST KeyWords_CSS = { EDITLEXER lexCSS = { SCLEX_CSS, IDS_LEX_CSS_STYLE, L"CSS Style Sheets", L"css; less; sass; scss", L"", +&LexFunction, // static &KeyWords_CSS, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_CSS_DEFAULT, IDS_LEX_STR_63126, L"CSS Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexD.c b/src/StyleLexers/styleLexD.c index 4ed6f1501..3dea38556 100644 --- a/src/StyleLexers/styleLexD.c +++ b/src/StyleLexers/styleLexD.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_D = { // Primary keywords and identifiers "abstract alias align asm assert auto body break case cast catch class const continue " @@ -30,6 +40,7 @@ KEYWORDLIST KeyWords_D = { EDITLEXER lexD = { SCLEX_D, IDS_LEX_D_SRC, L"D Source Code", L"d; dd; di", L"", +&LexFunction, // static &KeyWords_D, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_D_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexDIFF.c b/src/StyleLexers/styleLexDIFF.c index 9478c3f9a..14a7d9231 100644 --- a/src/StyleLexers/styleLexDIFF.c +++ b/src/StyleLexers/styleLexDIFF.c @@ -1,11 +1,21 @@ #include "StyleLexers.h" -KEYWORDLIST KeyWords_DIFF = { -"", "", "", "", "", "", "", "", "" }; +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + +KEYWORDLIST KeyWords_DIFF = EMPTY_KEYWORDLIST; EDITLEXER lexDIFF = { SCLEX_DIFF, IDS_LEX_DIFF, L"Diff Files", L"diff; patch", L"", +&LexFunction, // static &KeyWords_DIFF, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_DIFF_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexGo.c b/src/StyleLexers/styleLexGo.c index 004884d09..0b00a4a3a 100644 --- a/src/StyleLexers/styleLexGo.c +++ b/src/StyleLexers/styleLexGo.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_Go = { // Primary keywords and identifiers "break default func interface select case defer go map struct chan else goto package switch const fallthrough if range type " @@ -23,6 +33,7 @@ KEYWORDLIST KeyWords_Go = { EDITLEXER lexGo = { SCLEX_D, IDS_LEX_GO_SRC, L"Go Source Code", L"go", L"", +&LexFunction, // static &KeyWords_Go,{ { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_D_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexHTML.c b/src/StyleLexers/styleLexHTML.c index 5fd4b61bc..de1e3c285 100644 --- a/src/StyleLexers/styleLexHTML.c +++ b/src/StyleLexers/styleLexHTML.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_HTML = { "!doctype ^aria- ^data- a abbr accept accept-charset accesskey acronym action address align alink " "alt and applet archive area article aside async audio autocomplete autofocus autoplay axis b " @@ -59,6 +69,7 @@ KEYWORDLIST KeyWords_HTML = { EDITLEXER lexHTML = { SCLEX_HTML, IDS_LEX_WEB_SRC, L"Web Source Code", L"html; htm; asp; aspx; shtml; htd; xhtml; php; php3; phtml; htt; cfm; tpl; dtd; hta; htc", L"", +&LexFunction, // static &KeyWords_HTML, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, { MULTI_STYLE(SCE_H_TAG,SCE_H_TAGEND,0,0), IDS_LEX_STR_63136, L"HTML Tag", L"fore:#648000", L"" }, diff --git a/src/StyleLexers/styleLexINNO.c b/src/StyleLexers/styleLexINNO.c index 2f08dc7df..7579e2c06 100644 --- a/src/StyleLexers/styleLexINNO.c +++ b/src/StyleLexers/styleLexINNO.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_INNO = { "code components custommessages dirs files icons ini installdelete langoptions languages messages " "registry run setup types tasks uninstalldelete uninstallrun _istool", @@ -39,6 +49,7 @@ KEYWORDLIST KeyWords_INNO = { EDITLEXER lexINNO = { SCLEX_INNOSETUP, IDS_LEX_INNO, L"Inno Setup Script", L"iss; isl; islu", L"", +&LexFunction, // static &KeyWords_INNO, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_INNO_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexJAVA.c b/src/StyleLexers/styleLexJAVA.c index fa50a52d4..ec41d698f 100644 --- a/src/StyleLexers/styleLexJAVA.c +++ b/src/StyleLexers/styleLexJAVA.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_JAVA = { "@interface abstract assert boolean break byte case catch char class const " "continue default do double else enum extends final finally float for future " @@ -16,6 +26,7 @@ KEYWORDLIST KeyWords_JAVA = { EDITLEXER lexJAVA = { SCLEX_CPP, IDS_LEX_JAVA_SRC, L"Java Source Code", L"java", L"", +&LexFunction, // static &KeyWords_JAVA, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_C_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexJS.c b/src/StyleLexers/styleLexJS.c index e1294494c..98671a520 100644 --- a/src/StyleLexers/styleLexJS.c +++ b/src/StyleLexers/styleLexJS.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_JS = { "abstract boolean break byte case catch char class const continue debugger default delete do " "double else enum export extends false final finally float for function goto if implements " @@ -11,6 +21,7 @@ KEYWORDLIST KeyWords_JS = { EDITLEXER lexJS = { SCLEX_CPP, IDS_LEX_J_SCR, L"JavaScript", L"js; jse; jsm; as", L"", +&LexFunction, // static &KeyWords_JS, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_C_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexJSON.c b/src/StyleLexers/styleLexJSON.c index ca137866c..144a3e3d2 100644 --- a/src/StyleLexers/styleLexJSON.c +++ b/src/StyleLexers/styleLexJSON.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_JSON = { "false true null", "@id @context @type @value @language @container @list @set @reverse @index @base @vocab @graph", @@ -8,6 +18,7 @@ KEYWORDLIST KeyWords_JSON = { EDITLEXER lexJSON = { SCLEX_JSON, IDS_LEX_JSON, L"JSON", L"json; eslintrc; jshintrc; jsonld", L"", +&LexFunction, // static &KeyWords_JSON, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_C_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexLUA.c b/src/StyleLexers/styleLexLUA.c index 935899477..3da845ffe 100644 --- a/src/StyleLexers/styleLexLUA.c +++ b/src/StyleLexers/styleLexLUA.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_LUA = { "and break do else elseif end false for function goto if " "in local nil not or repeat return then true until while", @@ -31,6 +41,7 @@ KEYWORDLIST KeyWords_LUA = { EDITLEXER lexLUA = { SCLEX_LUA, IDS_LEX_LUA, L"Lua Script", L"lua", L"", +&LexFunction, // static &KeyWords_LUA, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_LUA_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexMAK.c b/src/StyleLexers/styleLexMAK.c index 729a4654e..8df445d4c 100644 --- a/src/StyleLexers/styleLexMAK.c +++ b/src/StyleLexers/styleLexMAK.c @@ -1,11 +1,21 @@ #include "StyleLexers.h" -KEYWORDLIST KeyWords_MAK = { -"", "", "", "", "", "", "", "", "" }; +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + +KEYWORDLIST KeyWords_MAK = EMPTY_KEYWORDLIST; EDITLEXER lexMAK = { SCLEX_MAKEFILE, IDS_LEX_MAKEFILES, L"Makefiles", L"mak; make; mk; dsp; msc; msvc", L"", +&LexFunction, // static &KeyWords_MAK, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_MAKE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexMARKDOWN.c b/src/StyleLexers/styleLexMARKDOWN.c index 300afe28d..5df86b3b0 100644 --- a/src/StyleLexers/styleLexMARKDOWN.c +++ b/src/StyleLexers/styleLexMARKDOWN.c @@ -1,11 +1,21 @@ #include "StyleLexers.h" -KEYWORDLIST KeyWords_MARKDOWN = { -"", "", "", "", "", "", "", "", "" }; +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + +KEYWORDLIST KeyWords_MARKDOWN = EMPTY_KEYWORDLIST; EDITLEXER lexMARKDOWN = { SCLEX_MARKDOWN, IDS_LEX_MARKDOWN, L"Markdown", L"md; markdown; mdown; mkdn; mkd", L"", +&LexFunction, // static &KeyWords_MARKDOWN, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_MARKDOWN_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexMATLAB.c b/src/StyleLexers/styleLexMATLAB.c index 58a324181..94c0d15a6 100644 --- a/src/StyleLexers/styleLexMATLAB.c +++ b/src/StyleLexers/styleLexMATLAB.c @@ -1,5 +1,14 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- KEYWORDLIST KeyWords_MATLAB = { "break case catch continue else elseif end for function global if otherwise " "persistent return switch try while ", @@ -8,6 +17,7 @@ KEYWORDLIST KeyWords_MATLAB = { EDITLEXER lexMATLAB = { SCLEX_MATLAB, IDS_LEX_MATLAB, L"MATLAB", L"matlab", L"", +&LexFunction, // static &KeyWords_MATLAB, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_MATLAB_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexNSIS.c b/src/StyleLexers/styleLexNSIS.c index 59158df22..ea836f4b5 100644 --- a/src/StyleLexers/styleLexNSIS.c +++ b/src/StyleLexers/styleLexNSIS.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_NSIS = { "!addincludedir !addplugindir !appendfile !cd !define !delfile !echo !else !endif !error " "!execute !finalize !getdllversion !if !ifdef !ifmacrodef !ifmacrondef !ifndef !include !insertmacro !macro " @@ -56,6 +66,7 @@ KEYWORDLIST KeyWords_NSIS = { EDITLEXER lexNSIS = { SCLEX_NSIS, IDS_LEX_NSIS, L"NSIS Script", L"nsi; nsh", L"", +&LexFunction, // static &KeyWords_NSIS, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //,{ SCE_NSIS_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexNimrod.c b/src/StyleLexers/styleLexNimrod.c index 4c69fda5e..eaf37f3ca 100644 --- a/src/StyleLexers/styleLexNimrod.c +++ b/src/StyleLexers/styleLexNimrod.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_Nimrod = { "addr and as asm atomic bind block break case cast concept const continue converter " "defer discard distinct div do elif else end enum except export finally for from func " @@ -9,18 +19,21 @@ KEYWORDLIST KeyWords_Nimrod = { "", "", "", "", "", "", "", "" }; -EDITLEXER lexNimrod = { SCLEX_NIMROD, IDS_LEX_NIM_SRC, L"Nim Source Code", L"nim; nimrod", L"", &KeyWords_Nimrod,{ - { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, - //{ SCE_P_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, - { MULTI_STYLE(SCE_P_COMMENTLINE,SCE_P_COMMENTBLOCK,SCE_C_COMMENTLINEDOC,0), IDS_LEX_STR_63127, L"Comment", L"fore:#880000", L"" }, - { SCE_P_WORD, IDS_LEX_STR_63128, L"Keyword", L"bold; fore:#000088", L"" }, - { SCE_P_IDENTIFIER, IDS_LEX_STR_63129, L"Identifier", L"", L"" }, - { MULTI_STYLE(SCE_P_STRING,SCE_P_STRINGEOL,0,0), IDS_LEX_STR_63211, L"String Double Quoted", L"fore:#008800", L"" }, - { SCE_P_CHARACTER, IDS_LEX_STR_63212, L"String Single Quoted", L"fore:#008800", L"" }, - { SCE_P_TRIPLEDOUBLE, IDS_LEX_STR_63244, L"String Triple Double Quotes", L"fore:#008800", L"" }, - { SCE_P_TRIPLE, IDS_LEX_STR_63245, L"String Triple Single Quotes", L"fore:#008800", L"" }, - { SCE_P_NUMBER, IDS_LEX_STR_63130, L"Number", L"fore:#FF4000", L"" }, - { SCE_P_OPERATOR, IDS_LEX_STR_63132, L"Operator", L"bold; fore:#666600", L"" }, - //{ SCE_P_DEFNAME, IDS_LEX_STR_63247, L"Function name", L"fore:#660066", L"" }, - //{ SCE_P_CLASSNAME, IDS_LEX_STR_63246, L"Class name", L"fore:#660066", L"" }, - EDITLEXER_SENTINEL } }; +EDITLEXER lexNimrod = { +SCLEX_NIMROD, IDS_LEX_NIM_SRC, L"Nim Source Code", L"nim; nimrod", L"", +&LexFunction, // static +&KeyWords_Nimrod,{ + { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, + //{ SCE_P_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, + { MULTI_STYLE(SCE_P_COMMENTLINE,SCE_P_COMMENTBLOCK,SCE_C_COMMENTLINEDOC,0), IDS_LEX_STR_63127, L"Comment", L"fore:#880000", L"" }, + { SCE_P_WORD, IDS_LEX_STR_63128, L"Keyword", L"bold; fore:#000088", L"" }, + { SCE_P_IDENTIFIER, IDS_LEX_STR_63129, L"Identifier", L"", L"" }, + { MULTI_STYLE(SCE_P_STRING,SCE_P_STRINGEOL,0,0), IDS_LEX_STR_63211, L"String Double Quoted", L"fore:#008800", L"" }, + { SCE_P_CHARACTER, IDS_LEX_STR_63212, L"String Single Quoted", L"fore:#008800", L"" }, + { SCE_P_TRIPLEDOUBLE, IDS_LEX_STR_63244, L"String Triple Double Quotes", L"fore:#008800", L"" }, + { SCE_P_TRIPLE, IDS_LEX_STR_63245, L"String Triple Single Quotes", L"fore:#008800", L"" }, + { SCE_P_NUMBER, IDS_LEX_STR_63130, L"Number", L"fore:#FF4000", L"" }, + { SCE_P_OPERATOR, IDS_LEX_STR_63132, L"Operator", L"bold; fore:#666600", L"" }, + //{ SCE_P_DEFNAME, IDS_LEX_STR_63247, L"Function name", L"fore:#660066", L"" }, + //{ SCE_P_CLASSNAME, IDS_LEX_STR_63246, L"Class name", L"fore:#660066", L"" }, + EDITLEXER_SENTINEL } }; diff --git a/src/StyleLexers/styleLexPAS.c b/src/StyleLexers/styleLexPAS.c index 6e07304e8..5ef9d0dc6 100644 --- a/src/StyleLexers/styleLexPAS.c +++ b/src/StyleLexers/styleLexPAS.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_PAS = { "absolute abstract alias and array as asm assembler begin break case cdecl class const constructor continue cppdecl default " "destructor dispose div do downto else end end. except exit export exports external false far far16 file finalization finally for " @@ -12,6 +22,7 @@ KEYWORDLIST KeyWords_PAS = { EDITLEXER lexPAS = { SCLEX_PASCAL, IDS_LEX_PASCAL_SRC, L"Pascal Source Code", L"pas; dpr; dpk; dfm; inc; pp", L"", +&LexFunction, // static &KeyWords_PAS, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_PAS_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexPL.c b/src/StyleLexers/styleLexPL.c index 681672460..4ec9424c2 100644 --- a/src/StyleLexers/styleLexPL.c +++ b/src/StyleLexers/styleLexPL.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_PL = { "__DATA__ __END__ __FILE__ __LINE__ __PACKAGE__ abs accept alarm and atan2 AUTOLOAD BEGIN " "bind binmode bless break caller chdir CHECK chmod chomp chop chown chr chroot close closedir " @@ -26,6 +36,7 @@ KEYWORDLIST KeyWords_PL = { EDITLEXER lexPL = { SCLEX_PERL, IDS_LEX_PERL_SCR, L"Perl Script", L"pl; pm; cgi; pod", L"", +&LexFunction, // static &KeyWords_PL, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_PL_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexPROPS.c b/src/StyleLexers/styleLexPROPS.c index b0b42415c..ac3ba5d6a 100644 --- a/src/StyleLexers/styleLexPROPS.c +++ b/src/StyleLexers/styleLexPROPS.c @@ -1,11 +1,21 @@ #include "StyleLexers.h" -KEYWORDLIST KeyWords_PROPS = { -"", "", "", "", "", "", "", "", "" }; +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + +KEYWORDLIST KeyWords_PROPS = EMPTY_KEYWORDLIST; EDITLEXER lexPROPS = { SCLEX_PROPERTIES, IDS_LEX_CONF, L"Configuration Files", L"ini; inf; cfg; properties; oem; sif; url; sed; theme", L"", +&LexFunction, // static &KeyWords_PROPS, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_PROPS_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexPS.c b/src/StyleLexers/styleLexPS.c index a8b704f52..7acd6b547 100644 --- a/src/StyleLexers/styleLexPS.c +++ b/src/StyleLexers/styleLexPS.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_PS = { "begin break catch continue data do dynamicparam else elseif end exit filter finally for foreach " "from function if in local param private process return switch throw trap try until where while", @@ -58,6 +68,7 @@ KEYWORDLIST KeyWords_PS = { EDITLEXER lexPS = { SCLEX_POWERSHELL, IDS_LEX_PWRSHELL, L"PowerShell Script", L"ps1; psd1; psm1", L"", +&LexFunction, // static &KeyWords_PS, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_POWERSHELL_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexPY.c b/src/StyleLexers/styleLexPY.c index 9220b6a7a..af1670e1a 100644 --- a/src/StyleLexers/styleLexPY.c +++ b/src/StyleLexers/styleLexPY.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_PY = { "and as assert break class continue def del elif else except " "exec False finally for from global if import in is lambda None " @@ -9,6 +19,7 @@ KEYWORDLIST KeyWords_PY = { EDITLEXER lexPY = { SCLEX_PYTHON, IDS_LEX_PYTHON, L"Python Script", L"py; pyw", L"", +&LexFunction, // static &KeyWords_PY, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_P_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexR.c b/src/StyleLexers/styleLexR.c index cc21db5c0..dedbb8fae 100644 --- a/src/StyleLexers/styleLexR.c +++ b/src/StyleLexers/styleLexR.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_R = { // Language Keywords "if else repeat while function for in next break " @@ -78,6 +88,7 @@ KEYWORDLIST KeyWords_R = { EDITLEXER lexR = { SCLEX_R, IDS_LEX_R_STAT, L"R-S-SPlus Statistics Code", L"R", L"", +&LexFunction, // static &KeyWords_R,{ { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_R_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexRC.c b/src/StyleLexers/styleLexRC.c index c4e652363..f36e2dd9b 100644 --- a/src/StyleLexers/styleLexRC.c +++ b/src/StyleLexers/styleLexRC.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_RC = { "ACCELERATORS ALT AUTO3STATE AUTOCHECKBOX AUTORADIOBUTTON " "BEGIN BITMAP BLOCK BUTTON CAPTION CHARACTERISTICS CHECKBOX " @@ -14,6 +24,7 @@ KEYWORDLIST KeyWords_RC = { EDITLEXER lexRC = { SCLEX_CPP, IDS_LEX_RESOURCE_SCR, L"Resource Script", L"rc; rc2; rct; rh; r; dlg", L"", +&LexFunction, // static &KeyWords_RC, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_C_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexRUBY.c b/src/StyleLexers/styleLexRUBY.c index 51fd31579..a67a3160a 100644 --- a/src/StyleLexers/styleLexRUBY.c +++ b/src/StyleLexers/styleLexRUBY.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_RUBY = { "__FILE__ __LINE__ alias and begin break case class def defined? do else elsif end ensure " "false for in if module next nil not or redo rescue retry return self super then true " @@ -8,6 +18,7 @@ KEYWORDLIST KeyWords_RUBY = { EDITLEXER lexRUBY = { SCLEX_RUBY, IDS_LEX_RUBY, L"Ruby Script", L"rb; ruby; rbw; rake; rjs; Rakefile; gemspec", L"", +&LexFunction, // static &KeyWords_RUBY, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_RB_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexRegistry.c b/src/StyleLexers/styleLexRegistry.c index 250de3809..959ea27ca 100644 --- a/src/StyleLexers/styleLexRegistry.c +++ b/src/StyleLexers/styleLexRegistry.c @@ -1,10 +1,20 @@ #include "StyleLexers.h" -KEYWORDLIST KeyWords_Registry = { -"", "", "", "", "", "", "", "", "" }; +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + +KEYWORDLIST KeyWords_Registry = EMPTY_KEYWORDLIST; EDITLEXER lexRegistry = { SCLEX_REGISTRY, IDS_LEX_REG_FILES, L"Registry Files", L"reg", L"", +&LexFunction, // static &KeyWords_Registry, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_REG_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexRust.c b/src/StyleLexers/styleLexRust.c index 3904e2adc..c33b573d9 100644 --- a/src/StyleLexers/styleLexRust.c +++ b/src/StyleLexers/styleLexRust.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_Rust = { // Primary keywords and identifiers "as be break const continue crate else enum extern false fn for " @@ -24,6 +34,7 @@ KEYWORDLIST KeyWords_Rust = { EDITLEXER lexRust = { SCLEX_RUST, IDS_LEX_RUST_SRC, L"Rust Source Code", L"rs; rust", L"", +&LexFunction, // static &KeyWords_Rust,{ { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_RUST_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexSQL.c b/src/StyleLexers/styleLexSQL.c index 7fd46b63c..dd7640019 100644 --- a/src/StyleLexers/styleLexSQL.c +++ b/src/StyleLexers/styleLexSQL.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_SQL = { "abort accessible action add after all alter analyze and as asc asensitive attach autoincrement " "before begin between bigint binary bit blob both by call cascade case cast change char character " @@ -28,6 +38,7 @@ KEYWORDLIST KeyWords_SQL = { EDITLEXER lexSQL = { SCLEX_SQL, IDS_LEX_SQL, L"SQL Query", L"sql", L"", +&LexFunction, // static &KeyWords_SQL, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_SQL_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexStandard.c b/src/StyleLexers/styleLexStandard.c index 5a643dbed..c576fb807 100644 --- a/src/StyleLexers/styleLexStandard.c +++ b/src/StyleLexers/styleLexStandard.c @@ -1,10 +1,39 @@ #include "StyleLexers.h" -KEYWORDLIST KeyWords_NULL = { "", "", "", "", "", "", "", "", "" }; +// ---------------------------------------------------------------------------- +static __int64 StdLexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +static __int64 Std2ndLexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +static __int64 AnsiLexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +static __int64 LatexLexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + + +// ---------------------------------------------------------------------------- + +KEYWORDLIST KeyWords_NULL = EMPTY_KEYWORDLIST; EDITLEXER lexStandard = { SCLEX_NULL, IDS_LEX_DEF_TXT, L"Default Text", L"txt; text; wtx; log; asc; doc", L"", +&StdLexFunction, // static &KeyWords_NULL, { /* 0 */ { STYLE_DEFAULT, IDS_LEX_STD_STYLE, L"Default Style", L"font:Default; size:10", L"" }, /* 1 */ { STYLE_LINENUMBER, IDS_LEX_STD_MARGIN, L"Margins and Line Numbers", L"size:-2; fore:#FF0000", L"" }, @@ -21,12 +50,13 @@ SCLEX_NULL, IDS_LEX_DEF_TXT, L"Default Text", L"txt; text; wtx; log; asc; doc", /* 12 */ { SCI_FOLDALL+SCI_MARKERSETALPHA, IDS_LEX_STD_BKMRK, L"Bookmarks and Folding (Colors, Size)", L"size:+2; fore:#000000; back:#808080; alpha:80", L"" }, /* 13 */ { SCI_MARKERSETBACK+SCI_MARKERSETALPHA, IDS_LEX_STR_63262, L"Mark Occurrences (Indicator)", L"alpha:100; alpha2:100; indic_roundbox", L"" }, /* 14 */ { SCI_SETHOTSPOTACTIVEFORE, IDS_LEX_STR_63264, L"Hyperlink Hotspots", L"italic; fore:#0000FF", L"" }, - /* 15 */ { SCI_INDICSETFORE, IDS_LEX_STR_63352, L"Inline-IME Color", L"fore:#00FF00", L"" }, + /* 15 */ { SCI_INDICSETFORE, IDS_LEX_STR_63352, L"Inline-IME Color", L"fore:#00AA00", L"" }, EDITLEXER_SENTINEL } }; EDITLEXER lexStandard2nd = { SCLEX_NULL, IDS_LEX_STR_63266, L"2nd Default Text", L"txt; text; wtx; log; asc; doc", L"", +&Std2ndLexFunction, // static &KeyWords_NULL,{ /* 0 */ { STYLE_DEFAULT, IDS_LEX_2ND_STYLE, L"2nd Default Style", L"font:Courier New; size:10", L"" }, /* 1 */ { STYLE_LINENUMBER, IDS_LEX_2ND_MARGIN, L"2nd Margins and Line Numbers", L"font:Tahoma; size:-2; fore:#FF0000", L"" }, @@ -49,6 +79,7 @@ SCLEX_NULL, IDS_LEX_STR_63266, L"2nd Default Text", L"txt; text; wtx; log; asc; EDITLEXER lexANSI = { SCLEX_NULL, IDS_LEX_ANSI_ART, L"ANSI Art", L"nfo; diz", L"", +&AnsiLexFunction, // static &KeyWords_NULL,{ { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"font:Lucida Console; none; size:11", L"" }, { STYLE_LINENUMBER, IDS_LEX_STD_MARGIN, L"Margins and Line Numbers", L"font:Lucida Console; size:-2", L"" }, @@ -60,6 +91,7 @@ SCLEX_NULL, IDS_LEX_ANSI_ART, L"ANSI Art", L"nfo; diz", L"", EDITLEXER lexLATEX = { SCLEX_LATEX, IDS_LEX_LATEX, L"LaTeX Files", L"tex; latex; sty", L"", +&LatexLexFunction, // static &KeyWords_NULL, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_L_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, @@ -71,7 +103,3 @@ SCLEX_LATEX, IDS_LEX_LATEX, L"LaTeX Files", L"tex; latex; sty", L"", { SCE_L_VERBATIM, IDS_LEX_STR_63307, L"Verbatim Segment", L"fore:#666666", L"" }, EDITLEXER_SENTINEL } }; - - - - diff --git a/src/StyleLexers/styleLexTCL.c b/src/StyleLexers/styleLexTCL.c index d8ce451f4..9ae034af9 100644 --- a/src/StyleLexers/styleLexTCL.c +++ b/src/StyleLexers/styleLexTCL.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_TCL = { // TCL Keywords "after append array auto_execok auto_import auto_load auto_load_index auto_qualify beep " @@ -32,6 +42,7 @@ KEYWORDLIST KeyWords_TCL = { EDITLEXER lexTCL = { SCLEX_TCL, IDS_LEX_TCL, L"Tcl Script", L"tcl; itcl", L"", +&LexFunction, // static &KeyWords_TCL, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_TCL_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexVB.c b/src/StyleLexers/styleLexVB.c index e247dc017..998e98946 100644 --- a/src/StyleLexers/styleLexVB.c +++ b/src/StyleLexers/styleLexVB.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_VB = { "addhandler addressof alias and andalso ansi any as assembly auto boolean byref byte byval call " "case catch cbool cbyte cchar cdate cdbl cdec char cint class clng cobj compare const cshort csng " @@ -17,6 +27,7 @@ KEYWORDLIST KeyWords_VB = { EDITLEXER lexVB = { SCLEX_VB, IDS_LEX_VIS_BAS, L"Visual Basic", L"vb; bas; frm; cls; ctl; pag; dsr; dob", L"", +&LexFunction, // static &KeyWords_VB, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_B_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexVBS.c b/src/StyleLexers/styleLexVBS.c index 577345a23..aef0bfcce 100644 --- a/src/StyleLexers/styleLexVBS.c +++ b/src/StyleLexers/styleLexVBS.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_VBS = { "alias and as attribute begin boolean byref byte byval call case class compare const continue " "currency date declare dim do double each else elseif empty end enum eqv erase error event exit " @@ -12,6 +22,7 @@ KEYWORDLIST KeyWords_VBS = { EDITLEXER lexVBS = { SCLEX_VBSCRIPT, IDS_LEX_VB_SCR, L"VBScript", L"vbs; dsm", L"", +&LexFunction, // static &KeyWords_VBS, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_B_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexVHDL.c b/src/StyleLexers/styleLexVHDL.c index 3b8275456..bbc756cce 100644 --- a/src/StyleLexers/styleLexVHDL.c +++ b/src/StyleLexers/styleLexVHDL.c @@ -1,5 +1,15 @@ #include "StyleLexers.h" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + KEYWORDLIST KeyWords_VHDL = { "access after alias all architecture array assert attribute begin block body buffer bus case component configuration " "constant disconnect downto else elsif end entity exit file for function generate generic group guarded if impure in " @@ -20,6 +30,7 @@ KEYWORDLIST KeyWords_VHDL = { EDITLEXER lexVHDL = { SCLEX_VHDL, IDS_LEX_VHDL, L"VHDL", L"vhdl; vhd", L"", +&LexFunction, // static &KeyWords_VHDL, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_VHDL_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/StyleLexers/styleLexXML.c b/src/StyleLexers/styleLexXML.c index b8d179d5a..d587cb7a7 100644 --- a/src/StyleLexers/styleLexXML.c +++ b/src/StyleLexers/styleLexXML.c @@ -1,12 +1,21 @@ #include "StyleLexers.h" -KEYWORDLIST KeyWords_XML = { -"", "", "", "", "", "", "", "", "" +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; }; +// ---------------------------------------------------------------------------- + +KEYWORDLIST KeyWords_XML = EMPTY_KEYWORDLIST; + EDITLEXER lexXML = { SCLEX_XML, IDS_LEX_XML_DOC, L"XML Document", L"xml; xsl; rss; svg; xul; xsd; xslt; axl; rdf; xaml; vcproj", L"", +&LexFunction, // static &KeyWords_XML, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, { MULTI_STYLE(SCE_H_TAG,SCE_H_TAGUNKNOWN,SCE_H_TAGEND,0), IDS_LEX_STR_63187, L"XML Tag", L"fore:#881280", L"" }, @@ -22,4 +31,3 @@ SCLEX_XML, IDS_LEX_XML_DOC, L"XML Document", L"xml; xsl; rss; svg; xul; xsd; xsl { SCE_H_CDATA, IDS_LEX_STR_63147, L"CDATA", L"fore:#646464", L"" }, EDITLEXER_SENTINEL } }; - diff --git a/src/StyleLexers/styleLexYAML.c b/src/StyleLexers/styleLexYAML.c index 870dc6499..a3cd9fd69 100644 --- a/src/StyleLexers/styleLexYAML.c +++ b/src/StyleLexers/styleLexYAML.c @@ -1,10 +1,20 @@ #include "StyleLexers.h" -KEYWORDLIST KeyWords_YAML = { -"y n yes no on off true false", "", "", "", "", "", "", "", "" }; +// ---------------------------------------------------------------------------- + +static __int64 LexFunction(LexFunctionType type, int value) +{ + LEX_FUNCTION_BODY(type, value); + return 0LL; +}; + +// ---------------------------------------------------------------------------- + +KEYWORDLIST KeyWords_YAML = { "y n yes no on off true false", "", "", "", "", "", "", "", "" }; EDITLEXER lexYAML = { SCLEX_YAML, IDS_LEX_YAML, L"YAML", L"yaml; yml", L"", +&LexFunction, // static &KeyWords_YAML, { { STYLE_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, //{ SCE_YAML_DEFAULT, IDS_LEX_STR_63126, L"Default", L"", L"" }, diff --git a/src/Styles.c b/src/Styles.c index 010ffb470..cf2f1d1c0 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -26,6 +26,7 @@ #define WIN32_LEAN_AND_MEAN 1 #define NOMINMAX 1 #include +#include #include #include #include @@ -46,29 +47,11 @@ #include "Styles.h" -extern HINSTANCE g_hInstance; -extern HMODULE g_hLngResContainer; -extern HICON g_hDlgIcon; - -extern HWND g_hwndMain; -extern HWND g_hwndDlgCustomizeSchemes; -extern EDITFINDREPLACE g_efrData; -extern WCHAR g_tchPrefLngLocName[]; - -extern int g_iRenderingTechnology; -extern int g_iSciFontQuality; extern const int FontQuality[4]; extern bool g_bCodeFoldingAvailable; -extern bool g_bShowCodeFolding; -extern bool g_bShowSelectionMargin; extern bool g_bIniFileFromScratch; - -extern int g_iMarkOccurrences; -extern bool g_bUseOldStyleBraceMatching; - -extern int xCustomSchemesDlg; -extern int yCustomSchemesDlg; +extern int g_iDefaultCharSet; bool ChooseFontDirectWrite(HWND hwnd, const WCHAR* localeName, UINT dpi, LPCHOOSEFONT lpCF); @@ -133,21 +116,18 @@ static PEDITLEXER g_pLexArray[NUMLEXERS] = // Currently used lexer -static int g_iDefaultLexer = 0; -static PEDITLEXER g_pLexCurrent = &lexStandard; +static int s_iDefaultLexer = 0; +static PEDITLEXER s_pLexCurrent = &lexStandard; -static bool g_fStylesModified = false; -static bool g_fWarnedNoIniFile = false; +static bool s_fWarnedNoIniFile = false; -static COLORREF g_colorCustom[16]; -static bool g_bAutoSelect; -static int g_cxStyleSelectDlg; -static int g_cyStyleSelectDlg; +static COLORREF s_colorCustom[16]; +static bool s_bAutoSelect = true; - -extern int g_iDefaultCharSet; -extern bool bHiliteCurrentLine; -extern bool g_bHyperlinkHotspot; +#define STYLESELECTDLG_X 304 +#define STYLESELECTDLG_Y 344 +static int s_cxStyleSelectDlg = STYLESELECTDLG_X; +static int s_cyStyleSelectDlg = STYLESELECTDLG_Y; //============================================================================= @@ -155,29 +135,29 @@ extern bool g_bHyperlinkHotspot; // IsLexerStandard() // -bool __fastcall IsLexerStandard(PEDITLEXER pLexer) +bool IsLexerStandard(PEDITLEXER pLexer) { return ( pLexer && ((pLexer == &lexStandard) || (pLexer == &lexStandard2nd)) ); } -PEDITLEXER __fastcall GetCurrentStdLexer() +PEDITLEXER GetCurrentStdLexer() { return (Style_GetUse2ndDefault() ? &lexStandard2nd : &lexStandard); } -bool __fastcall IsStyleStandardDefault(PEDITSTYLE pStyle) +bool IsStyleStandardDefault(PEDITSTYLE pStyle) { return (pStyle && ((pStyle->rid == IDS_LEX_STD_STYLE) || (pStyle->rid == IDS_LEX_2ND_STYLE))); } -bool __fastcall IsStyleSchemeDefault(PEDITSTYLE pStyle) +bool IsStyleSchemeDefault(PEDITSTYLE pStyle) { return (pStyle && (pStyle->rid == IDS_LEX_STR_63126)); } -PEDITLEXER __fastcall GetDefaultLexer() +PEDITLEXER GetDefaultLexer() { - return g_pLexArray[g_iDefaultLexer]; + return g_pLexArray[s_iDefaultLexer]; } @@ -188,7 +168,7 @@ PEDITLEXER __fastcall GetDefaultLexer() // bool Style_IsCurLexerStandard() { - return IsLexerStandard(g_pLexCurrent); + return IsLexerStandard(s_pLexCurrent); } @@ -196,7 +176,7 @@ bool Style_IsCurLexerStandard() // // _SetBaseFontSize(), _GetBaseFontSize() // -static float __fastcall _SetBaseFontSize(float fSize) +static float _SetBaseFontSize(float fSize) { static float fBaseFontSize = INITIAL_BASE_FONT_SIZE; @@ -206,7 +186,7 @@ static float __fastcall _SetBaseFontSize(float fSize) return fBaseFontSize; } -static float __fastcall _GetBaseFontSize() +static float _GetBaseFontSize() { return _SetBaseFontSize(-1.0); } @@ -216,7 +196,7 @@ static float __fastcall _GetBaseFontSize() // // Style_RgbAlpha() // -int __fastcall Style_RgbAlpha(int rgbFore, int rgbBack, int alpha) +int Style_RgbAlpha(int rgbFore, int rgbBack, int alpha) { return (int)RGB(\ (0xFF - alpha) * (int)GetRValue(rgbBack) / 0xFF + alpha * (int)GetRValue(rgbFore) / 0xFF, \ @@ -229,7 +209,7 @@ int __fastcall Style_RgbAlpha(int rgbFore, int rgbBack, int alpha) // // _SetCurrentFontSize(), _GetCurrentFontSize() // -static float __fastcall _SetCurrentFontSize(float fSize) +static float _SetCurrentFontSize(float fSize) { static float fCurrentFontSize = INITIAL_BASE_FONT_SIZE; @@ -252,34 +232,32 @@ float Style_GetCurrentFontSize() // void Style_Load() { - int i,iLexer; WCHAR tch[32] = { L'\0' }; - //WCHAR szTmpStyle[BUFSIZE_STYLE_VALUE] = { L'\0' }; size_t const len = NUMLEXERS * AVG_NUM_OF_STYLES_PER_LEXER * 100; WCHAR *pIniSection = AllocMem(len * sizeof(WCHAR), HEAP_ZERO_MEMORY); if (pIniSection) { int const cchIniSection = (int)len; // Custom colors - g_colorCustom[0] = RGB(0x00, 0x00, 0x00); - g_colorCustom[1] = RGB(0x0A, 0x24, 0x6A); - g_colorCustom[2] = RGB(0x3A, 0x6E, 0xA5); - g_colorCustom[3] = RGB(0x00, 0x3C, 0xE6); - g_colorCustom[4] = RGB(0x00, 0x66, 0x33); - g_colorCustom[5] = RGB(0x60, 0x80, 0x20); - g_colorCustom[6] = RGB(0x64, 0x80, 0x00); - g_colorCustom[7] = RGB(0xA4, 0x60, 0x00); - g_colorCustom[8] = RGB(0xFF, 0xFF, 0xFF); - g_colorCustom[9] = RGB(0xFF, 0xFF, 0xE2); - g_colorCustom[10] = RGB(0xFF, 0xF1, 0xA8); - g_colorCustom[11] = RGB(0xFF, 0xC0, 0x00); - g_colorCustom[12] = RGB(0xFF, 0x40, 0x00); - g_colorCustom[13] = RGB(0xC8, 0x00, 0x00); - g_colorCustom[14] = RGB(0xB0, 0x00, 0xB0); - g_colorCustom[15] = RGB(0xB2, 0x8B, 0x40); + s_colorCustom[0] = RGB(0x00, 0x00, 0x00); + s_colorCustom[1] = RGB(0x0A, 0x24, 0x6A); + s_colorCustom[2] = RGB(0x3A, 0x6E, 0xA5); + s_colorCustom[3] = RGB(0x00, 0x3C, 0xE6); + s_colorCustom[4] = RGB(0x00, 0x66, 0x33); + s_colorCustom[5] = RGB(0x60, 0x80, 0x20); + s_colorCustom[6] = RGB(0x64, 0x80, 0x00); + s_colorCustom[7] = RGB(0xA4, 0x60, 0x00); + s_colorCustom[8] = RGB(0xFF, 0xFF, 0xFF); + s_colorCustom[9] = RGB(0xFF, 0xFF, 0xE2); + s_colorCustom[10] = RGB(0xFF, 0xF1, 0xA8); + s_colorCustom[11] = RGB(0xFF, 0xC0, 0x00); + s_colorCustom[12] = RGB(0xFF, 0x40, 0x00); + s_colorCustom[13] = RGB(0xC8, 0x00, 0x00); + s_colorCustom[14] = RGB(0xB0, 0x00, 0xB0); + s_colorCustom[15] = RGB(0xB2, 0x8B, 0x40); LoadIniSection(L"Custom Colors", pIniSection, cchIniSection); - for (i = 0; i < 16; i++) { + for (int i = 0; i < 16; i++) { WCHAR wch[32] = { L'\0' }; StringCchPrintf(tch, COUNTOF(tch), L"%02i", i + 1); if (IniSectionGetString(pIniSection, tch, L"", wch, COUNTOF(wch))) { @@ -287,7 +265,7 @@ void Style_Load() unsigned int irgb; int itok = swscanf_s(CharNext(wch), L"%x", &irgb); if (itok == 1) - g_colorCustom[i] = RGB((irgb & 0xFF0000) >> 16, (irgb & 0xFF00) >> 8, irgb & 0xFF); + s_colorCustom[i] = RGB((irgb & 0xFF0000) >> 16, (irgb & 0xFF00) >> 8, irgb & 0xFF); } } } @@ -298,37 +276,40 @@ void Style_Load() Style_SetUse2ndDefault(IniSectionGetBool(pIniSection, L"Use2ndDefaultStyle", false)); // default scheme - g_iDefaultLexer = IniSectionGetInt(pIniSection, L"DefaultScheme", 0); - g_iDefaultLexer = clampi(g_iDefaultLexer, 0, COUNTOF(g_pLexArray) - 1); + s_iDefaultLexer = clampi(IniSectionGetInt(pIniSection, L"DefaultScheme", 0), 0, COUNTOF(g_pLexArray) - 1); // auto select - g_bAutoSelect = (IniSectionGetInt(pIniSection, L"AutoSelect", 1)) ? 1 : 0; + s_bAutoSelect = IniSectionGetBool(pIniSection, L"AutoSelect", true); // scheme select dlg dimensions - g_cxStyleSelectDlg = IniSectionGetInt(pIniSection, L"SelectDlgSizeX", 304); - g_cxStyleSelectDlg = max_i(g_cxStyleSelectDlg, 0); + s_cxStyleSelectDlg = clampi(IniSectionGetInt(pIniSection, L"SelectDlgSizeX", STYLESELECTDLG_X), 0, 8192); + s_cyStyleSelectDlg = clampi(IniSectionGetInt(pIniSection, L"SelectDlgSizeY", STYLESELECTDLG_Y), 0, 8192); + + + for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); iLexer++) { - g_cyStyleSelectDlg = IniSectionGetInt(pIniSection, L"SelectDlgSizeY", 0); - g_cyStyleSelectDlg = max_i(g_cyStyleSelectDlg, 324); + LexFunctionPtr_t const pLexFunction = g_pLexArray[iLexer]->pFctPtr; - for (iLexer = 0; iLexer < COUNTOF(g_pLexArray); iLexer++) { LoadIniSection(g_pLexArray[iLexer]->pszName, pIniSection, cchIniSection); - IniSectionGetString(pIniSection, L"FileNameExtensions", g_pLexArray[iLexer]->pszDefExt, - g_pLexArray[iLexer]->szExtensions, COUNTOF(g_pLexArray[iLexer]->szExtensions)); - i = 0; - while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) { - //szTmpStyle[0] = L'\0'; // clear - //IniSectionGetString(pIniSection, g_pLexArray[iLexer]->Styles[i].pszName, - // g_pLexArray[iLexer]->Styles[i].pszDefault, - // szTmpStyle, COUNTOF(szTmpStyle)); - //// normalize - //Style_CopyStyles_IfNotDefined(szTmpStyle, g_pLexArray[iLexer]->Styles[i].szValue, - // COUNTOF(g_pLexArray[iLexer]->Styles[i].szValue), true, true); - IniSectionGetString(pIniSection, g_pLexArray[iLexer]->Styles[i].pszName, - g_pLexArray[iLexer]->Styles[i].pszDefault, - g_pLexArray[iLexer]->Styles[i].szValue, - COUNTOF(g_pLexArray[iLexer]->Styles[i].szValue)); + 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); + } + } + int i = 0; + while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) + { + if (IniSectionGetString(pIniSection, g_pLexArray[iLexer]->Styles[i].pszName, + g_pLexArray[iLexer]->Styles[i].pszDefault, + 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)); + } + } ++i; } } @@ -355,50 +336,58 @@ void Style_Save() WCHAR wch[32] = { L'\0' }; StringCchPrintf(tch, COUNTOF(tch), L"%02i", i + 1); StringCchPrintf(wch, COUNTOF(wch), L"#%02X%02X%02X", - (int)GetRValue(g_colorCustom[i]), (int)GetGValue(g_colorCustom[i]), (int)GetBValue(g_colorCustom[i])); + (int)GetRValue(s_colorCustom[i]), (int)GetGValue(s_colorCustom[i]), (int)GetBValue(s_colorCustom[i])); IniSectionSetString(pIniSection, tch, wch); } SaveIniSection(L"Custom Colors", pIniSection); ZeroMemory(pIniSection, len * sizeof(WCHAR)); // auto select - IniSectionSetBool(pIniSection, L"Use2ndDefaultStyle", Style_GetUse2ndDefault()); + bool const bUse2ndSty = Style_GetUse2ndDefault(); + if (bUse2ndSty) + IniSectionSetBool(pIniSection, L"Use2ndDefaultStyle", bUse2ndSty); // default scheme - IniSectionSetInt(pIniSection, L"DefaultScheme", g_iDefaultLexer); + if (s_iDefaultLexer != 0) + IniSectionSetInt(pIniSection, L"DefaultScheme", s_iDefaultLexer); // auto select - IniSectionSetInt(pIniSection, L"AutoSelect", g_bAutoSelect); + if (!s_bAutoSelect) + IniSectionSetInt(pIniSection, L"AutoSelect", s_bAutoSelect); // scheme select dlg dimensions - IniSectionSetInt(pIniSection, L"SelectDlgSizeX", g_cxStyleSelectDlg); - IniSectionSetInt(pIniSection, L"SelectDlgSizeY", g_cyStyleSelectDlg); + if (s_cxStyleSelectDlg != STYLESELECTDLG_X) + IniSectionSetInt(pIniSection, L"SelectDlgSizeX", s_cxStyleSelectDlg); + if (s_cyStyleSelectDlg != STYLESELECTDLG_Y) + IniSectionSetInt(pIniSection, L"SelectDlgSizeY", s_cyStyleSelectDlg); SaveIniSection(L"Styles", pIniSection); ZeroMemory(pIniSection, len * sizeof(WCHAR)); - if (!g_fStylesModified) { - if (g_bIniFileFromScratch) { - for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); iLexer++) { - SaveIniSection(g_pLexArray[iLexer]->pszName, L"\0"); - } + if (g_bIniFileFromScratch) { + for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); iLexer++) { + SaveIniSection(g_pLexArray[iLexer]->pszName, L"\0"); } - FreeMem(pIniSection); - return; } for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); iLexer++) { - IniSectionSetString(pIniSection, L"FileNameExtensions", g_pLexArray[iLexer]->szExtensions); + LexFunctionPtr_t const pLexFunction = g_pLexArray[iLexer]->pFctPtr; + if (((*pLexFunction)(FCT_SETTING_CHANGE, 0) & (((__int64)1) << 1)) != 0LL) { + IniSectionSetString(pIniSection, L"FileNameExtensions", g_pLexArray[iLexer]->szExtensions); + } int i = 0; while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) { - // normalize - szTmpStyle[0] = L'\0'; // clear - Style_CopyStyles_IfNotDefined(g_pLexArray[iLexer]->Styles[i].szValue, szTmpStyle, COUNTOF(szTmpStyle), true, true); - IniSectionSetString(pIniSection, g_pLexArray[iLexer]->Styles[i].pszName, szTmpStyle); + if (((*pLexFunction)(FCT_SETTING_CHANGE, 0) & (((__int64)1) << (i+2))) != 0LL) { + // normalize + szTmpStyle[0] = L'\0'; // clear + Style_CopyStyles_IfNotDefined(g_pLexArray[iLexer]->Styles[i].szValue, szTmpStyle, COUNTOF(szTmpStyle), true, true); + IniSectionSetString(pIniSection, g_pLexArray[iLexer]->Styles[i].pszName, szTmpStyle); + } ++i; } SaveIniSection(g_pLexArray[iLexer]->pszName, pIniSection); ZeroMemory(pIniSection, len * sizeof(WCHAR)); + } FreeMem(pIniSection); } @@ -530,14 +519,14 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) // first set standard lexer's default values if (IsLexerStandard(pLexNew)) { - g_pLexCurrent = pLexNew; - Style_SetUse2ndDefault(g_pLexCurrent == &lexStandard2nd); // sync if forced + s_pLexCurrent = pLexNew; + Style_SetUse2ndDefault(s_pLexCurrent == &lexStandard2nd); // sync if forced } else { - g_pLexCurrent = GetCurrentStdLexer(); + s_pLexCurrent = GetCurrentStdLexer(); } - const WCHAR* const wchStandardStyleStrg = g_pLexCurrent->Styles[STY_DEFAULT].szValue; + const WCHAR* const wchStandardStyleStrg = s_pLexCurrent->Styles[STY_DEFAULT].szValue; // Lexer SendMessage(hwnd, SCI_SETLEXER, pLexNew->lexerID, 0); @@ -624,13 +613,13 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) if (IsLexerStandard(pLexNew)) { // styles ar already set - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_CURRENTSCHEME, false); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_CURRENTSCHEME, false); } else { // merge lexer default styles Style_SetStyles(hwnd, STYLE_DEFAULT, wchNewLexerStyleStrg, false); - EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_CURRENTSCHEME, true && !IsWindow(g_hwndDlgCustomizeSchemes)); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_CURRENTSCHEME, true && !IsWindow(Globals.hwndDlgCustomizeSchemes)); } // Broadcast STYLE_DEFAULT as base style to all other styles @@ -638,14 +627,14 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) // -------------------------------------------------------------------------- - const PEDITLEXER pCurrentStandard = g_pLexCurrent; + const PEDITLEXER pCurrentStandard = s_pLexCurrent; // -------------------------------------------------------------------------- Style_SetMargin(hwnd, pCurrentStandard->Styles[STY_MARGIN].iStyle, pCurrentStandard->Styles[STY_MARGIN].szValue); // margin (line number, bookmarks, folding) style - if (g_bUseOldStyleBraceMatching) { + if (Settings2.UseOldStyleBraceMatching) { Style_SetStyles(hwnd, pCurrentStandard->Styles[STY_BRACE_OK].iStyle, pCurrentStandard->Styles[STY_BRACE_OK].szValue, false); // brace light } @@ -666,7 +655,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) } SendMessage(hwnd, SCI_INDICSETSTYLE, INDIC_NP3_MATCH_BRACE, iValue); } - if (g_bUseOldStyleBraceMatching) { + if (Settings2.UseOldStyleBraceMatching) { Style_SetStyles(hwnd, pCurrentStandard->Styles[STY_BRACE_BAD].iStyle, pCurrentStandard->Styles[STY_BRACE_BAD].szValue, false); // brace bad } @@ -692,7 +681,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) if (!Style_StrGetColor(true, pCurrentStandard->Styles[STY_MARK_OCC].szValue, &dColor)) { WCHAR* sty = L""; - switch (g_iMarkOccurrences) { + switch (Settings.MarkOccurrences) { case 1: sty = L"fore:0xFF0000"; dColor = RGB(0xFF, 0x00, 0x00); @@ -831,10 +820,10 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) SendMessage(hwnd, SCI_SETWHITESPACESIZE, iValue, 0); // current line background - Style_SetCurrentLineBackground(hwnd, bHiliteCurrentLine); + Style_SetCurrentLineBackground(hwnd, Settings.HighlightCurrentLine); // bookmark line or marker - Style_SetBookmark(hwnd, g_bShowSelectionMargin); + Style_SetBookmark(hwnd, Settings.ShowSelectionMargin); // caret style and width if (StrStr(pCurrentStandard->Styles[STY_CARET].szValue,L"block")) { @@ -909,14 +898,14 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) } // here: global define current lexer (used in subsequent calls) - g_pLexCurrent = pLexNew; + s_pLexCurrent = pLexNew; - if (g_pLexCurrent == &lexANSI) { // special ANSI-Art style + if (s_pLexCurrent == &lexANSI) { // special ANSI-Art style - Style_SetMargin(hwnd, g_pLexCurrent->Styles[STY_MARGIN].iStyle, - g_pLexCurrent->Styles[STY_MARGIN].szValue); // margin (line number, bookmarks, folding) style + Style_SetMargin(hwnd, s_pLexCurrent->Styles[STY_MARGIN].iStyle, + s_pLexCurrent->Styles[STY_MARGIN].szValue); // margin (line number, bookmarks, folding) style - if (g_bUseOldStyleBraceMatching) { + if (Settings2.UseOldStyleBraceMatching) { Style_SetStyles(hwnd, pCurrentStandard->Styles[STY_BRACE_OK].iStyle, pCurrentStandard->Styles[STY_BRACE_OK].szValue, false); @@ -925,63 +914,63 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) } // (SCI_SETEXTRAASCENT + SCI_SETEXTRADESCENT) at pos STY_CTRL_CHR(4) ) - Style_SetExtraLineSpace(hwnd, g_pLexCurrent->Styles[STY_CTRL_CHR].szValue, - COUNTOF(g_pLexCurrent->Styles[STY_CTRL_CHR].szValue)); + Style_SetExtraLineSpace(hwnd, s_pLexCurrent->Styles[STY_CTRL_CHR].szValue, + COUNTOF(s_pLexCurrent->Styles[STY_CTRL_CHR].szValue)); } - else if (g_pLexCurrent->lexerID != SCLEX_NULL) + else if (s_pLexCurrent->lexerID != SCLEX_NULL) { // ----------------------------------------------- int i = 1; // don't re-apply lexer's default style // ----------------------------------------------- - while (g_pLexCurrent->Styles[i].iStyle != -1) + while (s_pLexCurrent->Styles[i].iStyle != -1) { // apply MULTI_STYLE() MACRO - for (int j = 0; j < 4 && (g_pLexCurrent->Styles[i].iStyle8[j] != 0 || j == 0); ++j) { - Style_SetStyles(hwnd, g_pLexCurrent->Styles[i].iStyle8[j], g_pLexCurrent->Styles[i].szValue, false); + for (int j = 0; j < 4 && (s_pLexCurrent->Styles[i].iStyle8[j] != 0 || j == 0); ++j) { + Style_SetStyles(hwnd, s_pLexCurrent->Styles[i].iStyle8[j], s_pLexCurrent->Styles[i].szValue, false); } - if (g_pLexCurrent->lexerID == SCLEX_HTML && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_HPHP_DEFAULT) { + if (s_pLexCurrent->lexerID == SCLEX_HTML && s_pLexCurrent->Styles[i].iStyle8[0] == SCE_HPHP_DEFAULT) { int iRelated[] = { SCE_HPHP_COMMENT, SCE_HPHP_COMMENTLINE, SCE_HPHP_WORD, SCE_HPHP_HSTRING, SCE_HPHP_SIMPLESTRING, SCE_HPHP_NUMBER, SCE_HPHP_OPERATOR, SCE_HPHP_VARIABLE, SCE_HPHP_HSTRING_VARIABLE, SCE_HPHP_COMPLEX_VARIABLE }; for (int j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue, false); + Style_SetStyles(hwnd,iRelated[j],s_pLexCurrent->Styles[i].szValue, false); } - if (g_pLexCurrent->lexerID == SCLEX_HTML && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_HJ_DEFAULT) { + if (s_pLexCurrent->lexerID == SCLEX_HTML && s_pLexCurrent->Styles[i].iStyle8[0] == SCE_HJ_DEFAULT) { int iRelated[] = { SCE_HJ_COMMENT, SCE_HJ_COMMENTLINE, SCE_HJ_COMMENTDOC, SCE_HJ_KEYWORD, SCE_HJ_WORD, SCE_HJ_DOUBLESTRING, SCE_HJ_SINGLESTRING, SCE_HJ_STRINGEOL, SCE_HJ_REGEX, SCE_HJ_NUMBER, SCE_HJ_SYMBOLS }; for (int j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue, false); + Style_SetStyles(hwnd,iRelated[j],s_pLexCurrent->Styles[i].szValue, false); } - if (g_pLexCurrent->lexerID == SCLEX_HTML && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_HJA_DEFAULT) { + if (s_pLexCurrent->lexerID == SCLEX_HTML && s_pLexCurrent->Styles[i].iStyle8[0] == SCE_HJA_DEFAULT) { int iRelated[] = { SCE_HJA_COMMENT, SCE_HJA_COMMENTLINE, SCE_HJA_COMMENTDOC, SCE_HJA_KEYWORD, SCE_HJA_WORD, SCE_HJA_DOUBLESTRING, SCE_HJA_SINGLESTRING, SCE_HJA_STRINGEOL, SCE_HJA_REGEX, SCE_HJA_NUMBER, SCE_HJA_SYMBOLS }; for (int j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue, false); + Style_SetStyles(hwnd,iRelated[j],s_pLexCurrent->Styles[i].szValue, false); } - if (g_pLexCurrent->lexerID == SCLEX_HTML && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_HB_DEFAULT) { + if (s_pLexCurrent->lexerID == SCLEX_HTML && s_pLexCurrent->Styles[i].iStyle8[0] == SCE_HB_DEFAULT) { int iRelated[] = { SCE_HB_COMMENTLINE, SCE_HB_WORD, SCE_HB_IDENTIFIER, SCE_HB_STRING, SCE_HB_STRINGEOL, SCE_HB_NUMBER }; for (int j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue, false); + Style_SetStyles(hwnd,iRelated[j],s_pLexCurrent->Styles[i].szValue, false); } - if (g_pLexCurrent->lexerID == SCLEX_HTML && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_HBA_DEFAULT) { + if (s_pLexCurrent->lexerID == SCLEX_HTML && s_pLexCurrent->Styles[i].iStyle8[0] == SCE_HBA_DEFAULT) { int iRelated[] = { SCE_HBA_COMMENTLINE, SCE_HBA_WORD, SCE_HBA_IDENTIFIER, SCE_HBA_STRING, SCE_HBA_STRINGEOL, SCE_HBA_NUMBER }; for (int j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue, false); + Style_SetStyles(hwnd,iRelated[j],s_pLexCurrent->Styles[i].szValue, false); } - if ((g_pLexCurrent->lexerID == SCLEX_HTML || g_pLexCurrent->lexerID == SCLEX_XML) && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_H_SGML_DEFAULT) { + if ((s_pLexCurrent->lexerID == SCLEX_HTML || s_pLexCurrent->lexerID == SCLEX_XML) && s_pLexCurrent->Styles[i].iStyle8[0] == SCE_H_SGML_DEFAULT) { int iRelated[] = { SCE_H_SGML_COMMAND, SCE_H_SGML_1ST_PARAM, SCE_H_SGML_DOUBLESTRING, SCE_H_SGML_SIMPLESTRING, SCE_H_SGML_ERROR, SCE_H_SGML_SPECIAL, SCE_H_SGML_ENTITY, SCE_H_SGML_COMMENT, SCE_H_SGML_1ST_PARAM_COMMENT, SCE_H_SGML_BLOCK_DEFAULT }; for (int j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue, false); + Style_SetStyles(hwnd,iRelated[j],s_pLexCurrent->Styles[i].szValue, false); } - if ((g_pLexCurrent->lexerID == SCLEX_HTML || g_pLexCurrent->lexerID == SCLEX_XML) && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_H_CDATA) { + if ((s_pLexCurrent->lexerID == SCLEX_HTML || s_pLexCurrent->lexerID == SCLEX_XML) && s_pLexCurrent->Styles[i].iStyle8[0] == SCE_H_CDATA) { int iRelated[] = { SCE_HP_START, SCE_HP_DEFAULT, SCE_HP_COMMENTLINE, SCE_HP_NUMBER, SCE_HP_STRING, SCE_HP_CHARACTER, SCE_HP_WORD, SCE_HP_TRIPLE, SCE_HP_TRIPLEDOUBLE, SCE_HP_CLASSNAME, SCE_HP_DEFNAME, SCE_HP_OPERATOR, SCE_HP_IDENTIFIER, SCE_HPA_START, SCE_HPA_DEFAULT, @@ -989,10 +978,10 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) SCE_HPA_TRIPLE, SCE_HPA_TRIPLEDOUBLE, SCE_HPA_CLASSNAME, SCE_HPA_DEFNAME, SCE_HPA_OPERATOR, SCE_HPA_IDENTIFIER }; for (int j = 0; j < COUNTOF(iRelated); j++) - Style_SetStyles(hwnd,iRelated[j],g_pLexCurrent->Styles[i].szValue, false); + Style_SetStyles(hwnd,iRelated[j],s_pLexCurrent->Styles[i].szValue, false); } - if (g_pLexCurrent->lexerID == SCLEX_XML && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_H_CDATA) { + if (s_pLexCurrent->lexerID == SCLEX_XML && s_pLexCurrent->Styles[i].iStyle8[0] == SCE_H_CDATA) { int iRelated[] = { SCE_H_SCRIPT, SCE_H_ASP, SCE_H_ASPAT, SCE_H_QUESTION, SCE_HPHP_DEFAULT, SCE_HPHP_COMMENT, SCE_HPHP_COMMENTLINE, SCE_HPHP_WORD, SCE_HPHP_HSTRING, SCE_HPHP_SIMPLESTRING, SCE_HPHP_NUMBER, SCE_HPHP_OPERATOR, SCE_HPHP_VARIABLE, @@ -1012,21 +1001,21 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) SCE_HPA_CLASSNAME, SCE_HPA_DEFNAME, SCE_HPA_OPERATOR, SCE_HPA_IDENTIFIER }; for (int j = 0; j < COUNTOF(iRelated); j++) { - Style_SetStyles(hwnd, iRelated[j], g_pLexCurrent->Styles[i].szValue, false); + Style_SetStyles(hwnd, iRelated[j], s_pLexCurrent->Styles[i].szValue, false); } } - if (g_pLexCurrent->lexerID == SCLEX_CPP && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_C_COMMENT) { + if (s_pLexCurrent->lexerID == SCLEX_CPP && s_pLexCurrent->Styles[i].iStyle8[0] == SCE_C_COMMENT) { int iRelated[] = { SCE_C_COMMENTLINE, SCE_C_COMMENTDOC, SCE_C_COMMENTLINEDOC, SCE_C_COMMENTDOCKEYWORD, SCE_C_COMMENTDOCKEYWORDERROR }; for (int j = 0; j < COUNTOF(iRelated); j++) { - Style_SetStyles(hwnd, iRelated[j], g_pLexCurrent->Styles[i].szValue, false); + Style_SetStyles(hwnd, iRelated[j], s_pLexCurrent->Styles[i].szValue, false); } } - if (g_pLexCurrent->lexerID == SCLEX_SQL && g_pLexCurrent->Styles[i].iStyle8[0] == SCE_SQL_COMMENT) { + if (s_pLexCurrent->lexerID == SCLEX_SQL && s_pLexCurrent->Styles[i].iStyle8[0] == SCE_SQL_COMMENT) { int iRelated[] = { SCE_SQL_COMMENTLINE, SCE_SQL_COMMENTDOC, SCE_SQL_COMMENTLINEDOC, SCE_SQL_COMMENTDOCKEYWORD, SCE_SQL_COMMENTDOCKEYWORDERROR }; for (int j = 0; j < COUNTOF(iRelated); j++) { - Style_SetStyles(hwnd, iRelated[j], g_pLexCurrent->Styles[i].szValue, false); + Style_SetStyles(hwnd, iRelated[j], s_pLexCurrent->Styles[i].szValue, false); } } ++i; @@ -1040,9 +1029,9 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) EditApplyLexerStyle(hwnd, 0, -1); // update UI for hotspots - if (g_bHyperlinkHotspot) { - Style_SetUrlHotSpot(hwnd, g_bHyperlinkHotspot); - EditUpdateUrlHotspots(hwnd, 0, Sci_GetDocEndPosition(), g_bHyperlinkHotspot); + if (Settings.HyperlinkHotspot) { + Style_SetUrlHotSpot(hwnd, Settings.HyperlinkHotspot); + EditUpdateUrlHotspots(hwnd, 0, Sci_GetDocEndPosition(), Settings.HyperlinkHotspot); } UpdateToolbar(); @@ -1090,7 +1079,7 @@ void Style_SetUrlHotSpot(HWND hwnd, bool bHotSpot) } } else { - const WCHAR* const lpszStyleHotSpot = g_pLexCurrent->Styles[STY_DEFAULT].szValue; + const WCHAR* const lpszStyleHotSpot = s_pLexCurrent->Styles[STY_DEFAULT].szValue; Style_SetStyles(hwnd, cHotSpotStyleID, lpszStyleHotSpot, false); SendMessage(hwnd, SCI_STYLESETHOTSPOT, cHotSpotStyleID, (LPARAM)false); } @@ -1180,7 +1169,7 @@ void Style_SetCurrentLineBackground(HWND hwnd, bool bHiLitCurrLn) // // _GetMarkerMarginWidth() // -static int __fastcall _GetMarkerMarginWidth() +static int _GetMarkerMarginWidth() { float fSize = _GetBaseFontSize(); Style_StrGetSize(GetCurrentStdLexer()->Styles[STY_MARGIN].szValue, &fSize); // relative to LineNumber @@ -1328,8 +1317,8 @@ void Style_SetMargin(HWND hwnd, int iStyle, LPCWSTR lpszStyle) } // set width - Style_SetBookmark(hwnd, g_bShowSelectionMargin); - Style_SetFolding(hwnd, (g_bCodeFoldingAvailable && g_bShowCodeFolding)); + Style_SetBookmark(hwnd, Settings.ShowSelectionMargin); + Style_SetFolding(hwnd, (g_bCodeFoldingAvailable && Settings.ShowCodeFolding)); } @@ -1337,7 +1326,7 @@ void Style_SetMargin(HWND hwnd, int iStyle, LPCWSTR lpszStyle) // // Style_SniffShebang() // -PEDITLEXER __fastcall Style_SniffShebang(char* pchText) +PEDITLEXER Style_SniffShebang(char* pchText) { if (StrCmpNA(pchText,"#!",2) == 0) { char *pch = pchText + 2; @@ -1378,40 +1367,37 @@ PEDITLEXER __fastcall Style_SniffShebang(char* pchText) // // Style_MatchLexer() // -PEDITLEXER __fastcall Style_MatchLexer(LPCWSTR lpszMatch,bool bCheckNames) { - int i; - WCHAR tch[COUNTOF(g_pLexArray[0]->szExtensions)] = { L'\0' }; - WCHAR *p1,*p2; +PEDITLEXER Style_MatchLexer(LPCWSTR lpszMatch, bool bCheckNames) +{ + int const cch = (int)StringCchLenW(lpszMatch, 0); if (!bCheckNames) { - for (i = 0; i < COUNTOF(g_pLexArray); i++) { - ZeroMemory(tch,sizeof(WCHAR)*COUNTOF(tch)); - StringCchCopy(tch,COUNTOF(tch),g_pLexArray[i]->szExtensions); - p1 = tch; - while (*p1) { - p2 = StrChr(p1,L';'); - if (p2) - *p2 = L'\0'; - else - p2 = StrEnd(p1,0); - StrTrim(p1,L" ."); - if (StringCchCompareXI(p1,lpszMatch) == 0) - return(g_pLexArray[i]); - p1 = p2 + 1; - } + for (int i = 0; i < COUNTOF(g_pLexArray); ++i) { + LPCWSTR p1 = g_pLexArray[i]->szExtensions; + do { + LPCWSTR p2 = StrStrI(p1, lpszMatch); + if (p2 == NULL) { + break; + } + WCHAR const ch = (p2 == p1) ? L'\0' : p2[-1]; + p2 += cch; + if ((ch == L';' || ch == ' ' || ch == L'\0') && (*p2 == L';' || *p2 == L' ' || *p2 == L'\0')) { + return g_pLexArray[i]; + } + p1 = StrChr(p2, L';'); + } while (p1 != NULL); } } else { - int cch = (int)StringCchLenW(lpszMatch,0); if (cch >= 3) { - for (i = 0; i < COUNTOF(g_pLexArray); i++) { - if (StrCmpNI(g_pLexArray[i]->pszName,lpszMatch,cch) == 0) + for (int i = 0; i < COUNTOF(g_pLexArray); ++i) { + if (StrCmpNI(g_pLexArray[i]->pszName, lpszMatch, cch) == 0) return(g_pLexArray[i]); } } } - return(NULL); + return NULL; } @@ -1430,8 +1416,6 @@ bool Style_HasLexerForExt(LPCWSTR lpszExt) // // Style_SetLexerFromFile() // -extern int g_flagNoHTMLGuess; -extern int g_flagNoCGIGuess; extern FILEVARS fvCurFile; void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile) @@ -1448,7 +1432,7 @@ void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile) MultiByteToWideCharStrg(Encoding_SciCP, fvCurFile.tchMode, wchMode); - if (!g_flagNoCGIGuess && (StringCchCompareNI(wchMode,COUNTOF(wchMode),L"cgi", CSTRLEN(L"cgi")) == 0 || + if (!Flags.NoCGIGuess && (StringCchCompareNI(wchMode,COUNTOF(wchMode),L"cgi", CSTRLEN(L"cgi")) == 0 || StringCchCompareNI(wchMode,COUNTOF(wchMode),L"fcgi", CSTRLEN(L"fcgi")) == 0)) { char tchText[256] = { L'\0' }; SciCall_GetText(COUNTOF(tchText) - 1, tchText); @@ -1481,12 +1465,12 @@ void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile) } } - if (!bFound && g_bAutoSelect && /* g_bAutoSelect == false skips lexer search */ + if (!bFound && s_bAutoSelect && /* s_bAutoSelect == false skips lexer search */ (lpszFile && StringCchLen(lpszFile,MAX_PATH) > 0 && *lpszExt)) { if (*lpszExt == L'.') ++lpszExt; - if (!g_flagNoCGIGuess && (StringCchCompareXI(lpszExt,L"cgi") == 0 || StringCchCompareXI(lpszExt,L"fcgi") == 0)) { + if (!Flags.NoCGIGuess && (StringCchCompareXI(lpszExt,L"cgi") == 0 || StringCchCompareXI(lpszExt,L"fcgi") == 0)) { char tchText[256] = { '\0' }; SciCall_GetText(COUNTOF(tchText) - 1, tchText); StrTrimA(tchText," \t\n\r"); @@ -1512,29 +1496,29 @@ void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile) } } - if (!bFound && g_bAutoSelect && lpszFile && + if (!bFound && s_bAutoSelect && lpszFile && StringCchCompareXI(PathFindFileName(lpszFile),L"makefile") == 0) { pLexNew = &lexMAK; bFound = true; } - if (!bFound && g_bAutoSelect && lpszFile && + if (!bFound && s_bAutoSelect && lpszFile && StringCchCompareXI(PathFindFileName(lpszFile),L"rakefile") == 0) { pLexNew = &lexRUBY; bFound = true; } - if (!bFound && g_bAutoSelect && lpszFile && + if (!bFound && s_bAutoSelect && lpszFile && StringCchCompareXI(PathFindFileName(lpszFile),L"mozconfig") == 0) { pLexNew = &lexBASH; bFound = true; } - if (!bFound && g_bAutoSelect && (!g_flagNoHTMLGuess || !g_flagNoCGIGuess)) { + if (!bFound && s_bAutoSelect && (!Flags.NoHTMLGuess || !Flags.NoCGIGuess)) { char tchText[512]; SciCall_GetText(COUNTOF(tchText) - 1, tchText); StrTrimA(tchText," \t\n\r"); - if (!g_flagNoCGIGuess) { + if (!Flags.NoCGIGuess) { if (tchText[0] == '<') { if (StrStrIA(tchText, "Styles[STY_DEFAULT]); + LexFunctionPtr_t const pLexFunction = pLexer->pFctPtr; StringCchCopyW(newStyle, COUNTOF(newStyle), pLexer->Styles[STY_DEFAULT].szValue); @@ -1674,7 +1659,7 @@ void Style_SetDefaultFont(HWND hwnd, bool bGlobalDefault) { // set new styles to current lexer's default text StringCchCopyW(pLexerDefStyle->szValue, COUNTOF(pLexerDefStyle->szValue), newStyle); - g_fStylesModified = true; + (*pLexFunction)(FCT_SETTING_CHANGE, STY_DEFAULT+2); Style_ResetCurrentLexer(hwnd); } } @@ -1701,14 +1686,14 @@ bool Style_GetUse2ndDefault() // // Style_SetIndentGuides() // -extern int g_flagSimpleIndentGuides; void Style_SetIndentGuides(HWND hwnd,bool bShow) { + UNUSED(hwnd); int iIndentView = SC_IV_NONE; if (bShow) { - if (!g_flagSimpleIndentGuides) { - switch (SendMessage(hwnd, SCI_GETLEXER, 0, 0)) { + if (!Flags.SimpleIndentGuides) { + switch (SciCall_GetLexer()) { case SCLEX_PYTHON: case SCLEX_NIMROD: iIndentView = SC_IV_LOOKFORWARD; @@ -1721,7 +1706,7 @@ void Style_SetIndentGuides(HWND hwnd,bool bShow) else iIndentView = SC_IV_REAL; } - SendMessage(hwnd,SCI_SETINDENTATIONGUIDES,iIndentView,0); + SciCall_SetIndentationGuides(iIndentView); } @@ -1760,15 +1745,14 @@ void Style_SetExtraLineSpace(HWND hwnd, LPWSTR lpszStyle, int cch) // // Style_GetFileOpenDlgFilter() // -extern WCHAR g_tchFileDlgFilters[XXXL_BUFFER]; bool Style_GetOpenDlgFilterStr(LPWSTR lpszFilter,int cchFilter) { - if (StringCchLenW(g_tchFileDlgFilters, COUNTOF(g_tchFileDlgFilters)) == 0) { + if (StringCchLenW(Settings2.FileDlgFilters, COUNTOF(Settings2.FileDlgFilters)) == 0) { GetLngString(IDS_MUI_FILTER_ALL, lpszFilter, cchFilter); } else { - StringCchCopyN(lpszFilter,cchFilter,g_tchFileDlgFilters,cchFilter - 2); + StringCchCopyN(lpszFilter,cchFilter,Settings2.FileDlgFilters,cchFilter - 2); StringCchCat(lpszFilter,cchFilter,L"||"); } PrepareFilterStr(lpszFilter); @@ -1780,28 +1764,22 @@ bool Style_GetOpenDlgFilterStr(LPWSTR lpszFilter,int cchFilter) // // Style_StrGetFont() // -bool Style_StrGetFont(LPCWSTR lpszStyle,LPWSTR lpszFont,int cchFont) +bool Style_StrGetFont(LPCWSTR lpszStyle, LPWSTR lpszFont, int cchFont) { - WCHAR tch[64] = { L'\0' }; WCHAR *p = StrStrI(lpszStyle, L"font:"); - if (p) - { - StringCchCopy(tch,COUNTOF(tch),p + CSTRLEN(L"font:")); - p = StrChr(tch, L';'); - if (p) + if (p) { + p += CSTRLEN(L"font:"); + while (*p == L' ') { ++p; } + StringCchCopyN(lpszFont, cchFont, p, cchFont); + if ((p = StrChr(lpszFont, L';')) != NULL) { *p = L'\0'; - TrimStringW(tch); - - if (StringCchCompareNI(tch,COUNTOF(tch),L"Default",CSTRLEN(L"Default")) == 0) - { + } + TrimStringW(lpszFont); + if (StringCchCompareNI(lpszFont, cchFont, L"Default", CSTRLEN(L"Default")) == 0) { if (IsFontAvailable(L"Consolas")) - StringCchCopyN(lpszFont,cchFont,L"Consolas",cchFont); + StringCchCopyN(lpszFont, cchFont, L"Consolas", cchFont); else - StringCchCopyN(lpszFont,cchFont,L"Lucida Console",cchFont); - } - else - { - StringCchCopyN(lpszFont,cchFont,tch, COUNTOF(tch)); + StringCchCopyN(lpszFont, cchFont, L"Lucida Console", cchFont); } return true; } @@ -2096,19 +2074,19 @@ bool Style_StrGetCase(LPCWSTR lpszStyle, int* i) { WCHAR *p = StrStrI(lpszStyle, L"case:"); if (p) { - WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; - StringCchCopy(tch,COUNTOF(tch),p + CSTRLEN(L"case:")); - p = StrChr(tch, L';'); - if (p) - *p = L'\0'; - TrimStringW(tch); - if (tch[0] == L'u' || tch[0] == L'U') { + p += CSTRLEN(L"case:"); + p += StrSpn(p, L" "); + switch (*p) { + case L'u': + case L'U': *i = SC_CASE_UPPER; return true; - } - else if (tch[0] == L'l' || tch[0] == L'L') { + case L'l': + case L'L': *i = SC_CASE_LOWER; return true; + default: + break; } } return false; @@ -2276,7 +2254,7 @@ void Style_CopyStyles_IfNotDefined(LPWSTR lpszStyleSrc, LPWSTR lpszStyleDest, in if (Style_StrGetCase(lpszStyleSrc, &iValue) && !StrStrI(lpszStyleDest, L"case:")) { StringCchCat(szTmpStyle, COUNTOF(szTmpStyle), L"; case:"); - StringCchCat(szTmpStyle, COUNTOF(szTmpStyle), (iValue == SC_CASE_UPPER) ? L"u" : L""); + StringCchCat(szTmpStyle, COUNTOF(szTmpStyle), (iValue == SC_CASE_UPPER) ? L"U" : L"L"); } if (!StrStrI(lpszStyleDest, L"alpha:")) { @@ -2402,7 +2380,7 @@ bool Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, LPCWSTR sLexerNam bool bIsUnderline = (StrStrI(lpszStyle, L"underline")) ? true : false; bool bIsStrikeout = (StrStrI(lpszStyle, L"strikeout")) ? true : false; - int iQuality = FontQuality[g_iSciFontQuality]; + int iQuality = FontQuality[Settings2.SciFontQuality]; switch (iQuality) { case SC_EFF_QUALITY_NON_ANTIALIASED: iQuality = NONANTIALIASED_QUALITY; @@ -2444,7 +2422,7 @@ bool Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, LPCWSTR sLexerNam //cf.nSizeMax = 128; cf.lStructSize = sizeof(CHOOSEFONT); cf.hwndOwner = hwnd; - cf.hInstance = g_hInstance; // ChooseFontDirectWrite + cf.hInstance = Globals.hInstance; // ChooseFontDirectWrite cf.rgbColors = color; cf.lpLogFont = &lf; cf.iPointSize = iPointSize; @@ -2489,8 +2467,8 @@ bool Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, LPCWSTR sLexerNam // --- open systems Font Selection dialog --- - if (g_iRenderingTechnology > 0) { - if (!ChooseFontDirectWrite(g_hwndMain, g_tchPrefLngLocName, g_uCurrentDPI, &cf) || + if (Settings.RenderingTechnology > 0) { + if (!ChooseFontDirectWrite(Globals.hwndMain, Settings2.PreferredLanguageLocaleName, Globals.uCurrentDPI, &cf) || (lf.lfFaceName[0] == L'\0')) { return false; } @@ -2683,7 +2661,7 @@ bool Style_SelectColor(HWND hwnd,bool bForeGround,LPWSTR lpszStyle,int cchStyle, cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = hwnd; cc.rgbResult = dRGBResult; - cc.lpCustColors = g_colorCustom; + cc.lpCustColors = s_colorCustom; cc.Flags = CC_FULLOPEN | CC_RGBINIT | CC_SOLIDCOLOR; if (!ChooseColor(&cc)) @@ -2788,7 +2766,7 @@ void Style_SetStyles(HWND hwnd, int iStyle, LPCWSTR lpszStyle, bool bInitDefault SendMessage(hwnd, SCI_SETFONTQUALITY, wQuality, 0); } else if (bInitDefault) { - WPARAM wQuality = (WPARAM)FontQuality[g_iSciFontQuality]; + WPARAM wQuality = (WPARAM)FontQuality[Settings2.SciFontQuality]; if (wQuality == SC_EFF_QUALITY_DEFAULT) { // undefined, use general settings, except for special fonts if (StringCchCompareXI(wchFontName, L"Calibri") == 0 || @@ -2905,7 +2883,7 @@ void Style_SetStyles(HWND hwnd, int iStyle, LPCWSTR lpszStyle, bool bInitDefault // PEDITLEXER Style_GetCurrentLexerPtr() { - return g_pLexCurrent; + return s_pLexCurrent; } @@ -2915,7 +2893,7 @@ PEDITLEXER Style_GetCurrentLexerPtr() // int Style_GetCurrentLexerRID() { - return g_pLexCurrent->resID; + return s_pLexCurrent->resID; } @@ -3061,36 +3039,43 @@ void Style_AddLexerToListView(HWND hwnd,PEDITLEXER plex) // // Style_CustomizeSchemesDlgProc() // -static void __fastcall _ApplyDialogItemText(HWND hwnd, - PEDITLEXER pCurrentLexer, PEDITSTYLE pCurrentStyle, bool bIsStyleSelected) +static bool _ApplyDialogItemText(HWND hwnd, + PEDITLEXER pCurrentLexer, PEDITSTYLE pCurrentStyle, int iStyleID, bool bIsStyleSelected) { - bool bChgNfy = false; WCHAR szBuf[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)]; + LexFunctionPtr_t const pLexFunction = pCurrentLexer->pFctPtr; + __int64 const mask = (((__int64)1) << (iStyleID + 2)) | (__int64)(!bIsStyleSelected ? 1 : 0); + + bool bChgNfy = (((*pLexFunction)(FCT_SETTING_CHANGE, 0) & mask) != 0); + GetDlgItemText(hwnd, IDC_STYLEEDIT, szBuf, COUNTOF(szBuf)); if (StringCchCompareXIW(szBuf, pCurrentStyle->szValue) != 0) { pCurrentStyle->szValue[0] = L'\0'; Style_CopyStyles_IfNotDefined(szBuf, pCurrentStyle->szValue, COUNTOF(pCurrentStyle->szValue), true, true); + (*pLexFunction)(FCT_SETTING_CHANGE, (iStyleID + 2)); bChgNfy = true; } - if (!bIsStyleSelected) { - - if (!GetDlgItemText(hwnd, IDC_STYLEEDIT_ROOT, szBuf, COUNTOF(szBuf))) { - + if (!bIsStyleSelected) + { + if (!GetDlgItemText(hwnd, IDC_STYLEEDIT_ROOT, szBuf, COUNTOF(szBuf))) + { StringCchCopy(szBuf, COUNTOF(szBuf), pCurrentLexer->pszDefExt); } - if (StringCchCompareXIW(szBuf, pCurrentLexer->szExtensions) != 0) { - + if (StringCchCompareXIW(szBuf, pCurrentLexer->szExtensions) != 0) + { StringCchCopyW(pCurrentLexer->szExtensions, COUNTOF(pCurrentLexer->szExtensions), szBuf); + (*pLexFunction)(FCT_SETTING_CHANGE, 1); bChgNfy = true; } } - if (bChgNfy && (IsLexerStandard(pCurrentLexer) || (pCurrentLexer == g_pLexCurrent))) { - - Style_ResetCurrentLexer(g_hwndEdit); + if (bChgNfy && (IsLexerStandard(pCurrentLexer) || (pCurrentLexer == s_pLexCurrent))) + { + Style_ResetCurrentLexer(Globals.hwndEdit); } + return bChgNfy; } @@ -3100,17 +3085,18 @@ static void __fastcall _ApplyDialogItemText(HWND hwnd, // INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam) { - static HWND hwndTV; static bool fDragging; - static PEDITLEXER pCurrentLexer; - static PEDITSTYLE pCurrentStyle; + static PEDITLEXER pCurrentLexer = NULL; + static PEDITSTYLE pCurrentStyle = NULL; + static int iCurStyleIdx = -1; static HFONT hFontTitle; static HBRUSH hbrFore; static HBRUSH hbrBack; static bool bIsStyleSelected = false; static WCHAR* Style_StylesBackup[NUMLEXERS * AVG_NUM_OF_STYLES_PER_LEXER]; + static __int64 Style_ChangedBackup[NUMLEXERS]; WCHAR tchBuf[128] = { L'\0' }; @@ -3119,7 +3105,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam case WM_INITDIALOG: { // Backup Styles - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } ZeroMemory(&Style_StylesBackup, NUMLEXERS * AVG_NUM_OF_STYLES_PER_LEXER * sizeof(WCHAR*)); int cnt = 0; for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); ++iLexer) { @@ -3129,6 +3115,8 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam Style_StylesBackup[cnt++] = StrDup(g_pLexArray[iLexer]->Styles[i].szValue); ++i; } + LexFunctionPtr_t const pLexFunction = g_pLexArray[iLexer]->pFctPtr; + Style_ChangedBackup[iLexer] = (*pLexFunction)(FCT_SETTING_CHANGE, 0); } hwndTV = GetDlgItem(hwnd,IDC_STYLELIST); @@ -3143,7 +3131,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam // findlexer int found = -1; for (int i = 0; i < COUNTOF(g_pLexArray); ++i) { - if (g_pLexArray[i] == g_pLexCurrent) { + if (g_pLexArray[i] == s_pLexCurrent) { found = i; break; } @@ -3166,18 +3154,19 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam } TreeView_Select(hwndTV, hCurrentTVLex, TVGN_CARET); - pCurrentLexer = (found >= 0) ? g_pLexCurrent : GetDefaultLexer(); + pCurrentLexer = (found >= 0) ? s_pLexCurrent : GetDefaultLexer(); pCurrentStyle = &(pCurrentLexer->Styles[STY_DEFAULT]); + iCurStyleIdx = STY_DEFAULT; SendDlgItemMessage(hwnd,IDC_STYLEEDIT,EM_LIMITTEXT, max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)-1,0); - MakeBitmapButton(hwnd,IDC_PREVSTYLE,g_hInstance,IDB_PREV); - MakeBitmapButton(hwnd,IDC_NEXTSTYLE,g_hInstance,IDB_NEXT); + MakeBitmapButton(hwnd,IDC_PREVSTYLE,Globals.hInstance,IDB_PREV); + MakeBitmapButton(hwnd,IDC_NEXTSTYLE,Globals.hInstance,IDB_NEXT); // Setup title font - if (hFontTitle) + if (hFontTitle) { DeleteObject(hFontTitle); - + } if (NULL == (hFontTitle = (HFONT)SendDlgItemMessage(hwnd,IDC_TITLE,WM_GETFONT,0,0))) hFontTitle = GetStockObject(DEFAULT_GUI_FONT); @@ -3188,10 +3177,10 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam hFontTitle = CreateFontIndirect(&lf); SendDlgItemMessage(hwnd,IDC_TITLE,WM_SETFONT,(WPARAM)hFontTitle,true); - if (xCustomSchemesDlg == 0 || yCustomSchemesDlg == 0) + if (Settings.CustomSchemesDlgPosX == 0 || Settings.CustomSchemesDlgPosY == 0) CenterDlgInParent(hwnd); else - SetDlgPos(hwnd, xCustomSchemesDlg, yCustomSchemesDlg); + SetDlgPos(hwnd, Settings.CustomSchemesDlgPosX, Settings.CustomSchemesDlgPosY); HMENU hmenu = GetSystemMenu(hwnd, false); GetLngString(IDS_MUI_PREVIEW, tchBuf, COUNTOF(tchBuf)); @@ -3206,7 +3195,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam return true; case WM_ACTIVATE: - DialogEnableWindow(hwnd, IDC_PREVIEW, ((pCurrentLexer == g_pLexCurrent) || (pCurrentLexer == GetCurrentStdLexer()))); + DialogEnableWindow(hwnd, IDC_PREVIEW, ((pCurrentLexer == s_pLexCurrent) || (pCurrentLexer == GetCurrentStdLexer()))); break; case WM_DESTROY: @@ -3235,6 +3224,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam } pCurrentLexer = NULL; pCurrentStyle = NULL; + iCurStyleIdx = -1; } return false; @@ -3264,7 +3254,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam case TVN_SELCHANGED: { if (pCurrentLexer && pCurrentStyle) { - _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, bIsStyleSelected); + _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, iCurStyleIdx, bIsStyleSelected); } WCHAR name[80] = { L'\0' }; @@ -3293,6 +3283,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam if (IsLexerStandard(pCurrentLexer)) { pCurrentStyle = &(pCurrentLexer->Styles[STY_DEFAULT]); + iCurStyleIdx = STY_DEFAULT; if (pCurrentStyle->rid == IDS_LEX_STD_STYLE) { GetLngString(IDS_MUI_STY_BASESTD, label, COUNTOF(label)); @@ -3304,6 +3295,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam } else { pCurrentStyle = &(pCurrentLexer->Styles[STY_DEFAULT]); + iCurStyleIdx = STY_DEFAULT; GetLngString(pCurrentLexer->resID, name, COUNTOF(name)); FormatLngStringW(label, COUNTOF(label), IDS_MUI_STY_LEXDEF, name); } @@ -3317,7 +3309,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam SetDlgItemText(hwnd, IDC_STYLELABEL, L""); DialogEnableWindow(hwnd, IDC_STYLEEDIT, false); } - DialogEnableWindow(hwnd, IDC_PREVIEW, ((pCurrentLexer == g_pLexCurrent) || (pCurrentLexer == GetCurrentStdLexer()))); + DialogEnableWindow(hwnd, IDC_PREVIEW, ((pCurrentLexer == s_pLexCurrent) || (pCurrentLexer == GetCurrentStdLexer()))); } // a style has been selected else @@ -3340,6 +3332,16 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam DialogEnableWindow(hwnd, IDC_STYLEEDIT_ROOT, false); pCurrentStyle = (PEDITSTYLE)lpnmtv->itemNew.lParam; + iCurStyleIdx = -1; + int i = 0; + while (pCurrentLexer->Styles[i].iStyle != -1) { + if (pCurrentLexer->Styles[i].rid == pCurrentStyle->rid) { + iCurStyleIdx = i; + break; + } + ++i; + } + assert(iCurStyleIdx != -1); } if (pCurrentStyle) { @@ -3351,6 +3353,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam } else { + iCurStyleIdx = -1; SetDlgItemText(hwnd, IDC_STYLELABEL, L""); DialogEnableWindow(hwnd, IDC_STYLEEDIT, false); } @@ -3363,7 +3366,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam TreeView_Select(hwndTV,lpnmtv->itemNew.hItem,TVGN_CARET); if (bIsStyleSelected) - DestroyCursor(SetCursor(LoadCursor(g_hInstance,MAKEINTRESOURCE(IDC_COPY)))); + DestroyCursor(SetCursor(LoadCursor(Globals.hInstance,MAKEINTRESOURCE(IDC_COPY)))); else DestroyCursor(SetCursor(LoadCursor(NULL,IDC_NO))); @@ -3383,8 +3386,8 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam if (fDragging && bIsStyleSelected) { - LONG xCur = LOWORD(lParam); - LONG yCur = HIWORD(lParam); + LONG xCur = (LONG)(short)LOWORD(lParam); + LONG yCur = (LONG)(short)HIWORD(lParam); //ImageList_DragMove(xCur,yCur); //ImageList_DragShowNolock(false); @@ -3427,7 +3430,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam // after select, this is new current item SetDlgItemText(hwnd,IDC_STYLEEDIT,tchCopy); - _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, bIsStyleSelected); + _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, iCurStyleIdx, bIsStyleSelected); } ReleaseCapture(); DestroyCursor(SetCursor(LoadCursor(NULL,IDC_ARROW))); @@ -3460,12 +3463,12 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam // find current lexer's tree entry HTREEITEM hCurrentTVLex = TreeView_GetRoot(hwndTV); for (int i = 0; i < COUNTOF(g_pLexArray); ++i) { - if (g_pLexArray[i] == g_pLexCurrent) { + if (g_pLexArray[i] == s_pLexCurrent) { break; } hCurrentTVLex = TreeView_GetNextSibling(hwndTV, hCurrentTVLex); // next } - if (g_pLexCurrent == pCurrentLexer) + if (s_pLexCurrent == pCurrentLexer) break; // no change // collaps current node @@ -3481,8 +3484,9 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam TreeView_Select(hwndTV, hCurrentTVLex, TVGN_CARET); TreeView_Expand(hwndTV, hCurrentTVLex, TVE_EXPAND); - pCurrentLexer = g_pLexCurrent; + pCurrentLexer = s_pLexCurrent; pCurrentStyle = &(pCurrentLexer->Styles[STY_DEFAULT]); + iCurStyleIdx = STY_DEFAULT; PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_STYLEEDIT)), 1); } @@ -3531,12 +3535,19 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam case IDC_STYLEDEFAULT: - SetDlgItemText(hwnd, IDC_STYLEEDIT, pCurrentStyle->pszDefault); - if (!bIsStyleSelected) { - SetDlgItemText(hwnd, IDC_STYLEEDIT_ROOT, pCurrentLexer->pszDefExt); + { + SetDlgItemText(hwnd, IDC_STYLEEDIT, pCurrentStyle->pszDefault); + if (!bIsStyleSelected) { + SetDlgItemText(hwnd, IDC_STYLEEDIT_ROOT, pCurrentLexer->pszDefExt); + } + + _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, iCurStyleIdx, bIsStyleSelected); + + LexFunctionPtr_t const pLexFunction = pCurrentLexer->pFctPtr; + (*pLexFunction)(FCT_SETTING_CHANGE, -(iCurStyleIdx + 2)); // reset + if (!bIsStyleSelected) { (*pLexFunction)(FCT_SETTING_CHANGE, -1); } // reset + PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_STYLEEDIT)), 1); } - _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, bIsStyleSelected); - PostMessage(hwnd, WM_NEXTDLGCTL, (WPARAM)(GetDlgItem(hwnd, IDC_STYLEEDIT)), 1); break; @@ -3549,11 +3560,11 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam COLORREF cr = (COLORREF)-1; // SciCall_StyleGetFore(STYLE_DEFAULT); Style_StrGetColor(true, tch, &cr); - MakeColorPickButton(hwnd, IDC_STYLEFORE, g_hInstance, cr); + MakeColorPickButton(hwnd, IDC_STYLEFORE, Globals.hInstance, cr); cr = (COLORREF)-1; // SciCall_StyleGetBack(STYLE_DEFAULT); Style_StrGetColor(false, tch, &cr); - MakeColorPickButton(hwnd, IDC_STYLEBACK, g_hInstance, cr); + MakeColorPickButton(hwnd, IDC_STYLEBACK, Globals.hInstance, cr); } } break; @@ -3569,7 +3580,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam SetDlgItemText(hwnd, IDC_STYLEEDIT_ROOT, pCurrentLexer->szExtensions); } TreeView_Select(hwndTV, TreeView_GetRoot(hwndTV), TVGN_CARET); - Style_ResetCurrentLexer(g_hwndEdit); + Style_ResetCurrentLexer(Globals.hwndEdit); } } break; @@ -3577,7 +3588,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam case IDC_EXPORT: { - _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, bIsStyleSelected); + _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, iCurStyleIdx, bIsStyleSelected); Style_Export(hwnd); } break; @@ -3585,14 +3596,14 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam case IDC_PREVIEW: { - _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, bIsStyleSelected); + _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, iCurStyleIdx, bIsStyleSelected); } break; case IDC_PREVSTYLE: { - _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, bIsStyleSelected); + _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, iCurStyleIdx, bIsStyleSelected); HTREEITEM hSel = TreeView_GetSelection(hwndTV); if (hSel) { HTREEITEM hPrev = TreeView_GetPrevVisible(hwndTV, hSel); @@ -3606,7 +3617,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam case IDC_NEXTSTYLE: { - _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, bIsStyleSelected); + _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, iCurStyleIdx, bIsStyleSelected); HTREEITEM hSel = TreeView_GetSelection(hwndTV); if (hSel) { HTREEITEM hNext = TreeView_GetNextVisible(hwndTV, hSel); @@ -3619,14 +3630,16 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam case IDOK: - _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, bIsStyleSelected); - g_fStylesModified = true; - if (!g_fWarnedNoIniFile && (StringCchLenW(g_wchIniFile, COUNTOF(g_wchIniFile)) == 0)) { - MsgBoxLng(MBWARN, IDS_MUI_SETTINGSNOTSAVED); - g_fWarnedNoIniFile = true; + { + _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, iCurStyleIdx, bIsStyleSelected); + + if (!s_fWarnedNoIniFile && (StringCchLenW(Globals.IniFile, COUNTOF(Globals.IniFile)) == 0)) { + MsgBoxLng(MBWARN, IDS_MUI_SETTINGSNOTSAVED); + s_fWarnedNoIniFile = true; + } + //EndDialog(hwnd,IDOK); + DestroyWindow(hwnd); } - //EndDialog(hwnd,IDOK); - DestroyWindow(hwnd); break; @@ -3635,20 +3648,34 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam SendMessage(hwnd, WM_CANCELMODE, 0, 0); } else { - _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, bIsStyleSelected); + _ApplyDialogItemText(hwnd, pCurrentLexer, pCurrentStyle, iCurStyleIdx, bIsStyleSelected); + // Restore Styles int cnt = 0; for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); ++iLexer) { + LexFunctionPtr_t const pLexFunction = g_pLexArray[iLexer]->pFctPtr; StringCchCopy(g_pLexArray[iLexer]->szExtensions, COUNTOF(g_pLexArray[iLexer]->szExtensions), Style_StylesBackup[cnt]); + + if ((Style_ChangedBackup[iLexer] & (((__int64)1) << 1)) != 0LL) + (*pLexFunction)(FCT_SETTING_CHANGE, 1); + else + (*pLexFunction)(FCT_SETTING_CHANGE, -1); + ++cnt; int i = 0; while (g_pLexArray[iLexer]->Styles[i].iStyle != -1) { StringCchCopy(g_pLexArray[iLexer]->Styles[i].szValue, COUNTOF(g_pLexArray[iLexer]->Styles[i].szValue), Style_StylesBackup[cnt]); + + if ((Style_ChangedBackup[iLexer] & (((__int64)1) << (i+2))) != 0LL) + (*pLexFunction)(FCT_SETTING_CHANGE, (i+2)); + else + (*pLexFunction)(FCT_SETTING_CHANGE, -(i+2)); + ++cnt; ++i; } } - Style_ResetCurrentLexer(g_hwndEdit); + Style_ResetCurrentLexer(Globals.hwndEdit); //EndDialog(hwnd,IDCANCEL); DestroyWindow(hwnd); } @@ -3664,12 +3691,12 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam break; case IDACC_SAVEPOS: - GetDlgPos(hwnd, &xCustomSchemesDlg, &yCustomSchemesDlg); + GetDlgPos(hwnd, &Settings.CustomSchemesDlgPosX, &Settings.CustomSchemesDlgPosY); break; case IDACC_RESETPOS: CenterDlgInParent(hwnd); - xCustomSchemesDlg = yCustomSchemesDlg = 0; + Settings.CustomSchemesDlgPosX = Settings.CustomSchemesDlgPosY = 0; break; @@ -3691,7 +3718,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam // HWND Style_CustomizeSchemesDlg(HWND hwnd) { - HWND hDlg = CreateThemedDialogParam(g_hLngResContainer, + HWND hDlg = CreateThemedDialogParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_STYLECONFIG), GetParent(hwnd), Style_CustomizeSchemesDlgProc, @@ -3724,7 +3751,7 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR WCHAR tch[MAX_PATH] = { L'\0' }; - if (g_hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_hDlgIcon); } + if (Globals.hDlgIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Globals.hDlgIcon); } RECT rc; GetClientRect(hwnd,&rc); @@ -3735,11 +3762,11 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR mmiPtMinX = rc.right-rc.left; mmiPtMaxY = rc.bottom-rc.top; - if (g_cxStyleSelectDlg < (rc.right-rc.left)) - g_cxStyleSelectDlg = rc.right-rc.left; - if (g_cyStyleSelectDlg < (rc.bottom-rc.top)) - g_cyStyleSelectDlg = rc.bottom-rc.top; - SetWindowPos(hwnd,NULL,rc.left,rc.top,g_cxStyleSelectDlg,g_cyStyleSelectDlg,SWP_NOZORDER); + if (s_cxStyleSelectDlg < (rc.right-rc.left)) + s_cxStyleSelectDlg = rc.right-rc.left; + if (s_cyStyleSelectDlg < (rc.bottom-rc.top)) + s_cyStyleSelectDlg = rc.bottom-rc.top; + SetWindowPos(hwnd,NULL,rc.left,rc.top,s_cxStyleSelectDlg,s_cyStyleSelectDlg,SWP_NOZORDER); SetWindowLongPtr(hwnd,GWL_STYLE,GetWindowLongPtr(hwnd,GWL_STYLE)|WS_THICKFRAME); SetWindowPos(hwnd,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED); @@ -3787,17 +3814,17 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR lvi.iItem = i; ListView_GetItem(hwndLV,&lvi); - if (((PEDITLEXER)lvi.lParam)->resID == g_pLexCurrent->resID) + if (((PEDITLEXER)lvi.lParam)->resID == s_pLexCurrent->resID) { ListView_SetItemState(hwndLV,i,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); ListView_EnsureVisible(hwndLV,i,false); - CheckDlgButton(hwnd, IDC_DEFAULTSCHEME, DlgBtnChk(g_iDefaultLexer == i)); + CheckDlgButton(hwnd, IDC_DEFAULTSCHEME, DlgBtnChk(s_iDefaultLexer == i)); break; } } - iInternalDefault = g_iDefaultLexer; - CheckDlgButton(hwnd,IDC_AUTOSELECT, DlgBtnChk(g_bAutoSelect)); + iInternalDefault = s_iDefaultLexer; + CheckDlgButton(hwnd,IDC_AUTOSELECT, DlgBtnChk(s_bAutoSelect)); CenterDlgInParent(hwnd); } @@ -3808,8 +3835,8 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR { RECT rc; GetWindowRect(hwnd,&rc); - g_cxStyleSelectDlg = rc.right-rc.left; - g_cyStyleSelectDlg = rc.bottom-rc.top; + s_cxStyleSelectDlg = rc.right-rc.left; + s_cyStyleSelectDlg = rc.bottom-rc.top; } return false; @@ -3910,9 +3937,9 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR lvi.mask = LVIF_PARAM; lvi.iItem = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED); if (ListView_GetItem(hwndLV, &lvi)) { - g_pLexCurrent = (PEDITLEXER)lvi.lParam; - g_iDefaultLexer = iInternalDefault; - g_bAutoSelect = (IsDlgButtonChecked(hwnd, IDC_AUTOSELECT) == BST_CHECKED) ? 1 : 0; + s_pLexCurrent = (PEDITLEXER)lvi.lParam; + s_iDefaultLexer = iInternalDefault; + s_bAutoSelect = (IsDlgButtonChecked(hwnd, IDC_AUTOSELECT) == BST_CHECKED) ? 1 : 0; EndDialog(hwnd,IDOK); } } @@ -3937,11 +3964,11 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR // void Style_SelectLexerDlg(HWND hwnd) { - if (IDOK == ThemedDialogBoxParam(g_hLngResContainer, + if (IDOK == ThemedDialogBoxParam(Globals.hLngResContainer, MAKEINTRESOURCE(IDD_MUI_STYLESELECT), GetParent(hwnd), Style_SelectLexerDlgProc, 0)) - Style_ResetCurrentLexer(g_hwndEdit); + Style_ResetCurrentLexer(Globals.hwndEdit); } // End of Styles.c diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 0f857fc26..3605f48bc 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -92,7 +92,7 @@ typedef enum XHUGE_BUFFER = 2048, XXXL_BUFFER = 4096, - FILE_ARG_BUF = MAX_PATH + 2, + ANSI_CHAR_BUFFER = 258, FNDRPL_BUFFER = 1024, LONG_LINES_MARKER_LIMIT = 4096 @@ -153,6 +153,28 @@ typedef struct _editfindreplace #define IDMSG_SWITCHTOFIND 300 #define IDMSG_SWITCHTOREPLACE 301 + +// -------------------------------------------------------------------------- + +#define MRU_MAXITEMS 32 +#define MRU_ITEMSFILE 32 +#define MRU_ITEMSFNDRPL 16 +#define MRU_NOCASE 1 +#define MRU_UTF8 2 +#define MRU_BMRK_SIZE 512 + +typedef struct _mrulist +{ + LPCWSTR szRegKey; + int iFlags; + int iSize; + LPWSTR pszItems[MRU_MAXITEMS]; + int iEncoding[MRU_MAXITEMS]; + DocPos iCaretPos[MRU_MAXITEMS]; + LPWSTR pszBookMarks[MRU_MAXITEMS]; +} +MRULIST, *PMRULIST, *LPMRULIST; + // -------------------------------------------------------------------------- typedef struct _cmq @@ -185,7 +207,204 @@ typedef struct _cmq #define INDIC_NP3_MATCH_BRACE 2 #define INDIC_NP3_BAD_BRACE 3 -// -------------------------------------------------------------------------- + +//============================================================================= + +typedef struct _constants_t +{ + const WCHAR* FileBrowserMiniPath; + +} CONSTANTS_T, *PCONSTANTS_T; + +extern CONSTANTS_T Constants; + +// ------------------------------------ + +typedef struct _globals_t +{ + HINSTANCE hInstance; + HINSTANCE hPrevInst; + HMODULE hLngResContainer; + HWND hwndMain; + HANDLE hndlProcessHeap; + HWND hwndEdit; + HANDLE hndlScintilla; + HWND hwndStatus; + HICON hDlgIcon; + HWND hwndDlgFindReplace; + HWND hwndDlgCustomizeSchemes; + UINT uCurrentDPI; + UINT uCurrentPPI; + LANGID iPrefLANGID; + int iEOLMode; + LPMRULIST pFileMRU; + LPMRULIST pMRUfind; + LPMRULIST pMRUreplace; + + + WCHAR WorkingDirectory[MAX_PATH + 1]; + WCHAR IniFile[MAX_PATH + 1]; + WCHAR CurrentFile[MAX_PATH + 1]; + +} GLOBALS_T, *PGLOBALS_T; + +extern GLOBALS_T Globals; + +// ------------------------------------ + +typedef struct _settings_t +{ + bool SaveRecentFiles; + bool PreserveCaretPos; + bool SaveFindReplace; + int PathNameFormat; + bool WordWrap; + int WordWrapMode; + int WordWrapIndent; + int WordWrapSymbols; + bool ShowWordWrapSymbols; + bool MatchBraces; + bool AutoCloseTags; + bool HighlightCurrentLine; + bool HyperlinkHotspot; + bool ScrollPastEOF; + bool AutoIndent; + bool AutoCompleteWords; + bool AutoCLexerKeyWords; + bool AccelWordNavigation; + bool ShowIndentGuides; + bool TabsAsSpaces; + bool TabIndents; + bool BackspaceUnindents; + int TabWidth; + int IndentWidth; + bool MarkLongLines; + int LongLinesLimit; + int LongLineMode; + bool ShowSelectionMargin; + bool ShowLineNumbers; + bool ShowCodeFolding; + int MarkOccurrences; + bool MarkOccurrencesMatchVisible; + bool MarkOccurrencesMatchCase; + bool MarkOccurrencesMatchWholeWords; + bool MarkOccurrencesCurrentWord; + bool ViewWhiteSpace; + bool ViewEOLs; + int DefaultEncoding; // default new file encoding + bool UseDefaultForFileEncoding; + bool SkipUnicodeDetection; + bool SkipANSICodePageDetection; + bool LoadASCIIasUTF8; + bool LoadNFOasOEM; + bool NoEncodingTags; + int DefaultEOLMode; + bool FixLineEndings; + bool FixTrailingBlanks; + int PrintHeader; + int PrintFooter; + int PrintColorMode; + int PrintZoom; + bool SaveBeforeRunningTools; + int FileWatchingMode; + bool ResetFileWatching; + int EscFunction; + bool AlwaysOnTop; + bool MinimizeToTray; + bool TransparentMode; + int RenderingTechnology; + int Bidirectional; + bool ShowToolbar; + bool ShowStatusbar; + int EncodingDlgSizeX; + int EncodingDlgSizeY; + int RecodeDlgSizeX; + int RecodeDlgSizeY; + int FileMRUDlgSizeX; + int FileMRUDlgSizeY; + int OpenWithDlgSizeX; + int OpenWithDlgSizeY; + int FavoritesDlgSizeX; + int FavoritesDlgSizeY; + int FindReplaceDlgPosX; + int FindReplaceDlgPosY; + int CustomSchemesDlgPosX; + int CustomSchemesDlgPosY; + + RECT PrintMargin; + EDITFINDREPLACE EFR_Data; + WCHAR OpenWithDir[MAX_PATH + 1]; + WCHAR FavoritesDir[MAX_PATH + 1]; + WCHAR ToolbarButtons[MIDSZ_BUFFER]; + +} SETTINGS_T, *PSETTINGS_T; + +extern SETTINGS_T Settings; + +// ------------------------------------ + +typedef struct _settings2_t +{ + int FileLoadWarningMB; + int OpacityLevel; + DWORD FileCheckInverval; + DWORD AutoReloadTimeout; + int IMEInteraction; + int SciFontQuality; + int MarkOccurrencesMaxCount; + int UpdateDelayHyperlinkStyling; + int UpdateDelayMarkAllOccurrences; + bool DenyVirtualSpaceAccess; + bool UseOldStyleBraceMatching; + int CurrentLineHorizontalSlop; + int CurrentLineVerticalSlop; + + WCHAR PreferredLanguageLocaleName[LOCALE_NAME_MAX_LENGTH+1]; + WCHAR DefaultExtension[64]; + WCHAR DefaultDirectory[MAX_PATH + 1]; + WCHAR FileDlgFilters[XHUGE_BUFFER]; + + WCHAR FileBrowserPath[MAX_PATH + 1]; + WCHAR AppUserModelID[32]; + WCHAR ExtendedWhiteSpaceChars[ANSI_CHAR_BUFFER + 1]; + WCHAR AutoCompleteWordCharSet[ANSI_CHAR_BUFFER + 1]; + WCHAR TimeStamp[128]; + WCHAR DateTimeShort[128]; + WCHAR DateTimeLong[128]; + WCHAR WebTemplate1[MAX_PATH + 1]; + WCHAR WebTemplate2[MAX_PATH + 1]; + WCHAR AdministrationTool[MAX_PATH + 1]; + WCHAR DefaultWindowPosition[64]; + +} SETTINGS2_T, *PSETTINGS2_T; + +extern SETTINGS2_T Settings2; + +// ------------------------------------ + +typedef struct _flags_t +{ + int StickyWindowPosition; + int ReuseWindow; + int NoReuseWindow; + int SingleFileInstance; + int MultiFileArg; + int RelativeFileMRU; + int PortableMyDocs; + int NoFadeHidden; + int ToolbarLook; + int SimpleIndentGuides; + int NoHTMLGuess; + int NoCGIGuess; + int NoFileVariables; + int ShellUseSystemMRU; + int PrintFileAndLeave; + +} FLAGS_T, *PFLAGS_T; + +extern FLAGS_T Flags; + + //============================================================================= diff --git a/src/Version.h b/src/Version.h index 272daa26c..4d82e865e 100644 Binary files a/src/Version.h and b/src/Version.h differ diff --git a/src/VersionEx.h b/src/VersionEx.h index 236392fba..81614e8d6 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -6,8 +6,8 @@ #define APPNAME "Notepad3" #define VERSION_MAJOR 4 #define VERSION_MINOR 18 -#define VERSION_REV 920 -#define VERSION_BUILD 1113 +#define VERSION_REV 921 +#define VERSION_BUILD 1116 #define SCINTILLA_VER 411 #define ONIGMO_REGEX_VER 6.1.3 #define VERSION_PATCH " TinyExpr"