mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-20 21:13:25 +08:00
commit
95b10e05d4
@ -573,31 +573,33 @@
|
||||
#define IDM_EDIT_LINECOMMENT 40355
|
||||
#define IDM_EDIT_STREAMCOMMENT 40356
|
||||
#define IDM_EDIT_URLENCODE 40357
|
||||
#define IDM_EDIT_URLDECODE 40358
|
||||
#define IDM_EDIT_ESCAPECCHARS 40359
|
||||
#define IDM_EDIT_UNESCAPECCHARS 40360
|
||||
#define IDM_EDIT_CHAR2HEX 40361
|
||||
#define IDM_EDIT_HEX2CHAR 40362
|
||||
#define IDM_EDIT_FINDMATCHINGBRACE 40363
|
||||
#define IDM_EDIT_SELTOMATCHINGBRACE 40364
|
||||
#define IDM_EDIT_FIND 40365
|
||||
#define IDM_EDIT_SAVEFIND 40366
|
||||
#define IDM_EDIT_FINDNEXT 40367
|
||||
#define IDM_EDIT_FINDPREV 40368
|
||||
#define IDM_EDIT_REPLACE 40369
|
||||
#define IDM_EDIT_REPLACENEXT 40370
|
||||
#define IDM_EDIT_GOTOLINE 40371
|
||||
#define IDM_EDIT_SELTONEXT 40372
|
||||
#define IDM_EDIT_SELTOPREV 40373
|
||||
#define IDM_EDIT_COMPLETEWORD 40374
|
||||
#define IDM_EDIT_JOINLN_NOSP 40375
|
||||
#define IDM_EDIT_REMOVEDUPLICATELINES 40376
|
||||
#define IDM_EDIT_REMOVEEMPTYLINES 40377
|
||||
#define IDM_EDIT_MERGEEMPTYLINES 40378
|
||||
#define IDM_EDIT_CLEAR_MARKER 40379
|
||||
#define IDM_EDIT_CUT_MARKED 40380
|
||||
#define IDM_EDIT_COPY_MARKED 40381
|
||||
#define IDM_EDIT_DELETE_MARKED 40382
|
||||
#define IDM_EDIT_URL2PATH 40358
|
||||
#define IDM_EDIT_URLDECODE 40359
|
||||
#define IDM_EDIT_PATH2URL 40360
|
||||
#define IDM_EDIT_ESCAPECCHARS 40361
|
||||
#define IDM_EDIT_UNESCAPECCHARS 40362
|
||||
#define IDM_EDIT_CHAR2HEX 40363
|
||||
#define IDM_EDIT_HEX2CHAR 40364
|
||||
#define IDM_EDIT_FINDMATCHINGBRACE 40365
|
||||
#define IDM_EDIT_SELTOMATCHINGBRACE 40366
|
||||
#define IDM_EDIT_FIND 40367
|
||||
#define IDM_EDIT_SAVEFIND 40368
|
||||
#define IDM_EDIT_FINDNEXT 40369
|
||||
#define IDM_EDIT_FINDPREV 40370
|
||||
#define IDM_EDIT_REPLACE 40371
|
||||
#define IDM_EDIT_REPLACENEXT 40372
|
||||
#define IDM_EDIT_GOTOLINE 40373
|
||||
#define IDM_EDIT_SELTONEXT 40374
|
||||
#define IDM_EDIT_SELTOPREV 40375
|
||||
#define IDM_EDIT_COMPLETEWORD 40376
|
||||
#define IDM_EDIT_JOINLN_NOSP 40377
|
||||
#define IDM_EDIT_REMOVEDUPLICATELINES 40378
|
||||
#define IDM_EDIT_REMOVEEMPTYLINES 40379
|
||||
#define IDM_EDIT_MERGEEMPTYLINES 40380
|
||||
#define IDM_EDIT_CLEAR_MARKER 40381
|
||||
#define IDM_EDIT_CUT_MARKED 40382
|
||||
#define IDM_EDIT_COPY_MARKED 40383
|
||||
#define IDM_EDIT_DELETE_MARKED 40384
|
||||
|
||||
#define IDM_VIEW_SCHEME 40400
|
||||
#define IDM_VIEW_USE2NDDEFAULT 40401
|
||||
|
||||
@ -256,11 +256,13 @@ BEGIN
|
||||
MENUITEM "Mittels Tabulatoren einrücken\tCtrl+Alt+T", IDM_EDIT_CONVERTSPACES2
|
||||
MENUITEM "Mittels Leerzeichen einrücken\tCtrl+Alt+S", IDM_EDIT_CONVERTTABS2
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&URL Codierung\tCtrl+Shift+E", IDM_EDIT_URLENCODE
|
||||
MENUITEM "URL Decodierung\tCtrl+Shift+R", IDM_EDIT_URLDECODE
|
||||
MENUITEM "&URL Codierung\tCtrl+Shift+E", IDM_EDIT_URLENCODE
|
||||
MENUITEM "URL Decodierung\tCtrl+Shift+R", IDM_EDIT_URLDECODE
|
||||
MENUITEM "Datei-System Pfad als URL", IDM_EDIT_PATH2URL
|
||||
MENUITEM "URL als Datei-System Pfad", IDM_EDIT_URL2PATH
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Zeichen zu Hex\tCtrl+Alt+X", IDM_EDIT_CHAR2HEX
|
||||
MENUITEM "&Hex zu Zeichen\tCtrl+Alt+C", IDM_EDIT_HEX2CHAR
|
||||
MENUITEM "&Zeichen zu Hex\tCtrl+Alt+X", IDM_EDIT_CHAR2HEX
|
||||
MENUITEM "&Hex zu Zeichen\tCtrl+Alt+C", IDM_EDIT_HEX2CHAR
|
||||
END
|
||||
POPUP "&Einfügen"
|
||||
BEGIN
|
||||
|
||||
@ -256,11 +256,13 @@ BEGIN
|
||||
MENUITEM "Ta&bify Indent\tCtrl+Alt+T", IDM_EDIT_CONVERTSPACES2
|
||||
MENUITEM "Untabi&fy Indent\tCtrl+Alt+S", IDM_EDIT_CONVERTTABS2
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "URL &Encode\tCtrl+Shift+E", IDM_EDIT_URLENCODE
|
||||
MENUITEM "URL &Decode\tCtrl+Shift+R", IDM_EDIT_URLDECODE
|
||||
MENUITEM "URL &Encode\tCtrl+Shift+E", IDM_EDIT_URLENCODE
|
||||
MENUITEM "URL &Decode\tCtrl+Shift+R", IDM_EDIT_URLDECODE
|
||||
MENUITEM "File System Path to URL", IDM_EDIT_PATH2URL
|
||||
MENUITEM "URL to File System Path", IDM_EDIT_URL2PATH
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Char To &Hex\tCtrl+Alt+X", IDM_EDIT_CHAR2HEX
|
||||
MENUITEM "Hex To &Char\tCtrl+Alt+C", IDM_EDIT_HEX2CHAR
|
||||
MENUITEM "Char To &Hex\tCtrl+Alt+X", IDM_EDIT_CHAR2HEX
|
||||
MENUITEM "Hex To &Char\tCtrl+Alt+C", IDM_EDIT_HEX2CHAR
|
||||
END
|
||||
POPUP "&Insert"
|
||||
BEGIN
|
||||
|
||||
57
src/Edit.c
57
src/Edit.c
@ -1703,7 +1703,7 @@ void EditSentenceCase(HWND hwnd)
|
||||
//
|
||||
// EditURLEncode()
|
||||
//
|
||||
void EditURLEncode()
|
||||
void EditURLEncode(const bool isPathConvert)
|
||||
{
|
||||
if (SciCall_IsSelectionEmpty()) {
|
||||
return;
|
||||
@ -1740,11 +1740,16 @@ void EditURLEncode()
|
||||
}
|
||||
|
||||
DWORD cchEscapedW = (DWORD)cchEscaped;
|
||||
if (isPathConvert) {
|
||||
if (FAILED(PathCreateFromUrl(szTextW, pszEscapedW, &cchEscapedW, 0))) {
|
||||
StringCchCopy(pszEscapedW, cchEscapedW, szTextW); // no op
|
||||
}
|
||||
} else {
|
||||
UrlEscapeEx(szTextW, pszEscapedW, &cchEscapedW, true);
|
||||
}
|
||||
|
||||
UrlEscapeEx(szTextW, pszEscapedW, &cchEscapedW, true);
|
||||
|
||||
ptrdiff_t const cchEscapedEnc = WideCharToMultiByte(Encoding_SciCP, 0, pszEscapedW, cchEscapedW,
|
||||
pszEscaped, (int)cchEscaped, NULL, NULL);
|
||||
int const cchEscapedEnc = WideCharToMultiByte(Encoding_SciCP, 0, pszEscapedW, cchEscapedW,
|
||||
pszEscaped, (int)cchEscaped, NULL, NULL);
|
||||
|
||||
_BEGIN_UNDO_ACTION_;
|
||||
|
||||
@ -1774,7 +1779,7 @@ void EditURLEncode()
|
||||
//
|
||||
// EditURLDecode()
|
||||
//
|
||||
void EditURLDecode()
|
||||
void EditURLDecode(const bool isPathConvert)
|
||||
{
|
||||
if (SciCall_IsSelectionEmpty()) {
|
||||
return;
|
||||
@ -1798,9 +1803,9 @@ void EditURLDecode()
|
||||
return;
|
||||
}
|
||||
|
||||
/*ptrdiff_t cchTextW =*/ MultiByteToWideCharEx(Encoding_SciCP, 0, pszText, (iSelSize-1), pszTextW, iSelSize);
|
||||
/*int cchTextW =*/ MultiByteToWideChar(Encoding_SciCP, 0, pszText, (int)(iSelSize-1), pszTextW, (int)iSelSize);
|
||||
|
||||
size_t const cchUnescaped = iSelSize * 3;
|
||||
size_t const cchUnescaped = iSelSize * 3 + 1;
|
||||
char* pszUnescaped = (char*)AllocMem(cchUnescaped, HEAP_ZERO_MEMORY);
|
||||
if (pszUnescaped == NULL) {
|
||||
FreeMem(pszTextW);
|
||||
@ -1815,7 +1820,13 @@ void EditURLDecode()
|
||||
}
|
||||
|
||||
DWORD cchUnescapedW = (DWORD)cchUnescaped;
|
||||
UrlUnescapeEx(pszTextW, pszUnescapedW, &cchUnescapedW);
|
||||
if (isPathConvert) {
|
||||
if (FAILED(UrlCreateFromPath(pszTextW, pszUnescapedW, &cchUnescapedW, 0))) {
|
||||
StringCchCopy(pszUnescapedW, cchUnescaped, pszTextW); // no op
|
||||
}
|
||||
} else {
|
||||
UrlUnescapeEx(pszTextW, pszUnescapedW, &cchUnescapedW);
|
||||
}
|
||||
|
||||
int const cchUnescapedDec = WideCharToMultiByte(Encoding_SciCP, 0, pszUnescapedW, cchUnescapedW,
|
||||
pszUnescaped, (int)cchUnescaped, NULL, NULL);
|
||||
@ -1845,6 +1856,34 @@ void EditURLDecode()
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// EditPath2URL()
|
||||
//
|
||||
bool EditPath2URL() {
|
||||
|
||||
bool success = false;
|
||||
|
||||
if (SciCall_IsSelectionEmpty()) {
|
||||
return success;
|
||||
}
|
||||
|
||||
if (Sci_IsMultiOrRectangleSelection()) {
|
||||
InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECTORMULTI);
|
||||
return success;
|
||||
}
|
||||
|
||||
_SAVE_TARGET_RANGE_;
|
||||
|
||||
|
||||
|
||||
|
||||
_RESTORE_TARGET_RANGE_;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// EditEscapeCChars()
|
||||
|
||||
14
src/Edit.h
14
src/Edit.h
@ -45,8 +45,8 @@ void EditInvertCase(HWND hwnd);
|
||||
void EditTitleCase(HWND hwnd);
|
||||
void EditSentenceCase(HWND hwnd);
|
||||
|
||||
void EditURLEncode();
|
||||
void EditURLDecode();
|
||||
void EditURLEncode(const bool isPathConvert);
|
||||
void EditURLDecode(const bool isPathConvert);
|
||||
void EditEscapeCChars(HWND hwnd);
|
||||
void EditUnescapeCChars(HWND hwnd);
|
||||
void EditChar2Hex(HWND hwnd);
|
||||
@ -134,11 +134,11 @@ void EditSelectionMultiSelectAll();
|
||||
void EditSelectionMultiSelectAllEx(CLPCEDITFINDREPLACE edFndRpl);
|
||||
|
||||
// maybe removed beyond next release
|
||||
#define _SAVE_TARGET_RANGE_ DocPos const _saveTargetBeg_ = SciCall_GetTargetStart();\
|
||||
DocPos const _saveTargetEnd_ = SciCall_GetTargetEnd()
|
||||
#define _RESTORE_TARGET_RANGE_ SciCall_SetTargetRange(_saveTargetBeg_, _saveTargetEnd_)
|
||||
//#define _SAVE_TARGET_RANGE_
|
||||
//#define _RESTORE_TARGET_RANGE_
|
||||
//#define _SAVE_TARGET_RANGE_ DocPos const _saveTargetBeg_ = SciCall_GetTargetStart();\
|
||||
// DocPos const _saveTargetEnd_ = SciCall_GetTargetEnd()
|
||||
//#define _RESTORE_TARGET_RANGE_ SciCall_SetTargetRange(_saveTargetBeg_, _saveTargetEnd_)
|
||||
#define _SAVE_TARGET_RANGE_
|
||||
#define _RESTORE_TARGET_RANGE_
|
||||
|
||||
//
|
||||
// Folding Functions
|
||||
|
||||
@ -445,15 +445,19 @@ int LoadLngStringW(UINT uID, LPWSTR lpBuffer, int nBufferMax)
|
||||
//
|
||||
// LoadLngStringW2MB()
|
||||
//
|
||||
static WCHAR s_tmpStringBuffer[512];
|
||||
|
||||
ptrdiff_t LoadLngStringW2MB(UINT uID, LPSTR lpBuffer, int nBufferMax)
|
||||
int LoadLngStringW2MB(UINT uID, LPSTR lpBuffer, int nBufferMax)
|
||||
{
|
||||
const int nLen = LoadStringW(Globals.hLngResContainer, uID, s_tmpStringBuffer, COUNTOF(s_tmpStringBuffer));
|
||||
if (nLen == 0) {
|
||||
LoadStringW(Globals.hInstance, uID, s_tmpStringBuffer, COUNTOF(s_tmpStringBuffer));
|
||||
int len = 0;
|
||||
WCHAR * const pBuffer = (WCHAR *)AllocMem(sizeof(WCHAR) * nBufferMax, HEAP_ZERO_MEMORY);
|
||||
if (pBuffer) {
|
||||
const int nLen = LoadStringW(Globals.hLngResContainer, uID, pBuffer, nBufferMax);
|
||||
if (nLen == 0) {
|
||||
LoadStringW(Globals.hInstance, uID, pBuffer, nBufferMax);
|
||||
}
|
||||
len = WideCharToMultiByte(Encoding_SciCP, 0, pBuffer, -1, lpBuffer, nBufferMax, NULL, NULL);
|
||||
FreeMem(pBuffer);
|
||||
}
|
||||
return WideCharToMultiByteEx(CP_UTF8, 0, s_tmpStringBuffer, -1, lpBuffer, nBufferMax, NULL, NULL);
|
||||
return len;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -473,7 +477,7 @@ int LoadLngStringA(UINT uID, LPSTR lpBuffer, int nBufferMax)
|
||||
//
|
||||
int FormatLngStringW(LPWSTR lpOutput, int nOutput, UINT uIdFormat, ...)
|
||||
{
|
||||
WCHAR* pBuffer = AllocMem(sizeof(WCHAR) * nOutput, HEAP_ZERO_MEMORY);
|
||||
WCHAR* const pBuffer = AllocMem(sizeof(WCHAR) * nOutput, HEAP_ZERO_MEMORY);
|
||||
if (pBuffer) {
|
||||
if (LoadLngStringW(uIdFormat, pBuffer, nOutput)) {
|
||||
StringCchVPrintfW(lpOutput, nOutput, pBuffer, (LPVOID)((PUINT_PTR)& uIdFormat + 1));
|
||||
@ -490,7 +494,7 @@ int FormatLngStringW(LPWSTR lpOutput, int nOutput, UINT uIdFormat, ...)
|
||||
//
|
||||
int FormatLngStringA(LPSTR lpOutput, int nOutput, UINT uIdFormat, ...)
|
||||
{
|
||||
CHAR* pBuffer = AllocMem(sizeof(CHAR) * nOutput, HEAP_ZERO_MEMORY);
|
||||
CHAR* const pBuffer = AllocMem(sizeof(CHAR) * nOutput, HEAP_ZERO_MEMORY);
|
||||
if (pBuffer) {
|
||||
if (LoadLngStringA(uIdFormat, pBuffer, nOutput)) {
|
||||
StringCchVPrintfA(lpOutput, nOutput, pBuffer, (LPVOID)((PUINT_PTR)& uIdFormat + 1));
|
||||
|
||||
@ -55,7 +55,7 @@ int LoadLngStringW(UINT uID, LPWSTR lpBuffer, int nBufferMax);
|
||||
int LoadLngStringA(UINT uID, LPSTR lpBuffer, int nBufferMax);
|
||||
int FormatLngStringW(LPWSTR lpOutput, int nOutput, UINT uIdFormat, ...);
|
||||
int FormatLngStringA(LPSTR lpOutput, int nOutput, UINT uIdFormat, ...);
|
||||
ptrdiff_t LoadLngStringW2MB(UINT uID, LPSTR lpBuffer, int nBufferMax);
|
||||
int LoadLngStringW2MB(UINT uID, LPSTR lpBuffer, int nBufferMax);
|
||||
|
||||
#define GetLngString(id,pb,cb) LoadLngStringW((id),(pb),(cb))
|
||||
#define GetLngStringA(id,pb,cb) LoadLngStringA((id),(pb),(cb))
|
||||
|
||||
@ -5033,13 +5033,25 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
|
||||
case IDM_EDIT_URLENCODE: {
|
||||
EditURLEncode(Globals.hwndEdit);
|
||||
EditURLEncode(false);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case IDM_EDIT_URL2PATH: {
|
||||
EditURLEncode(true);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case IDM_EDIT_URLDECODE: {
|
||||
EditURLDecode(Globals.hwndEdit);
|
||||
EditURLDecode(false);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case IDM_EDIT_PATH2URL: {
|
||||
EditURLDecode(true);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -6939,18 +6951,15 @@ void HandleDWellStartEnd(const DocPos position, const UINT uid)
|
||||
break;
|
||||
}
|
||||
|
||||
WCHAR wchCalltipAdd[SMALL_BUFFER] = { L'\0' };
|
||||
CHAR chCalltipAdd[LARGE_BUFFER] = { L'\0' };
|
||||
if (StrStrIA(chText, "file:") == chText) {
|
||||
GetLngString(IDS_MUI_URL_OPEN_FILE, wchCalltipAdd, COUNTOF(wchCalltipAdd));
|
||||
GetLngStringW2MB(IDS_MUI_URL_OPEN_FILE, chCalltipAdd, COUNTOF(chCalltipAdd));
|
||||
} else {
|
||||
GetLngString(IDS_MUI_URL_OPEN_BROWSER, wchCalltipAdd, COUNTOF(wchCalltipAdd));
|
||||
GetLngStringW2MB(IDS_MUI_URL_OPEN_BROWSER, chCalltipAdd, COUNTOF(chCalltipAdd));
|
||||
}
|
||||
CHAR chAdd[LARGE_BUFFER] = { L'\0' };
|
||||
WideCharToMultiByte(Encoding_SciCP, 0, wchCalltipAdd, -1, chAdd, (int)COUNTOF(chAdd), NULL, NULL);
|
||||
|
||||
char chCallTip[HUGE_BUFFER] = { '\0' };
|
||||
StringCchCatA(chCallTip, COUNTOF(chCallTip), chText);
|
||||
StringCchCatA(chCallTip, COUNTOF(chCallTip), chAdd);
|
||||
StringCchCatA(chCallTip, COUNTOF(chCallTip), chCalltipAdd);
|
||||
//SciCall_CallTipSetPosition(true);
|
||||
SciCall_CallTipShow(position, chCallTip);
|
||||
SciCall_CallTipSetHlt(0, (int)length);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user