forked from bruderstein/PythonScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonHandler.h
More file actions
87 lines (59 loc) · 2.04 KB
/
PythonHandler.h
File metadata and controls
87 lines (59 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once
#include "stdafx.h"
#include "PyProducerConsumer.h"
// Forward def
class ScintillaWrapper;
class NotepadPlusWrapper;
class PythonConsole;
struct SCNotification;
struct RunScriptArgs;
class PythonHandler : NppPythonScript::PyProducerConsumer<RunScriptArgs*>
{
public:
PythonHandler::PythonHandler(char *pluginsDir, char *configDir, HINSTANCE hInst, HWND nppHandle, HWND scintilla1Handle, HWND scintilla2Handle, PythonConsole *pythonConsole);
~PythonHandler();
bool runScript(const char *filename, bool synchronous = false, bool allowQueuing = false, HANDLE completedEvent = NULL, bool isStatement = false);
bool runScript(const std::string& filename, bool synchronous = false, bool allowQueuing = false, HANDLE completedEvent = NULL, bool isStatement = false);
void runScriptWorker(RunScriptArgs* args);
void consume(RunScriptArgs* args);
void notify(SCNotification *notifyCode);
void initPython();
void runStartupScripts();
void stopScript();
PyThreadState* getMainThreadState() { return mp_mainThreadState; };
DWORD getExecutingThreadID() { return getConsumerThreadID(); };
protected:
virtual ScintillaWrapper* createScintillaWrapper();
virtual NotepadPlusWrapper* createNotepadPlusWrapper();
virtual void queueComplete();
// Handles
HWND m_nppHandle;
HWND m_scintilla1Handle;
HWND m_scintilla2Handle;
private:
// Private methods
void initModules();
static void stopScriptWorker(PythonHandler *handler);
// Private member vars
std::string m_machineBaseDir;
std::string m_userBaseDir;
ScintillaWrapper *mp_scintilla;
ScintillaWrapper *mp_scintilla1;
ScintillaWrapper *mp_scintilla2;
NotepadPlusWrapper *mp_notepad;
PythonConsole *mp_console;
int m_currentView;
PyThreadState *mp_mainThreadState;
PythonHandler *mp_python;
bool m_consumerStarted;
HANDLE m_hKillWait;
HINSTANCE m_hInst;
};
struct RunScriptArgs
{
char* filename;
PyThreadState *threadState;
bool synchronous;
HANDLE completedEvent;
bool isStatement;
};