mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
Merge pull request #3548 from RaiKoHoff/Dev_DM_STD
Launching file URL (Alt+Click) with respect to flags "Reuse Window" and "Only one Instance per File"
This commit is contained in:
commit
891f101e32
@ -1472,7 +1472,7 @@ CASE_WM_CTLCOLOR_SET:
|
||||
}
|
||||
|
||||
SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
|
||||
//sei.fMask = 0;
|
||||
sei.fMask = SEE_MASK_DEFAULT;
|
||||
sei.hwnd = hwnd;
|
||||
sei.lpVerb = NULL;
|
||||
sei.lpFile = arg1;
|
||||
@ -1736,7 +1736,7 @@ bool OpenWithDlg(HWND hwnd,LPCWSTR lpstrFile)
|
||||
}
|
||||
|
||||
SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
|
||||
//sei.fMask = 0;
|
||||
sei.fMask = SEE_MASK_DEFAULT;
|
||||
sei.hwnd = hwnd;
|
||||
sei.lpVerb = NULL;
|
||||
sei.lpFile = dliOpenWith.szFileName;
|
||||
|
||||
@ -4159,7 +4159,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
PathCchRemoveFileSpec(tchMaxPathBuffer, COUNTOF(tchMaxPathBuffer));
|
||||
|
||||
SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
|
||||
//sei.fMask = 0;
|
||||
sei.fMask = SEE_MASK_DEFAULT;
|
||||
sei.hwnd = hwnd;
|
||||
sei.lpVerb = NULL;
|
||||
sei.lpFile = Paths.CurrentFile;
|
||||
@ -4301,7 +4301,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case IDM_FILE_MANAGEFAV: {
|
||||
SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
|
||||
//sei.fMask = 0;
|
||||
sei.fMask = SEE_MASK_DEFAULT;
|
||||
sei.hwnd = hwnd;
|
||||
sei.lpVerb = NULL;
|
||||
sei.lpFile = Settings.FavoritesDir;
|
||||
@ -6924,8 +6924,7 @@ void HandleDWellStartEnd(const DocPos position, const UINT uid)
|
||||
wchUrl[cchUrl] = L'\0';
|
||||
StrTrim(wchUrl, L" \r\n\t");
|
||||
|
||||
int ln = -1;
|
||||
SplitFilePathLineNum(wchUrl, &ln);
|
||||
SplitFilePathLineNum(wchUrl, NULL); // cut off possible linenum spec
|
||||
|
||||
WCHAR wchPath[MAX_PATH] = { L'\0' };
|
||||
DWORD cchPath = MAX_PATH;
|
||||
@ -7133,28 +7132,41 @@ bool HandleHotSpotURLClicked(const DocPos position, const HYPERLINK_OPS operatio
|
||||
|
||||
int lineNum = -1;
|
||||
SplitFilePathLineNum(szTextW, &lineNum);
|
||||
lineNum = clampi(lineNum, 0, INT_MAX);
|
||||
|
||||
if ((operation & OPEN_WITH_NOTEPAD3) && UrlIsFileUrl(szTextW)) {
|
||||
|
||||
PathCreateFromUrl(szTextW, szUnEscW, &dCch, 0);
|
||||
szUnEscW[min_u(MAX_PATH, INTERNET_MAX_URL_LENGTH)] = L'\0'; // limit length
|
||||
|
||||
WCHAR * const szFileName = szUnEscW;
|
||||
StrTrim(szFileName, L"/");
|
||||
WCHAR * const szFilePath = szUnEscW;
|
||||
StrTrim(szFilePath, L"/");
|
||||
|
||||
PathCanonicalizeEx(szFileName, (DWORD)(COUNTOF(szUnEscW) - lenPfx));
|
||||
PathCanonicalizeEx(szFilePath, (DWORD)(COUNTOF(szUnEscW) - lenPfx));
|
||||
|
||||
bool success = false;
|
||||
if (PathIsExistingFile(szFileName)) {
|
||||
success = FileLoad(szFileName, false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, false);
|
||||
}
|
||||
else if (PathIsDirectory(szFileName)) {
|
||||
WCHAR tchFile[MAX_PATH] = { L'\0' };
|
||||
if (OpenFileDlg(Globals.hwndMain, tchFile, COUNTOF(tchFile), szFileName)) {
|
||||
success = FileLoad(tchFile, false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, false);
|
||||
if (PathIsExistingFile(szFilePath)) {
|
||||
if (Flags.bReuseWindow) {
|
||||
success = FileLoad(szFilePath, false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, false);
|
||||
} else {
|
||||
WCHAR wchParams[64];
|
||||
StringCchPrintf(wchParams, COUNTOF(wchParams), L"%s /g %i", Flags.bSingleFileInstance ? L"/ns" : L"/n", lineNum);
|
||||
success = LaunchNewInstance(Globals.hwndMain, wchParams, szFilePath);
|
||||
}
|
||||
}
|
||||
if (success && (lineNum >= 0)) {
|
||||
else if (PathIsDirectory(szFilePath)) {
|
||||
if (Flags.bReuseWindow) {
|
||||
WCHAR tchFile[MAX_PATH] = { L'\0' };
|
||||
if (OpenFileDlg(Globals.hwndMain, tchFile, COUNTOF(tchFile), szFilePath)) {
|
||||
success = FileLoad(tchFile, false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, false);
|
||||
}
|
||||
} else {
|
||||
WCHAR wchParams[64];
|
||||
StringCchPrintf(wchParams, COUNTOF(wchParams), L"%s", Flags.bSingleFileInstance ? L"/ns" : L"/n");
|
||||
success = LaunchNewInstance(Globals.hwndMain, wchParams, szFilePath);
|
||||
}
|
||||
}
|
||||
if (Flags.bReuseWindow && success && (lineNum >= 0)) {
|
||||
lineNum = clampi(lineNum - 1, 0, INT_MAX);
|
||||
//~SciCall_GotoLine((DocLn)lineNum);
|
||||
PostMessage(Globals.hwndEdit, SCI_GOTOLINE, (WPARAM)lineNum, 0);
|
||||
@ -10915,6 +10927,37 @@ bool ActivatePrevInst()
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// LaunchNewInstance()
|
||||
//
|
||||
//
|
||||
bool LaunchNewInstance(HWND hwnd, LPCWSTR lpszParameter, LPCWSTR lpszFilePath)
|
||||
{
|
||||
WCHAR lpExe[MAX_PATH];
|
||||
GetModuleFileName(NULL, lpExe, COUNTOF(lpExe)); // full path
|
||||
PathCanonicalizeEx(lpExe, COUNTOF(lpExe));
|
||||
|
||||
WCHAR wchDir[MAX_PATH] = { L'\0' };
|
||||
if (StrIsNotEmpty(lpszFilePath)) {
|
||||
StringCchCopy(wchDir, COUNTOF(wchDir), lpszFilePath);
|
||||
PathCchRemoveFileSpec(wchDir, COUNTOF(wchDir));
|
||||
}
|
||||
WCHAR wchParams[MAX_PATH * 2];
|
||||
StringCchPrintf(wchParams, COUNTOF(wchParams), L"%s \"%s\"", lpszParameter, lpszFilePath);
|
||||
|
||||
SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) };
|
||||
sei.fMask = SEE_MASK_DEFAULT;
|
||||
sei.hwnd = hwnd;
|
||||
sei.lpVerb = NULL;
|
||||
sei.lpFile = lpExe;
|
||||
sei.lpParameters = wchParams;
|
||||
sei.lpDirectory = StrIsNotEmpty(wchDir) ? wchDir : Paths.WorkingDirectory;
|
||||
sei.nShow = SW_NORMAL;
|
||||
return ShellExecuteExW(&sei);
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// RelaunchMultiInst()
|
||||
|
||||
@ -107,6 +107,7 @@ HWND InitInstance(const HINSTANCE hInstance, LPCWSTR pszCmdLine, int nCmdShow);
|
||||
WININFO GetFactoryDefaultWndPos(const int flagsPos);
|
||||
WININFO GetWinInfoByFlag(const int flagsPos);
|
||||
bool ActivatePrevInst();
|
||||
bool LaunchNewInstance(HWND hwnd, LPCWSTR lpszParameter, LPCWSTR lpszFilePath);
|
||||
bool RelaunchMultiInst();
|
||||
bool RelaunchElevated(LPWSTR lpNewCmdLnArgs);
|
||||
bool DoElevatedRelaunch(EditFileIOStatus* pFioStatus, bool bAutoSaveOnRelaunch);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user