Beispiel #1
0
    static void
getGvimInvocation(char *name, int runtime)
{
    getGvimName(name, runtime);
    // avoid that Vim tries to expand wildcards in the file names
    strcat(name, " --literal");
}
Beispiel #2
0
BOOL CShellExt::LoadMenuIcon()
{
	char vimExeFile[BUFSIZE];
	getGvimName(vimExeFile, 1);
	if (vimExeFile[0] == '\0')
		return FALSE;
	HICON hVimIcon;
	if (ExtractIconEx(vimExeFile, 0, NULL, &hVimIcon, 1) == 0)
		return FALSE;
	m_hVimIconBitmap = IconToBitmap(hVimIcon,
		GetSysColorBrush(COLOR_MENU),
		GetSystemMetrics(SM_CXSMICON),
		GetSystemMetrics(SM_CYSMICON));
	return TRUE;
}
Beispiel #3
0
//
// Get the Vim runtime directory into buf[BUFSIZE].
// The result is empty when it failed.
// When it works, the path ends in a slash or backslash.
//
    static void
getRuntimeDir(char *buf)
{
    int		idx;

    getGvimName(buf, 1);
    if (buf[0] != 0)
    {
	// When no path found, use the search path to expand it.
	if (strchr(buf, '/') == NULL && strchr(buf, '\\') == NULL)
	    strcpy(buf, searchpath(buf));

	// remove "gvim.exe" from the end
	for (idx = (int)strlen(buf) - 1; idx >= 0; idx--)
	    if (buf[idx] == '\\' || buf[idx] == '/')
	    {
		buf[idx + 1] = 0;
		break;
	    }
    }
}
Beispiel #4
0
STDMETHODIMP CShellExt::InvokeSingleGvim(HWND hParent,
				   LPCSTR  /* pszWorkingDir */,
				   LPCSTR  /* pszCmd */,
				   LPCSTR  /* pszParam */,
				   int  /* iShowCmd */,
				   int useDiff)
{
    char	m_szFileUserClickedOn[BUFSIZE];
    char	*cmdStr;
    size_t	cmdlen;
    size_t	len;
    UINT i;

    cmdlen = BUFSIZE;
    cmdStr = (char *)malloc(cmdlen);
    getGvimName(cmdStr, 0);
    if (useDiff)
	strcat(cmdStr, " -d");
    for (i = 0; i < cbFiles; i++)
    {
	DragQueryFile((HDROP)medium.hGlobal,
		i,
		m_szFileUserClickedOn,
		sizeof(m_szFileUserClickedOn));

	len = strlen(cmdStr) + strlen(m_szFileUserClickedOn) + 4;
	if (len > cmdlen)
	{
	    cmdlen = len + BUFSIZE;
	    cmdStr = (char *)realloc(cmdStr, cmdlen);
	}
	strcat(cmdStr, " \"");
	strcat(cmdStr, m_szFileUserClickedOn);
	strcat(cmdStr, "\"");
    }

    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory(&si, sizeof(si));
    si.cb = sizeof(si);

    // Start the child process.
    if (!CreateProcess(NULL,	// No module name (use command line).
		cmdStr,		// 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);
    }

    free(cmdStr);

    return NOERROR;
}
STDMETHODIMP CShellExt::InvokeGvim(HWND hParent,
				   LPCSTR pszWorkingDir,
				   LPCSTR pszCmd,
				   LPCSTR pszParam,
				   int iShowCmd)
{
    char m_szFileUserClickedOn[BUFSIZE];
    char cmdStr[BUFSIZE];
    UINT i;

    for (i = 0; i < cbFiles; i++)
    {
	DragQueryFile((HDROP)medium.hGlobal,
		i,
		m_szFileUserClickedOn,
		sizeof(m_szFileUserClickedOn));

	getGvimName(cmdStr, 0);
	strcat(cmdStr, " \"");

	if ((strlen(cmdStr) + strlen(m_szFileUserClickedOn) + 2) < BUFSIZE)
	{
	    strcat(cmdStr, m_szFileUserClickedOn);
	    strcat(cmdStr, "\"");

	    STARTUPINFO si;
	    PROCESS_INFORMATION pi;

	    ZeroMemory(&si, sizeof(si));
	    si.cb = sizeof(si);

	    // Start the child process.
	    if (!CreateProcess(NULL,	// No module name (use command line).
			cmdStr,		// 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)
{
    char	m_szFileUserClickedOn[BUFSIZE];
    char	*cmdStr;
    size_t	cmdlen;
    size_t	len;
    bool        bUseTab;
    UINT i;

    cmdlen = BUFSIZE;
    cmdStr = (char *)malloc(cmdlen);
    getGvimName(cmdStr, 0);
    bUseTab = false;
    if(m_bUseTab)
        bUseTab = true;
    if (useDiff)
    {
	strcat(cmdStr, " -d");
        bUseTab = false;
    }
    if (cbFiles == 1)
    {
        bUseTab = false;
    }
    if(!bUseTab)
    {
        for (i = 0; i < cbFiles; i++)
        {
            DragQueryFile((HDROP)medium.hGlobal,
                    i,
                    m_szFileUserClickedOn,
                    sizeof(m_szFileUserClickedOn));

            len = strlen(cmdStr) + strlen(m_szFileUserClickedOn) + 4;
            if (len > cmdlen)
            {
                cmdlen = len + BUFSIZE;
                cmdStr = (char *)realloc(cmdStr, cmdlen);
            }
            strcat(cmdStr, " \"");
            strcat(cmdStr, m_szFileUserClickedOn);
            strcat(cmdStr, "\"");
        }
    }

    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory(&si, sizeof(si));
    si.cb = sizeof(si);

    // Start the child process.
    if (!CreateProcess(NULL,	// No module name (use command line).
		cmdStr,		// 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
    {
        if(bUseTab)
        {
            //Size of 2*BUFSIZE should be big enough for the Vim Command text string
            char	szVimCmdText[BUFSIZE*2];
            //Send the first file using the following syntax: :e c:\temp\dave1.txt
            DragQueryFile((HDROP)medium.hGlobal,
                    0,
                    m_szFileUserClickedOn,
                    sizeof(m_szFileUserClickedOn));
            strcpy(szVimCmdText, ":e ");
            strcat(szVimCmdText, m_szFileUserClickedOn);
            strcat(szVimCmdText, "{ENTER}");
            SendToWindow(pi.hProcess, szVimCmdText);
            for (i = 1; i < cbFiles; i++)
            {
                //Send each subsequent file using the following syntax: :tab new c:\temp\dave.txt
                DragQueryFile((HDROP)medium.hGlobal,
                        i,
                        m_szFileUserClickedOn,
                        sizeof(m_szFileUserClickedOn));
                strcpy(szVimCmdText, ":tab new ");
                strcat(szVimCmdText, m_szFileUserClickedOn);
                strcat(szVimCmdText, "{ENTER}");
                SendToWindow(pi.hProcess, szVimCmdText);
            }
        }
	CloseHandle(pi.hProcess);
	CloseHandle(pi.hThread);
    }

    free(cmdStr);

    return NOERROR;
}