mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.3243: MS-Windows: "edit with multiple Vim" choice is less useful
Problem: MS-Windows: the "edit with multiple Vim" choice is not that useful. Solution: Change it to "Edit with multiple tabs". (Michael Soyka, closes #8645)
This commit is contained in:
parent
0732932553
commit
83cd0156e0
@ -35,6 +35,15 @@ UINT cbFiles = 0;
|
||||
* enough */
|
||||
#define BUFSIZE 1100
|
||||
|
||||
// The "Edit with Vim" shell extension provides these choices when
|
||||
// a new instance of Gvim is selected:
|
||||
// - use tabpages
|
||||
// - enable diff mode
|
||||
// - none of the above
|
||||
#define EDIT_WITH_VIM_USE_TABPAGES (2)
|
||||
#define EDIT_WITH_VIM_IN_DIFF_MODE (1)
|
||||
#define EDIT_WITH_VIM_NO_OPTIONS (0)
|
||||
|
||||
//
|
||||
// Get the name of the Gvim executable to use, with the path.
|
||||
// When "runtime" is non-zero, we were called to find the runtime directory.
|
||||
@ -613,7 +622,7 @@ STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu,
|
||||
if (cbFiles > 1)
|
||||
{
|
||||
mii.wID = idCmd++;
|
||||
mii.dwTypeData = _("Edit with &multiple Vims");
|
||||
mii.dwTypeData = _("Edit with Vim using &tabpages");
|
||||
mii.cch = lstrlen(mii.dwTypeData);
|
||||
InsertMenuItem(hMenu, indexMenu++, TRUE, &mii);
|
||||
|
||||
@ -726,6 +735,7 @@ STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu,
|
||||
STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
|
||||
{
|
||||
HRESULT hr = E_INVALIDARG;
|
||||
int gvimExtraOptions;
|
||||
|
||||
// If HIWORD(lpcmi->lpVerb) then we have been called programmatically
|
||||
// and lpVerb is a command that should be invoked. Otherwise, the shell
|
||||
@ -750,29 +760,28 @@ STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
|
||||
switch (idCmd)
|
||||
{
|
||||
case 0:
|
||||
hr = InvokeGvim(lpcmi->hwnd,
|
||||
lpcmi->lpDirectory,
|
||||
lpcmi->lpVerb,
|
||||
lpcmi->lpParameters,
|
||||
lpcmi->nShow);
|
||||
gvimExtraOptions = EDIT_WITH_VIM_USE_TABPAGES;
|
||||
break;
|
||||
case 1:
|
||||
hr = InvokeSingleGvim(lpcmi->hwnd,
|
||||
lpcmi->lpDirectory,
|
||||
lpcmi->lpVerb,
|
||||
lpcmi->lpParameters,
|
||||
lpcmi->nShow,
|
||||
0);
|
||||
gvimExtraOptions = EDIT_WITH_VIM_NO_OPTIONS;
|
||||
break;
|
||||
case 2:
|
||||
hr = InvokeSingleGvim(lpcmi->hwnd,
|
||||
lpcmi->lpDirectory,
|
||||
lpcmi->lpVerb,
|
||||
lpcmi->lpParameters,
|
||||
lpcmi->nShow,
|
||||
1);
|
||||
gvimExtraOptions = EDIT_WITH_VIM_IN_DIFF_MODE;
|
||||
break;
|
||||
default:
|
||||
// If execution reaches this point we likely have an
|
||||
// inconsistency between the code that setup the menus
|
||||
// and this code that determines what the user
|
||||
// selected. This should be detected and fixed during
|
||||
// development.
|
||||
return E_FAIL;
|
||||
}
|
||||
hr = InvokeSingleGvim(lpcmi->hwnd,
|
||||
lpcmi->lpDirectory,
|
||||
lpcmi->lpVerb,
|
||||
lpcmi->lpParameters,
|
||||
lpcmi->nShow,
|
||||
gvimExtraOptions);
|
||||
}
|
||||
}
|
||||
return hr;
|
||||
@ -873,82 +882,13 @@ searchpath(char *name)
|
||||
return (char *)"";
|
||||
}
|
||||
|
||||
STDMETHODIMP CShellExt::InvokeGvim(HWND hParent,
|
||||
LPCSTR /* pszWorkingDir */,
|
||||
LPCSTR /* pszCmd */,
|
||||
LPCSTR /* pszParam */,
|
||||
int /* iShowCmd */)
|
||||
{
|
||||
wchar_t m_szFileUserClickedOn[BUFSIZE];
|
||||
wchar_t cmdStrW[BUFSIZE];
|
||||
UINT i;
|
||||
|
||||
for (i = 0; i < cbFiles; i++)
|
||||
{
|
||||
DragQueryFileW((HDROP)medium.hGlobal,
|
||||
i,
|
||||
m_szFileUserClickedOn,
|
||||
sizeof(m_szFileUserClickedOn));
|
||||
|
||||
getGvimInvocationW(cmdStrW);
|
||||
wcscat(cmdStrW, L" \"");
|
||||
|
||||
if ((wcslen(cmdStrW) + wcslen(m_szFileUserClickedOn) + 2) < BUFSIZE)
|
||||
{
|
||||
wcscat(cmdStrW, m_szFileUserClickedOn);
|
||||
wcscat(cmdStrW, L"\"");
|
||||
|
||||
STARTUPINFOW si;
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
|
||||
// Start the child process.
|
||||
if (!CreateProcessW(NULL, // No module name (use command line).
|
||||
cmdStrW, // Command line.
|
||||
NULL, // Process handle not inheritable.
|
||||
NULL, // Thread handle not inheritable.
|
||||
FALSE, // Set handle inheritance to FALSE.
|
||||
0, // No creation flags.
|
||||
NULL, // Use parent's environment block.
|
||||
NULL, // Use parent's starting directory.
|
||||
&si, // Pointer to STARTUPINFO structure.
|
||||
&pi) // Pointer to PROCESS_INFORMATION structure.
|
||||
)
|
||||
{
|
||||
MessageBox(
|
||||
hParent,
|
||||
_("Error creating process: Check if gvim is in your path!"),
|
||||
_("gvimext.dll error"),
|
||||
MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseHandle( pi.hProcess );
|
||||
CloseHandle( pi.hThread );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(
|
||||
hParent,
|
||||
_("Path length too long!"),
|
||||
_("gvimext.dll error"),
|
||||
MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
return NOERROR;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent,
|
||||
LPCSTR /* pszWorkingDir */,
|
||||
LPCSTR /* pszCmd */,
|
||||
LPCSTR /* pszParam */,
|
||||
int /* iShowCmd */,
|
||||
int useDiff)
|
||||
int gvimExtraOptions)
|
||||
{
|
||||
wchar_t m_szFileUserClickedOn[BUFSIZE];
|
||||
wchar_t *cmdStrW;
|
||||
@ -962,8 +902,10 @@ STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent,
|
||||
return E_FAIL;
|
||||
getGvimInvocationW(cmdStrW);
|
||||
|
||||
if (useDiff)
|
||||
if (gvimExtraOptions == EDIT_WITH_VIM_IN_DIFF_MODE)
|
||||
wcscat(cmdStrW, L" -d");
|
||||
else if (gvimExtraOptions == EDIT_WITH_VIM_USE_TABPAGES)
|
||||
wcscat(cmdStrW, L" -p");
|
||||
for (i = 0; i < cbFiles; i++)
|
||||
{
|
||||
DragQueryFileW((HDROP)medium.hGlobal,
|
||||
|
@ -129,18 +129,12 @@ protected:
|
||||
int iShowCmd,
|
||||
int idHWnd);
|
||||
|
||||
STDMETHODIMP InvokeGvim(HWND hParent,
|
||||
LPCSTR pszWorkingDir,
|
||||
LPCSTR pszCmd,
|
||||
LPCSTR pszParam,
|
||||
int iShowCmd);
|
||||
|
||||
STDMETHODIMP InvokeSingleGvim(HWND hParent,
|
||||
LPCSTR pszWorkingDir,
|
||||
LPCSTR pszCmd,
|
||||
LPCSTR pszParam,
|
||||
int iShowCmd,
|
||||
int useDiff);
|
||||
int gvimExtraOptions);
|
||||
|
||||
public:
|
||||
int m_cntOfHWnd;
|
||||
|
@ -755,6 +755,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
3243,
|
||||
/**/
|
||||
3242,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user