Skip to content

Commit

Permalink
Released v1.1, PyNPP now kills the Python it launched when file is re…
Browse files Browse the repository at this point in the history
…-run
  • Loading branch information
mpcabd committed Apr 27, 2014
1 parent 3373992 commit 263b55f
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
19 changes: 18 additions & 1 deletion PluginDefinition.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "AboutDlg.h"
#include <string>
#include <sstream>
#include <map>
using namespace std;
#include <windows.h>

Expand All @@ -33,6 +34,7 @@ FuncItem funcItem[nbFunc];
//
// The data of Notepad++ that you can use in your plugin commands
//
map<std::wstring, PROCESS_INFORMATION> pi_map;


void pluginInit(HANDLE hModule)
Expand Down Expand Up @@ -160,7 +162,17 @@ bool launchPython(std::wstring &command, std::wstring &path)
memset(&pi, 0, sizeof(pi));
si.cb = sizeof(si);

return CreateProcess(
bool ok = false;
std::wstring filename = getCurrentFile(ok);
if (ok) {
map<std::wstring, PROCESS_INFORMATION>::iterator it = pi_map.find(filename);
if (it != pi_map.end()) {
TerminateProcess(it->second.hProcess, 1);
pi_map.erase(it);
}
}

bool result = CreateProcess(
NULL,
const_cast<LPWSTR>(command.c_str()),
NULL,
Expand All @@ -171,6 +183,11 @@ bool launchPython(std::wstring &command, std::wstring &path)
path.c_str(),
&si,
&pi) != 0;

if (result)
pi_map[filename] = pi;

return result;
}

void run(bool isW, bool isI) {
Expand Down
Binary file removed Unicode Debug/PyNPP.dll
Binary file not shown.
Binary file added Unicode Release/PyNPP.dll
Binary file not shown.
51 changes: 51 additions & 0 deletions versionRC.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <windows.h>

#define VER_FILEVERSION 1,1,0,0
#define VER_FILEVERSION_STR "1.1\0"

#define VER_PRODUCTVERSION 1,1,0,0
#define VER_PRODUCTVERSION_STR "1.1\0"

#ifndef DEBUG
#define VER_DEBUG 0
#else
#define VER_DEBUG VS_FF_DEBUG
#endif

VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0x17L
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "Abd Allah Diab\0"
VALUE "FileDescription", "PyNPP Notepad++ Plugin\0"
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", "PyNPP\0"
VALUE "LegalCopyright", "GPLv3\0"
VALUE "OriginalFilename", "PyNPP.dll\0"
VALUE "ProductName", "PyNPP\0"
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END
END

BLOCK "VarFileInfo"
BEGIN
/* The following line should only be modified for localized versions. */
/* It consists of any number of WORD,WORD pairs, with each pair */
/* describing a language,codepage combination supported by the file. */
/* */
/* For example, a file might have values "0x409,1252" indicating that it */
/* supports English language (0x409) in the Windows ANSI codepage (1252). */

VALUE "Translation", 0x409, 1252

END
END

0 comments on commit 263b55f

Please sign in to comment.