mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
some more LongPath handling
This commit is contained in:
parent
7389e774b7
commit
ed0a440d40
@ -1858,21 +1858,22 @@ static bool _SaveSettings(bool bForceSaveSettings)
|
||||
IniSectionDelete(IniSecSettings, L"efrData_fuFlags", false);
|
||||
}
|
||||
|
||||
WCHAR wchTmp[MAX_PATH] = { L'\0' };
|
||||
HPATHL hpth = Path_Allocate(NULL);
|
||||
if (StringCchCompareXI(Settings.OpenWithDir, Defaults.OpenWithDir) != 0) {
|
||||
StringCchCopy(wchTmp, COUNTOF(wchTmp), Settings.OpenWithDir);
|
||||
PathRelativeToApp(wchTmp, COUNTOF(wchTmp), false, true, Flags.PortableMyDocs);
|
||||
IniSectionSetString(IniSecSettings, L"OpenWithDir", wchTmp);
|
||||
Path_Reset(hpth, Settings.OpenWithDir);
|
||||
Path_RelativeToApp(hpth, false, true, Flags.PortableMyDocs);
|
||||
IniSectionSetString(IniSecSettings, L"OpenWithDir", Path_Get(hpth));
|
||||
} else {
|
||||
IniSectionDelete(IniSecSettings, L"OpenWithDir", false);
|
||||
}
|
||||
if (StringCchCompareXI(Settings.FavoritesDir, Defaults.FavoritesDir) != 0) {
|
||||
StringCchCopy(wchTmp, COUNTOF(wchTmp), Settings.FavoritesDir);
|
||||
PathRelativeToApp(wchTmp, COUNTOF(wchTmp), false, true, Flags.PortableMyDocs);
|
||||
IniSectionSetString(IniSecSettings, L"Favorites", wchTmp);
|
||||
Path_Reset(hpth, Settings.FavoritesDir);
|
||||
Path_RelativeToApp(hpth, false, true, Flags.PortableMyDocs);
|
||||
IniSectionSetString(IniSecSettings, L"Favorites", Path_Get(hpth));
|
||||
} else {
|
||||
IniSectionDelete(IniSecSettings, L"Favorites", false);
|
||||
}
|
||||
Path_Release(hpth);
|
||||
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, PathNameFormat);
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, WordWrap);
|
||||
@ -2340,56 +2341,58 @@ bool MRU_Add(LPMRULIST pmru, LPCWSTR pszNew, cpi_enc_t iEnc, DocPos iPos, DocPos
|
||||
bool MRU_FindFile(LPMRULIST pmru, LPCWSTR pszFile, int* iIndex)
|
||||
{
|
||||
*iIndex = 0;
|
||||
bool res = false;
|
||||
if (pmru) {
|
||||
WCHAR wchItem[MAX_PATH] = { L'\0' };
|
||||
int i = 0;
|
||||
HPATHL hpth = Path_Allocate(NULL);
|
||||
int i = 0;
|
||||
for (i = 0; i < pmru->iSize; ++i) {
|
||||
if (pmru->pszItems[i] == NULL) {
|
||||
*iIndex = i;
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
if (StringCchCompareXI(pmru->pszItems[i], pszFile) == 0) {
|
||||
*iIndex = i;
|
||||
return true;
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
StringCchCopy(wchItem, COUNTOF(wchItem), pmru->pszItems[i]);
|
||||
PathAbsoluteFromApp(wchItem, COUNTOF(wchItem), true);
|
||||
if (StringCchCompareXI(wchItem, pszFile) == 0) {
|
||||
*iIndex = i;
|
||||
return true;
|
||||
Path_Reset(hpth, pmru->pszItems[i]);
|
||||
Path_AbsoluteFromApp(hpth, true);
|
||||
if (StringCchCompareXI(Path_Get(hpth), pszFile) == 0) {
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*iIndex = i;
|
||||
Path_Release(hpth);
|
||||
}
|
||||
return false;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool MRU_FindPath(LPMRULIST pmru, const HPATHL hpth, int* iIndex)
|
||||
{
|
||||
*iIndex = 0;
|
||||
bool res = false;
|
||||
if (pmru) {
|
||||
WCHAR wchItem[MAX_PATH] = { L'\0' };
|
||||
int i = 0;
|
||||
HPATHL hcmp = Path_Allocate(NULL);
|
||||
int i = 0;
|
||||
for (i = 0; i < pmru->iSize; ++i) {
|
||||
if (pmru->pszItems[i] == NULL) {
|
||||
*iIndex = i;
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
if (StringCchCompareXI(pmru->pszItems[i], Path_Get(hpth)) == 0) {
|
||||
*iIndex = i;
|
||||
return true;
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
StringCchCopy(wchItem, COUNTOF(wchItem), pmru->pszItems[i]);
|
||||
PathAbsoluteFromApp(wchItem, COUNTOF(wchItem), true);
|
||||
if (StringCchCompareXI(wchItem, Path_Get(hpth)) == 0) {
|
||||
*iIndex = i;
|
||||
return true;
|
||||
Path_Reset(hcmp, pmru->pszItems[i]);
|
||||
Path_AbsoluteFromApp(hcmp, true);
|
||||
if (StringCchCompareXI(Path_Get(hcmp), Path_Get(hpth)) == 0) {
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*iIndex = i;
|
||||
Path_Release(hcmp);
|
||||
}
|
||||
return false;
|
||||
return res;
|
||||
}
|
||||
|
||||
bool MRU_AddFile(LPMRULIST pmru, LPCWSTR pszFile, bool bRelativePath, bool bUnexpandMyDocs,
|
||||
@ -2623,16 +2626,18 @@ bool MRU_MergeSave(LPMRULIST pmru, bool bAddFiles, bool bRelativePath, bool bUne
|
||||
MRU_Load(pmruBase, bAddFiles);
|
||||
|
||||
if (bAddFiles) {
|
||||
HPATHL hpth = Path_Allocate(NULL);
|
||||
for (int i = pmru->iSize - 1; i >= 0; i--) {
|
||||
if (pmru->pszItems[i]) {
|
||||
WCHAR wchItem[MAX_PATH] = { L'\0' };
|
||||
StringCchCopy(wchItem, COUNTOF(wchItem), pmru->pszItems[i]);
|
||||
PathAbsoluteFromApp(wchItem, COUNTOF(wchItem), true);
|
||||
MRU_AddFile(pmruBase, wchItem, bRelativePath, bUnexpandMyDocs,
|
||||
Path_Reset(hpth, pmru->pszItems[i]);
|
||||
Path_AbsoluteFromApp(hpth, true);
|
||||
MRU_AddFile(pmruBase, Path_Get(hpth), bRelativePath, bUnexpandMyDocs,
|
||||
pmru->iEncoding[i], pmru->iCaretPos[i], pmru->iSelAnchPos[i], pmru->pszBookMarks[i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Path_Release(hpth);
|
||||
}
|
||||
else {
|
||||
for (int i = pmru->iSize - 1; i >= 0; i--) {
|
||||
if (pmru->pszItems[i])
|
||||
MRU_Add(pmruBase, pmru->pszItems[i],
|
||||
|
||||
@ -280,10 +280,6 @@ enum class SI_Error : int {
|
||||
#define SI_UTF16LE_SIGNATURE "\xFF\xFE"
|
||||
#define SI_UTF16BE_SIGNATURE "\xFE\xFF"
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 260
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# define SI_NEWLINE_A "\r\n"
|
||||
# define SI_NEWLINE_W L"\r\n"
|
||||
|
||||
@ -5106,9 +5106,11 @@ void ComboBox_SetTextMB2W(HWND hDlg, int nIDDlgItem, LPCSTR lpString)
|
||||
#if 0
|
||||
void ComboBox_AddStringMB2W(HWND hDlg, int nIDDlgItem, LPCSTR lpString)
|
||||
{
|
||||
WCHAR wsz[FNDRPL_BUFFER] = { L'\0' };
|
||||
MultiByteToWideChar(Encoding_SciCP, 0, lpString, -1, wsz, (int)COUNTOF(wsz));
|
||||
ComboBox_AddString(GetDlgItem(hDlg, nIDDlgItem), wsz);
|
||||
int const len = MultiByteToWideChar(CP_UTF8, 0, lpString, -1, NULL, 0) + 1;
|
||||
wchar_t* const buf = AllocMem(len * sizeof(wchar_t), HEAP_ZERO_MEMORY);
|
||||
MultiByteToWideChar(CP_UTF8, 0, lpString, -1, buf, len);
|
||||
ComboBox_AddString(GetDlgItem(hDlg, nIDDlgItem), buf);
|
||||
FreeMem(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
85
src/Edit.c
85
src/Edit.c
@ -1849,23 +1849,25 @@ void EditURLEncode(const bool isPathConvert)
|
||||
return;
|
||||
}
|
||||
|
||||
LPWSTR const pszEscapedW = (LPWSTR)AllocMem(max_s(cchEscaped, MAX_PATH) * sizeof(WCHAR), HEAP_ZERO_MEMORY);
|
||||
size_t const lenEsc = min_s(cchEscaped, INTERNET_MAX_URL_LENGTH) + 4;
|
||||
LPWSTR const pszEscapedW = (LPWSTR)AllocMem(lenEsc * sizeof(WCHAR), HEAP_ZERO_MEMORY);
|
||||
|
||||
if (pszEscapedW == NULL) {
|
||||
FreeMem(pszEscaped);
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD cchEscapedW = (DWORD)cchEscaped;
|
||||
DWORD cchEscapedW = (DWORD)lenEsc;
|
||||
if (isPathConvert) {
|
||||
if (FAILED(PathCreateFromUrl(szTextW, pszEscapedW, &cchEscapedW, 0))) {
|
||||
StringCchCopy(pszEscapedW, cchEscapedW, szTextW); // no op
|
||||
cchEscapedW = (DWORD)StringCchLen(pszEscapedW, INTERNET_MAX_URL_LENGTH);
|
||||
StringCchCopy(pszEscapedW, lenEsc, szTextW); // no op
|
||||
cchEscapedW = (DWORD)StringCchLen(pszEscapedW, lenEsc - 1);
|
||||
}
|
||||
if (StrStr(pszEscapedW, L" ") != NULL) {
|
||||
// quote paths with spaces in
|
||||
StringCchCopy(szTextW, INTERNET_MAX_URL_LENGTH, pszEscapedW);
|
||||
StringCchPrintf(pszEscapedW, INTERNET_MAX_URL_LENGTH, L"\"%s\"", szTextW);
|
||||
cchEscapedW = (DWORD)StringCchLen(pszEscapedW, INTERNET_MAX_URL_LENGTH);
|
||||
StringCchCopy(szTextW, COUNTOF(szTextW), pszEscapedW);
|
||||
StringCchPrintf(pszEscapedW, lenEsc, L"\"%s\"", szTextW);
|
||||
cchEscapedW = (DWORD)StringCchLen(pszEscapedW, lenEsc - 1);
|
||||
}
|
||||
} else {
|
||||
UrlEscapeEx(szTextW, pszEscapedW, &cchEscapedW, true);
|
||||
@ -5719,7 +5721,7 @@ static void _EscapeWildcards(wchar_t* wchFind, size_t cch, LPEDITFINDREPLACE lp
|
||||
//
|
||||
// _EditGetFindStrg()
|
||||
//
|
||||
static size_t _EditGetFindStrg(HWND hwnd, LPEDITFINDREPLACE lpefr, LPSTR szFind, size_t cchCnt)
|
||||
static char* _EditGetFindStrg(HWND hwnd, LPEDITFINDREPLACE lpefr)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hwnd);
|
||||
|
||||
@ -5737,14 +5739,14 @@ static size_t _EditGetFindStrg(HWND hwnd, LPEDITFINDREPLACE lpefr, LPSTR szFind,
|
||||
}
|
||||
if (StrgIsEmpty(hfind)) {
|
||||
// get most recently used find pattern
|
||||
wchar_t* const buf = StrgWriteAccessBuf(hfind, cchCnt + 1);
|
||||
MRU_Enum(Globals.pMRUfind, 0, buf, (int)cchCnt);
|
||||
wchar_t* const buf = StrgWriteAccessBuf(hfind, 0);
|
||||
MRU_Enum(Globals.pMRUfind, 0, buf, (int)StrgGetAllocLength(hfind));
|
||||
StrgSanitize(hfind);
|
||||
}
|
||||
if (StrgIsEmpty(hfind)) {
|
||||
// get clipboard content
|
||||
wchar_t* const buf = StrgWriteAccessBuf(hfind, cchCnt + 1);
|
||||
EditGetClipboardW(buf, cchCnt);
|
||||
wchar_t* const buf = StrgWriteAccessBuf(hfind, 0);
|
||||
EditGetClipboardW(buf, StrgGetAllocLength(hfind));
|
||||
StrgSanitize(hfind);
|
||||
}
|
||||
|
||||
@ -5757,20 +5759,23 @@ static size_t _EditGetFindStrg(HWND hwnd, LPEDITFINDREPLACE lpefr, LPSTR szFind,
|
||||
StrgReset(lpefr->chFindPattern, StrgGet(hfind));
|
||||
|
||||
if (lpefr->bWildcardSearch) {
|
||||
wchar_t* const buf = StrgWriteAccessBuf(hfind, cchCnt + 1);
|
||||
_EscapeWildcards(buf, cchCnt, lpefr);
|
||||
wchar_t* const buf = StrgWriteAccessBuf(hfind, 0);
|
||||
_EscapeWildcards(buf, StrgGetAllocLength(hfind), lpefr);
|
||||
StrgSanitize(hfind);
|
||||
}
|
||||
|
||||
StrgGetAsUTF8(hfind, szFind, (int)cchCnt);
|
||||
int const len = StrgLengthAsUTF8(hfind) << 1;
|
||||
char* const chFind = AllocMem(len * sizeof(char), HEAP_ZERO_MEMORY);
|
||||
|
||||
StrgGetAsUTF8(hfind, chFind, len);
|
||||
StrgDestroy(hfind);
|
||||
|
||||
bool const bIsRegEx = (lpefr->fuFlags & SCFIND_REGEXP);
|
||||
if (lpefr->bTransformBS || bIsRegEx) {
|
||||
TransformBackslashes(szFind, bIsRegEx, Encoding_SciCP, NULL);
|
||||
TransformBackslashes(chFind, bIsRegEx, CP_UTF8, NULL);
|
||||
}
|
||||
|
||||
return strlen(szFind);
|
||||
return chFind; // transfer ownership
|
||||
}
|
||||
|
||||
|
||||
@ -5843,9 +5848,10 @@ typedef enum { MATCH = 0, NO_MATCH = 1, INVALID = 2 } RegExResult_t;
|
||||
|
||||
static RegExResult_t _FindHasMatch(HWND hwnd, LPEDITFINDREPLACE lpefr, DocPos iStartPos, bool bMarkAll)
|
||||
{
|
||||
char szFind[FNDRPL_BUFFER] = { '\0' };
|
||||
DocPos const slen = _EditGetFindStrg(hwnd, lpefr, szFind, COUNTOF(szFind));
|
||||
char* const szFind = _EditGetFindStrg(hwnd, lpefr);
|
||||
DocPos const slen = strlen(szFind);
|
||||
if (slen == 0) {
|
||||
FreeMem(szFind);
|
||||
return NO_MATCH;
|
||||
}
|
||||
int const sFlags = (int)(lpefr->fuFlags);
|
||||
@ -5870,6 +5876,7 @@ static RegExResult_t _FindHasMatch(HWND hwnd, LPEDITFINDREPLACE lpefr, DocPos iS
|
||||
}
|
||||
}
|
||||
}
|
||||
FreeMem(szFind);
|
||||
return ((iPos >= 0) ? MATCH : ((iPos == (DocPos)(-1)) ? NO_MATCH : INVALID));
|
||||
}
|
||||
|
||||
@ -5899,7 +5906,7 @@ static bool s_SaveMarkMatchVisible = false;
|
||||
// EditBoxForPasteFixes()
|
||||
//
|
||||
static LRESULT CALLBACK EditBoxForPasteFixes(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
|
||||
UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
|
||||
UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
|
||||
{
|
||||
WCHAR* const s_wchBuffer = (WCHAR*)dwRefData;
|
||||
|
||||
@ -6440,20 +6447,17 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
|
||||
}
|
||||
|
||||
if (Globals.bFindReplCopySelOrClip) {
|
||||
char *lpszSelection = NULL;
|
||||
char* lpszSelection = NULL;
|
||||
DocPos const cchSelection = SciCall_GetSelText(NULL);
|
||||
if ((cchSelection > 1) && (LOWORD(wParam) != IDC_REPLACETEXT)) {
|
||||
lpszSelection = AllocMem(cchSelection + 1, HEAP_ZERO_MEMORY);
|
||||
SciCall_GetSelText(lpszSelection);
|
||||
} else { // (cchSelection <= 1)
|
||||
// nothing is selected in the editor:
|
||||
lpszSelection = AllocMem(FNDRPL_BUFFER, HEAP_ZERO_MEMORY);
|
||||
if (lpszSelection) {
|
||||
// if first time you bring up find/replace dialog,
|
||||
// use most recent search pattern to find box
|
||||
// in case of no history: paste clipboard
|
||||
_EditGetFindStrg(Globals.hwndEdit, s_pEfrData, lpszSelection, SizeOfMem(lpszSelection));
|
||||
}
|
||||
lpszSelection = _EditGetFindStrg(Globals.hwndEdit, s_pEfrData);
|
||||
// if first time you bring up find/replace dialog,
|
||||
// use most recent search pattern to find box
|
||||
// in case of no history: paste clipboard
|
||||
}
|
||||
if (lpszSelection) {
|
||||
ComboBox_SetTextMB2W(hwnd, IDC_FINDTEXT, lpszSelection);
|
||||
@ -6952,9 +6956,10 @@ bool EditFindNext(HWND hwnd, LPEDITFINDREPLACE lpefr, bool bExtendSelection, boo
|
||||
SetFocus(hwnd);
|
||||
}
|
||||
|
||||
char szFind[FNDRPL_BUFFER];
|
||||
DocPos const slen = _EditGetFindStrg(hwnd, lpefr, szFind, COUNTOF(szFind));
|
||||
char* const szFind = _EditGetFindStrg(hwnd, lpefr);
|
||||
DocPos const slen = strlen(szFind);
|
||||
if (slen <= 0LL) {
|
||||
FreeMem(szFind);
|
||||
return false;
|
||||
}
|
||||
int const sFlags = (int)(lpefr->fuFlags);
|
||||
@ -6998,6 +7003,7 @@ bool EditFindNext(HWND hwnd, LPEDITFINDREPLACE lpefr, bool bExtendSelection, boo
|
||||
}
|
||||
}
|
||||
}
|
||||
FreeMem(szFind);
|
||||
|
||||
if (iPos < 0LL) {
|
||||
if (!bSuppressNotFound) {
|
||||
@ -7037,9 +7043,10 @@ bool EditFindPrev(HWND hwnd, LPEDITFINDREPLACE lpefr, bool bExtendSelection, boo
|
||||
if (bFocusWnd) {
|
||||
SetFocus(hwnd);
|
||||
}
|
||||
char szFind[FNDRPL_BUFFER];
|
||||
DocPos const slen = _EditGetFindStrg(hwnd, lpefr, szFind, COUNTOF(szFind));
|
||||
char* const szFind = _EditGetFindStrg(hwnd, lpefr);
|
||||
DocPos const slen = strlen(szFind);
|
||||
if (slen <= 0LL) {
|
||||
FreeMem(szFind);
|
||||
return false;
|
||||
}
|
||||
int const sFlags = (int)(lpefr->fuFlags);
|
||||
@ -7083,6 +7090,7 @@ bool EditFindPrev(HWND hwnd, LPEDITFINDREPLACE lpefr, bool bExtendSelection, boo
|
||||
}
|
||||
}
|
||||
}
|
||||
FreeMem(szFind);
|
||||
|
||||
if (iPos < 0LL) {
|
||||
if (!bSuppressNotFound) {
|
||||
@ -7241,10 +7249,11 @@ bool EditReplace(HWND hwnd, LPEDITFINDREPLACE lpefr)
|
||||
DocPos _start = start;
|
||||
Globals.iReplacedOccurrences = 0;
|
||||
|
||||
char szFind[FNDRPL_BUFFER];
|
||||
DocPos const slen = _EditGetFindStrg(hwnd, lpefr, szFind, COUNTOF(szFind));
|
||||
char* const szFind = _EditGetFindStrg(hwnd, lpefr);
|
||||
DocPos const slen = strlen(szFind);
|
||||
int const sFlags = (int)(lpefr->fuFlags);
|
||||
DocPos const iPos = _FindInTarget(szFind, slen, sFlags, &start, &end, false, FRMOD_NORM);
|
||||
FreeMem(szFind);
|
||||
|
||||
// w/o selection, replacement string is put into current position
|
||||
// but this maybe not intended here
|
||||
@ -7295,9 +7304,10 @@ int EditReplaceAllInRange(HWND hwnd, LPEDITFINDREPLACE lpefr, DocPos iStartPos,
|
||||
}
|
||||
DocPos const iOrigEndPos = iEndPos; // remember
|
||||
|
||||
char szFind[FNDRPL_BUFFER];
|
||||
size_t const slen = _EditGetFindStrg(hwnd, lpefr, szFind, COUNTOF(szFind));
|
||||
char* const szFind = _EditGetFindStrg(hwnd, lpefr);
|
||||
size_t const slen = strlen(szFind);
|
||||
if (slen <= 0) {
|
||||
FreeMem(szFind);
|
||||
return FALSE;
|
||||
}
|
||||
int const sFlags = (int)(lpefr->fuFlags);
|
||||
@ -7308,6 +7318,7 @@ int EditReplaceAllInRange(HWND hwnd, LPEDITFINDREPLACE lpefr, DocPos iStartPos,
|
||||
int iReplaceMsg = SCI_REPLACETARGET;
|
||||
char *pszReplace = _GetReplaceString(hwnd, lpefr, &iReplaceMsg);
|
||||
if (!pszReplace) {
|
||||
FreeMem(szFind);
|
||||
return -1; // recoding of clipboard canceled
|
||||
}
|
||||
|
||||
@ -7320,6 +7331,7 @@ int EditReplaceAllInRange(HWND hwnd, LPEDITFINDREPLACE lpefr, DocPos iStartPos,
|
||||
|
||||
if ((iPos < -1LL) && bIsRegExpr) {
|
||||
InfoBoxLng(MB_ICONWARNING, L"MsgInvalidRegex", IDS_MUI_REGEX_INVALID);
|
||||
FreeMem(szFind);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -7344,6 +7356,7 @@ int EditReplaceAllInRange(HWND hwnd, LPEDITFINDREPLACE lpefr, DocPos iStartPos,
|
||||
|
||||
*enlargement = (iEndPos - iOrigEndPos);
|
||||
SciCall_SetTargetRange(_saveTargetBeg_, _saveTargetEnd_ + *enlargement); //restore
|
||||
FreeMem(szFind);
|
||||
return iCount;
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ extern "C" void Style_SetMultiEdgeLine(const int colVec[], const size_t count);
|
||||
|
||||
//=============================================================================
|
||||
|
||||
static WCHAR wchEncodingInfo[MAX_PATH] = { L'\0' };
|
||||
static WCHAR wchEncodingInfo[MIDSZ_BUFFER] = { L'\0' };
|
||||
|
||||
static void _SetEncodingTitleInfo(const ENC_DET_T* pEncDetInfo);
|
||||
|
||||
@ -65,7 +65,7 @@ extern "C" const WCHAR* Encoding_GetTitleInfo()
|
||||
|
||||
extern "C" const char* Encoding_GetTitleInfoA()
|
||||
{
|
||||
static char chEncodingInfo[MAX_PATH] = { '\0' };
|
||||
static char chEncodingInfo[MIDSZ_BUFFER] = { '\0' };
|
||||
::WideCharToMultiByte(CP_ACP, 0, wchEncodingInfo, -1, chEncodingInfo, (int)COUNTOF(chEncodingInfo), NULL, NULL);
|
||||
return chEncodingInfo;
|
||||
}
|
||||
|
||||
@ -1557,47 +1557,47 @@ void TransformBackslashes(char* pszInput, bool bRegEx, UINT cpEdit, int* iReplac
|
||||
}
|
||||
|
||||
|
||||
void TransformMetaChars(char* pszInput, bool bRegEx, int iEOLMode)
|
||||
#if 0
|
||||
void TransformMetaChars(char* pszInput, size_t cch, bool bRegEx, int iEOLMode)
|
||||
{
|
||||
if (!bRegEx) {
|
||||
return;
|
||||
}
|
||||
|
||||
char buffer[FNDRPL_BUFFER + 1] = { '\0' };
|
||||
char* s = pszInput;
|
||||
char* o = buffer;
|
||||
while (*s) {
|
||||
if ((s[0] != '\\') && (s[1] == '$')) {
|
||||
*o = *s;
|
||||
++o;
|
||||
++s;
|
||||
switch (iEOLMode) {
|
||||
case SC_EOL_LF:
|
||||
*o = '\n';
|
||||
break;
|
||||
case SC_EOL_CR:
|
||||
*o = '\r';
|
||||
break;
|
||||
case SC_EOL_CRLF:
|
||||
default:
|
||||
*o = '\r';
|
||||
++o;
|
||||
*o = '\n';
|
||||
break;
|
||||
char* buffer = AllocMem((cch << 1) * sizeof(char), HEAP_ZERO_MEMORY);
|
||||
if (buffer) {
|
||||
char* s = pszInput;
|
||||
char* o = buffer;
|
||||
while (*s) {
|
||||
if ((s[0] != '\\') && (s[1] == '$')) {
|
||||
*o++ = *s++;
|
||||
switch (iEOLMode) {
|
||||
case SC_EOL_LF:
|
||||
*o++ = '\n';
|
||||
break;
|
||||
case SC_EOL_CR:
|
||||
*o++ = '\r';
|
||||
break;
|
||||
case SC_EOL_CRLF:
|
||||
default:
|
||||
*o++ = '\r';
|
||||
*o++ = '\n';
|
||||
break;
|
||||
}
|
||||
++s; // skip $
|
||||
}
|
||||
else {
|
||||
*o++ = *s;
|
||||
}
|
||||
if (*s) {
|
||||
++s;
|
||||
}
|
||||
++s; // skip $
|
||||
} else {
|
||||
*o = *s;
|
||||
}
|
||||
++o;
|
||||
if (*s) {
|
||||
++s;
|
||||
}
|
||||
*o = '\0';
|
||||
StringCchCopyA(pszInput, cch, buffer);
|
||||
FreeMem(buffer);
|
||||
}
|
||||
*o = '\0';
|
||||
StringCchCopyA(pszInput, FNDRPL_BUFFER, buffer);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
|
||||
@ -473,7 +473,7 @@ size_t SlashCtrlW(LPWSTR pchOutput, size_t cchOutLen, LPCWSTR pchInput);
|
||||
size_t UnSlashCtrlW(LPWSTR pchInOut);
|
||||
|
||||
void TransformBackslashes(char *pszInput, bool bRegEx, UINT cpEdit, int *iReplaceMsg);
|
||||
void TransformMetaChars(char *pszInput, bool bRegEx, int iEOLMode);
|
||||
//void TransformMetaChars(char *pszInput, size_t cch, bool bRegEx, int iEOLMode);
|
||||
|
||||
|
||||
//==== Large Text Conversion ==================================================
|
||||
@ -487,7 +487,7 @@ ptrdiff_t WideCharToMultiByteEx(
|
||||
LPSTR lpMultiByteStr, ptrdiff_t cbMultiByte, LPCCH lpDefaultChar, LPBOOL lpUsedDefaultChar);
|
||||
#else
|
||||
|
||||
__inline ptrdiff_t WideCharToMultiByteEx(
|
||||
__forceinline ptrdiff_t WideCharToMultiByteEx(
|
||||
UINT CodePage, DWORD dwFlags, LPCWCH lpWideCharStr, ptrdiff_t cchWideChar,
|
||||
LPSTR lpMultiByteStr, ptrdiff_t cbMultiByte, LPCCH lpDefaultChar, LPBOOL lpUsedDefaultChar)
|
||||
{
|
||||
@ -504,7 +504,7 @@ ptrdiff_t MultiByteToWideCharEx(
|
||||
LPWSTR lpWideCharStr, ptrdiff_t cchWideChar);
|
||||
#else
|
||||
|
||||
__inline ptrdiff_t MultiByteToWideCharEx(
|
||||
__forceinline ptrdiff_t MultiByteToWideCharEx(
|
||||
UINT CodePage, DWORD dwFlags, LPCCH lpMultiByteStr, ptrdiff_t cbMultiByte,
|
||||
LPWSTR lpWideCharStr, ptrdiff_t cchWideChar)
|
||||
{
|
||||
|
||||
@ -268,10 +268,9 @@ unsigned GetMUILanguageIndexByLocaleName(LPCWSTR pLocaleName) {
|
||||
//
|
||||
static unsigned _CheckAvailableLanguageDLLs()
|
||||
{
|
||||
WCHAR wchAbsPath[MAX_PATH] = { L'\0' };
|
||||
|
||||
unsigned count = 1; // internal instance always available
|
||||
|
||||
HPATHL hpth = Path_Allocate(NULL);
|
||||
|
||||
for (unsigned lng = 1; lng < MuiLanguages_CountOf(); ++lng) {
|
||||
|
||||
@ -285,13 +284,16 @@ static unsigned _CheckAvailableLanguageDLLs()
|
||||
}
|
||||
#endif
|
||||
// check for DLL
|
||||
StringCchPrintf(wchAbsPath, COUNTOF(wchAbsPath), L"lng/%s/np3lng.dll.mui", MUI_LanguageDLLs[lng].LocaleName);
|
||||
PathAbsoluteFromApp(wchAbsPath, COUNTOF(wchAbsPath), false);
|
||||
bool const bAvail = PathIsExistingFile(wchAbsPath);
|
||||
WCHAR wchRelPath[SMALL_BUFFER] = { L'\0' };
|
||||
StringCchPrintf(wchRelPath, COUNTOF(wchRelPath), L"lng/%s/np3lng.dll.mui", MUI_LanguageDLLs[lng].LocaleName);
|
||||
Path_Reset(hpth, wchRelPath);
|
||||
Path_AbsoluteFromApp(hpth, false);
|
||||
bool const bAvail = Path_IsExistingFile(hpth);
|
||||
MUI_LanguageDLLs[lng].bHasDLL = bAvail;
|
||||
count += bAvail ? 1 : 0;
|
||||
}
|
||||
}
|
||||
Path_Release(hpth);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
@ -7508,49 +7508,48 @@ static void _HandleAutoIndent(int const charAdded)
|
||||
//
|
||||
static void _HandleAutoCloseTags()
|
||||
{
|
||||
///int lexerID = SciCall_GetLexer();
|
||||
///int const lexerID = SciCall_GetLexer();
|
||||
///if (lexerID == SCLEX_HTML || lexerID == SCLEX_XML)
|
||||
DocPos const maxSearchBackward = 4096;
|
||||
{
|
||||
DocPos const iCurPos = SciCall_GetCurrentPos();
|
||||
DocPos const iHelper = iCurPos - maxSearchBackward;
|
||||
DocPos const iStartPos = max_p(0, iHelper);
|
||||
DocPos const iSize = iCurPos - iStartPos;
|
||||
DocPos const maxSearchBackward = 8192;
|
||||
DocPos const iCurPos = SciCall_GetCurrentPos();
|
||||
DocPos const iHelper = iCurPos - maxSearchBackward;
|
||||
DocPos const iStartPos = max_p(0, iHelper);
|
||||
DocPos const iSize = iCurPos - iStartPos;
|
||||
|
||||
if (iSize >= 3) {
|
||||
const char* pBegin = SciCall_GetRangePointer(iStartPos, iSize);
|
||||
if (iSize >= 3) {
|
||||
|
||||
if (pBegin[iSize - 2] != '/') {
|
||||
const char* pCur = &pBegin[iSize - 2];
|
||||
while (pCur > pBegin && *pCur != '<' && *pCur != '>') {
|
||||
--pCur;
|
||||
const char* const pBegin = SciCall_GetRangePointer(iStartPos, iSize);
|
||||
|
||||
if (pBegin[iSize - 2] != '/') {
|
||||
const char* pCur = &pBegin[iSize - 2];
|
||||
while (pCur > pBegin && *pCur != '<' && *pCur != '>') {
|
||||
--pCur;
|
||||
}
|
||||
|
||||
int cchIns = 2;
|
||||
char replaceBuf[SMALL_BUFFER];
|
||||
StringCchCopyA(replaceBuf, COUNTOF(replaceBuf), "</");
|
||||
|
||||
if (*pCur == '<') {
|
||||
++pCur;
|
||||
while ((StrChrA(":_-.", *pCur) || IsCharAlphaNumericA(*pCur)) && (cchIns < (COUNTOF(replaceBuf) - 2))) {
|
||||
replaceBuf[cchIns++] = *pCur++;
|
||||
}
|
||||
}
|
||||
replaceBuf[cchIns++] = '>';
|
||||
replaceBuf[cchIns] = '\0';
|
||||
|
||||
int cchIns = 2;
|
||||
char replaceBuf[FNDRPL_BUFFER+2];
|
||||
StringCchCopyA(replaceBuf, FNDRPL_BUFFER, "</");
|
||||
if (*pCur == '<') {
|
||||
++pCur;
|
||||
while ((StrChrA(":_-.", *pCur) || IsCharAlphaNumericA(*pCur)) && (cchIns < (FNDRPL_BUFFER-2))) {
|
||||
replaceBuf[cchIns++] = *pCur;
|
||||
++pCur;
|
||||
}
|
||||
}
|
||||
replaceBuf[cchIns++] = '>';
|
||||
replaceBuf[cchIns] = '\0';
|
||||
// except tags w/o closing tags
|
||||
const char* const nonClosingTags[9] = { "</base>", "</bgsound>", "</br>", "</embed>", "</hr>", "</img>", "</input>", "</link>", "</meta>" };
|
||||
int const cntCount = COUNTOF(nonClosingTags);
|
||||
|
||||
// except tags w/o closing tags
|
||||
const char* const nonClosingTags[9] = { "</base>", "</bgsound>", "</br>", "</embed>", "</hr>", "</img>", "</input>", "</link>", "</meta>" };
|
||||
int const cntCount = COUNTOF(nonClosingTags);
|
||||
|
||||
bool isNonClosingTag = false;
|
||||
for (int i = 0; ((i < cntCount) && !isNonClosingTag); ++i) {
|
||||
isNonClosingTag = (StringCchCompareXIA(replaceBuf, nonClosingTags[i]) == 0);
|
||||
}
|
||||
if ((cchIns > 3) && !isNonClosingTag) {
|
||||
EditReplaceSelection(replaceBuf,false);
|
||||
SciCall_SetSel(iCurPos,iCurPos);
|
||||
}
|
||||
bool isNonClosingTag = false;
|
||||
for (int i = 0; ((i < cntCount) && !isNonClosingTag); ++i) {
|
||||
isNonClosingTag = (StringCchCompareXIA(replaceBuf, nonClosingTags[i]) == 0);
|
||||
}
|
||||
if ((cchIns > 3) && !isNonClosingTag) {
|
||||
EditReplaceSelection(replaceBuf, false);
|
||||
SciCall_SetSel(iCurPos, iCurPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,8 +241,8 @@ typedef struct _editfindreplace
|
||||
bool bHideNonMatchedLines;
|
||||
bool bStateChanged;
|
||||
HWND hwnd;
|
||||
HSTRINGW chFindPattern; //[FNDRPL_BUFFER];
|
||||
HSTRINGW chReplaceTemplate; //[FNDRPL_BUFFER];
|
||||
HSTRINGW chFindPattern;
|
||||
HSTRINGW chReplaceTemplate;
|
||||
|
||||
} EDITFINDREPLACE, *LPEDITFINDREPLACE;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user