mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
Merge pull request #1063 from RaiKoHoff/Dev_UCHARDET
Remember last used theme (if save settings is enabled)
This commit is contained in:
commit
7bfe1a29d3
@ -411,7 +411,7 @@
|
||||
#define IDS_MUI_LANG_ZH_CN 34516
|
||||
|
||||
#define IDS_MUI_MENU_THEMES 37000
|
||||
#define IDM_THEMES_DEFAULT 37001
|
||||
#define IDM_THEMES_DEFAULT 37001
|
||||
#define IDM_THEMES_FILE_ITEM 37002
|
||||
/// !!! dont use IDs until ...37100
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ setlocal enableextensions
|
||||
|
||||
:: ====================================================================================================================
|
||||
|
||||
set NP3_LANGUAGE_SET=af-ZA be-BY de-DE en-GB es-ES fr-FR hu-HU it-IT ja-JP ko-KR nl-NL pt-BR ru-RU zh-CN
|
||||
set NP3_LANGUAGE_SET=af-ZA be-BY de-DE en-GB es-ES fr-FR hu-HU it-IT ja-JP ko-KR nl-NL pl-PL pt-BR ru-RU zh-CN
|
||||
|
||||
:: ====================================================================================================================
|
||||
|
||||
|
||||
10
src/Edit.c
10
src/Edit.c
@ -7274,10 +7274,12 @@ static INT_PTR CALLBACK EditModifyLinesDlgProc(HWND hwnd,UINT umsg,WPARAM wParam
|
||||
|
||||
if (dwId >= 200 && dwId <= 205) {
|
||||
SetBkMode(hdc,TRANSPARENT);
|
||||
if (GetSysColorBrush(COLOR_HOTLIGHT))
|
||||
SetTextColor(hdc,GetSysColor(COLOR_HOTLIGHT));
|
||||
else
|
||||
SetTextColor(hdc,RGB(0, 0, 0xFF));
|
||||
if (GetSysColorBrush(COLOR_HOTLIGHT)) {
|
||||
SetTextColor(hdc, GetSysColor(COLOR_HOTLIGHT));
|
||||
}
|
||||
else {
|
||||
SetTextColor(hdc, RGB(0, 0, 0xFF));
|
||||
}
|
||||
SelectObject(hdc,/*dwId == id_hover?*/hFontHover/*:hFontNormal*/);
|
||||
return (INT_PTR)GetSysColorBrush(COLOR_BTNFACE);
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ int IniSectionGetInt(LPCWSTR lpCachedIniSection, LPCWSTR lpName, int iDefault)
|
||||
{
|
||||
LPWSTR p = (LPWSTR)lpCachedIniSection;
|
||||
if (p) {
|
||||
int ich = (int)StringCchLen(lpName,0);
|
||||
int const ich = (int)StringCchLen(lpName,0);
|
||||
while (*p) {
|
||||
if ((StrCmpNI(p, lpName, ich) == 0) && (p[ich] == L'=')) {
|
||||
int i = 0;
|
||||
@ -873,8 +873,9 @@ bool PathGetLnkPath(LPCWSTR pszLnkFile,LPWSTR pszResPath,int cchResPath)
|
||||
}
|
||||
|
||||
// This additional check seems reasonable
|
||||
if (!StringCchLen(pszResPath,cchResPath))
|
||||
if (StrIsEmpty(pszResPath)) {
|
||||
bSucceeded = false;
|
||||
}
|
||||
|
||||
if (bSucceeded) {
|
||||
ExpandEnvironmentStringsEx(pszResPath,cchResPath);
|
||||
@ -935,8 +936,7 @@ bool PathCreateDeskLnk(LPCWSTR pszDocument)
|
||||
bool bSucceeded = false;
|
||||
BOOL fMustCopy;
|
||||
|
||||
if (!pszDocument || StringCchLen(pszDocument,MAX_PATH) == 0)
|
||||
return true;
|
||||
if (StrIsEmpty(pszDocument)) { return true; }
|
||||
|
||||
// init strings
|
||||
GetModuleFileName(NULL,tchExeFile,COUNTOF(tchExeFile));
|
||||
@ -1002,8 +1002,7 @@ bool PathCreateFavLnk(LPCWSTR pszName,LPCWSTR pszTarget,LPCWSTR pszDir)
|
||||
IShellLink *psl;
|
||||
bool bSucceeded = false;
|
||||
|
||||
if (!pszName || StringCchLen(pszName,MAX_PATH) == 0)
|
||||
return true;
|
||||
if (StrIsEmpty(pszName)) { return true; }
|
||||
|
||||
StringCchCopy(tchLnkFileName,COUNTOF(tchLnkFileName),pszDir);
|
||||
PathCchAppend(tchLnkFileName,COUNTOF(tchLnkFileName),pszName);
|
||||
@ -1347,16 +1346,14 @@ DWORD NormalizePathEx(LPWSTR lpszPath, DWORD cchBuffer, bool bRealPath, bool bSe
|
||||
p += 2;
|
||||
*p = L'\\';
|
||||
}
|
||||
StringCchCopyW(lpszPath, MAX_PATH, p);
|
||||
StringCchCopy(lpszPath, cchBuffer, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
size_t pathLen = 0;
|
||||
StringCchLength(lpszPath, cchBuffer, &pathLen);
|
||||
return (DWORD)pathLen;
|
||||
return (DWORD)StringCchLen(lpszPath, cchBuffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -286,13 +286,18 @@ bool GetKnownFolderPath(REFKNOWNFOLDERID, LPWSTR lpOutPath, size_t cchCount);
|
||||
void PathRelativeToApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,bool,bool,bool);
|
||||
void PathAbsoluteFromApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,bool);
|
||||
|
||||
|
||||
bool PathIsLnkFile(LPCWSTR pszPath);
|
||||
bool PathGetLnkPath(LPCWSTR pszLnkFile,LPWSTR pszResPath,int cchResPath);
|
||||
bool PathIsLnkToDirectory(LPCWSTR pszPath,LPWSTR pszResPath,int cchResPath);
|
||||
bool PathCreateDeskLnk(LPCWSTR pszDocument);
|
||||
bool PathCreateFavLnk(LPCWSTR pszName,LPCWSTR pszTarget,LPCWSTR pszDir);
|
||||
|
||||
void ExpandEnvironmentStringsEx(LPWSTR lpSrc, DWORD dwSrc);
|
||||
void PathCanonicalizeEx(LPWSTR lpszPath, DWORD cchBuffer);
|
||||
DWORD GetLongPathNameEx(LPWSTR lpszPath, DWORD cchBuffer);
|
||||
void PathGetDisplayName(LPWSTR lpszDestPath, DWORD cchDestBuffer, LPCWSTR lpszSourcePath);
|
||||
DWORD NormalizePathEx(LPWSTR lpszPath, DWORD cchBuffer, bool bRealPath, bool bSearchPathIfRelative);
|
||||
|
||||
|
||||
bool StrLTrim(LPWSTR pszSource,LPCWSTR pszTrimChars);
|
||||
|
||||
@ -322,13 +327,6 @@ void StrTab2Space(LPWSTR lpsz);
|
||||
void PathFixBackslashes(LPWSTR lpsz);
|
||||
|
||||
|
||||
void ExpandEnvironmentStringsEx(LPWSTR lpSrc,DWORD dwSrc);
|
||||
void PathCanonicalizeEx(LPWSTR lpszPath, DWORD cchBuffer);
|
||||
DWORD GetLongPathNameEx(LPWSTR lpszPath, DWORD cchBuffer);
|
||||
void PathGetDisplayName(LPWSTR lpszDestPath, DWORD cchDestBuffer, LPCWSTR lpszSourcePath);
|
||||
DWORD NormalizePathEx(LPWSTR lpszPath, DWORD cchBuffer, bool bRealPath, bool bSearchPathIfRelative);
|
||||
|
||||
|
||||
size_t FormatNumberStr(LPWSTR lpNumberStr, size_t cch, int fixedWidth);
|
||||
bool SetDlgItemIntEx(HWND hwnd,int nIdItem,UINT uValue);
|
||||
|
||||
|
||||
@ -136,7 +136,7 @@ static bool _GetUserPreferredLanguage(LPWSTR pszPrefLocaleName, int cchBuffer, L
|
||||
LANGID lngID = *pLangID;
|
||||
WCHAR wchLngLocalName[LOCALE_NAME_MAX_LENGTH+1];
|
||||
|
||||
if (StringCchLen(pszPrefLocaleName, cchBuffer) > 0)
|
||||
if (StrIsNotEmpty(pszPrefLocaleName))
|
||||
{
|
||||
res = ResolveLocaleName(pszPrefLocaleName, wchLngLocalName, COUNTOF(wchLngLocalName));
|
||||
if (res > 0) {
|
||||
|
||||
@ -1804,7 +1804,7 @@ bool SelectExternalToolBar(HWND hwnd)
|
||||
|
||||
if (GetOpenFileName(&ofn)) {
|
||||
PathQuoteSpaces(szFile);
|
||||
if (StringCchLen(szArg2, COUNTOF(szArg2)))
|
||||
if (StrIsNotEmpty(szArg2))
|
||||
{
|
||||
StringCchCat(szFile, COUNTOF(szFile), L" ");
|
||||
StringCchCat(szFile, COUNTOF(szFile), szArg2);
|
||||
@ -7571,6 +7571,7 @@ void SaveSettings(bool bSaveSettingsNow)
|
||||
|
||||
Style_Save(); // Scintilla Styles
|
||||
|
||||
|
||||
int ResX, ResY;
|
||||
GetCurrentMonitorResolution(Globals.hwndMain, &ResX, &ResY);
|
||||
|
||||
@ -9790,7 +9791,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload,
|
||||
//
|
||||
bool FileRevert(LPCWSTR szFileName, bool bIgnoreCmdLnEnc)
|
||||
{
|
||||
if (StringCchLen(szFileName, MAX_PATH) != 0) {
|
||||
if (StrIsNotEmpty(szFileName)) {
|
||||
|
||||
const DocPos iCurPos = SciCall_IsSelectionRectangle() ? SciCall_GetRectangularSelectionCaret() : SciCall_GetCurrentPos();
|
||||
const DocPos iAnchorPos = SciCall_IsSelectionRectangle() ? SciCall_GetRectangularSelectionAnchor() : SciCall_GetAnchor();
|
||||
@ -10645,7 +10646,7 @@ void CancelCallTip()
|
||||
void InstallFileWatching(LPCWSTR lpszFile)
|
||||
{
|
||||
// Terminate
|
||||
if (!Settings.FileWatchingMode || !lpszFile || StringCchLen(lpszFile,MAX_PATH) == 0)
|
||||
if (!Settings.FileWatchingMode || StrIsEmpty(lpszFile))
|
||||
{
|
||||
if (s_bRunningWatch)
|
||||
{
|
||||
|
||||
66
src/Styles.c
66
src/Styles.c
@ -121,7 +121,7 @@ static int s_cyStyleSelectDlg = STYLESELECTDLG_Y;
|
||||
typedef struct _themeFiles
|
||||
{
|
||||
UINT rid;
|
||||
WCHAR szFileName[80];
|
||||
WCHAR szName[80];
|
||||
WCHAR szFilePath[MAX_PATH];
|
||||
|
||||
} THEMEFILES, * PTHEMEFILES;
|
||||
@ -155,12 +155,10 @@ static THEMEFILES Theme_Files[] =
|
||||
{ 0, L"", L"" },
|
||||
{ 0, L"", L"" }
|
||||
};
|
||||
|
||||
unsigned ThemeItems_CountOf() { return COUNTOF(Theme_Files); }
|
||||
|
||||
|
||||
static unsigned s_idxSelectedTheme = 1; // Default(0), Standard(1)
|
||||
|
||||
const WCHAR* const STYLING_THEME_NAME = L"ThemeFileName";
|
||||
|
||||
static void _FillThemesMenuTable()
|
||||
{
|
||||
@ -168,12 +166,12 @@ static void _FillThemesMenuTable()
|
||||
|
||||
Theme_Files[0].rid = IDM_THEMES_DEFAULT; // factory default
|
||||
GetLngString(IDM_THEMES_DEFAULT, wchStdName, COUNTOF(wchStdName));
|
||||
StringCchCopy(Theme_Files[0].szFileName, COUNTOF(Theme_Files[0].szFileName), wchStdName);
|
||||
StringCchCopy(Theme_Files[0].szName, COUNTOF(Theme_Files[0].szName), wchStdName);
|
||||
StringCchCopy(Theme_Files[0].szFilePath, COUNTOF(Theme_Files[0].szFilePath), L"");
|
||||
|
||||
Theme_Files[1].rid = IDM_THEMES_FILE_ITEM; // NP3.ini settings
|
||||
GetLngString(IDM_THEMES_FILE_ITEM, wchStdName, COUNTOF(wchStdName));
|
||||
StringCchCopy(Theme_Files[1].szFileName, COUNTOF(Theme_Files[1].szFileName), wchStdName);
|
||||
StringCchCopy(Theme_Files[1].szName, COUNTOF(Theme_Files[1].szName), wchStdName);
|
||||
StringCchCopy(Theme_Files[1].szFilePath, COUNTOF(Theme_Files[1].szFilePath), Globals.IniFile);
|
||||
|
||||
unsigned iTheme = 1; // Standard
|
||||
@ -209,7 +207,7 @@ static void _FillThemesMenuTable()
|
||||
|
||||
StringCchCopy(tchThemePath, COUNTOF(tchThemePath), PathFindFileName(FindFileData.cFileName));
|
||||
PathRemoveExtension(tchThemePath);
|
||||
StringCchCopy(Theme_Files[iTheme].szFileName, COUNTOF(Theme_Files[iTheme].szFileName), tchThemePath);
|
||||
StringCchCopy(Theme_Files[iTheme].szName, COUNTOF(Theme_Files[iTheme].szName), tchThemePath);
|
||||
|
||||
StringCchCopy(tchThemePath, COUNTOF(tchThemePath), tchThemeDir);
|
||||
PathCchAppend(tchThemePath, COUNTOF(tchThemePath), FindFileData.cFileName);
|
||||
@ -220,16 +218,17 @@ static void _FillThemesMenuTable()
|
||||
}
|
||||
FindClose(hFindFile);
|
||||
}
|
||||
s_idxSelectedTheme = clampu(s_idxSelectedTheme, 0, iTheme);
|
||||
|
||||
for (++iTheme; iTheme < ThemeItems_CountOf(); ++iTheme) {
|
||||
for (++iTheme; iTheme < ThemeItems_CountOf(); ++iTheme)
|
||||
{
|
||||
Theme_Files[iTheme].rid = 0; // no themes available
|
||||
Theme_Files[iTheme].szFileName[0] = L'\0';
|
||||
Theme_Files[iTheme].szName[0] = L'\0';
|
||||
Theme_Files[iTheme].szFilePath[0] = L'\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Style_SetIniFile()
|
||||
@ -250,9 +249,9 @@ bool Style_InsertThemesMenu(HMENU hMenuBar)
|
||||
HMENU hmenuThemes = CreatePopupMenu();
|
||||
int const pos = GetMenuItemCount(hMenuBar) - 1;
|
||||
|
||||
AppendMenu(hmenuThemes, MF_ENABLED | MF_STRING, Theme_Files[0].rid, Theme_Files[0].szFileName);
|
||||
AppendMenu(hmenuThemes, MF_ENABLED | MF_STRING, Theme_Files[0].rid, Theme_Files[0].szName);
|
||||
|
||||
AppendMenu(hmenuThemes, MF_ENABLED | MF_STRING, Theme_Files[1].rid, Theme_Files[1].szFileName);
|
||||
AppendMenu(hmenuThemes, MF_ENABLED | MF_STRING, Theme_Files[1].rid, Theme_Files[1].szName);
|
||||
|
||||
for (unsigned i = 2; i < ThemeItems_CountOf(); ++i)
|
||||
{
|
||||
@ -260,7 +259,7 @@ bool Style_InsertThemesMenu(HMENU hMenuBar)
|
||||
AppendMenu(hmenuThemes, MF_SEPARATOR, 0, 0);
|
||||
}
|
||||
if (Theme_Files[i].rid > 0) {
|
||||
AppendMenu(hmenuThemes, MF_ENABLED | MF_STRING, Theme_Files[i].rid, Theme_Files[i].szFileName);
|
||||
AppendMenu(hmenuThemes, MF_ENABLED | MF_STRING, Theme_Files[i].rid, Theme_Files[i].szName);
|
||||
}
|
||||
else {
|
||||
break; // done
|
||||
@ -479,12 +478,25 @@ void Style_Load()
|
||||
s_colorDefault[14] = RGB(0xB0, 0x00, 0xB0);
|
||||
s_colorDefault[15] = RGB(0xB2, 0x8B, 0x40);
|
||||
|
||||
Style_ImportFromFile(Theme_Files[s_idxSelectedTheme].szFilePath);
|
||||
|
||||
// 2nd Default Style has same filename extension list as (1st) Default Style
|
||||
StringCchCopyW(lexStandard2nd.szExtensions, COUNTOF(lexStandard2nd.szExtensions), lexStandard.szExtensions);
|
||||
|
||||
_FillThemesMenuTable();
|
||||
|
||||
// get theme name from settings2
|
||||
WCHAR wchThemeName[80];
|
||||
IniGetString(L"Styles", STYLING_THEME_NAME, L"", wchThemeName, COUNTOF(wchThemeName));
|
||||
|
||||
unsigned iTheme = 1;
|
||||
if (StrIsNotEmpty(wchThemeName)) {
|
||||
for (; iTheme < ThemeItems_CountOf(); ++iTheme)
|
||||
{
|
||||
if (StringCchCompareXI(wchThemeName, Theme_Files[iTheme].szName) == 0) { break; }
|
||||
}
|
||||
}
|
||||
s_idxSelectedTheme = (iTheme < ThemeItems_CountOf()) ? iTheme : 1;
|
||||
|
||||
Style_ImportFromFile(Theme_Files[s_idxSelectedTheme].szFilePath);
|
||||
}
|
||||
|
||||
|
||||
@ -615,7 +627,8 @@ bool Style_ImportFromFile(const WCHAR* szFile)
|
||||
//
|
||||
void Style_Save()
|
||||
{
|
||||
Style_ExportToFile(Theme_Files[s_idxSelectedTheme].szFilePath, false);
|
||||
Style_ExportToFile(Theme_Files[s_idxSelectedTheme].szFilePath, false);
|
||||
IniSetString(L"Styles", STYLING_THEME_NAME, (s_idxSelectedTheme > 1) ? Theme_Files[s_idxSelectedTheme].szName : NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -943,23 +956,23 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew)
|
||||
// Occurrences Marker
|
||||
if (!Style_StrGetColor(pCurrentStandard->Styles[STY_MARK_OCC].szValue, FOREGROUND_LAYER, &dColor))
|
||||
{
|
||||
WCHAR* sty = L"";
|
||||
switch (Settings.MarkOccurrences) {
|
||||
case 1:
|
||||
sty = L"fore:0xFF0000";
|
||||
dColor = RGB(0xFF, 0x00, 0x00);
|
||||
break;
|
||||
case 2:
|
||||
sty = L"fore:0x00FF00";
|
||||
dColor = RGB(0x00, 0xFF, 0x00);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
sty = L"fore:0x0000FF";
|
||||
dColor = RGB(0x00, 0xFF, 0x00);
|
||||
break;
|
||||
default:
|
||||
dColor = GetSysColor(COLOR_HIGHLIGHT);
|
||||
break;
|
||||
}
|
||||
StringCchCopyW(pCurrentStandard->Styles[STY_MARK_OCC].szValue, COUNTOF(pCurrentStandard->Styles[0].szValue), sty);
|
||||
WCHAR sty[32] = { L'\0' };
|
||||
StringCchPrintf(sty, COUNTOF(sty), L"fore:#%02X%02X%02X", (int)GetRValue(dColor), (int)GetGValue(dColor), (int)GetBValue(dColor));
|
||||
StringCchCopy(pCurrentStandard->Styles[STY_MARK_OCC].szValue, COUNTOF(pCurrentStandard->Styles[0].szValue), sty);
|
||||
}
|
||||
SendMessage(hwnd, SCI_INDICSETFORE, INDIC_NP3_MARK_OCCURANCE, dColor);
|
||||
|
||||
@ -1403,14 +1416,13 @@ void Style_SetLongLineColors(HWND hwnd)
|
||||
if (!Style_StrGetColor(GetCurrentStdLexer()->Styles[STY_LONG_LN_MRK].szValue, FOREGROUND_LAYER, &rgb)) { // edge fore
|
||||
rgb = GetSysColor(COLOR_3DLIGHT);
|
||||
}
|
||||
SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0);
|
||||
}
|
||||
else {
|
||||
if (Style_StrGetColor(GetCurrentStdLexer()->Styles[STY_LONG_LN_MRK].szValue, BACKGROUND_LAYER, &rgb)) { // edge back
|
||||
rgb = GetSysColor(COLOR_3DLIGHT);
|
||||
if (!Style_StrGetColor(GetCurrentStdLexer()->Styles[STY_LONG_LN_MRK].szValue, BACKGROUND_LAYER, &rgb)) { // edge back
|
||||
rgb = GetSysColor(COLOR_3DSHADOW);
|
||||
}
|
||||
SendMessage(hwnd,SCI_SETEDGECOLOUR,rgb,0);
|
||||
}
|
||||
SendMessage(hwnd, SCI_SETEDGECOLOUR, rgb, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -1764,7 +1776,7 @@ void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile)
|
||||
}
|
||||
|
||||
if (!bFound && s_bAutoSelect && /* s_bAutoSelect == false skips lexer search */
|
||||
(lpszFile && StringCchLen(lpszFile,MAX_PATH) > 0 && *lpszExt)) {
|
||||
(StrIsNotEmpty(lpszFile) && *lpszExt)) {
|
||||
|
||||
if (*lpszExt == L'.') ++lpszExt;
|
||||
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
#define NUMLEXERS 49
|
||||
#define AVG_NUM_OF_STYLES_PER_LEXER 20
|
||||
|
||||
|
||||
void Style_Load();
|
||||
bool Style_Import(HWND hwnd);
|
||||
bool Style_ImportFromFile(const WCHAR* szFile);
|
||||
|
||||
@ -175,9 +175,12 @@ do {
|
||||
|
||||
#define HASH_FIND(hh,head,keyptr,keylen,out) \
|
||||
do { \
|
||||
unsigned _hf_hashv; \
|
||||
HASH_VALUE(keyptr, keylen, _hf_hashv); \
|
||||
HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \
|
||||
(out) = NULL; \
|
||||
if (head) { \
|
||||
unsigned _hf_hashv; \
|
||||
HASH_VALUE(keyptr, keylen, _hf_hashv); \
|
||||
HASH_FIND_BYHASHVALUE(hh, head, keyptr, keylen, _hf_hashv, out); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef HASH_BLOOM
|
||||
|
||||
Loading…
Reference in New Issue
Block a user