+ further discussions on notepad2-mod PR #200 convinced me, that the "reload UTF-8 bugfix" solves a problem regarding pure ASCII files reloaded as UTF-8.

+ add menu entries for launching WebTemplates (specified in section [Settings2]) with selected text as arguments
This commit is contained in:
Rainer Kottenhoff 2017-08-15 19:12:13 +02:00
parent 2a11751359
commit 2e2e1707cd
3 changed files with 8 additions and 4 deletions

View File

@ -1352,12 +1352,13 @@ BOOL EditLoadFile(
((IsUTF8Signature(lpData) ||
FileVars_IsUTF8(&fvCurFile) ||
(iSrcEncoding == CPI_UTF8 || iSrcEncoding == CPI_UTF8SIGN) ||
(!bPreferOEM && bLoadASCIIasUTF8) ||
(IsUTF8(lpData,cbData) &&
(((UTF8_mbslen_bytes(UTF8StringStart(lpData)) - 1 !=
UTF8_mbslen(UTF8StringStart(lpData),IsUTF8Signature(lpData) ? cbData-3 : cbData)) ||
(!bPreferOEM && (
mEncoding[_iPrefEncoding].uFlags & NCP_UTF8 ||
bLoadASCIIasUTF8 )) ))))) && !(FileVars_IsNonUTF8(&fvCurFile) &&
mEncoding[_iPrefEncoding].uFlags & NCP_UTF8
)) ))))) && !(FileVars_IsNonUTF8(&fvCurFile) &&
(iSrcEncoding != CPI_UTF8 && iSrcEncoding != CPI_UTF8SIGN)))
{
SendMessage(hwnd,SCI_SETCODEPAGE,Encoding_GetSciCodePage(CPI_UTF8),0);

View File

@ -4707,10 +4707,10 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
cchSelection = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) -
(int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
if (cchSelection > 0 && cchSelection <= 500 && SendMessage(hwndEdit,SCI_GETSELTEXT,0,0) < COUNTOF(mszSelection))
if ((cchSelection > 0) && (cchSelection <= 500) && (SendMessage(hwndEdit,SCI_GETSELTEXT,0,0) < COUNTOF(mszSelection)))
{
SendMessage(hwndEdit,SCI_GETSELTEXT,0,(LPARAM)mszSelection);
mszSelection[cchSelection] = 0; // zero terminate
mszSelection[cchSelection] = '\0'; // zero terminate
// Check lpszSelection and truncate bad WCHARs
lpsz = StrChrA(mszSelection,13);

View File

@ -94,6 +94,9 @@ BEGIN
MENUITEM "Execute &Document\tCtrl+L", IDM_FILE_LAUNCH
MENUITEM "&Open with...\tAlt+L", IDM_FILE_OPENWITH
MENUITEM "&Command...\tCtrl+R", IDM_FILE_RUN
MENUITEM SEPARATOR
MENUITEM "Web Template &1\tCtrl+Shift+1", CMD_WEBACTION1
MENUITEM "Web Template &2\tCtrl+Shift+2", CMD_WEBACTION2
END
MENUITEM SEPARATOR
POPUP "&Encoding"