Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
112 lines (83 loc) · 3.06 KB

File metadata and controls

112 lines (83 loc) · 3.06 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#ifndef _PYTHONCONSOLE_H
#define _PYTHONCONSOLE_H
#ifndef _CONSOLEINTERFACE_H
#include "ConsoleInterface.h"
#endif
#ifndef _PYPRODUCER_H
#include "PyProducerConsumer.h"
#endif
struct NppData;
namespace NppPythonScript
{
class PythonHandler;
class ScintillaWrapper;
class ConsoleDialog;
struct RunStatementArgs;
class PythonConsole : public PyProducerConsumer<std::string>, public ConsoleInterface
{
public:
explicit PythonConsole(HWND hNotepad);
~PythonConsole();
void init(HINSTANCE hInst, NppData& nppData);
void initPython(PythonHandler *pythonHandler);
void showDialog();
// Show console but fire a message to get it created on the right thread.
void pythonShowDialog();
void hideDialog();
void message(const char *msg);
void writeText(boost::python::object text);
void writeError(boost::python::object text);
void clear();
/* Console Interface members */
void runStatement(const char *statement);
void stopStatement();
void openFile(const char *filename, idx_t lineNumber);
/* ConsoleInterface end */
static void stopStatementWorker(PythonConsole *console);
DWORD runCommand(boost::python::str text, boost::python::object pyStdout, boost::python::object pyStderr);
DWORD runCommandNoStderr(boost::python::str text, boost::python::object pyStdout)
{
boost::python::object sys_module( (boost::python::handle<>(PyImport_ImportModule("sys"))) );
boost::python::object sys_namespace = sys_module.attr("__dict__");
return runCommand(text, pyStdout, sys_namespace["stderr"]);
}
DWORD runCommandNoStdout(boost::python::str text)
{
boost::python::object sys_module( (boost::python::handle<>(PyImport_ImportModule("sys"))) );
boost::python::object sys_namespace = sys_module.attr("__dict__");
boost::python::object npp_module( (boost::python::handle<>(PyImport_ImportModule("Npp"))) );
boost::python::object npp_namespace = npp_module.attr("__dict__");
return runCommand(text, npp_namespace["console"], sys_namespace["stderr"]);
}
HWND getScintillaHwnd();
boost::shared_ptr<ScintillaWrapper> getScintillaWrapper() { return mp_scintillaWrapper; }
boost::shared_ptr<ScintillaWrapper> mp_scintillaWrapper;
static boost::python::str getEncoding() { return boost::python::str("utf-8"); }
protected:
virtual void consume(std::shared_ptr<std::string> statement);
virtual void queueComplete();
private:
PythonConsole(); // default constructor disabled
PythonConsole& operator = (const PythonConsole&); // assignment operator disabled
PythonConsole(const PythonConsole& other);
ConsoleDialog *mp_consoleDlg;
boost::python::object m_console;
boost::python::object m_pushFunc;
boost::python::object m_sys;
PyThreadState* mp_mainThreadState;
HANDLE m_statementRunning;
HWND m_hNotepad;
bool m_consumerStarted;
bool m_runStatementExecuted;
NppData* m_nppData;
};
void export_console();
void importConsole(boost::shared_ptr<PythonConsole> console);
struct RunStatementArgs
{
char *statement;
HANDLE statementRunning;
PythonConsole *console;
};
}
#endif
Morty Proxy This is a proxified and sanitized view of the page, visit original site.