├── .github
├── FUNDING.yml
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── .gitignore
├── Capture.JPG
├── GPL_and_Commercial.txt
├── Highlighter.sln
├── LoadLib.test.js
├── Readme.md
├── Release
├── Win32
│ └── Npp-Highlighter.dll
└── x64
│ └── Npp-Highlighter.dll
├── Sci_Position.h
├── VersionInfo.h
├── VersionInfo_tmpl.h
├── appveyor.yml
├── build.xml
├── common
├── AcceleratorHook.cpp
├── AcceleratorHook.h
├── AcceleratorTable.h
├── ActiveScriptSiteDebug.cpp
├── ActiveScriptSiteDebug.h
├── ComBase.h
├── Dialog
│ ├── Dialog.cpp
│ ├── Dialog.h
│ ├── MDocHostUIHandler.cpp
│ ├── MDocHostUIHandler.h
│ ├── MOleClientSite.cpp
│ ├── MOleClientSite.h
│ ├── MOleInPlaceFrame.cpp
│ ├── MOleInPlaceFrame.h
│ ├── MOleInPlaceSite.cpp
│ ├── MOleInPlaceSite.h
│ ├── WindowClass.cpp
│ └── WindowClass.h
├── ForegroundIdleHook.cpp
├── ForegroundIdleHook.h
├── LastError.cpp
├── LastError.h
├── Library.cpp
├── Library.h
├── Menu.cpp
├── Menu.h
├── MessageOnlyWindow.h
├── MyActiveSite.cpp
├── MyActiveSite.h
├── ScriptedIdleHandler.cpp
├── ScriptedIdleHandler.h
├── Scripting
│ ├── Dispex.h
│ ├── EULA.txt
│ ├── HostInfo.h
│ ├── Multinfo.h
│ ├── Readme.txt
│ ├── activdbg.h
│ ├── activdbg_.h
│ ├── activscp.h
│ ├── ad1ex.h
│ └── dbgprop.h
├── Statics.cpp
├── Statics.h
├── SysStr.h
├── System.cpp
├── System.h
├── Timer.cpp
├── Timer.h
└── common.idl
├── editor
├── DockableDialog.cpp
├── DockableDialog.h
├── Editor.cpp
├── Editor.h
├── editor.idl
└── view
│ ├── EditorView.cpp
│ ├── EditorView.h
│ ├── IndicatorPanel.cpp
│ ├── IndicatorPanel.h
│ ├── SCIView.cpp
│ ├── SCIView.h
│ ├── ViewLine.cpp
│ ├── ViewLine.h
│ ├── ViewLines.cpp
│ └── ViewLines.h
├── jN.9.sln
├── jN.bmp
├── jN.cpp
├── jN.ico
├── jN.vcproj
├── jN.vcxproj
├── jN.vcxproj.filters
├── jN.vcxproj.user
├── npp
├── Docking.h
├── Notepad_plus_msgs.h
├── PluginDefinition.cpp
├── PluginDefinition.h
├── PluginInterface.h
├── Scintilla.h
├── dockingResource.h
└── menuCmdID.h
├── readme.txt
├── res.rc
└── resource.h
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: paypal.me/kremereugen
13 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Environment**
27 | - OS: [e.g. Win7, Win10]
28 | - OS Arch: [x64, x86]
29 | - Notepad++ Version
30 | - Notepad+ Arch: [x64, x86]
31 | - jN Version [e.g. 22]
32 |
33 | **Additional context**
34 | Add any other context about the problem here.
35 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] or consider the job you are trying to solve.
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /deploy/\[Notepad++ Directory\]/plugins/jN.dll
2 | /deploy/*.zip
3 | Debug
4 | /*.ncb
5 | /Interfaces.h
6 | /editor_i.c
7 | /jN.9.suo
8 | /jN.vcproj.Emilie-PC.Emilie.user
9 | /project.tlb
10 | /.vs
11 | /*.opensdf
12 | /Release/Highlighter.tlog
13 | /Release/jN.tlog
14 | *.obj
15 | *.iobj
16 | *.ipdb
17 | /Release/vc142.pdb
18 | /Release/res.res
19 | /Release/jN.vcxproj.FileListAbsolute.txt
20 | /Release/jN.pdb
21 | /Release/jN.log
22 | /Release/jN.lib
23 | /Release/jN.exp
24 | /Release/jN.dll.recipe
25 | /Release/jN.Build.CppClean.log
26 | /Release/Highlighter.pdb
27 | /Release/Highlighter.lib
28 | /Release/Highlighter.exp
29 | /Release/Highlighter.dll.recipe
30 |
--------------------------------------------------------------------------------
/Capture.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michaelxzhang/Npp-Highlighter/7d4cc7bccdccd1528f022749fe2b0d1bd0f3ad44/Capture.JPG
--------------------------------------------------------------------------------
/GPL_and_Commercial.txt:
--------------------------------------------------------------------------------
1 | Copyright (C)2013 Eugen Kremer
2 |
3 | This program is free software: you can redistribute it and/or modify
4 | it under the terms of the GNU General Public License as published by
5 | the Free Software Foundation, either version 3 of the License, or
6 | (at your option) any later version.
7 |
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 |
13 | You should have received a copy of the GNU General Public License
14 | along with this program. If not, see .
15 |
16 |
17 |
18 |
19 | Using of Common part of jN in non-GPL applications
20 | _______________________________________________________________________________
21 |
22 | A commercial license to Common part of jN provides you the legal means
23 | both to modify it and to incorporate it into a product, without the obligation
24 | of providing the resulting code under the GPL license. Fees vary depending on
25 | the application and the scale of its use. For more information about licensing,
26 | please contact me at eugen DOT kremer AT gmail DOT com
27 |
--------------------------------------------------------------------------------
/Highlighter.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31410.357
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Npp-Highlighter", "jN.vcxproj", "{1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Debug|x64.ActiveCfg = Debug|Win32
17 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Debug|x86.ActiveCfg = Debug|Win32
18 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Debug|x86.Build.0 = Debug|Win32
19 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Release|x64.ActiveCfg = Release|x64
20 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Release|x64.Build.0 = Release|x64
21 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Release|x86.ActiveCfg = Release|Win32
22 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Release|x86.Build.0 = Release|Win32
23 | EndGlobalSection
24 | GlobalSection(SolutionProperties) = preSolution
25 | HideSolutionNode = FALSE
26 | EndGlobalSection
27 | GlobalSection(ExtensibilityGlobals) = postSolution
28 | SolutionGuid = {1EC8B4E4-C628-4D3D-8F8A-1E155157536F}
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------
/LoadLib.test.js:
--------------------------------------------------------------------------------
1 | var Types = {
2 | DWord : 4,
3 | Word : 2,
4 | BOOL : 'DWord',
5 | BSTR : 'DWord',
6 | DWORD : 'DWord',
7 | HWND : 'DWord',
8 | HANDLE:'DWord',
9 | HINSTANCE : 'DWord',
10 | LPCTSTR : 'BSTR',
11 | UINT : 'DWord',
12 | LPPROC:'DWord',
13 | LPARAM :'DWord',
14 | 'int' : 'DWord',
15 | 'void': 0,
16 | GetSimple:function(name){
17 | var ft = this[name];
18 | if (typeof(ft) == 'number')
19 | return name;
20 |
21 | if (ft == null)
22 | throw "Unknown type: '"+name+"'";
23 |
24 | return this.GetSimple(ft);
25 | },
26 | GetSize:function(name){
27 | var ft = this[this.GetSimple(name)];
28 |
29 | return ft;
30 | },
31 | Register:function(name, cfg){ // cfg = {name1:"type1", name2:"type2"}
32 | if (!this.Register.complex)
33 | this.Register.complex = {};
34 |
35 | if ( this[name])
36 | throw "Type exists: '"+name+"'";
37 |
38 |
39 | this.Register.complex[name] = cfg;
40 | this[name] = 'LPCTSTR';
41 | }
42 | };
43 |
44 | function Library(path){
45 | var lib = loadLibrary(path);
46 | this.lib =lib;
47 |
48 | var BufSize = function (formals){
49 | var result = 0;
50 | for(var i=2, c=formals.length; i
7 | // The License.txt file describes the conditions under which this software may be distributed.
8 |
9 | #ifndef SCI_POSITION_H
10 | #define SCI_POSITION_H
11 |
12 | #include
13 |
14 | // Basic signed type used throughout interface
15 | typedef ptrdiff_t Sci_Position;
16 |
17 | // Unsigned variant used for ILexer::Lex and ILexer::Fold
18 | typedef size_t Sci_PositionU;
19 |
20 | // For Sci_CharacterRange which is defined as long to be compatible with Win32 CHARRANGE
21 | typedef long Sci_PositionCR;
22 |
23 | #ifdef _WIN32
24 | #define SCI_METHOD __stdcall
25 | #else
26 | #define SCI_METHOD
27 | #endif
28 |
29 | #endif
--------------------------------------------------------------------------------
/VersionInfo.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of jN, a plugin for Notepad++
3 | Copyright (C)2017 Eugen Kremer
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #define VERSION_MA 1
20 | #define VERSION_MI 0
21 |
22 | // increment revision in case of modification
23 | #define REVISION 0
24 | #define xstr(s) str(s)
25 | #define str(s) #s
26 | #define _VERSION_STR VERSION_MA ## . ## REVISION
27 |
28 |
--------------------------------------------------------------------------------
/VersionInfo_tmpl.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of jN, a plugin for Notepad++
3 | Copyright (C)2013 Eugen Kremer
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #define VERSION_MA 1
20 | #define VERSION_MI 0
21 |
22 | // increment revision in case of modification
23 | #define REVISION $WCREV$
24 | #define xstr(s) str(s)
25 | #define str(s) #s
26 | #define _VERSION_STR VERSION_MA ## . ## REVISION
27 |
28 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: 2.2.185.{build}
2 | image: Visual Studio 2017
3 |
4 |
5 | environment:
6 | matrix:
7 | - PlatformToolset: v140_xp
8 | - PlatformToolset: v141_xp
9 |
10 | platform:
11 | - x64
12 | - Win32
13 |
14 | configuration:
15 | - Release
16 | - Debug
17 |
18 | install:
19 | - if "%platform%"=="x64" set archi=amd64
20 | - if "%platform%"=="x64" set platform_input=x64
21 |
22 | - if "%platform%"=="Win32" set archi=x86
23 | - if "%platform%"=="Win32" set platform_input=x86
24 |
25 | - if "%PlatformToolset%"=="v140_xp" call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %archi%
26 | - if "%PlatformToolset%"=="v141_xp" call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" %archi%
27 |
28 | build_script:
29 | - cd "%APPVEYOR_BUILD_FOLDER%"
30 | - msbuild jN.vcxproj /p:configuration="%configuration%" /p:platform="%platform_input%" /p:PlatformToolset="%PlatformToolset%" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
31 |
32 | after_build:
33 | - cd "%APPVEYOR_BUILD_FOLDER%"
34 | - ps: >-
35 |
36 | if ($env:PLATFORM_INPUT -eq "x64") {
37 | Push-AppveyorArtifact "$env:PLATFORM\$env:CONFIGURATION\jN.dll" -FileName jN.dll
38 | }
39 |
40 | if ($env:PLATFORM_INPUT -eq "x86" ) {
41 | Push-AppveyorArtifact "$env:CONFIGURATION\jN.dll" -FileName jN.dll
42 | }
43 |
44 | if ($($env:APPVEYOR_REPO_TAG) -eq "true" -and $env:CONFIGURATION -eq "Release" -and $env:PLATFORMTOOLSET -eq "v140_xp") {
45 | $ZipFileName = "jN_$($env:APPVEYOR_REPO_TAG_NAME)_$($env:PLATFORM_INPUT).zip"
46 | $JnDllPath = ""
47 |
48 | if($env:PLATFORM_INPUT -eq "x64"){
49 | $JnDllPath = "$env:PLATFORM\$env:CONFIGURATION\*.dll"
50 | }
51 | if($env:PLATFORM_INPUT -eq "x86"){
52 | $JnDllPath = "$env:CONFIGURATION\*.dll"
53 | }
54 | if($ZipFileName -ne ""){
55 | $ZipFileName = "..\" + $ZipFileName
56 | copy $JnDllPath ".\deploy\"
57 | cd .\deploy
58 | 7z a $ZipFileName *
59 | }
60 | }
61 |
62 | artifacts:
63 | - path: jN_*.zip
64 | name: releases
65 |
66 | deploy:
67 | provider: GitHub
68 | auth_token:
69 | secure: EHciC6DIkOPXC2qWw4tnn7Q95AeBqXun6w4YVjFm0GZ1PLVZAzpUh85N50eCnNtC
70 | artifact: releases
71 | draft: false
72 | prerelease: false
73 | force_update: true
74 | on:
75 | appveyor_repo_tag: true
76 | PlatformToolset: v140_xp
77 | configuration: Release
78 |
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/common/AcceleratorHook.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of jN, a plugin for Notepad++
3 | Copyright (C)2013 Eugen Kremer
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #include
20 | #include "AcceleratorHook.h"
21 |
22 | LRESULT CALLBACK AcceleratorHook::Handler( int code, WPARAM wParam, LPARAM lParam ){
23 | AcceleratorHook* instance = AcceleratorHook::getInstance();
24 |
25 | MSG* msg = (MSG*)lParam;
26 |
27 | if (msg && code == HC_ACTION){
28 | bool q = msg->message == WM_QUIT;
29 |
30 | EnterCriticalSection(&instance->m_CriticalSection);
31 | for(Handlers::iterator it=instance->m_Handlers.begin(); it!=instance->m_Handlers.end(); ++it){
32 | AcceleratorHandler* handler = *it;
33 | if (handler->execute(msg)){
34 | msg->message = WM_NULL;
35 | break;
36 | }
37 | }
38 | LeaveCriticalSection(&instance->m_CriticalSection);
39 | }
40 |
41 | return CallNextHookEx(instance->m_Hook, code, wParam, lParam);
42 | }
43 |
44 | AcceleratorHook::AcceleratorHook(){
45 |
46 | InitializeCriticalSection(&m_CriticalSection);
47 |
48 | m_Hook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC) Handler, 0, GetCurrentThreadId());
49 |
50 | }
51 | AcceleratorHook::~AcceleratorHook(){
52 | UnhookWindowsHookEx(m_Hook);
53 |
54 | DeleteCriticalSection(&m_CriticalSection);
55 | }
56 |
57 | AcceleratorHook* AcceleratorHook::getInstance(){
58 | static AcceleratorHook instance;
59 |
60 | return &instance;
61 | }
62 |
63 | void AcceleratorHook::remove(AcceleratorHandler* h){
64 | EnterCriticalSection(&m_CriticalSection);
65 |
66 | m_Handlers.erase(h);
67 |
68 | LeaveCriticalSection(&m_CriticalSection);
69 | }
70 |
71 | void AcceleratorHook::add(AcceleratorHandler* h){
72 | EnterCriticalSection(&m_CriticalSection);
73 |
74 | if (h)
75 | m_Handlers.insert(h);
76 |
77 | LeaveCriticalSection(&m_CriticalSection);
78 | }
79 |
--------------------------------------------------------------------------------
/common/AcceleratorHook.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of jN, a plugin for Notepad++
3 | Copyright (C)2013 Eugen Kremer
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 | #pragma once
19 |
20 | #include
21 | #include
22 |
23 | // hook Message befor npp receive it
24 | // try to translate accelerator and if was translated
25 | // say npp to do nothing
26 |
27 | class AcceleratorHook{
28 | private:
29 | HHOOK m_Hook;
30 | CRITICAL_SECTION m_CriticalSection;
31 |
32 | static LRESULT CALLBACK Handler( int code, WPARAM wParam, LPARAM lParam );
33 |
34 | AcceleratorHook();
35 | ~AcceleratorHook();
36 |
37 | public:
38 | class AcceleratorHandler{
39 | public:
40 | virtual int execute(MSG* msg){
41 | // overload this method
42 | return 0;
43 | }
44 | };
45 |
46 | static AcceleratorHook* getInstance();
47 |
48 | void remove(AcceleratorHandler* h);
49 |
50 | void add(AcceleratorHandler* h);
51 |
52 | private:
53 | typedef std::set Handlers;
54 | Handlers m_Handlers;
55 |
56 | };
57 |
--------------------------------------------------------------------------------
/common/AcceleratorTable.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of jN, a plugin for Notepad++
3 | Copyright (C)2013 Eugen Kremer
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 | #pragma once
19 | #include
20 |
21 | #include "AcceleratorHook.h"
22 | #include "MessageOnlyWindow.h"
23 |
24 | class CAcceleratorTable: public AcceleratorHook::AcceleratorHandler, private MessageOnlyWindow{
25 | LRESULT MessageProc(UINT message, WPARAM wp, LPARAM lp) override{
26 | switch(message){
27 | case WM_HOTKEY:
28 | break;
29 | case WM_COMMAND:{
30 | CallHandler(LOWORD(wp));
31 | }
32 | }
33 |
34 | return MessageOnlyWindow::MessageProc(message, wp, lp);
35 | }
36 |
37 | public:
38 |
39 |
40 | class Accelerator{
41 | public:
42 | virtual int execute(){
43 | return 0;
44 | }
45 | };
46 |
47 | typedef std::vector ACCELS;
48 | ACCELS m_HotKeyArray;
49 |
50 | typedef std::vector Accelerators;
51 | Accelerators m_Accelerators;
52 |
53 | HACCEL m_HotKeyTable;
54 | HWND m_Window;
55 |
56 | CAcceleratorTable(HWND window){
57 | m_HotKeyTable = NULL;
58 | m_Window = window;
59 | }
60 |
61 | ~CAcceleratorTable(){
62 | destroyTable();
63 |
64 | for(size_t i=0, c=m_Accelerators.size(); i= (int)m_Accelerators.size())
105 | return 0;
106 |
107 | int result = m_Accelerators[command]->execute();
108 |
109 | return result;
110 | }
111 | };
112 |
--------------------------------------------------------------------------------
/common/ActiveScriptSiteDebug.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of jN, a plugin for Notepad++
3 | Copyright (C)2013 Eugen Kremer
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 | #include "ActiveScriptSiteDebug.h"
19 | #include
20 | #include "SysStr.h"
21 |
22 | class ActiveScriptSiteDebugExImpl : public CComBase{
23 | public:
24 | virtual HRESULT STDMETHODCALLTYPE OnCanNotJITScriptErrorDebug(IActiveScriptErrorDebug *pErrorDebug, BOOL *pfCallOnScriptErrorWhenContinuing){
25 | *pfCallOnScriptErrorWhenContinuing = true;
26 | return S_OK;
27 | }
28 | };
29 |
30 | class DebugDocumentHostImpl : public CComBase{
31 | private:
32 | SysStr m_FilePath;
33 | LocRef m_ActiveScriptDebug;
34 | public:
35 | DebugDocumentHostImpl(const BSTR filePath, IActiveScriptDebug* activeScriptDebug):m_FilePath(filePath), m_ActiveScriptDebug(activeScriptDebug){
36 | }
37 | virtual HRESULT STDMETHODCALLTYPE GetDeferredText(
38 | /* [in] */ DWORD dwTextStartCookie,
39 | /* [size_is][length_is][out][in] */ __RPC__inout_ecount_part(cMaxChars, *pcNumChars) WCHAR *pcharText,
40 | /* [size_is][length_is][out][in] */ __RPC__inout_ecount_part(cMaxChars, *pcNumChars) SOURCE_TEXT_ATTR *pstaTextAttr,
41 | /* [out][in] */ __RPC__inout ULONG *pcNumChars,
42 | /* [in] */ ULONG cMaxChars){
43 | return E_NOTIMPL;
44 | }
45 |
46 | virtual HRESULT STDMETHODCALLTYPE GetScriptTextAttributes(
47 | /* [size_is][in] */ __RPC__in_ecount_full(uNumCodeChars) LPCOLESTR pstrCode,
48 | /* [in] */ ULONG uNumCodeChars,
49 | /* [in] */ __RPC__in LPCOLESTR pstrDelimiter,
50 | /* [in] */ DWORD dwFlags,
51 | /* [size_is][out][in] */ __RPC__inout_ecount_full(uNumCodeChars) SOURCE_TEXT_ATTR *pattr){
52 |
53 | if (!m_ActiveScriptDebug)
54 | return E_NOTIMPL;
55 |
56 | return m_ActiveScriptDebug->GetScriptTextAttributes(pstrCode, uNumCodeChars, pstrDelimiter, dwFlags, pattr);
57 | }
58 |
59 | virtual HRESULT STDMETHODCALLTYPE OnCreateDocumentContext(IUnknown **ppunkOuter){
60 | return E_NOTIMPL;
61 | }
62 |
63 | virtual HRESULT STDMETHODCALLTYPE GetPathName(BSTR *pbstrLongName, BOOL *pfIsOriginalFile){
64 | *pfIsOriginalFile = true;
65 | *pbstrLongName = SysAllocString(m_FilePath);
66 | return S_OK;
67 | }
68 |
69 | virtual HRESULT STDMETHODCALLTYPE GetFileName(BSTR *pbstrShortName){
70 | *pbstrShortName = SysAllocString(PathFindFileName(m_FilePath));
71 | return (*pbstrShortName == NULL)? E_FAIL : S_OK;
72 | }
73 |
74 | virtual HRESULT STDMETHODCALLTYPE NotifyChanged(){
75 | return E_NOTIMPL;
76 | }
77 | };
78 |
79 |
80 | ActiveScriptSiteDebug::ActiveScriptSiteDebug(TCHAR *appName, IActiveScript* as):m_ActiveScript(as){
81 |
82 | if (FAILED(CoCreateInstance(
83 | CLSID_ProcessDebugManager, NULL,
84 | CLSCTX_INPROC_SERVER | /*CLSCTX_INPROC_HANDLER |*/ CLSCTX_LOCAL_SERVER,
85 | __uuidof(IProcessDebugManager), (void **)m_Pdm)))
86 | throw TEXT("PDM creation failed");
87 |
88 | if (FAILED(m_Pdm->CreateApplication(&m_App)))
89 | throw TEXT("Debug application creation failed");
90 |
91 | HRESULT res = m_App->SetName(appName);
92 |
93 | if (FAILED(m_Pdm->AddApplication(m_App, &m_AppCookie)))
94 | throw TEXT("Debug application adding failed");
95 | }
96 |
97 | ActiveScriptSiteDebug::~ActiveScriptSiteDebug(){
98 | for(Docs::const_iterator it=m_Docs.begin(); it!=m_Docs.end(); ++it){
99 | it->second->Detach();
100 | it->second->Release();
101 | }
102 |
103 | if (FAILED(m_Pdm->RemoveApplication(m_AppCookie)))
104 | throw "Debug application removing failed";
105 |
106 | if (m_App)
107 | m_App->Close();
108 |
109 | }
110 |
111 | DWORD ActiveScriptSiteDebug::AddScript(BSTR script, BSTR name){
112 | IDebugDocumentHelper* doc;
113 | m_Pdm->CreateDebugDocumentHelper(NULL, &doc);
114 |
115 | if (!doc)
116 | return 0;
117 |
118 | DWORD scriptAttr = 0;
119 | TCHAR buf[100];
120 | if (name == 0){
121 | StringCbPrintf(buf, sizeof(buf) , TEXT("local_%d.js"), doc);
122 | name = buf;
123 | scriptAttr = TEXT_DOC_ATTR_READONLY;
124 | }
125 |
126 | HRESULT res;
127 |
128 | res = doc->Init(m_App, name, name, scriptAttr);
129 | res = doc->Attach(NULL);
130 |
131 | res = doc->SetDocumentAttr(scriptAttr);
132 |
133 | // Syntax highlighting via script engine and right file names
134 | LocRef asd;
135 | if ((res = m_ActiveScript->QueryInterface(__uuidof(IActiveScriptDebug), (void**)asd))==S_OK){
136 | LocRef ddh(new DebugDocumentHostImpl(name, asd));
137 | res = doc->SetDebugDocumentHost(ddh);
138 | }
139 |
140 | res = doc->AddUnicodeText(script);
141 |
142 | DWORD_PTR srcContext = 0;
143 | res = doc->DefineScriptBlock(0, SysStringLen(script), m_ActiveScript, false, &srcContext);
144 |
145 | m_Docs.insert(Docs::value_type(srcContext, doc));
146 |
147 | return srcContext;
148 | }
149 |
150 | HRESULT ActiveScriptSiteDebug::GetApplication(IDebugApplication **ppda){
151 | if (!ppda)
152 | return E_POINTER;
153 |
154 | *ppda = static_cast(m_App);
155 | (*ppda)->AddRef();
156 |
157 | return S_OK;
158 | }
159 |
160 | HRESULT ActiveScriptSiteDebug::GetDocumentContextFromPosition(DWORD_PTR dwSourceContext, ULONG uCharacterOffset, ULONG uNumChars, IDebugDocumentContext **ppsc){
161 | if (!ppsc)
162 | return E_POINTER;
163 |
164 | *ppsc = NULL;
165 |
166 | IDebugDocumentHelper* doc = GetDocumentFromContext(dwSourceContext);
167 | if (doc == NULL)
168 | return E_UNEXPECTED;
169 |
170 | // every running document has a special "cookie" associated with it.
171 | // this code assumes only 1 document with a cookie value stored in
172 | // m_dwDocCookie. It then asks the helper interface IDebugDocumentHelper
173 | // to convert from a character offset to a document context interface.
174 | ULONG ulStartPos=0;
175 | HRESULT hr = doc->GetScriptBlockInfo(dwSourceContext,NULL,&ulStartPos,NULL);
176 | if ( SUCCEEDED(hr) )
177 | return doc->CreateDebugDocumentContext( ulStartPos + uCharacterOffset, uNumChars, ppsc);
178 |
179 | return hr;
180 | }
181 |
182 | IDebugDocumentHelper* ActiveScriptSiteDebug::GetDocumentFromContext(DWORD_PTR dwSourceContext) {
183 | Docs::iterator it = m_Docs.find(dwSourceContext);
184 | if (it == m_Docs.end())
185 | return NULL;
186 |
187 | return it->second;
188 | }
189 |
190 | HRESULT ActiveScriptSiteDebug::GetRootApplicationNode(IDebugApplicationNode **ppdanRoot){
191 | if (!ppdanRoot)
192 | return E_POINTER;
193 |
194 | *ppdanRoot = NULL;
195 |
196 | return S_OK;
197 | }
198 |
199 | HRESULT ActiveScriptSiteDebug::OnScriptErrorDebug(IActiveScriptErrorDebug *pErrorDebug, BOOL *pfEnterDebugger, BOOL *pfCallOnScriptErrorWhenContinuing){
200 | *pfEnterDebugger=FALSE;
201 | *pfCallOnScriptErrorWhenContinuing=TRUE;
202 | return S_OK;
203 | }
204 |
205 | HRESULT ActiveScriptSiteDebug::QueryInterface(REFIID riid, LPVOID *ppv){
206 | if (S_OK == CComBase::QueryInterface(riid, ppv))
207 | return S_OK;
208 |
209 |
210 | if (IsEqualIID(riid, __uuidof(IActiveScriptSiteDebugEx))){
211 | LocRef debEx(new ActiveScriptSiteDebugExImpl());
212 | return debEx->QueryInterface(riid, ppv);
213 | }
214 |
215 | return E_NOINTERFACE;
216 | }
217 |
--------------------------------------------------------------------------------
/common/ActiveScriptSiteDebug.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of jN, a plugin for Notepad++
3 | Copyright (C)2013 Eugen Kremer
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 | #pragma once
19 |
20 | #include
21 | #include