mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
Merge branch 'Bugfixes_and_More'
This commit is contained in:
commit
194c4ccf10
Binary file not shown.
@ -154,8 +154,9 @@ long DeelxRegexSearch::FindText(Document* doc, int minPos, int maxPos, const cha
|
||||
startPos = doc->MovePositionOutsideChar(startPos, 1, false);
|
||||
endPos = doc->MovePositionOutsideChar(endPos, 1, false);
|
||||
|
||||
int compileFlags(deelx::MULTILINE | deelx::GLOBAL | deelx::EXTENDED); // the .(dot) does not match line-breaks
|
||||
//int compileFlags(deelx::SINGLELINE | deelx::MULTILINE | deelx::GLOBAL | deelx::EXTENDED); // the .(dot) also matches line-breaks
|
||||
//int compileFlags(deelx::SINGLELINE | deelx::MULTILINE | deelx::GLOBAL); // the .(dot) also matches line-breaks
|
||||
int compileFlags(deelx::MULTILINE | deelx::GLOBAL); // the .(dot) does not match line-breaks
|
||||
//compileFlags |= deelx::EXTENDED; // ignore spaces and use '#' as line-comment)
|
||||
compileFlags |= (caseSensitive) ? deelx::NO_FLAG : deelx::IGNORECASE;
|
||||
compileFlags |= (left2right) ? deelx::NO_FLAG : deelx::RIGHTTOLEFT;
|
||||
|
||||
|
||||
@ -2897,7 +2897,8 @@ struct Sci_TextToFind {
|
||||
number used by the C and C++ lexer to display literal strings; it has the value 6). This
|
||||
feature works differently on Windows and GTK+.<br />
|
||||
The default character set is <code>SC_CHARSET_DEFAULT</code>.</p>
|
||||
<p><code>SC_CHARSET_ANSI</code> and <code>SC_CHARSET_DEFAULT</code> specify European Windows code page 1252 unless the code page is set.</p>
|
||||
<p><code>SC_CHARSET_ANSI</code> specifies European Windows code page 1252.</p>
|
||||
<p><code>SC_CHARSET_DEFAULT</code> specifies the system-default code page unless the code page is set.</p>
|
||||
|
||||
<table class="standard" summary="Character Sets supported"><tbody>
|
||||
<tr>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
@ -1028,7 +1028,7 @@
|
||||
C++11 range-based for loops used in SciTE so GCC 4.6 is now the minimum supported version.
|
||||
</li>
|
||||
<li>
|
||||
SC_CHARSET_DEFAULT now means code page 1252 on Windows unless a code page is set.
|
||||
(REVERTED in Notepad2-mod) SC_CHARSET_DEFAULT now means code page 1252 on Windows unless a code page is set.
|
||||
This prevents unexpected behaviour and crashes on East Asian systems where default locales are commonly DBCS.
|
||||
Projects which want to default to DBCS code pages in East Asian locales should set the code page and
|
||||
character set explicitly.
|
||||
|
||||
@ -1144,7 +1144,8 @@ UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage) {
|
||||
}
|
||||
switch (characterSet) {
|
||||
case SC_CHARSET_ANSI: return 1252;
|
||||
case SC_CHARSET_DEFAULT: return documentCodePage ? documentCodePage : 1252;
|
||||
//case SC_CHARSET_DEFAULT: return documentCodePage ? documentCodePage : 1252; // SCI orig
|
||||
case SC_CHARSET_DEFAULT: return documentCodePage;
|
||||
case SC_CHARSET_BALTIC: return 1257;
|
||||
case SC_CHARSET_CHINESEBIG5: return 950;
|
||||
case SC_CHARSET_EASTEUROPE: return 1250;
|
||||
|
||||
251
src/Edit.c
251
src/Edit.c
@ -73,15 +73,15 @@ WCHAR wchANSI[8] = L"";
|
||||
WCHAR wchOEM [8] = L"";
|
||||
|
||||
NP2ENCODING mEncoding[] = {
|
||||
{ NCP_DEFAULT|NCP_RECODE, 0, "ansi,ansi,ascii,", 61000, L"" },
|
||||
{ NCP_8BIT|NCP_RECODE, 0, "oem,oem,", 61001, L"" },
|
||||
{ NCP_UNICODE|NCP_UNICODE_BOM, 0, "", 61002, L"" },
|
||||
{ NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_UNICODE_BOM, 0, "", 61003, L"" },
|
||||
{ NCP_UNICODE|NCP_RECODE, 0, "utf-16,utf16,unicode,", 61004, L"" },
|
||||
{ NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_RECODE, 0, "utf-16be,utf16be,unicodebe,", 61005, L"" },
|
||||
{ NCP_UTF8|NCP_RECODE, 0, "utf-8,utf8,", 61006, L"" },
|
||||
{ NCP_UTF8|NCP_UTF8_SIGN, 0, "utf-8,utf8,", 61007, L"" },
|
||||
{ NCP_8BIT|NCP_RECODE, CP_UTF7, "utf-7,utf7,", 61008, L"" },
|
||||
{ NCP_ANSI|NCP_RECODE, CP_ACP, "ansi,ansi,ascii,", 61000, L"" },
|
||||
{ NCP_8BIT|NCP_RECODE, CP_OEMCP, "oem,oem,", 61001, L"" },
|
||||
{ NCP_UNICODE|NCP_UNICODE_BOM, CP_UTF8, "", 61002, L"" },
|
||||
{ NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_UNICODE_BOM, CP_UTF8, "", 61003, L"" },
|
||||
{ NCP_UNICODE|NCP_RECODE, CP_UTF8, "utf-16,utf16,unicode,", 61004, L"" },
|
||||
{ NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_RECODE, CP_UTF8, "utf-16be,utf16be,unicodebe,", 61005, L"" },
|
||||
{ NCP_UTF8|NCP_RECODE, CP_UTF8, "utf-8,utf8,", 61006, L"" },
|
||||
{ NCP_UTF8|NCP_UTF8_SIGN, CP_UTF8, "utf-8,utf8,", 61007, L"" },
|
||||
{ NCP_8BIT|NCP_RECODE, CP_UTF7, "utf-7,utf7,", 61008, L"" },
|
||||
{ NCP_8BIT|NCP_RECODE, 720, "DOS-720,dos720,", 61009, L"" },
|
||||
{ NCP_8BIT|NCP_RECODE, 28596, "iso-8859-6,iso88596,arabic,csisolatinarabic,ecma114,isoir127,", 61010, L"" },
|
||||
{ NCP_8BIT|NCP_RECODE, 10004, "x-mac-arabic,xmacarabic,", 61011, L"" },
|
||||
@ -238,7 +238,7 @@ HWND EditCreate(HWND hwndParent)
|
||||
g_hInstance,
|
||||
NULL);
|
||||
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,iDefaultCodePage,0);
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,Encoding_GetSciCodePage(iDefaultEncoding),0);
|
||||
SendMessage(hwnd,SCI_SETEOLMODE,SC_EOL_CRLF,0);
|
||||
SendMessage(hwnd,SCI_SETPASTECONVERTENDINGS,1,0);
|
||||
SendMessage(hwnd,SCI_SETMODEVENTMASK,/*SC_MODEVENTMASKALL*/SC_MOD_INSERTTEXT|SC_MOD_DELETETEXT,0);
|
||||
@ -315,16 +315,19 @@ void EditSetNewText(HWND hwnd,char* lpstrText,DWORD cbText)
|
||||
//
|
||||
// EditConvertText()
|
||||
//
|
||||
BOOL EditConvertText(HWND hwnd,UINT cpSource,UINT cpDest,BOOL bSetSavePoint)
|
||||
BOOL EditConvertText(HWND hwnd,int encSource,int encDest,BOOL bSetSavePoint)
|
||||
{
|
||||
struct Sci_TextRange tr = { { 0, -1 }, NULL };
|
||||
int length, cbText, cbwText;
|
||||
char *pchText;
|
||||
WCHAR *pwchText;
|
||||
|
||||
if (cpSource == cpDest)
|
||||
if (encSource == encDest)
|
||||
return(TRUE);
|
||||
|
||||
if (!(Encoding_IsValid(encSource) && Encoding_IsValid(encDest)))
|
||||
return(FALSE);
|
||||
|
||||
length = (int)SendMessage(hwnd,SCI_GETLENGTH,0,0);
|
||||
|
||||
if (length == 0) {
|
||||
@ -333,7 +336,7 @@ BOOL EditConvertText(HWND hwnd,UINT cpSource,UINT cpDest,BOOL bSetSavePoint)
|
||||
SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0);
|
||||
SendMessage(hwnd,SCI_CLEARALL,0,0);
|
||||
SendMessage(hwnd,SCI_MARKERDELETEALL,(WPARAM)-1,0);
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,cpDest,0);
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE, Encoding_GetSciCodePage(encDest),0);
|
||||
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0);
|
||||
SendMessage(hwnd,EM_EMPTYUNDOBUFFER,0,0);
|
||||
SendMessage(hwnd,SCI_GOTOPOS,0,0);
|
||||
@ -344,21 +347,25 @@ BOOL EditConvertText(HWND hwnd,UINT cpSource,UINT cpDest,BOOL bSetSavePoint)
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
pchText = GlobalAlloc(GPTR,length*5+2);
|
||||
|
||||
tr.lpstrText = pchText;
|
||||
SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr);
|
||||
|
||||
pwchText = GlobalAlloc(GPTR,length*3+2);
|
||||
cbwText = MultiByteToWideChar(cpSource,0,pchText,length,pwchText,length*3+2);
|
||||
cbText = WideCharToMultiByte(cpDest,0,pwchText,cbwText,pchText,length*5+2,NULL,NULL);
|
||||
|
||||
UINT cpSrc = mEncoding[encSource].uCodePage;
|
||||
UINT cpDst = mEncoding[encDest].uCodePage;
|
||||
cbwText = MultiByteToWideChar(cpSrc,0,pchText,length,pwchText,length*3+2);
|
||||
cbText = WideCharToMultiByte(cpDst,0,pwchText,cbwText,pchText,length*5+2,NULL,NULL);
|
||||
|
||||
SendMessage(hwnd,SCI_CANCEL,0,0);
|
||||
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0);
|
||||
SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0);
|
||||
SendMessage(hwnd,SCI_CLEARALL,0,0);
|
||||
SendMessage(hwnd,SCI_MARKERDELETEALL,(WPARAM)-1,0);
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,cpDest,0);
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,Encoding_GetSciCodePage(encDest),0);
|
||||
SendMessage(hwnd,SCI_ADDTEXT,cbText,(LPARAM)pchText);
|
||||
SendMessage(hwnd,SCI_EMPTYUNDOBUFFER,0,0);
|
||||
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0);
|
||||
@ -380,51 +387,39 @@ BOOL EditSetNewEncoding(HWND hwnd,int iCurrentEncoding,int iNewEncoding,BOOL bNo
|
||||
|
||||
if (iCurrentEncoding != iNewEncoding) {
|
||||
|
||||
if ((iCurrentEncoding == CPI_DEFAULT && iNewEncoding == CPI_DEFAULT) ||
|
||||
(iCurrentEncoding != CPI_DEFAULT && iNewEncoding != CPI_DEFAULT))
|
||||
return(TRUE);
|
||||
BOOL bOneEncodingIsANSI = (Encoding_IsANSI(iCurrentEncoding) || Encoding_IsANSI(iNewEncoding));
|
||||
BOOL bBothEncodingsAreANSI = (Encoding_IsANSI(iCurrentEncoding) && Encoding_IsANSI(iNewEncoding));
|
||||
|
||||
// conversion between arbirtaty encodings may lead to unexpected results
|
||||
if (!bOneEncodingIsANSI || bBothEncodingsAreANSI) {
|
||||
// ~ return(TRUE); // this would imply a successful conversion - it is not !
|
||||
// return(FALSE); // commented out ? : allow conversion between arbirtaty encodings
|
||||
}
|
||||
|
||||
if (SendMessage(hwnd, SCI_GETLENGTH, 0, 0) == 0) {
|
||||
|
||||
if (SendMessage(hwnd,SCI_GETLENGTH,0,0) == 0) {
|
||||
BOOL bIsEmptyUndoHistory = (SendMessage(hwnd, SCI_CANUNDO, 0, 0) == 0 && SendMessage(hwnd, SCI_CANREDO, 0, 0) == 0);
|
||||
|
||||
BOOL bIsEmptyUndoHistory =
|
||||
(SendMessage(hwnd,SCI_CANUNDO,0,0) == 0 && SendMessage(hwnd,SCI_CANREDO,0,0) == 0);
|
||||
BOOL doNewEncoding = (!bIsEmptyUndoHistory && !bNoUI) ?
|
||||
(InfoBox(MBYESNO, L"MsgConv2", IDS_ASK_ENCODING2) == IDYES) : TRUE;
|
||||
|
||||
if ((iCurrentEncoding == CPI_DEFAULT || iNewEncoding == CPI_DEFAULT) &&
|
||||
(bNoUI || bIsEmptyUndoHistory || InfoBox(MBYESNO,L"MsgConv2",IDS_ASK_ENCODING2) == IDYES)) {
|
||||
|
||||
EditConvertText(hwnd,
|
||||
(mEncoding[iCurrentEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,
|
||||
(mEncoding[iNewEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,
|
||||
bSetSavePoint);
|
||||
|
||||
return(TRUE);
|
||||
if (doNewEncoding) {
|
||||
return EditConvertText(hwnd,iCurrentEncoding,iNewEncoding,bSetSavePoint);
|
||||
}
|
||||
|
||||
else
|
||||
return(FALSE);
|
||||
}
|
||||
else {
|
||||
|
||||
BOOL doNewEncoding = (!bNoUI) ? (InfoBox(MBYESNO, L"MsgConv1", IDS_ASK_ENCODING) == IDYES) : TRUE;
|
||||
|
||||
else if ((iCurrentEncoding == CPI_DEFAULT || iNewEncoding == CPI_DEFAULT) &&
|
||||
(bNoUI || InfoBox(MBYESNO,L"MsgConv1",IDS_ASK_ENCODING) == IDYES)) {
|
||||
|
||||
BeginWaitCursor();
|
||||
|
||||
EditConvertText(hwnd,
|
||||
(mEncoding[iCurrentEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,
|
||||
(mEncoding[iNewEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,
|
||||
FALSE);
|
||||
|
||||
EndWaitCursor();
|
||||
|
||||
return(TRUE);
|
||||
if (doNewEncoding) {
|
||||
BeginWaitCursor();
|
||||
BOOL result = EditConvertText(hwnd,iCurrentEncoding,iNewEncoding,FALSE);
|
||||
EndWaitCursor();
|
||||
return(result);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
else
|
||||
return(FALSE);
|
||||
}
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
||||
@ -628,8 +623,7 @@ void Encoding_InitDefaults() {
|
||||
// Try to set the DOS encoding to DOS-437 if the default OEMCP is not DOS-437
|
||||
if (mEncoding[g_DOSEncoding].uCodePage != 437)
|
||||
{
|
||||
int i;
|
||||
for (i = CPI_UTF7 + 1; i < COUNTOF(mEncoding); ++i) {
|
||||
for (int i = CPI_UTF7 + 1; i < COUNTOF(mEncoding); ++i) {
|
||||
if (mEncoding[i].uCodePage == 437 && Encoding_IsValid(i)) {
|
||||
g_DOSEncoding = i;
|
||||
break;
|
||||
@ -642,37 +636,43 @@ void Encoding_InitDefaults() {
|
||||
int Encoding_MapIniSetting(BOOL bLoad,int iSetting) {
|
||||
if (bLoad) {
|
||||
switch (iSetting) {
|
||||
case 0: return CPI_DEFAULT;
|
||||
case 1: return CPI_UNICODEBOM;
|
||||
case 2: return CPI_UNICODEBEBOM;
|
||||
case 3: return CPI_UTF8;
|
||||
case 4: return CPI_UTF8SIGN;
|
||||
case 5: return CPI_OEM;
|
||||
case 6: return CPI_UNICODE;
|
||||
case 7: return CPI_UNICODEBE;
|
||||
case 8: return CPI_UTF7;
|
||||
case -1: return CPI_NONE;
|
||||
case 0: return CPI_ANSI_DEFAULT;
|
||||
case 1: return CPI_UNICODEBOM;
|
||||
case 2: return CPI_UNICODEBEBOM;
|
||||
case 3: return CPI_UTF8;
|
||||
case 4: return CPI_UTF8SIGN;
|
||||
case 5: return CPI_OEM;
|
||||
case 6: return CPI_UNICODE;
|
||||
case 7: return CPI_UNICODEBE;
|
||||
case 8: return CPI_UTF7;
|
||||
default: {
|
||||
int i;
|
||||
for (i = CPI_UTF7 + 1; i < COUNTOF(mEncoding); i++) {
|
||||
if (mEncoding[i].uCodePage == (UINT)iSetting && Encoding_IsValid(i))
|
||||
for (int i = CPI_UTF7 + 1; i < COUNTOF(mEncoding); i++) {
|
||||
if ((mEncoding[i].uCodePage == (UINT)iSetting) && Encoding_IsValid(i))
|
||||
return(i);
|
||||
}
|
||||
return CPI_DEFAULT;
|
||||
return CPI_ANSI_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (iSetting) {
|
||||
case CPI_DEFAULT: return 0;
|
||||
case CPI_UNICODEBOM: return 1;
|
||||
case CPI_UNICODEBEBOM: return 2;
|
||||
case CPI_UTF8: return 3;
|
||||
case CPI_UTF8SIGN: return 4;
|
||||
case CPI_OEM: return 5;
|
||||
case CPI_UNICODE: return 6;
|
||||
case CPI_UNICODEBE: return 7;
|
||||
case CPI_UTF7: return 8;
|
||||
default: return(mEncoding[iSetting].uCodePage);
|
||||
case CPI_NONE: return -1;
|
||||
case CPI_ANSI_DEFAULT: return 0;
|
||||
case CPI_UNICODEBOM: return 1;
|
||||
case CPI_UNICODEBEBOM: return 2;
|
||||
case CPI_UTF8: return 3;
|
||||
case CPI_UTF8SIGN: return 4;
|
||||
case CPI_OEM: return 5;
|
||||
case CPI_UNICODE: return 6;
|
||||
case CPI_UNICODEBE: return 7;
|
||||
case CPI_UTF7: return 8;
|
||||
default: {
|
||||
if (Encoding_IsValid(iSetting))
|
||||
return(mEncoding[iSetting].uCodePage);
|
||||
else
|
||||
return CPI_ANSI_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -703,7 +703,6 @@ int Encoding_MatchW(LPCWSTR pwszTest) {
|
||||
|
||||
|
||||
int Encoding_MatchA(char *pchTest) {
|
||||
int i;
|
||||
char chTest[256];
|
||||
char *pchSrc = pchTest;
|
||||
char *pchDst = chTest;
|
||||
@ -715,7 +714,7 @@ int Encoding_MatchA(char *pchTest) {
|
||||
}
|
||||
*pchDst++ = ',';
|
||||
*pchDst = 0;
|
||||
for (i = 0; i < COUNTOF(mEncoding); i++) {
|
||||
for (int i = 0; i < COUNTOF(mEncoding); i++) {
|
||||
if (StrStrIA(mEncoding[i].pszParseNames,chTest)) {
|
||||
CPINFO cpi;
|
||||
if ((mEncoding[i].uFlags & NCP_INTERNAL) ||
|
||||
@ -789,7 +788,7 @@ void Encoding_AddToListView(HWND hwnd,int idSel,BOOL bRecodeOnly)
|
||||
else
|
||||
StrCpyN(wchBuf,pEE[i].wch,COUNTOF(wchBuf));
|
||||
|
||||
if (id == CPI_DEFAULT)
|
||||
if (Encoding_IsANSI(id))
|
||||
StrCatN(wchBuf,wchANSI,COUNTOF(wchBuf));
|
||||
else if (id == CPI_OEM)
|
||||
StrCatN(wchBuf,wchOEM,COUNTOF(wchBuf));
|
||||
@ -881,7 +880,7 @@ void Encoding_AddToComboboxEx(HWND hwnd,int idSel,BOOL bRecodeOnly)
|
||||
else
|
||||
StrCpyN(wchBuf,pEE[i].wch,COUNTOF(wchBuf));
|
||||
|
||||
if (id == CPI_DEFAULT)
|
||||
if (Encoding_IsANSI(id))
|
||||
StrCatN(wchBuf,wchANSI,COUNTOF(wchBuf));
|
||||
else if (id == CPI_OEM)
|
||||
StrCatN(wchBuf,wchOEM,COUNTOF(wchBuf));
|
||||
@ -927,6 +926,25 @@ BOOL Encoding_GetFromComboboxEx(HWND hwnd,int *pidEncoding)
|
||||
}
|
||||
|
||||
|
||||
BOOL Encoding_IsDefault(int iEncoding)
|
||||
{
|
||||
return (mEncoding[iEncoding].uFlags & NCP_DEFAULT);
|
||||
}
|
||||
|
||||
BOOL Encoding_IsANSI(int iEncoding)
|
||||
{
|
||||
return (mEncoding[iEncoding].uFlags & NCP_ANSI);
|
||||
}
|
||||
|
||||
int Encoding_GetSciCodePage(int iEncoding)
|
||||
{
|
||||
if (Encoding_IsDefault(iEncoding))
|
||||
return iDefaultCodePage;
|
||||
|
||||
return (Encoding_IsANSI(iEncoding)) ? 0 : SC_CP_UTF8;
|
||||
}
|
||||
|
||||
|
||||
BOOL IsUnicode(const char* pBuffer,int cb,LPBOOL lpbBOM,LPBOOL lpbReverse)
|
||||
{
|
||||
int i = 0xFFFF;
|
||||
@ -1191,13 +1209,14 @@ BOOL EditLoadFile(
|
||||
char* lpData;
|
||||
DWORD cbData;
|
||||
//char *cp;
|
||||
int _iDefaultEncoding;
|
||||
int _iPrefEncoding;
|
||||
|
||||
BOOL bBOM;
|
||||
BOOL bReverse = FALSE;
|
||||
|
||||
BOOL bPreferOEM = FALSE;
|
||||
|
||||
*iEncoding = CPI_ANSI_DEFAULT;
|
||||
*pbUnicodeErr = FALSE;
|
||||
*pbFileTooBig = FALSE;
|
||||
|
||||
@ -1211,8 +1230,8 @@ BOOL EditLoadFile(
|
||||
dwLastIOError = GetLastError();
|
||||
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
iSrcEncoding = -1;
|
||||
iWeakSrcEncoding = -1;
|
||||
iSrcEncoding = CPI_NONE;
|
||||
iWeakSrcEncoding = CPI_NONE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1226,8 +1245,8 @@ BOOL EditLoadFile(
|
||||
if (InfoBox(MBYESNO,L"MsgFileSizeWarning",IDS_WARNLOADBIGFILE) != IDYES) {
|
||||
CloseHandle(hFile);
|
||||
*pbFileTooBig = TRUE;
|
||||
iSrcEncoding = -1;
|
||||
iWeakSrcEncoding = -1;
|
||||
iSrcEncoding = CPI_NONE;
|
||||
iWeakSrcEncoding = CPI_NONE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@ -1239,8 +1258,8 @@ BOOL EditLoadFile(
|
||||
|
||||
if (!bReadSuccess) {
|
||||
GlobalFree(lpData);
|
||||
iSrcEncoding = -1;
|
||||
iWeakSrcEncoding = -1;
|
||||
iSrcEncoding = CPI_NONE;
|
||||
iWeakSrcEncoding = CPI_NONE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1251,33 +1270,29 @@ BOOL EditLoadFile(
|
||||
bPreferOEM = TRUE;
|
||||
}
|
||||
|
||||
if (!Encoding_IsValid(iDefaultEncoding))
|
||||
iDefaultEncoding = CPI_DEFAULT;
|
||||
|
||||
_iDefaultEncoding = (bPreferOEM) ? g_DOSEncoding : iDefaultEncoding;
|
||||
if (iWeakSrcEncoding != -1 && Encoding_IsValid(iWeakSrcEncoding))
|
||||
_iDefaultEncoding = iWeakSrcEncoding;
|
||||
|
||||
*iEncoding = CPI_DEFAULT;
|
||||
_iPrefEncoding = (bPreferOEM) ? g_DOSEncoding : iDefaultEncoding;
|
||||
if (Encoding_IsValid(iWeakSrcEncoding))
|
||||
_iPrefEncoding = iWeakSrcEncoding;
|
||||
|
||||
if (cbData == 0) {
|
||||
FileVars_Init(NULL,0,&fvCurFile);
|
||||
*iEOLMode = iLineEndings[iDefaultEOLMode];
|
||||
if (iSrcEncoding == -1) {
|
||||
if (iSrcEncoding == CPI_NONE) {
|
||||
if (bLoadASCIIasUTF8 && !bPreferOEM)
|
||||
*iEncoding = CPI_UTF8;
|
||||
else
|
||||
*iEncoding = _iDefaultEncoding;
|
||||
*iEncoding = _iPrefEncoding;
|
||||
}
|
||||
else
|
||||
*iEncoding = iSrcEncoding;
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,(mEncoding[*iEncoding].uFlags & NCP_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0);
|
||||
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,Encoding_GetSciCodePage(*iEncoding),0);
|
||||
EditSetNewText(hwnd,"",0);
|
||||
SendMessage(hwnd,SCI_SETEOLMODE,iLineEndings[iDefaultEOLMode],0);
|
||||
GlobalFree(lpData);
|
||||
}
|
||||
|
||||
else if (!bSkipEncodingDetection && (iSrcEncoding == -1 || iSrcEncoding == CPI_UNICODE || iSrcEncoding == CPI_UNICODEBE) &&
|
||||
else if (!bSkipEncodingDetection && (iSrcEncoding == CPI_NONE || iSrcEncoding == CPI_UNICODE || iSrcEncoding == CPI_UNICODEBE) &&
|
||||
(iSrcEncoding == CPI_UNICODE || iSrcEncoding == CPI_UNICODEBE || IsUnicode(lpData,cbData,&bBOM,&bReverse)) &&
|
||||
(iSrcEncoding == CPI_UNICODE || iSrcEncoding == CPI_UNICODEBE || !IsUTF8Signature(lpData))) // check for UTF-8 signature
|
||||
{
|
||||
@ -1315,7 +1330,7 @@ BOOL EditLoadFile(
|
||||
}
|
||||
|
||||
GlobalFree(lpData);
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,SC_CP_UTF8,0);
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,Encoding_GetSciCodePage(*iEncoding),0);
|
||||
EditSetNewText(hwnd,"",0);
|
||||
FileVars_Init(lpDataUTF8,cbData-1,&fvCurFile);
|
||||
EditSetNewText(hwnd,lpDataUTF8,cbData-1);
|
||||
@ -1325,7 +1340,7 @@ BOOL EditLoadFile(
|
||||
|
||||
else {
|
||||
FileVars_Init(lpData,cbData,&fvCurFile);
|
||||
if (!bSkipEncodingDetection && (iSrcEncoding == -1 || iSrcEncoding == CPI_UTF8 || iSrcEncoding == CPI_UTF8SIGN) &&
|
||||
if (!bSkipEncodingDetection && (iSrcEncoding == CPI_NONE || iSrcEncoding == CPI_UTF8 || iSrcEncoding == CPI_UTF8SIGN) &&
|
||||
((IsUTF8Signature(lpData) ||
|
||||
FileVars_IsUTF8(&fvCurFile) ||
|
||||
(iSrcEncoding == CPI_UTF8 || iSrcEncoding == CPI_UTF8SIGN) ||
|
||||
@ -1333,11 +1348,11 @@ BOOL EditLoadFile(
|
||||
(((UTF8_mbslen_bytes(UTF8StringStart(lpData)) - 1 !=
|
||||
UTF8_mbslen(UTF8StringStart(lpData),IsUTF8Signature(lpData) ? cbData-3 : cbData)) ||
|
||||
(!bPreferOEM && (
|
||||
mEncoding[_iDefaultEncoding].uFlags & NCP_UTF8 ||
|
||||
mEncoding[_iPrefEncoding].uFlags & NCP_UTF8 ||
|
||||
bLoadASCIIasUTF8 )) ))))) && !(FileVars_IsNonUTF8(&fvCurFile) &&
|
||||
(iSrcEncoding != CPI_UTF8 && iSrcEncoding != CPI_UTF8SIGN)))
|
||||
{
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,SC_CP_UTF8,0);
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,Encoding_GetSciCodePage(CPI_UTF8),0);
|
||||
EditSetNewText(hwnd,"",0);
|
||||
if (IsUTF8Signature(lpData)) {
|
||||
EditSetNewText(hwnd,UTF8StringStart(lpData),cbData-3);
|
||||
@ -1358,20 +1373,20 @@ BOOL EditLoadFile(
|
||||
LPWSTR lpDataWide;
|
||||
int cbDataWide;
|
||||
|
||||
if (iSrcEncoding != -1)
|
||||
if (iSrcEncoding != CPI_NONE)
|
||||
*iEncoding = iSrcEncoding;
|
||||
else {
|
||||
*iEncoding = FileVars_GetEncoding(&fvCurFile);
|
||||
if (*iEncoding == -1) {
|
||||
if (*iEncoding == CPI_NONE) {
|
||||
if (fvCurFile.mask & FV_ENCODING)
|
||||
*iEncoding = CPI_DEFAULT;
|
||||
*iEncoding = CPI_ANSI_DEFAULT;
|
||||
else {
|
||||
if (iWeakSrcEncoding == -1)
|
||||
*iEncoding = _iDefaultEncoding;
|
||||
if (iWeakSrcEncoding == CPI_NONE)
|
||||
*iEncoding = _iPrefEncoding;
|
||||
else if (mEncoding[iWeakSrcEncoding].uFlags & NCP_INTERNAL)
|
||||
*iEncoding = iDefaultEncoding;
|
||||
else
|
||||
*iEncoding = _iDefaultEncoding;
|
||||
*iEncoding = _iPrefEncoding;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1390,28 +1405,26 @@ BOOL EditLoadFile(
|
||||
cbData = WideCharToMultiByte(CP_UTF8,0,lpDataWide,cbDataWide,lpData,(int)GlobalSize(lpData),NULL,NULL);
|
||||
GlobalFree(lpDataWide);
|
||||
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,SC_CP_UTF8,0);
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,Encoding_GetSciCodePage(*iEncoding),0);
|
||||
EditSetNewText(hwnd,"",0);
|
||||
EditSetNewText(hwnd,lpData,cbData);
|
||||
*iEOLMode = EditDetectEOLMode(hwnd,lpData,cbData);
|
||||
|
||||
GlobalFree(lpData);
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,iDefaultCodePage,0);
|
||||
*iEncoding = iDefaultEncoding;
|
||||
SendMessage(hwnd,SCI_SETCODEPAGE,Encoding_GetSciCodePage(*iEncoding),0);
|
||||
EditSetNewText(hwnd,"",0);
|
||||
EditSetNewText(hwnd,lpData,cbData);
|
||||
*iEncoding = CPI_DEFAULT;
|
||||
*iEOLMode = EditDetectEOLMode(hwnd,lpData,cbData);
|
||||
GlobalFree(lpData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iSrcEncoding = -1;
|
||||
iWeakSrcEncoding = -1;
|
||||
iSrcEncoding = CPI_NONE;
|
||||
iWeakSrcEncoding = CPI_NONE;
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
12
src/Edit.h
12
src/Edit.h
@ -65,7 +65,7 @@ typedef struct _editfindreplace
|
||||
|
||||
HWND EditCreate(HWND);
|
||||
void EditSetNewText(HWND,char*,DWORD);
|
||||
BOOL EditConvertText(HWND,UINT,UINT,BOOL);
|
||||
BOOL EditConvertText(HWND,int,int,BOOL);
|
||||
BOOL EditSetNewEncoding(HWND,int,int,BOOL,BOOL);
|
||||
char* EditGetClipboardText(HWND);
|
||||
BOOL EditCopyAppend(HWND);
|
||||
@ -137,10 +137,11 @@ extern int g_DOSEncoding;
|
||||
#define NCP_UNICODE_REVERSE 16
|
||||
#define NCP_UNICODE_BOM 32
|
||||
#define NCP_8BIT 64
|
||||
#define NCP_INTERNAL (NCP_DEFAULT|NCP_UTF8|NCP_UTF8_SIGN|NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_UNICODE_BOM)
|
||||
#define NCP_RECODE 128
|
||||
#define NCP_ANSI 128
|
||||
#define NCP_INTERNAL (NCP_DEFAULT|NCP_UTF8|NCP_UTF8_SIGN|NCP_UNICODE|NCP_UNICODE_REVERSE|NCP_UNICODE_BOM|NCP_ANSI)
|
||||
#define NCP_RECODE 256
|
||||
#define CPI_NONE -1
|
||||
#define CPI_DEFAULT 0
|
||||
#define CPI_ANSI_DEFAULT 0
|
||||
#define CPI_OEM 1
|
||||
#define CPI_UNICODEBOM 2
|
||||
#define CPI_UNICODEBEBOM 3
|
||||
@ -171,6 +172,9 @@ void Encoding_AddToListView(HWND,int,BOOL);
|
||||
BOOL Encoding_GetFromListView(HWND,int *);
|
||||
void Encoding_AddToComboboxEx(HWND,int,BOOL);
|
||||
BOOL Encoding_GetFromComboboxEx(HWND,int *);
|
||||
BOOL Encoding_IsDefault(int);
|
||||
BOOL Encoding_IsANSI(int);
|
||||
int Encoding_GetSciCodePage(int);
|
||||
|
||||
BOOL IsUnicode(const char*,int,LPBOOL,LPBOOL);
|
||||
BOOL IsUTF8(const char*,int);
|
||||
|
||||
@ -93,6 +93,34 @@ int IniSectionGetInt(
|
||||
}
|
||||
|
||||
|
||||
UINT IniSectionGetUInt(
|
||||
LPCWSTR lpCachedIniSection,
|
||||
LPCWSTR lpName,
|
||||
UINT uDefault) {
|
||||
WCHAR *p = (WCHAR *)lpCachedIniSection;
|
||||
WCHAR tch[256];
|
||||
int ich;
|
||||
UINT u;
|
||||
|
||||
if (p) {
|
||||
lstrcpy(tch, lpName);
|
||||
lstrcat(tch, L"=");
|
||||
ich = lstrlen(tch);
|
||||
|
||||
while (*p) {
|
||||
if (StrCmpNI(p, tch, ich) == 0) {
|
||||
if (swscanf_s(p + ich, L"%u", &u) == 1)
|
||||
return(u);
|
||||
else
|
||||
return(uDefault);
|
||||
}
|
||||
else
|
||||
p = StrEnd(p) + 1;
|
||||
}
|
||||
}
|
||||
return(uDefault);
|
||||
}
|
||||
|
||||
BOOL IniSectionSetString(LPWSTR lpCachedIniSection,LPCWSTR lpName,LPCWSTR lpString)
|
||||
{
|
||||
WCHAR tch[32+512*3+32];
|
||||
|
||||
@ -41,6 +41,7 @@ __inline BOOL IniSetInt(LPCWSTR lpSection,LPCWSTR lpName,int i) {
|
||||
WritePrivateProfileSection(lpSection,lpBuf,szIniFile)
|
||||
int IniSectionGetString(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,int);
|
||||
int IniSectionGetInt(LPCWSTR,LPCWSTR,int);
|
||||
UINT IniSectionGetUInt(LPCWSTR,LPCWSTR,UINT);
|
||||
BOOL IniSectionSetString(LPWSTR,LPCWSTR,LPCWSTR);
|
||||
__inline BOOL IniSectionSetInt(LPWSTR lpCachedIniSection,LPCWSTR lpName,int i) {
|
||||
WCHAR tch[32]; wsprintf(tch,L"%i",i); return IniSectionSetString(lpCachedIniSection,lpName,tch);
|
||||
|
||||
156
src/Notepad3.c
156
src/Notepad3.c
@ -170,6 +170,23 @@ BOOL bTransparentMode;
|
||||
BOOL bTransparentModeAvailable;
|
||||
BOOL bShowToolbar;
|
||||
BOOL bShowStatusbar;
|
||||
int iSciDirectWriteTech;
|
||||
int iSciFontQuality;
|
||||
|
||||
const int DirectWriteTechnology[] = {
|
||||
SC_TECHNOLOGY_DEFAULT
|
||||
, SC_TECHNOLOGY_DIRECTWRITE
|
||||
, SC_TECHNOLOGY_DIRECTWRITERETAIN
|
||||
, SC_TECHNOLOGY_DIRECTWRITEDC
|
||||
};
|
||||
|
||||
const int FontQuality[] = {
|
||||
SC_EFF_QUALITY_DEFAULT
|
||||
, SC_EFF_QUALITY_NON_ANTIALIASED
|
||||
, SC_EFF_QUALITY_ANTIALIASED
|
||||
, SC_EFF_QUALITY_LCD_OPTIMIZED
|
||||
};
|
||||
|
||||
|
||||
typedef struct _wi
|
||||
{
|
||||
@ -246,7 +263,22 @@ UINT msgTaskbarCreated = 0;
|
||||
|
||||
HMODULE hModUxTheme = NULL;
|
||||
|
||||
EDITFINDREPLACE efrData = { "", "", "", "", 0, 0, 0, 0, 0, 0, NULL };
|
||||
EDITFINDREPLACE efrData = {
|
||||
""
|
||||
,""
|
||||
,""
|
||||
,""
|
||||
,0
|
||||
,0
|
||||
,0
|
||||
,0
|
||||
,0
|
||||
,0
|
||||
,NULL
|
||||
#ifdef BOOKMARK_EDITION
|
||||
,0
|
||||
#endif
|
||||
};
|
||||
UINT cpLastFind = 0;
|
||||
BOOL bReplaceInitialized = FALSE;
|
||||
|
||||
@ -672,6 +704,13 @@ int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpCmdLine,int n
|
||||
|
||||
if (!(hwnd = InitInstance(hInstance,lpCmdLine,nCmdShow)))
|
||||
return FALSE;
|
||||
|
||||
if (IsVista()) {
|
||||
if (iSciDirectWriteTech >= 0)
|
||||
SciCall_SetTechnology(DirectWriteTechnology[iSciDirectWriteTech]);
|
||||
if (iSciFontQuality >= 0)
|
||||
SciCall_SetFontQuality(FontQuality[iSciFontQuality]);
|
||||
}
|
||||
|
||||
hAccMain = LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_MAINWND));
|
||||
hAccFindReplace = LoadAccelerators(hInstance,MAKEINTRESOURCE(IDR_ACCFINDREPLACE));
|
||||
@ -904,7 +943,7 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow)
|
||||
if (iSrcEncoding != -1) {
|
||||
iEncoding = iSrcEncoding;
|
||||
iOriginalEncoding = iSrcEncoding;
|
||||
SendMessage(hwndEdit,SCI_SETCODEPAGE,(iEncoding == CPI_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0);
|
||||
SendMessage(hwndEdit,SCI_SETCODEPAGE,Encoding_GetSciCodePage(iEncoding),0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1211,7 +1250,7 @@ LRESULT CALLBACK MainWndProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
|
||||
SetDlgItemInt(hwnd,IDC_REUSELOCK,GetTickCount(),FALSE);
|
||||
|
||||
if (pcds->dwData == DATA_NOTEPAD3_PARAMS) {
|
||||
LPnp3params params = LocalAlloc(LPTR,pcds->cbData);
|
||||
LPnp3params params = LocalAlloc(LPTR,pcds->cbData);
|
||||
CopyMemory(params,pcds->lpData,pcds->cbData);
|
||||
|
||||
if (params->flagLexerSpecified)
|
||||
@ -2082,7 +2121,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
i = IDM_ENCODING_UTF8SIGN;
|
||||
else if (mEncoding[iEncoding].uFlags & NCP_UTF8)
|
||||
i = IDM_ENCODING_UTF8;
|
||||
else if (mEncoding[iEncoding].uFlags & NCP_DEFAULT)
|
||||
else if (mEncoding[iEncoding].uFlags & NCP_ANSI)
|
||||
i = IDM_ENCODING_ANSI;
|
||||
else
|
||||
i = -1;
|
||||
@ -2104,8 +2143,11 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
i = (int)SendMessage(hwndEdit,SCI_GETSELECTIONEND,0,0) - (int)SendMessage(hwndEdit,SCI_GETSELECTIONSTART,0,0);
|
||||
i2 = (int)SendMessage(hwndEdit,SCI_CANPASTE,0,0);
|
||||
|
||||
EnableCmd(hmenu,IDM_EDIT_CUT,i /*&& !bReadOnly*/);
|
||||
EnableCmd(hmenu,IDM_EDIT_COPY,i /*&& !bReadOnly*/);
|
||||
//~EnableCmd(hmenu,IDM_EDIT_CUT,i /*&& !bReadOnly*/);
|
||||
//~EnableCmd(hmenu,IDM_EDIT_COPY,i /*&& !bReadOnly*/);
|
||||
EnableCmd(hmenu,IDM_EDIT_CUT,1 /*&& !bReadOnly*/); // allow Ctrl-X w/o selection
|
||||
EnableCmd(hmenu,IDM_EDIT_COPY,1 /*&& !bReadOnly*/); // allow Ctrl-C w/o selection
|
||||
|
||||
EnableCmd(hmenu,IDM_EDIT_COPYALL,SendMessage(hwndEdit,SCI_GETLENGTH,0,0) /*&& !bReadOnly*/);
|
||||
EnableCmd(hmenu,IDM_EDIT_COPYADD,i /*&& !bReadOnly*/);
|
||||
EnableCmd(hmenu,IDM_EDIT_PASTE,i2 /*&& !bReadOnly*/);
|
||||
@ -2169,7 +2211,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
|
||||
i = (int)SendMessage(hwndEdit,SCI_GETLEXER,0,0);
|
||||
EnableCmd(hmenu,IDM_EDIT_LINECOMMENT,
|
||||
!(i == SCLEX_NULL || i == SCLEX_CSS || i == SCLEX_DIFF || SCLEX_MARKDOWN));
|
||||
!(i == SCLEX_NULL || i == SCLEX_CSS || i == SCLEX_DIFF || i == SCLEX_MARKDOWN || i == SCLEX_JSON));
|
||||
EnableCmd(hmenu,IDM_EDIT_STREAMCOMMENT,
|
||||
!(i == SCLEX_NULL || i == SCLEX_VBSCRIPT || i == SCLEX_MAKEFILE || i == SCLEX_VB || i == SCLEX_ASM ||
|
||||
i == SCLEX_SQL || i == SCLEX_PERL || i == SCLEX_PYTHON || i == SCLEX_PROPERTIES ||i == SCLEX_CONF ||
|
||||
@ -2366,7 +2408,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
break;
|
||||
|
||||
|
||||
case IDM_FILE_READONLY:
|
||||
case IDM_FILE_READONLY:
|
||||
//bReadOnly = (bReadOnly) ? FALSE : TRUE;
|
||||
//SendMessage(hwndEdit,SCI_SETREADONLY,bReadOnly,0);
|
||||
//UpdateToolbar();
|
||||
@ -2732,7 +2774,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
case IDM_ENCODING_UNICODEREV: iNewEncoding = CPI_UNICODEBEBOM; break;
|
||||
case IDM_ENCODING_UTF8: iNewEncoding = CPI_UTF8; break;
|
||||
case IDM_ENCODING_UTF8SIGN: iNewEncoding = CPI_UTF8SIGN; break;
|
||||
case IDM_ENCODING_ANSI: iNewEncoding = CPI_DEFAULT; break;
|
||||
case IDM_ENCODING_ANSI: iNewEncoding = CPI_ANSI_DEFAULT; break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2745,8 +2787,8 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
iOriginalEncoding = iNewEncoding;
|
||||
}
|
||||
else {
|
||||
if (iEncoding == CPI_DEFAULT || iNewEncoding == CPI_DEFAULT)
|
||||
iOriginalEncoding = -1;
|
||||
if (Encoding_IsANSI(iEncoding) || Encoding_IsANSI(iNewEncoding))
|
||||
iOriginalEncoding = CPI_NONE;
|
||||
iEncoding = iNewEncoding;
|
||||
}
|
||||
|
||||
@ -2767,21 +2809,21 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
|
||||
WCHAR tchCurFile2[MAX_PATH];
|
||||
|
||||
int iNewEncoding = -1;
|
||||
if (iEncoding != CPI_DEFAULT)
|
||||
iNewEncoding = iEncoding;
|
||||
// file to ANSI is default loading behaviour, recoding does not make sense
|
||||
int iNewEncoding = Encoding_IsANSI(iEncoding) ? CPI_NONE : iEncoding;
|
||||
|
||||
if (iEncoding == CPI_UTF8SIGN)
|
||||
iNewEncoding = CPI_UTF8;
|
||||
if (iEncoding == CPI_UNICODEBOM)
|
||||
else if (iEncoding == CPI_UNICODEBOM)
|
||||
iNewEncoding = CPI_UNICODE;
|
||||
if (iEncoding == CPI_UNICODEBEBOM)
|
||||
else if (iEncoding == CPI_UNICODEBEBOM)
|
||||
iNewEncoding = CPI_UNICODEBE;
|
||||
|
||||
if ((bModified || iEncoding != iOriginalEncoding) && MsgBox(MBOKCANCEL,IDS_ASK_RECODE) != IDOK)
|
||||
return(0);
|
||||
|
||||
if (RecodeDlg(hwnd,&iNewEncoding)) {
|
||||
|
||||
if (RecodeDlg(hwnd,&iNewEncoding))
|
||||
{
|
||||
lstrcpy(tchCurFile2,szCurFile);
|
||||
iSrcEncoding = iNewEncoding;
|
||||
FileLoad(TRUE,FALSE,TRUE,FALSE,tchCurFile2);
|
||||
@ -2832,14 +2874,25 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
case IDM_EDIT_CUT:
|
||||
if (flagPasteBoard)
|
||||
bLastCopyFromMe = TRUE;
|
||||
SendMessage(hwndEdit,SCI_CUT,0,0);
|
||||
if ((int)SendMessage(hwndEdit, SCI_GETSELECTIONEND, 0, 0) != (int)SendMessage(hwndEdit, SCI_GETSELECTIONSTART, 0, 0)) {
|
||||
SendMessage(hwndEdit, SCI_CUT, 0, 0);
|
||||
}
|
||||
else {
|
||||
SendMessage(hwndEdit, SCI_LINECUT, 0, 0); // VisualStudio behaviour
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case IDM_EDIT_COPY:
|
||||
if (flagPasteBoard)
|
||||
bLastCopyFromMe = TRUE;
|
||||
SendMessage(hwndEdit,SCI_COPY,0,0);
|
||||
if ((int)SendMessage(hwndEdit, SCI_GETSELECTIONEND, 0, 0) != (int)SendMessage(hwndEdit, SCI_GETSELECTIONSTART, 0, 0))
|
||||
{
|
||||
SendMessage(hwndEdit, SCI_COPY, 0, 0);
|
||||
}
|
||||
else {
|
||||
SendMessage(hwndEdit, SCI_LINECOPY, 0, 0); // VisualStudio behaviour
|
||||
}
|
||||
UpdateToolbar();
|
||||
break;
|
||||
|
||||
@ -4385,9 +4438,9 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
GetFileKey(hwndEdit);
|
||||
break;
|
||||
|
||||
case IDM_HELP_CMD:
|
||||
DisplayCmdLineHelp();
|
||||
break;
|
||||
case IDM_HELP_CMD:
|
||||
DisplayCmdLineHelp();
|
||||
break;
|
||||
|
||||
case CMD_ESCAPE:
|
||||
//close the autocomplete box
|
||||
@ -4488,7 +4541,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
WCHAR tchCurFile2[MAX_PATH];
|
||||
if (lstrlen(szCurFile)) {
|
||||
iSrcEncoding = CPI_DEFAULT;
|
||||
iSrcEncoding = CPI_ANSI_DEFAULT;
|
||||
lstrcpy(tchCurFile2,szCurFile);
|
||||
FileLoad(FALSE,FALSE,TRUE,FALSE,tchCurFile2);
|
||||
}
|
||||
@ -4967,6 +5020,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CUT,1),0);
|
||||
else
|
||||
MessageBeep(0);
|
||||
//SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_CUTLINE,1),0);
|
||||
break;
|
||||
|
||||
|
||||
@ -4975,6 +5029,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_COPY,1),0);
|
||||
else
|
||||
SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_COPYALL,1),0);
|
||||
//SendMessage(hwnd,WM_COMMAND,MAKELONG(IDM_EDIT_COPYLINE,1),0);
|
||||
break;
|
||||
|
||||
|
||||
@ -5547,6 +5602,16 @@ void LoadSettings()
|
||||
efrData.bNoFindWrap = IniSectionGetInt(pIniSection,L"NoFindWrap",0);
|
||||
if (efrData.bNoFindWrap) efrData.bNoFindWrap = TRUE;
|
||||
|
||||
efrData.bTransformBS = IniSectionGetInt(pIniSection,L"FindTransformBS",0);
|
||||
if (efrData.bTransformBS) efrData.bTransformBS = TRUE;
|
||||
|
||||
#ifdef BOOKMARK_EDITION
|
||||
efrData.bWildcardSearch = IniSectionGetInt(pIniSection,L"WildcardSearch",0);
|
||||
if (efrData.bWildcardSearch) efrData.bWildcardSearch = TRUE;
|
||||
#endif
|
||||
|
||||
efrData.fuFlags = IniSectionGetUInt(pIniSection, L"efrData_fuFlags", 0);
|
||||
|
||||
if (!IniSectionGetString(pIniSection,L"OpenWithDir",L"",
|
||||
tchOpenWithDir,COUNTOF(tchOpenWithDir)))
|
||||
SHGetSpecialFolderPath(NULL,tchOpenWithDir,CSIDL_DESKTOPDIRECTORY,TRUE);
|
||||
@ -5644,14 +5709,20 @@ void LoadSettings()
|
||||
bViewEOLs = IniSectionGetInt(pIniSection,L"ViewEOLs",0);
|
||||
if (bViewEOLs) bViewEOLs = 1;
|
||||
|
||||
iDefaultEncoding = IniSectionGetInt(pIniSection,L"DefaultEncoding",0);
|
||||
iDefaultEncoding = Encoding_MapIniSetting(TRUE,iDefaultEncoding);
|
||||
if (!Encoding_IsValid(iDefaultEncoding)) iDefaultEncoding = CPI_UTF8;
|
||||
iDefaultEncoding = IniSectionGetInt(pIniSection,L"DefaultEncoding", CPI_ANSI_DEFAULT);
|
||||
// if DefaultEncoding is defined as CPI_NONE(-1) explicitly, set to system's current code-page
|
||||
iDefaultEncoding = (iDefaultEncoding == CPI_NONE) ?
|
||||
Encoding_MapIniSetting(TRUE, (int)GetACP()) :
|
||||
Encoding_MapIniSetting(TRUE, iDefaultEncoding);
|
||||
if (!Encoding_IsValid(iDefaultEncoding))
|
||||
iDefaultEncoding = CPI_ANSI_DEFAULT;
|
||||
// set flag for encoding default
|
||||
mEncoding[iDefaultEncoding].uFlags |= NCP_DEFAULT;
|
||||
|
||||
bSkipUnicodeDetection = IniSectionGetInt(pIniSection,L"SkipUnicodeDetection",0);
|
||||
bSkipUnicodeDetection = IniSectionGetInt(pIniSection, L"SkipUnicodeDetection", 0);
|
||||
if (bSkipUnicodeDetection) bSkipUnicodeDetection = 1;
|
||||
|
||||
bLoadASCIIasUTF8 = IniSectionGetInt(pIniSection,L"LoadASCIIasUTF8",0);
|
||||
bLoadASCIIasUTF8 = IniSectionGetInt(pIniSection, L"LoadASCIIasUTF8", 0);
|
||||
if (bLoadASCIIasUTF8) bLoadASCIIasUTF8 = 1;
|
||||
|
||||
bLoadNFOasOEM = IniSectionGetInt(pIniSection,L"LoadNFOasOEM",1);
|
||||
@ -5760,6 +5831,12 @@ void LoadSettings()
|
||||
xFindReplaceDlg = IniSectionGetInt(pIniSection,L"FindReplaceDlgPosX",0);
|
||||
yFindReplaceDlg = IniSectionGetInt(pIniSection,L"FindReplaceDlgPosY",0);
|
||||
|
||||
iSciDirectWriteTech = IniSectionGetInt(pIniSection,L"SciDirectWriteTech",-1);
|
||||
iSciDirectWriteTech = max(min(iSciDirectWriteTech,3),-1);
|
||||
|
||||
iSciFontQuality = IniSectionGetInt(pIniSection,L"SciFontQuality",-1);
|
||||
iSciFontQuality = max(min(iSciFontQuality,3),-1);
|
||||
|
||||
LoadIniSection(L"Settings2",pIniSection,cchIniSection);
|
||||
|
||||
bStickyWinPos = IniSectionGetInt(pIniSection,L"StickyWindowPosition",0);
|
||||
@ -5812,15 +5889,19 @@ void LoadSettings()
|
||||
|
||||
LocalFree(pIniSection);
|
||||
|
||||
iDefaultCodePage = 0; {
|
||||
int acp = GetACP();
|
||||
// define scintilla internal code page, don't use Encoding_GetSciCodePage(iDefaultEncoding) here
|
||||
iDefaultCodePage = (iDefaultEncoding == CPI_ANSI_DEFAULT) ? 0 : SC_CP_UTF8;
|
||||
{
|
||||
// check for Chinese, Japan, Korean DBCS code pages and switch accordingly
|
||||
int acp = (int)GetACP();
|
||||
if (acp == 932 || acp == 936 || acp == 949 || acp == 950 || acp == 1361)
|
||||
iDefaultCodePage = acp;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
CHARSETINFO ci;
|
||||
if (TranslateCharsetInfo((DWORD*)(UINT_PTR)iDefaultCodePage,&ci,TCI_SRCCODEPAGE))
|
||||
if (TranslateCharsetInfo((DWORD*)(UINT_PTR)iDefaultCodePage, &ci, TCI_SRCCODEPAGE))
|
||||
iDefaultCharSet = ci.ciCharset;
|
||||
else
|
||||
iDefaultCharSet = ANSI_CHARSET;
|
||||
@ -5863,6 +5944,9 @@ void SaveSettings(BOOL bSaveSettingsNow)
|
||||
IniSectionSetInt(pIniSection,L"CloseFind",efrData.bFindClose);
|
||||
IniSectionSetInt(pIniSection,L"CloseReplace",efrData.bReplaceClose);
|
||||
IniSectionSetInt(pIniSection,L"NoFindWrap",efrData.bNoFindWrap);
|
||||
IniSectionSetInt(pIniSection,L"FindTransformBS", efrData.bTransformBS);
|
||||
IniSectionSetInt(pIniSection,L"WildcardSearch", efrData.bWildcardSearch);
|
||||
IniSectionSetInt(pIniSection,L"efrData_fuFlags", efrData.fuFlags);
|
||||
PathRelativeToApp(tchOpenWithDir,wchTmp,COUNTOF(wchTmp),FALSE,TRUE,flagPortableMyDocs);
|
||||
IniSectionSetString(pIniSection,L"OpenWithDir",wchTmp);
|
||||
PathRelativeToApp(tchFavoritesDir,wchTmp,COUNTOF(wchTmp),FALSE,TRUE,flagPortableMyDocs);
|
||||
@ -5934,6 +6018,8 @@ void SaveSettings(BOOL bSaveSettingsNow)
|
||||
IniSectionSetInt(pIniSection,L"FavoritesDlgSizeY",cyFavoritesDlg);
|
||||
IniSectionSetInt(pIniSection,L"FindReplaceDlgPosX",xFindReplaceDlg);
|
||||
IniSectionSetInt(pIniSection,L"FindReplaceDlgPosY",yFindReplaceDlg);
|
||||
IniSectionSetInt(pIniSection, L"SciDrawTechnology",iSciDirectWriteTech);
|
||||
IniSectionSetInt(pIniSection, L"SciFontQuality",iSciFontQuality);
|
||||
|
||||
SaveIniSection(L"Settings",pIniSection);
|
||||
LocalFree(pIniSection);
|
||||
@ -6897,7 +6983,7 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp
|
||||
SendMessage(hwndEdit,SCI_SETEOLMODE,iLineEndings[iDefaultEOLMode],0);
|
||||
iEncoding = iDefaultEncoding;
|
||||
iOriginalEncoding = iDefaultEncoding;
|
||||
SendMessage(hwndEdit,SCI_SETCODEPAGE,(iDefaultEncoding == CPI_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0);
|
||||
SendMessage(hwndEdit,SCI_SETCODEPAGE,Encoding_GetSciCodePage(iDefaultEncoding),0);
|
||||
EditSetNewText(hwndEdit,"",0);
|
||||
SetWindowTitle(hwndMain,uidsAppTitle,fIsElevated,IDS_UNTITLED,szCurFile,
|
||||
iPathNameFormat,bModified || iEncoding != iOriginalEncoding,
|
||||
@ -6962,7 +7048,7 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp
|
||||
iEncoding = iDefaultEncoding;
|
||||
iOriginalEncoding = iDefaultEncoding;
|
||||
}
|
||||
SendMessage(hwndEdit,SCI_SETCODEPAGE,(iEncoding == CPI_DEFAULT) ? iDefaultCodePage : SC_CP_UTF8,0);
|
||||
SendMessage(hwndEdit,SCI_SETCODEPAGE,Encoding_GetSciCodePage(iEncoding),0);
|
||||
bReadOnly = FALSE;
|
||||
EditSetNewText(hwndEdit,"",0);
|
||||
}
|
||||
@ -7006,7 +7092,7 @@ BOOL FileLoad(BOOL bDontSave,BOOL bNew,BOOL bReload,BOOL bNoEncDetect,LPCWSTR lp
|
||||
if (SendMessage(hwndEdit,SCI_GETLENGTH,0,0) >= 4) {
|
||||
char tchLog[5] = "";
|
||||
SendMessage(hwndEdit,SCI_GETTEXT,5,(LPARAM)tchLog);
|
||||
if (lstrcmpiA(tchLog,".LOG") == 0) {
|
||||
if (lstrcmpA(tchLog,".LOG") == 0) {
|
||||
EditJumpTo(hwndEdit,-1,0);
|
||||
SendMessage(hwndEdit,SCI_BEGINUNDOACTION,0,0);
|
||||
SendMessage(hwndEdit,SCI_NEWLINE,0,0);
|
||||
|
||||
@ -507,7 +507,7 @@ BEGIN
|
||||
VK_F8, IDM_ENCODING_RECODE, VIRTKEY, NOINVERT
|
||||
VK_F8, IDM_EDIT_INSERT_ENCODING, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_F8, CMD_RELOADNOFILEVARS, VIRTKEY, ALT, NOINVERT
|
||||
VK_F8, CMD_RELOADASCIIASUTF8, VIRTKEY, SHIFT, NOINVERT
|
||||
VK_F8, IDM_ENCODING_UTF8, VIRTKEY, SHIFT, NOINVERT
|
||||
VK_F9, IDM_ENCODING_SELECT, VIRTKEY, NOINVERT
|
||||
VK_F9, IDM_EDIT_INSERT_FILENAME, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_F9, IDM_FILE_MANAGEFAV, VIRTKEY, ALT, NOINVERT
|
||||
@ -1421,8 +1421,8 @@ BEGIN
|
||||
IDS_FIND_WRAPRE "Reached the beginning of the document, restarting search at the end."
|
||||
IDS_NOTFOUND "The specified text was not found."
|
||||
IDS_REPLCOUNT "%i occurrences of the specified text have been replaced."
|
||||
IDS_ASK_ENCODING "Switching the file encoding from ANSI to non-ANSI (and vice versa) may replace unsupported text with default characters, and the undo history will be cleared. Continue?"
|
||||
IDS_ASK_ENCODING2 "You are about to change the encoding of an empty file from ANSI to non-ANSI. Note that this will clear the undo history, as it can't be synchronized with the new encoding. Continue?"
|
||||
IDS_ASK_ENCODING "Switching the file encoding from one encoding to another may replace unsupported text with default characters, and the undo history will be cleared. Continue?"
|
||||
IDS_ASK_ENCODING2 "You are about to change the encoding of an empty file. Note that this will clear the undo history, as it can't be synchronized with the new encoding. Continue?"
|
||||
IDS_ERR_ENCODINGNA "Code page conversion tables for the selected encoding are not available on your system."
|
||||
IDS_ERR_UNICODE "Error converting this Unicode file.\nData will be lost if the file is saved!"
|
||||
END
|
||||
|
||||
@ -148,3 +148,19 @@ DeclareSciCallV1(EnsureVisible, ENSUREVISIBLE, int, line);
|
||||
//
|
||||
//
|
||||
DeclareSciCallV2(SetProperty, SETPROPERTY, const char *, key, const char *, value);
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// SetTechnology
|
||||
//
|
||||
//
|
||||
DeclareSciCallV1(SetTechnology, SETTECHNOLOGY, int, technology);
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// SetFontQuality
|
||||
//
|
||||
//
|
||||
DeclareSciCallV1(SetFontQuality, SETFONTQUALITY, int, quality);
|
||||
|
||||
@ -70,7 +70,6 @@ EDITLEXER lexDefault = { SCLEX_NULL, 63000, L"Default Text", L"txt; text; wtx;
|
||||
/* 23 */ { SCI_SETEXTRAASCENT+SCI_SETEXTRADESCENT, 63123, L"2nd Extra Line Spacing (Size)", L"", L"" },
|
||||
{ -1, 00000, L"", L"", L"" } } };
|
||||
|
||||
|
||||
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 "
|
||||
@ -2656,7 +2655,6 @@ int iDefaultLexer;
|
||||
BOOL bAutoSelect;
|
||||
int cxStyleSelectDlg;
|
||||
int cyStyleSelectDlg;
|
||||
extern int iDefaultCodePage;
|
||||
extern int iDefaultCharSet;
|
||||
extern BOOL bHiliteCurrentLine;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user