forked from gclxry/NppMarkdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dllmain.cpp
173 lines (143 loc) · 3.49 KB
/
dllmain.cpp
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include "PluginDefinition.h"
#include "PreViewDlg.h"
#include "GoToLineDlg.h"
#include <atlfile.h>
#include <vector>
#include <fstream>
#include <sstream>
#include <process.h>
#include "markdown.h"
#include <atlconv.h>
#include <atlctrls.h>
using namespace std;
extern FuncItem funcItem[nbFunc];
extern NppData nppData;
CAppModule _Module;
HMODULE g_Module;
extern DemoDlg _goToLine;
extern BOOL bReady;
class CPerformanceWatch
{
public:
CPerformanceWatch()
{
QueryPerformanceFrequency(&m_liPerfFreq);
Start();
}
// 返回执行秒
__int64 Now() const
{
LARGE_INTEGER liPerfNow;
QueryPerformanceCounter(&liPerfNow);
return (((liPerfNow.QuadPart - m_liPerfStart.QuadPart) * 1000) / m_liPerfFreq.QuadPart);
}
// 返回执行微妙
__int64 NowInMicro() const
{
LARGE_INTEGER liPerfNow;
QueryPerformanceCounter(&liPerfNow);
return (((liPerfNow.QuadPart - m_liPerfStart.QuadPart) * 1000000) / m_liPerfFreq.QuadPart);
}
private:
LARGE_INTEGER m_liPerfFreq;
LARGE_INTEGER m_liPerfStart;
void Start()
{
QueryPerformanceCounter(&m_liPerfStart);
}
};
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
pluginInit(hModule);
g_Module = hModule;
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
commandMenuCleanUp();
pluginCleanUp();
break;
}
return TRUE;
}
extern "C" __declspec(dllexport) void setInfo(NppData notpadPlusData)
{
nppData = notpadPlusData;
commandMenuInit();
}
extern "C" __declspec(dllexport) const TCHAR * getName()
{
return NPP_PLUGIN_NAME;
}
extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *nbF)
{
*nbF = nbFunc;
return funcItem;
}
void vSplitString( wstring& strSrc , vector<wstring>& vecDest , char cSeparator)
{
if( strSrc.empty() )
return ;
wstring::size_type size_pos = 0;
wstring::size_type size_prev_pos = 0;
while( (size_pos = strSrc.find_first_of( cSeparator , size_pos)) != wstring::npos)
{
wstring strTemp = strSrc.substr(size_prev_pos , size_pos - size_prev_pos );
vecDest.push_back(strTemp);
size_prev_pos = ++size_pos;
MessageBox(NULL, strTemp.c_str(), L"", 0);
}
}
unsigned _stdcall ThreadProc(void* param)
{
return 0;
}
extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
{
if (notifyCode->nmhdr.code == SCN_MODIFIED && bReady)
// if (notifyCode->line)
{
if (_goToLine.dlg)
{
CButton check;
HWND hwndCheck = ::GetDlgItem(_goToLine.dlg->m_hWnd, IDC_CHECK_LIVE_PREVIEW);
check.Attach(hwndCheck);
BOOL bCheck = check.GetCheck();
if (!bCheck)
{
return;
}
_goToLine.dlg->Tans();
}
}
}
// Here you can process the Npp Messages
// I will make the messages accessible little by little, according to the need of plugin development.
// Please let me know if you need to access to some messages :
// http://sourceforge.net/forum/forum.php?forum_id=482781
//
extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam, LPARAM lParam)
{/*
if (Message == WM_MOVE)
{
::MessageBox(NULL, "move", "", MB_OK);
}
*/
return TRUE;
}
#ifdef UNICODE
extern "C" __declspec(dllexport) BOOL isUnicode()
{
return TRUE;
}
#endif