From 1cd30a4847b72a7c156f6752f5bdc11700e9a335 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Sat, 21 Oct 2017 13:10:13 +0200 Subject: [PATCH 1/4] + implement Feature Request #51 (buffer size of file extension edit box) --- src/Notepad3.rc | Bin 182294 -> 182296 bytes src/Styles.c | 67 ++++++++++++++++++++++-------------------------- src/Styles.h | 7 +++-- 3 files changed, 36 insertions(+), 38 deletions(-) diff --git a/src/Notepad3.rc b/src/Notepad3.rc index 197c62e5c364cd5582f3916e6ad3d9f1ef58873d..8f56f566ae925613a3e87c0de292307ae4e4283c 100644 GIT binary patch delta 322 zcmbO>fqTXT?hU(``I8wk7!(*Z7(y9>85|ijr#Big3Qym#pNVa{!$GF3<~Ww^aV(6F zVi`TA+uJhgPCsy#k!5;B5@V8}5rYncA%h7J>M$5Fm@`;TU$~ahaym;gql7p_&XmCn zCI?n)G+l8MqxSZ=WJax&=^Nx3xwe<>XAEQ7e(NM-jm35oMkWEq?J>+uZ)~PJXfSbX zXL4kkB{=<+1Czk?HTFzg(}NtCW=vlp%Vf9xRuI#o9IP(i4s>|{qoNB#Dnltl2}3ah h%zMFLRyj~Slc5UPo7;ijoWx9mjy2nN9A%1Q0sv7fRD}Ql delta 358 zcmbO+fqU8n?hU(`Su+?E7&NA9=QBx9*E`76((J>s-G_zoQS5Yq7)Gh-NlA~*-k%W&%`xdC5UOp^i^I=0@D*Tm^iiszExtensions)] = { L'\0' }; WCHAR *p1,*p2; if (!bCheckNames) { @@ -3780,7 +3780,7 @@ BOOL Style_StrGetFont(LPCWSTR lpszStyle,LPWSTR lpszFont,int cchFont) // BOOL Style_StrGetFontQuality(LPCWSTR lpszStyle,LPWSTR lpszQuality,int cchQuality) { - WCHAR tch[MIDSZ_BUFFER] = { L'\0' }; + WCHAR tch[64] = { L'\0' }; WCHAR *p = StrStrI(lpszStyle, L"smoothing:"); if (p) { @@ -3834,7 +3834,7 @@ BOOL Style_StrGetCharSet(LPCWSTR lpszStyle,int *i) // BOOL Style_StrGetSize(LPCWSTR lpszStyle,int *i) { - WCHAR tch[256] = { L'\0' }; + WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; int iSign = 0; WCHAR *p = StrStrI(lpszStyle, L"size:"); @@ -3898,7 +3898,7 @@ BOOL Style_StrGetSizeStr(LPCWSTR lpszStyle,LPWSTR lpszSize,int cchSize) // BOOL Style_StrGetColor(BOOL bFore,LPCWSTR lpszStyle,int *rgb) { - WCHAR tch[256] = { L'\0' }; + WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; WCHAR *pItem = (bFore) ? L"fore:" : L"back:"; WCHAR *p = StrStrI(lpszStyle, pItem); @@ -3957,7 +3957,7 @@ BOOL Style_StrGetCase(LPCWSTR lpszStyle,int *i) // BOOL Style_StrGetAlpha(LPCWSTR lpszStyle,int *i) { - WCHAR tch[256] = { L'\0' }; + WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; WCHAR *p = StrStrI(lpszStyle, L"alpha:"); if (p) { @@ -4234,7 +4234,7 @@ BOOL Style_SelectColor(HWND hwnd,BOOL bFore,LPWSTR lpszStyle,int cchStyle) void Style_SetStyles(HWND hwnd,int iStyle,LPCWSTR lpszStyle) { - WCHAR tch[256] = { L'\0' }; + WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; int iValue; // Font @@ -4344,26 +4344,23 @@ void Style_GetCurrentLexerName(LPWSTR lpszName,int cchName) // int Style_GetLexerIconId(PEDITLEXER plex) { - WCHAR *pszExtensions; - WCHAR *pszFile; + WCHAR pszFile[MAX_PATH]; + WCHAR *pszExtensions; if (StringCchLen(plex->szExtensions)) pszExtensions = plex->szExtensions; else pszExtensions = plex->pszDefExt; - size_t len = sizeof(WCHAR)*(StringCchLenN(pszExtensions,230) + CSTRLEN(L"*.txt") + 16); - pszFile = GlobalAlloc(GPTR,len); - StringCchCopy(pszFile,len,L"*."); - StringCchCat(pszFile,len,pszExtensions); + StringCchCopy(pszFile,COUNTOF(pszFile),L"*."); + StringCchCat(pszFile,COUNTOF(pszFile),pszExtensions); WCHAR *p = StrChr(pszFile, L';'); - if (p) - *p = L'\0'; + if (p) { *p = L'\0'; } // check for ; at beginning - if (StringCchLenN(pszFile,MAX_PATH) < 3) - StringCchCat(pszFile,len,L"txt"); + if (StringCchLenN(pszFile, COUNTOF(pszFile)) < 3) + StringCchCat(pszFile, COUNTOF(pszFile),L"txt"); SHFILEINFO shfi; ZeroMemory(&shfi,sizeof(SHFILEINFO)); @@ -4371,8 +4368,6 @@ int Style_GetLexerIconId(PEDITLEXER plex) SHGetFileInfo(pszFile,FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO), SHGFI_SMALLICON | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES); - GlobalFree(pszFile); - return (shfi.iIcon); } @@ -4493,13 +4488,13 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP Style_AddLexerToTreeView(hwndTV,pLexArray[i]); } - pCurrentStyle = 0; + pCurrentStyle = NULL; //SetExplorerTheme(hwndTV); //TreeView_Expand(hwndTV,TreeView_GetRoot(hwndTV),TVE_EXPAND); TreeView_Select(hwndTV,currentLex,TVGN_CARET); - SendDlgItemMessage(hwnd,IDC_STYLEEDIT,EM_LIMITTEXT,COUNTOF(lexDefault.Styles[0].szValue)-1,0); + 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); @@ -4543,7 +4538,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); else if (pCurrentLexer) { - WCHAR szBuf[256] = { L'\0' }; + WCHAR szBuf[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; if (GetDlgItemText(hwnd, IDC_STYLEEDIT, szBuf, COUNTOF(szBuf))) StringCchCopy(pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions),szBuf); } @@ -4551,10 +4546,10 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP // a lexer has been selected if (!TreeView_GetParent(hwndTV,lpnmtv->itemNew.hItem)) { - WCHAR wch[256] = { L'\0' }; + WCHAR wch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; GetDlgItemText(hwnd,IDC_STYLELABELS,wch,COUNTOF(wch)); - if (StrChr(wch,L'|')) *StrChr(wch,L'|') = 0; + if (StrChr(wch,L'|')) *StrChr(wch,L'|') = L'\0'; pCurrentStyle = 0; pCurrentLexer = (PEDITLEXER)lpnmtv->itemNew.lParam; @@ -4599,10 +4594,10 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP // a style has been selected else { - WCHAR wch[256] = { L'\0' }; + WCHAR wch[BUFSIZE_STYLE_VALUE] = { L'\0' }; GetDlgItemText(hwnd,IDC_STYLELABELS,wch,COUNTOF(wch)); - if (StrChr(wch,L'|')) *StrChr(wch,L'|') = 0; + if (StrChr(wch,L'|')) *StrChr(wch,L'|') = L'\0'; pCurrentLexer = 0; @@ -4719,7 +4714,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP htiTarget = TreeView_GetDropHilight(hwndTV); if (htiTarget) { - WCHAR tchCopy[256] = { L'\0' }; + WCHAR tchCopy[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; TreeView_SelectDropTarget(hwndTV,NULL); GetDlgItemText(hwnd,IDC_STYLEEDIT,tchCopy,COUNTOF(tchCopy)); TreeView_Select(hwndTV,htiTarget,TVGN_CARET); @@ -4779,7 +4774,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP case IDC_STYLEFONT: if (pCurrentStyle) { - WCHAR tch[256] = { L'\0' }; + WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); if (Style_SelectFont(hwnd,tch,COUNTOF(tch), StringCchCompareIX(pCurrentStyle->pszName,L"Default Style") == 0 || @@ -4797,7 +4792,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP case IDC_STYLEFORE: if (pCurrentStyle) { - WCHAR tch[256] = { L'\0' }; + WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); if (Style_SelectColor(hwnd,TRUE,tch,COUNTOF(tch))) { SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); @@ -4813,7 +4808,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP case IDC_STYLEBACK: if (pCurrentStyle) { - WCHAR tch[256] = { L'\0' }; + WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); if (Style_SelectColor(hwnd,FALSE,tch,COUNTOF(tch))) { SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); @@ -4846,7 +4841,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP //case IDC_STYLEBOLD: // if (pCurrentStyle) // { - // WCHAR tch[256] = { L'\0' }; + // WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); // Style_StrSetAttribute(tch,COUNTOF(tch),L"bold",IsDlgButtonChecked(hwnd,IDC_STYLEBOLD)); // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); @@ -4856,7 +4851,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP //case IDC_STYLEITALIC: // if (pCurrentStyle) // { - // WCHAR tch[256] = { L'\0' }; + // WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); // Style_StrSetAttribute(tch,COUNTOF(tch),L"italic",IsDlgButtonChecked(hwnd,IDC_STYLEITALIC)); // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); @@ -4866,7 +4861,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP //case IDC_STYLEUNDERLINE: // if (pCurrentStyle) // { - // WCHAR tch[256] = { L'\0' }; + // WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); // Style_StrSetAttribute(tch,COUNTOF(tch),L"underline",IsDlgButtonChecked(hwnd,IDC_STYLEUNDERLINE)); // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); @@ -4876,7 +4871,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP //case IDC_STYLEEOLFILLED: // if (pCurrentStyle) // { - // WCHAR tch[256] = { L'\0' }; + // WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); // Style_StrSetAttribute(tch,COUNTOF(tch),L"eolfilled",IsDlgButtonChecked(hwnd,IDC_STYLEEOLFILLED)); // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); @@ -4887,7 +4882,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP { if (HIWORD(wParam) == EN_CHANGE) { int cr; - WCHAR tch[256] = { L'\0' }; + WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); @@ -4990,7 +4985,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP void Style_ConfigDlg(HWND hwnd) { - WCHAR *StyleBackup[1024]; + WCHAR *StyleBackup[NUMLEXERS * 64]; int c,cItems,i,iLexer; // Backup Styles diff --git a/src/Styles.h b/src/Styles.h index f97102956..5bde5938d 100644 --- a/src/Styles.h +++ b/src/Styles.h @@ -16,6 +16,9 @@ #ifndef _NP3_STYLES_H_ #define _NP3_STYLES_H_ +#define BUFSIZE_STYLE_VALUE 256 +#define BUFZIZE_STYLE_EXTENTIONS 1024 + typedef struct _editstyle { #pragma warning(disable : 4201) // MS's Non-Std: Struktur/Union ohne Namen @@ -27,7 +30,7 @@ typedef struct _editstyle int rid; WCHAR* pszName; WCHAR* pszDefault; - WCHAR szValue[256]; + WCHAR szValue[BUFSIZE_STYLE_VALUE]; } EDITSTYLE, *PEDITSTYLE; @@ -45,7 +48,7 @@ typedef struct _editlexer int rid; WCHAR* pszName; WCHAR* pszDefExt; - WCHAR szExtensions[256]; + WCHAR szExtensions[BUFZIZE_STYLE_EXTENTIONS]; PKEYWORDLIST pKeyWords; EDITSTYLE Styles[]; From b74feba1d82d0e99d29beb43b392d7d771850c47 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Mon, 23 Oct 2017 10:04:50 +0200 Subject: [PATCH 2/4] + change buffers for operating edit box in customize schemes --- src/Styles.c | 46 +++++++++++++++++++++++----------------------- src/Styles.h | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Styles.c b/src/Styles.c index 50331431c..76897e3e9 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -3073,7 +3073,7 @@ void Style_SetLexer(HWND hwnd,PEDITLEXER pLexNew) if (Style_StrGetSize(lexDefault.Styles[7+iIdx].szValue,&iValue)) { WCHAR tch[32] = { L'\0' }; - WCHAR wchStyle[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)]; + WCHAR wchStyle[BUFSIZE_STYLE_VALUE]; StringCchCopyN(wchStyle,COUNTOF(wchStyle),lexDefault.Styles[7 + iIdx].szValue,COUNTOF(lexDefault.Styles[7 + iIdx].szValue)); iValue = max(min(iValue,5),0); @@ -3855,7 +3855,7 @@ BOOL Style_StrGetCharSet(LPCWSTR lpszStyle,int *i) // BOOL Style_StrGetSize(LPCWSTR lpszStyle,int *i) { - WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; + WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; int iSign = 0; WCHAR *p = StrStrI(lpszStyle, L"size:"); @@ -3897,7 +3897,7 @@ BOOL Style_StrGetSize(LPCWSTR lpszStyle,int *i) // BOOL Style_StrGetSizeStr(LPCWSTR lpszStyle,LPWSTR lpszSize,int cchSize) { - WCHAR tch[MIDSZ_BUFFER] = { L'\0' }; + WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; WCHAR *p = StrStrI(lpszStyle, L"size:"); if (p) { @@ -3919,7 +3919,7 @@ BOOL Style_StrGetSizeStr(LPCWSTR lpszStyle,LPWSTR lpszSize,int cchSize) // BOOL Style_StrGetColor(BOOL bFore,LPCWSTR lpszStyle,int *rgb) { - WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; + WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; WCHAR *pItem = (bFore) ? L"fore:" : L"back:"; WCHAR *p = StrStrI(lpszStyle, pItem); @@ -3949,7 +3949,7 @@ BOOL Style_StrGetColor(BOOL bFore,LPCWSTR lpszStyle,int *rgb) // Style_StrGetCase() // BOOL Style_StrGetAlpha(LPCWSTR lpszStyle, int *i) { - WCHAR tch[256] = { L'\0' }; + WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; WCHAR *p = StrStrI(lpszStyle, L"alpha:"); if (p) { StringCchCopy(tch, COUNTOF(tch), p + CSTRLEN(L"alpha:")); @@ -3974,7 +3974,7 @@ BOOL Style_StrGetAlpha(LPCWSTR lpszStyle, int *i) { // BOOL Style_StrGetCase(LPCWSTR lpszStyle,int *i) { - WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; + WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; WCHAR *p = StrStrI(lpszStyle, L"case:"); if (p) { @@ -4004,7 +4004,7 @@ BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle,BOOL bDefaultStyle { CHOOSEFONT cf; LOGFONT lf; - WCHAR szNewStyle[512] = { L'\0' }; + WCHAR szNewStyle[BUFSIZE_STYLE_VALUE] = { L'\0' }; int iValue; WCHAR tch[LF_FACESIZE+1] = { L'\0' }; HDC hdc; @@ -4114,7 +4114,7 @@ BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle,BOOL bDefaultStyle BOOL Style_SelectColor(HWND hwnd,BOOL bFore,LPWSTR lpszStyle,int cchStyle) { CHOOSECOLOR cc; - WCHAR szNewStyle[512] = { L'\0' }; + WCHAR szNewStyle[BUFSIZE_STYLE_VALUE] = { L'\0' }; int iRGBResult; int iValue; WCHAR tch[64] = { L'\0' }; @@ -4252,12 +4252,12 @@ BOOL Style_SelectColor(HWND hwnd,BOOL bFore,LPWSTR lpszStyle,int cchStyle) void Style_SetStyles(HWND hwnd,int iStyle,LPCWSTR lpszStyle) { - WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; + WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; int iValue; // Font if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch))) { - char mch[256] = { '\0' }; + char mch[BUFSIZE_STYLE_VALUE] = { '\0' }; WideCharToMultiByteStrg(CP_UTF8,tch,mch); SendMessage(hwnd,SCI_STYLESETFONT,iStyle,(LPARAM)mch); } @@ -4316,7 +4316,7 @@ void Style_SetStyles(HWND hwnd,int iStyle,LPCWSTR lpszStyle) void Style_SetFontQuality(HWND hwnd,LPCWSTR lpszStyle) { WPARAM wQuality = (WPARAM)FontQuality[iSciFontQuality];; - WCHAR tch[64] = { L'\0' }; + WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; if (Style_StrGetFontQuality(lpszStyle,tch,COUNTOF(tch))) { if (StringCchCompareIN(tch,COUNTOF(tch),L"default",-1) == 0) @@ -4362,7 +4362,7 @@ void Style_GetCurrentLexerName(LPWSTR lpszName,int cchName) // int Style_GetLexerIconId(PEDITLEXER plex) { - WCHAR pszFile[MAX_PATH]; + WCHAR pszFile[MAX_PATH + BUFZIZE_STYLE_EXTENTIONS]; WCHAR *pszExtensions; if (StringCchLen(plex->szExtensions)) @@ -4397,7 +4397,7 @@ int Style_GetLexerIconId(PEDITLEXER plex) HTREEITEM Style_AddLexerToTreeView(HWND hwnd,PEDITLEXER plex) { int i = 0; - WCHAR tch[256] = { L'\0' }; + WCHAR tch[MIDSZ_BUFFER] = { L'\0' }; HTREEITEM hTreeNode; @@ -4444,7 +4444,7 @@ HTREEITEM Style_AddLexerToTreeView(HWND hwnd,PEDITLEXER plex) // void Style_AddLexerToListView(HWND hwnd,PEDITLEXER plex) { - WCHAR tch[256] = { L'\0' }; + WCHAR tch[MIDSZ_BUFFER] = { L'\0' }; LVITEM lvi; ZeroMemory(&lvi,sizeof(LVITEM)); @@ -4556,7 +4556,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP GetDlgItemText(hwnd,IDC_STYLEEDIT,pCurrentStyle->szValue,COUNTOF(pCurrentStyle->szValue)); else if (pCurrentLexer) { - WCHAR szBuf[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; + WCHAR szBuf[BUFZIZE_STYLE_EXTENTIONS] = { L'\0' }; if (GetDlgItemText(hwnd, IDC_STYLEEDIT, szBuf, COUNTOF(szBuf))) StringCchCopy(pCurrentLexer->szExtensions,COUNTOF(pCurrentLexer->szExtensions),szBuf); } @@ -4792,7 +4792,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP case IDC_STYLEFONT: if (pCurrentStyle) { - WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; + WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); if (Style_SelectFont(hwnd,tch,COUNTOF(tch), StringCchCompareIX(pCurrentStyle->pszName,L"Default Style") == 0 || @@ -4810,7 +4810,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP case IDC_STYLEFORE: if (pCurrentStyle) { - WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; + WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); if (Style_SelectColor(hwnd,TRUE,tch,COUNTOF(tch))) { SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); @@ -4826,7 +4826,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP case IDC_STYLEBACK: if (pCurrentStyle) { - WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; + WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); if (Style_SelectColor(hwnd,FALSE,tch,COUNTOF(tch))) { SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); @@ -4859,7 +4859,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP //case IDC_STYLEBOLD: // if (pCurrentStyle) // { - // WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; + // WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); // Style_StrSetAttribute(tch,COUNTOF(tch),L"bold",IsDlgButtonChecked(hwnd,IDC_STYLEBOLD)); // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); @@ -4869,7 +4869,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP //case IDC_STYLEITALIC: // if (pCurrentStyle) // { - // WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; + // WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); // Style_StrSetAttribute(tch,COUNTOF(tch),L"italic",IsDlgButtonChecked(hwnd,IDC_STYLEITALIC)); // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); @@ -4879,7 +4879,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP //case IDC_STYLEUNDERLINE: // if (pCurrentStyle) // { - // WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; + // WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); // Style_StrSetAttribute(tch,COUNTOF(tch),L"underline",IsDlgButtonChecked(hwnd,IDC_STYLEUNDERLINE)); // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); @@ -4889,7 +4889,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP //case IDC_STYLEEOLFILLED: // if (pCurrentStyle) // { - // WCHAR tch[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = { L'\0' }; + // WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' }; // GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch)); // Style_StrSetAttribute(tch,COUNTOF(tch),L"eolfilled",IsDlgButtonChecked(hwnd,IDC_STYLEEOLFILLED)); // SetDlgItemText(hwnd,IDC_STYLEEDIT,tch); @@ -5003,7 +5003,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP void Style_ConfigDlg(HWND hwnd) { - WCHAR *StyleBackup[NUMLEXERS * 64]; + WCHAR* StyleBackup[NUMLEXERS * 64]; int c,cItems,i,iLexer; // Backup Styles diff --git a/src/Styles.h b/src/Styles.h index 1e461d924..979aee729 100644 --- a/src/Styles.h +++ b/src/Styles.h @@ -16,7 +16,7 @@ #ifndef _NP3_STYLES_H_ #define _NP3_STYLES_H_ -#define BUFSIZE_STYLE_VALUE 128 +#define BUFSIZE_STYLE_VALUE 256 #define BUFZIZE_STYLE_EXTENTIONS 512 typedef struct _editstyle From 6eb4d02593d8c78a4685d2176efaef7f3070da51 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Mon, 23 Oct 2017 10:42:49 +0200 Subject: [PATCH 3/4] + fix: pasting clipboard content into selection box should replace text and cancel selection then (in case of swapping clipboard, the selection is preserved) --- src/Notepad3.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Notepad3.c b/src/Notepad3.c index 20b28e04e..76fc41a01 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -3045,11 +3045,12 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) SendMessage(hwndEdit,SCI_REPLACESEL,0,(LPARAM)pClip); - if (iCurrPos > iAnchor) - SendMessage(hwndEdit,SCI_SETSEL, iAnchor, iAnchor + lstrlenA(pClip)); - else - SendMessage(hwndEdit,SCI_SETSEL, iCurrPos + lstrlenA(pClip), iCurrPos); - + if (bSwapClipBoard) { + if (iCurrPos > iAnchor) + SendMessage(hwndEdit, SCI_SETSEL, iAnchor, iAnchor + lstrlenA(pClip)); + else + SendMessage(hwndEdit, SCI_SETSEL, iCurrPos + lstrlenA(pClip), iCurrPos); + } } EndSelUndoAction(token); LocalFree(pClip); From 8baacd6e62e635f755338bb0cd0d5322fdf80fbd Mon Sep 17 00:00:00 2001 From: Derick Payne Date: Mon, 23 Oct 2017 23:22:52 +0200 Subject: [PATCH 4/4] Prepared Build 632 --- Versions/build.txt | 2 +- distrib/Changes.txt | 32 ++++++++++++++++++++++++++++++++ res/Notepad3.exe.manifest.conf | 2 +- src/VersionEx.h | 4 ++-- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Versions/build.txt b/Versions/build.txt index 502380c6c..c9a777fb5 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -610 +632 diff --git a/distrib/Changes.txt b/distrib/Changes.txt index 0e73f6746..17eb2fafa 100644 --- a/distrib/Changes.txt +++ b/distrib/Changes.txt @@ -2,6 +2,38 @@ Rizonesoft Notepad3 CHANGES ================================================== +-------------------------------------------------- +Version 2.17.1023.632 (16 October 2017) +-------------------------------------------------- +~ Fix: pasting clipboard content into selection box should replace text and + cancel selection then (in case of swapping clipboard, the selection is preserved). +~ Changed buffers for operating edit box in customize schemes. +~ Implemented Feature Request #51 (buffer size of file extension edit box). +~ First prottotype of VirtualSpace RectangularSelection by default (very old + behavior can be turned on by [Settings2] DenyVirtualSpaceAccess=1). +~ Added switch ([Settings2] UseOldStyleBraceMatching) to preserve old style + brace matching behavior. +~ Applied patch from Neil Hodgson (Master of Scintilla Lib - respond to + scintilla lib issue report #1976). +~ Fixed .ini paths for np3portableapps. +~ Restore wrongly discarded np3portableapps .ini files for NP3Portable, + redirecting .ini reading to correct path. +~ Documentation: Minor changes to Notepad3.txt. +~ Documentation: doc/Notepad3.txt - add description of [Section2] .ini settings + (mostly taken from orig. Notepad2 FAQs). +~ Remove settings for "Favorites" directory -> NP3 uses then users system + default folder (%USERPROFILE%\Favorites). +~ Default to modern displays settings, using Scintilla's new technology + : SciDirectWriteTech=1, SciFontQuality=3 +~ Settings [Section2] (cannot be set via GUI) add all possible names and + default values, if applicable. +~ License.txt: switch to UTF-8 encoding. +~ Feature: Show warning before loading file with unknown (custom schemes) file + name extension. +~ Add code snippet (activation only prepare for future extensions). +~ Fix: Crash in Favorites management. +~ Small code refactoring (replacing deprecated methods). + -------------------------------------------------- Version 2.17.1016.610 (16 October 2017) -------------------------------------------------- diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index 0dc1f349d..572af4067 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 diff --git a/src/VersionEx.h b/src/VersionEx.h index 5403b35dd..7e0a8aa4b 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -1,5 +1,5 @@ #define VERSION_MAJOR 2 #define VERSION_MINOR 17 -#define VERSION_REV 1016 -#define VERSION_BUILD 610 +#define VERSION_REV 1023 +#define VERSION_BUILD 632 #define SCINTILLA_VER 400