├── .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 22 | 23 | #include "combase.h" 24 | #include "Scripting\activdbg.h" 25 | 26 | 27 | class ActiveScriptSiteDebug : public CComBase 28 | { 29 | private: 30 | LocRef m_ActiveScript; 31 | LocRef m_Pdm; // because of permanent deadlocks 32 | LocRef m_App; // make them without LocRef 33 | DWORD m_AppCookie; 34 | typedef std::map Docs; 35 | Docs m_Docs; 36 | public: 37 | virtual HRESULT __stdcall QueryInterface(REFIID riid, LPVOID *ppv); 38 | 39 | #pragma region IActiveScriptSiteDebug 40 | HRESULT STDMETHODCALLTYPE GetDocumentContextFromPosition( 41 | DWORD_PTR dwSourceContext, 42 | ULONG uCharacterOffset, 43 | ULONG uNumChars, 44 | IDebugDocumentContext** ppsc); 45 | 46 | HRESULT STDMETHODCALLTYPE GetApplication(IDebugApplication** ppda); 47 | 48 | HRESULT STDMETHODCALLTYPE GetRootApplicationNode(IDebugApplicationNode** ppdanRoot); 49 | 50 | HRESULT STDMETHODCALLTYPE OnScriptErrorDebug( 51 | IActiveScriptErrorDebug* pErrorDebug, 52 | BOOL* pfEnterDebugger, 53 | BOOL* pfCallOnScriptErrorWhenContinuing); 54 | #pragma endregion 55 | 56 | DWORD AddScript(BSTR script, BSTR name); 57 | 58 | IDebugDocumentHelper* GetDocumentFromContext(DWORD_PTR dwSourceContext); 59 | 60 | ActiveScriptSiteDebug(TCHAR* appName, IActiveScript* as); 61 | ~ActiveScriptSiteDebug(); 62 | }; 63 | -------------------------------------------------------------------------------- /common/ComBase.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 | #pragma once 20 | #include 21 | #include 22 | 23 | #include "Statics.h" 24 | 25 | #pragma warning(disable : 4250) 26 | 27 | 28 | template 29 | class LocRef{ 30 | public: 31 | T* m_Reference; 32 | LocRef(T* val){ 33 | m_Reference = val; 34 | if(Increment && m_Reference) 35 | m_Reference->AddRef(); 36 | } 37 | LocRef():m_Reference(NULL){ 38 | 39 | } 40 | ~LocRef(){ 41 | if (m_Reference) 42 | m_Reference->Release(); 43 | } 44 | 45 | template 46 | void CopyTo(C p){ 47 | *p = *static_cast(&m_Reference); 48 | if (m_Reference) 49 | m_Reference->AddRef(); 50 | } 51 | 52 | operator void**(){ 53 | // release existing reference 54 | if(m_Reference){ 55 | m_Reference->Release(); 56 | m_Reference = NULL; 57 | } 58 | 59 | return (void**)&m_Reference; 60 | } 61 | 62 | operator bool(){ 63 | return m_Reference != NULL; 64 | } 65 | 66 | operator T*(){ 67 | return m_Reference; 68 | } 69 | T* operator-> () { return m_Reference; } 70 | T** operator& () { return &m_Reference; } 71 | }; 72 | // class for single threaded Objects that uses c++ increment and decrement operators for reference 73 | // count purposes .. 74 | // 75 | class CSingleThreaded 76 | { 77 | public: 78 | static STDMETHODIMP_(ULONG) Increment(long &reflong) 79 | { 80 | reflong ++; 81 | return reflong; 82 | } 83 | 84 | static STDMETHODIMP_(ULONG) Decrement(long &reflong) 85 | { 86 | reflong --; 87 | return reflong; 88 | } 89 | }; 90 | 91 | // class for multi threaded Objects that uses Win32 API for reference 92 | // count purposes .. 93 | // 94 | class CMultiThreaded 95 | { 96 | public: 97 | static STDMETHODIMP_(ULONG) Increment(long &reflong) 98 | { 99 | ::InterlockedIncrement(&reflong); 100 | return reflong; 101 | } 102 | 103 | static STDMETHODIMP_(ULONG) Decrement(long &reflong) 104 | { 105 | ::InterlockedDecrement(&reflong); 106 | return reflong; 107 | } 108 | }; 109 | 110 | template 111 | class QI1 : public Interface{ 112 | public: 113 | typedef Interface InterfaceType; 114 | protected: 115 | virtual HRESULT Query(REFIID riid, LPVOID *ppv){ 116 | *ppv = NULL; 117 | 118 | if(IsEqualIID(riid, IID_IUnknown)){ 119 | *ppv = static_cast(this); 120 | }else if (IsEqualIID(riid, __uuidof(Interface))){ 121 | *ppv = static_cast(this); 122 | }else 123 | return E_NOINTERFACE; 124 | 125 | return S_OK; 126 | } 127 | }; 128 | 129 | class Empty{ 130 | 131 | }; 132 | 133 | template class QI2: public virtual I1, public virtual I2{ 134 | protected: 135 | HRESULT Query(REFIID riid, LPVOID *ppv){ 136 | *ppv = NULL; 137 | 138 | if (IsEqualIID(riid, __uuidof(I2))){ 139 | *ppv = static_cast(this); 140 | }else if ( IsEqualIID(riid, __uuidof(I1))){ 141 | *ppv = static_cast(this); 142 | }else 143 | return E_NOINTERFACE; 144 | 145 | return S_OK; 146 | } 147 | }; 148 | 149 | 150 | 151 | // this mandatory class manages the life of the COM object it uses a perticular threading model 152 | // for reference count management.. 153 | // 154 | template > 155 | class CComBase : public CInterface 156 | { 157 | protected: 158 | long m_cRef; 159 | 160 | public: 161 | CComBase() { 162 | m_cRef = 1; 163 | }; 164 | 165 | virtual ~CComBase(){ 166 | } 167 | virtual HRESULT __stdcall QueryInterface(REFIID riid, LPVOID *ppv){ 168 | *ppv = NULL; 169 | 170 | if (CInterface::Query(riid, ppv) == S_OK){ 171 | 172 | }else 173 | return E_NOINTERFACE; 174 | 175 | 176 | AddRef(); 177 | 178 | return S_OK; 179 | } 180 | 181 | virtual STDMETHODIMP_(ULONG) AddRef() 182 | { 183 | return ThreadModel::Increment(m_cRef); 184 | } 185 | virtual STDMETHODIMP_(ULONG) Release() 186 | { 187 | long Value = ThreadModel::Decrement(m_cRef); 188 | if(!m_cRef) 189 | delete this; 190 | 191 | return Value; 192 | } 193 | }; 194 | 195 | 196 | template > 197 | class CComDispatch : public CComBase 198 | { 199 | protected: 200 | LocRef m_TypeLib; 201 | public: 202 | CComDispatch(): m_TypeLib(Statics::instance().GetTypeLib()){ 203 | } 204 | virtual ~CComDispatch(){ 205 | } 206 | 207 | HRESULT __stdcall QueryInterface(REFIID riid, LPVOID *ppv){ 208 | 209 | *ppv = NULL; 210 | 211 | if (CImplementInt::Query(riid, ppv)== S_OK){ 212 | } else if (IsEqualIID(riid,IID_IDispatch)) 213 | *ppv = static_cast(this); 214 | else 215 | return E_NOINTERFACE; 216 | 217 | AddRef(); 218 | 219 | return S_OK; 220 | } 221 | 222 | // IDispatch standard 223 | 224 | 225 | virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount( 226 | /* [out] */ __RPC__out UINT *pctinfo){ 227 | *pctinfo = 1; 228 | return S_OK; 229 | } 230 | 231 | virtual HRESULT STDMETHODCALLTYPE GetTypeInfo( 232 | /* [in] */ UINT iTInfo, 233 | /* [in] */ LCID lcid, 234 | /* [out] */ __RPC__deref_out_opt ITypeInfo **ppTInfo){ 235 | 236 | if (iTInfo != 0) 237 | return DISP_E_BADINDEX; 238 | 239 | HRESULT res = m_TypeLib->GetTypeInfoOfGuid(__uuidof(DispInterface), ppTInfo); 240 | 241 | return res; 242 | } 243 | 244 | virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames( 245 | /* [in] */ __RPC__in REFIID riid, 246 | /* [size_is][in] */ __RPC__in_ecount_full(cNames) LPOLESTR *rgszNames, 247 | /* [range][in] */ UINT cNames, 248 | /* [in] */ LCID lcid, 249 | /* [size_is][out] */ __RPC__out_ecount_full(cNames) DISPID *rgDispId){ 250 | 251 | LocRef typeInfo; 252 | m_TypeLib->GetTypeInfoOfGuid(__uuidof(DispInterface), &typeInfo); 253 | 254 | HRESULT res = DispGetIDsOfNames(typeInfo, rgszNames, cNames, rgDispId); 255 | return res; 256 | } 257 | 258 | virtual /* [local] */ HRESULT STDMETHODCALLTYPE Invoke( 259 | /* [in] */ DISPID dispIdMember, 260 | /* [in] */ REFIID riid, 261 | /* [in] */ LCID lcid, 262 | /* [in] */ WORD wFlags, 263 | /* [out][in] */ DISPPARAMS *pDispParams, 264 | /* [out] */ VARIANT *pVarResult, 265 | /* [out] */ EXCEPINFO *pExcepInfo, 266 | /* [out] */ UINT *puArgErr){ 267 | 268 | LocRef typeInfo; 269 | m_TypeLib->GetTypeInfoOfGuid(__uuidof(DispInterface), &typeInfo); 270 | 271 | HRESULT res = DispInvoke( 272 | static_cast(this),//this, 273 | typeInfo, 274 | dispIdMember, 275 | wFlags, 276 | pDispParams, 277 | pVarResult, 278 | pExcepInfo, 279 | puArgErr); 280 | 281 | return res; 282 | } 283 | 284 | template 285 | T* As(){ 286 | return static_cast(this); 287 | } 288 | }; 289 | 290 | -------------------------------------------------------------------------------- /common/Dialog/Dialog.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 | #include 21 | #include 22 | 23 | #include "..\lasterror.h" 24 | 25 | #include "..\MyActiveSite.h" 26 | #include "..\AcceleratorHook.h" 27 | 28 | #include "MDocHostUIHandler.h" 29 | #include "MOleClientSite.h" 30 | #include "MOleInPlaceFrame.h" 31 | #include "MOleInPlaceSite.h" 32 | 33 | #include "Interfaces.h" 34 | 35 | #include "WindowClass.h" 36 | #include "..\SysStr.h" 37 | 38 | class Dialog : virtual public CComDispatch, public AcceleratorHook::AcceleratorHandler 39 | { 40 | 41 | protected : 42 | HWND m_Parent; 43 | HWND m_Hwnd; 44 | 45 | virtual void BeforeCreate(); 46 | 47 | ATOM GetWindowClassAtom(); 48 | 49 | void destroy(); 50 | 51 | 52 | bool isCreated() const; 53 | 54 | bool isInParentChain(HWND parent, HWND child) const; 55 | 56 | int getWidth() const; 57 | 58 | int getHeight() const; 59 | 60 | int getClientHeight() const; 61 | 62 | int getClientWidth() const; 63 | 64 | void display(bool toShow = true) const; 65 | 66 | void goToCenter(); 67 | 68 | 69 | void create(); 70 | 71 | bool IsClosingAllowed(); 72 | 73 | 74 | static LRESULT CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); 75 | 76 | ScriptObj* m_Cfg; 77 | 78 | virtual LRESULT CALLBACK MessageProc(UINT message, WPARAM wParam, LPARAM lParam); 79 | 80 | /** PUBLIC */ 81 | public: 82 | 83 | IOleInPlaceActiveObject* m_ActiveObject; 84 | 85 | MOleClientSite m_OleClientSite; 86 | MOleInPlaceFrame m_OleInPlaceFrame; 87 | MOleInPlaceSite m_OleInPlaceSite; 88 | MDocHostUIHandler m_DocHostUIHandler; 89 | 90 | DWORD m_ExStyle; 91 | DWORD m_Style; 92 | 93 | HWND hwnd(){ 94 | return m_Hwnd; 95 | } 96 | 97 | Dialog(ScriptObj* cfg, HWND parent); 98 | 99 | ~Dialog(); 100 | 101 | void Init(); 102 | 103 | virtual void AfterCreate(); 104 | 105 | int execute(MSG* msg); 106 | 107 | void ReleaseBrowser(); 108 | 109 | 110 | #pragma region IDialog INTERFACE IMPLEMENTING 111 | 112 | HRESULT STDMETHODCALLTYPE get_visible( VARIANT_BOOL *result); 113 | 114 | HRESULT STDMETHODCALLTYPE put_visible( VARIANT_BOOL value); 115 | 116 | HRESULT STDMETHODCALLTYPE get_height( int *result); 117 | 118 | HRESULT STDMETHODCALLTYPE put_height( int value); 119 | 120 | HRESULT STDMETHODCALLTYPE get_width( int *result); 121 | 122 | HRESULT STDMETHODCALLTYPE put_width( int value); 123 | 124 | HRESULT STDMETHODCALLTYPE get_clientHeight( /* [retval][out] */ int *result); 125 | 126 | HRESULT STDMETHODCALLTYPE put_clientHeight( /* [in] */ int value); 127 | 128 | HRESULT STDMETHODCALLTYPE get_clientWidth(/* [retval][out] */ int *result); 129 | 130 | HRESULT STDMETHODCALLTYPE put_clientWidth( /* [in] */ int value); 131 | 132 | HRESULT STDMETHODCALLTYPE get_top( /* [retval][out] */ int *result); 133 | 134 | HRESULT STDMETHODCALLTYPE put_top( /* [in] */ int value); 135 | 136 | HRESULT STDMETHODCALLTYPE get_left( /* [retval][out] */ int *result); 137 | 138 | HRESULT STDMETHODCALLTYPE put_left( /* [in] */ int value); 139 | 140 | HRESULT STDMETHODCALLTYPE get_title( BSTR* result); 141 | 142 | HRESULT STDMETHODCALLTYPE put_title( BSTR* value); 143 | 144 | HRESULT STDMETHODCALLTYPE get_document( IDispatch **result); 145 | 146 | HRESULT STDMETHODCALLTYPE close(); 147 | 148 | HRESULT STDMETHODCALLTYPE get_handle(int *result); 149 | 150 | HRESULT STDMETHODCALLTYPE foreground(); 151 | 152 | #pragma endregion 153 | 154 | 155 | 156 | #pragma region BROWSER STUFF 157 | 158 | IOleObject* m_BrowserObject; 159 | IWebBrowser2* m_WebBrowser2; 160 | 161 | long EmbedBrowserObject(HWND hwnd) 162 | { 163 | LPCLASSFACTORY pClassFactory; 164 | RECT rect; 165 | 166 | pClassFactory = 0; 167 | if (!CoGetClassObject(CLSID_WebBrowser, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER, NULL, IID_IClassFactory, (void **)&pClassFactory) && pClassFactory) 168 | { 169 | // Call the IClassFactory's CreateInstance() to create a browser object 170 | if (!pClassFactory->CreateInstance(0, IID_IOleObject,(void **) &m_BrowserObject)) 171 | { 172 | // Free the IClassFactory. We need it only to create a browser object instance 173 | pClassFactory->Release(); 174 | 175 | // Give the browser a pointer to my IOleClientSite object 176 | if (!m_BrowserObject->SetClientSite((IOleClientSite *)&m_OleClientSite)) 177 | { 178 | m_BrowserObject->SetHostNames(L"HTML Based Dialog", 0); 179 | 180 | ::GetClientRect(m_Hwnd, &rect); 181 | 182 | // Let browser object know that it is embedded in an OLE container. 183 | if (!OleSetContainedObject((struct IUnknown *)m_BrowserObject, TRUE) && 184 | 185 | // Set the display area of our browser control the same as our window's size 186 | // and actually put the browser object into our window. 187 | !m_BrowserObject->DoVerb(OLEIVERB_SHOW, NULL, (IOleClientSite *)&m_OleClientSite, -1, m_Hwnd, &rect) && 188 | 189 | // Ok, now things may seem to get even trickier, One of those function pointers in the browser's VTable is 190 | // to the QueryInterface() function. What does this function do? It lets us grab the base address of any 191 | // other object that may be embedded within the browser object. And this other object has its own VTable 192 | // containing pointers to more functions we can call for that object. 193 | // 194 | // We want to get the base address (ie, a pointer) to the IWebBrowser2 object embedded within the browser 195 | // object, so we can call some of the functions in the former's table. For example, one IWebBrowser2 function 196 | // we intend to call below will be Navigate2(). So we call the browser object's QueryInterface to get our 197 | // pointer to the IWebBrowser2 object. 198 | !m_BrowserObject->QueryInterface(IID_IWebBrowser2, (void**)&m_WebBrowser2)) 199 | { 200 | // Ok, now the pointer to our IWebBrowser2 object is in 'webBrowser2', and so its VTable is 201 | // webBrowser2->lpVtbl. 202 | 203 | // Let's call several functions in the IWebBrowser2 object to position the browser display area 204 | // in our window. The functions we call are put_Left(), put_Top(), put_Width(), and put_Height(). 205 | // Note that we reference the IWebBrowser2 object's VTable to get pointers to those functions. And 206 | // also note that the first arg we pass to each is the pointer to the IWebBrowser2 object. 207 | m_WebBrowser2->put_Left(0); 208 | m_WebBrowser2->put_Top(0); 209 | m_WebBrowser2->put_Width(rect.right); 210 | m_WebBrowser2->put_Height(rect.bottom); 211 | 212 | SysStr aboutBlank(TEXT("about:blank")); 213 | m_WebBrowser2->Navigate(aboutBlank, NULL, NULL, NULL, NULL); 214 | 215 | // Success 216 | return(0); 217 | } 218 | } 219 | 220 | // Something went wrong setting up the browser! 221 | //UnEmbedBrowserObject(hwnd); 222 | return(-4); 223 | } 224 | 225 | pClassFactory->Release(); 226 | 227 | // Can't create an instance of the browser! 228 | return(-3); 229 | } 230 | 231 | // Can't get the web browser's IClassFactory! 232 | return(-2); 233 | } 234 | 235 | #pragma endregion 236 | 237 | 238 | 239 | }; -------------------------------------------------------------------------------- /common/Dialog/MDocHostUIHandler.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 | class Dialog; 19 | 20 | class MDocHostUIHandler: public CComBase{ 21 | public: 22 | Dialog* m_Dialog; 23 | virtual ULONG STDMETHODCALLTYPE AddRef(); 24 | 25 | virtual ULONG STDMETHODCALLTYPE Release(); 26 | 27 | virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppv); 28 | virtual HRESULT STDMETHODCALLTYPE ShowContextMenu( 29 | /* [in] */ DWORD dwID, 30 | /* [in] */ POINT *ppt, 31 | /* [in] */ IUnknown *pcmdtReserved, 32 | /* [in] */ IDispatch *pdispReserved); 33 | virtual HRESULT STDMETHODCALLTYPE GetHostInfo( DOCHOSTUIINFO *pInfo); 34 | 35 | virtual HRESULT STDMETHODCALLTYPE ShowUI( 36 | /* [in] */ DWORD dwID, 37 | /* [in] */ IOleInPlaceActiveObject *pActiveObject, 38 | /* [in] */ IOleCommandTarget *pCommandTarget, 39 | /* [in] */ IOleInPlaceFrame *pFrame, 40 | /* [in] */ IOleInPlaceUIWindow *pDoc); 41 | 42 | virtual HRESULT STDMETHODCALLTYPE HideUI( void); 43 | 44 | virtual HRESULT STDMETHODCALLTYPE UpdateUI( void); 45 | 46 | virtual HRESULT STDMETHODCALLTYPE EnableModeless( 47 | /* [in] */ BOOL fEnable); 48 | 49 | virtual HRESULT STDMETHODCALLTYPE OnDocWindowActivate( 50 | /* [in] */ BOOL fActivate); 51 | 52 | virtual HRESULT STDMETHODCALLTYPE OnFrameWindowActivate( 53 | /* [in] */ BOOL fActivate); 54 | 55 | virtual HRESULT STDMETHODCALLTYPE ResizeBorder( 56 | /* [in] */ LPCRECT prcBorder, 57 | /* [in] */ IOleInPlaceUIWindow *pUIWindow, 58 | /* [in] */ BOOL fRameWindow); 59 | 60 | virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator( 61 | /* [in] */ LPMSG lpMsg, 62 | /* [in] */ const GUID *pguidCmdGroup, 63 | /* [in] */ DWORD nCmdID); 64 | 65 | virtual HRESULT STDMETHODCALLTYPE GetOptionKeyPath( LPOLESTR *pchKey,DWORD dw); 66 | 67 | virtual HRESULT STDMETHODCALLTYPE GetDropTarget( IDropTarget *pDropTarget,IDropTarget **ppDropTarget); 68 | 69 | virtual HRESULT STDMETHODCALLTYPE GetExternal( IDispatch **ppDispatch); 70 | 71 | virtual HRESULT STDMETHODCALLTYPE TranslateUrl( DWORD dwTranslate,OLECHAR *pchURLIn,OLECHAR **ppchURLOut); 72 | 73 | virtual HRESULT STDMETHODCALLTYPE FilterDataObject(IDataObject *pDO,IDataObject **ppDORet); 74 | 75 | }; 76 | 77 | -------------------------------------------------------------------------------- /common/Dialog/MOleClientSite.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 "MOleClientSite.h" 19 | #include "Dialog.h" 20 | 21 | ULONG STDMETHODCALLTYPE MOleClientSite::AddRef(){ 22 | return m_Dialog->AddRef(); 23 | } 24 | 25 | ULONG STDMETHODCALLTYPE MOleClientSite::Release(){ 26 | return m_Dialog->Release(); 27 | } 28 | 29 | 30 | HRESULT STDMETHODCALLTYPE MOleClientSite::QueryInterface(REFIID riid, LPVOID *ppv){ 31 | // It just so happens that the first arg passed to us is our _IOleClientSiteEx struct we allocated 32 | // and passed to DoVerb() and OleCreate(). Nevermind that 'This' is declared is an IOleClientSite *. 33 | // Remember that in EmbedBrowserObject(), we allocated our own _IOleClientSiteEx struct, and lied 34 | // to OleCreate() and DoVerb() -- passing our _IOleClientSiteEx struct and saying it was an 35 | // IOleClientSite struct. It's ok. An _IOleClientSiteEx starts with an embedded IOleClientSite, so 36 | // the browser didn't mind. So that's what the browser object is passing us now. The browser doesn't 37 | // know that it's really an _IOleClientSiteEx struct. But we do. So we can recast it and use it as 38 | // so here. 39 | 40 | // If the browser is asking us to match IID_IOleClientSite, then it wants us to return a pointer to 41 | // our IOleClientSite struct. Then the browser will use the VTable in that struct to call our 42 | // IOleClientSite functions. It will also pass this same pointer to all of our IOleClientSite 43 | // functions. 44 | // 45 | // Actually, we're going to lie to the browser again. We're going to return our own _IOleClientSiteEx 46 | // struct, and tell the browser that it's a IOleClientSite struct. It's ok. The first thing in our 47 | // _IOleClientSiteEx is an embedded IOleClientSite, so the browser doesn't mind. We want the browser 48 | // to continue passing our _IOleClientSiteEx pointer wherever it would normally pass a IOleClientSite 49 | // pointer. 50 | // 51 | // The IUnknown interface uses the same VTable as the first object in our _IOleClientSiteEx 52 | // struct (which happens to be an IOleClientSite). So if the browser is asking us to match 53 | // IID_IUnknown, then we'll also return a pointer to our _IOleClientSiteEx. 54 | 55 | if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IOleClientSite)){ 56 | *ppv = this; 57 | this->AddRef(); 58 | } 59 | // If the browser is asking us to match IID_IOleInPlaceSite, then it wants us to return a pointer to 60 | // our IOleInPlaceSite struct. Then the browser will use the VTable in that struct to call our 61 | // IOleInPlaceSite functions. It will also pass this same pointer to all of our IOleInPlaceSite 62 | // functions (except for Site_QueryInterface, Site_AddRef, and Site_Release. Those will always get 63 | // the pointer to our _IOleClientSiteEx. 64 | // 65 | // Actually, we're going to lie to the browser. We're going to return our own _IOleInPlaceSiteEx 66 | // struct, and tell the browser that it's a IOleInPlaceSite struct. It's ok. The first thing in 67 | // our _IOleInPlaceSiteEx is an embedded IOleInPlaceSite, so the browser doesn't mind. We want the 68 | // browser to continue passing our _IOleInPlaceSiteEx pointer wherever it would normally pass a 69 | // IOleInPlaceSite pointer. 70 | else if (IsEqualIID(riid, IID_IOleInPlaceSite)){ 71 | *ppv = &m_Dialog->m_OleInPlaceSite; 72 | m_Dialog->m_OleInPlaceSite.AddRef(); 73 | } 74 | // If the browser is asking us to match IID_IDocHostUIHandler, then it wants us to return a pointer to 75 | // our IDocHostUIHandler struct. Then the browser will use the VTable in that struct to call our 76 | // IDocHostUIHandler functions. It will also pass this same pointer to all of our IDocHostUIHandler 77 | // functions (except for Site_QueryInterface, Site_AddRef, and Site_Release. Those will always get 78 | // the pointer to our _IOleClientSiteEx. 79 | // 80 | // Actually, we're going to lie to the browser. We're going to return our own _IDocHostUIHandlerEx 81 | // struct, and tell the browser that it's a IDocHostUIHandler struct. It's ok. The first thing in 82 | // our _IDocHostUIHandlerEx is an embedded IDocHostUIHandler, so the browser doesn't mind. We want the 83 | // browser to continue passing our _IDocHostUIHandlerEx pointer wherever it would normally pass a 84 | // IDocHostUIHandler pointer. My, we're really playing dirty tricks on the browser here. heheh. 85 | else if (IsEqualIID(riid, IID_IDocHostUIHandler)){ 86 | *ppv = &m_Dialog->m_DocHostUIHandler; 87 | m_Dialog->m_DocHostUIHandler.AddRef(); 88 | } 89 | // For other types of objects the browser wants, just report that we don't have any such objects. 90 | // NOTE: If you want to add additional functionality to your browser hosting, you may need to 91 | // provide some more objects here. You'll have to investigate what the browser is asking for 92 | // (ie, what REFIID it is passing). 93 | else 94 | { 95 | *ppv = 0; 96 | return(E_NOINTERFACE); 97 | } 98 | 99 | return(S_OK); 100 | } 101 | 102 | HRESULT STDMETHODCALLTYPE MOleClientSite::SaveObject(){ 103 | return E_NOTIMPL; 104 | } 105 | 106 | HRESULT STDMETHODCALLTYPE MOleClientSite::GetMoniker( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk){ 107 | return E_NOTIMPL; 108 | } 109 | 110 | HRESULT STDMETHODCALLTYPE MOleClientSite::GetContainer( IOleContainer **ppContainer){ 111 | // Tell the browser that we are a simple object and don't support a container 112 | *ppContainer = 0; 113 | 114 | return(E_NOINTERFACE); 115 | } 116 | 117 | HRESULT STDMETHODCALLTYPE MOleClientSite::ShowObject(){ 118 | return(NOERROR); 119 | } 120 | 121 | HRESULT STDMETHODCALLTYPE MOleClientSite::OnShowWindow(BOOL fShow){ 122 | return E_NOTIMPL; 123 | } 124 | 125 | HRESULT STDMETHODCALLTYPE MOleClientSite::RequestNewObjectLayout(){ 126 | return E_NOTIMPL; 127 | } 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /common/Dialog/MOleClientSite.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 "..\ComBase.h" 20 | 21 | class Dialog; 22 | 23 | class MOleClientSite : public CComBase{ 24 | public: 25 | Dialog* m_Dialog; 26 | 27 | virtual ULONG STDMETHODCALLTYPE AddRef(); 28 | 29 | virtual ULONG STDMETHODCALLTYPE Release(); 30 | 31 | virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppv); 32 | 33 | virtual HRESULT STDMETHODCALLTYPE SaveObject(); 34 | 35 | virtual HRESULT STDMETHODCALLTYPE GetMoniker( DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk); 36 | 37 | virtual HRESULT STDMETHODCALLTYPE GetContainer( IOleContainer **ppContainer); 38 | 39 | virtual HRESULT STDMETHODCALLTYPE ShowObject(); 40 | 41 | virtual HRESULT STDMETHODCALLTYPE OnShowWindow(BOOL fShow); 42 | 43 | virtual HRESULT STDMETHODCALLTYPE RequestNewObjectLayout(); 44 | }; 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /common/Dialog/MOleInPlaceFrame.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 "MOleInPlaceFrame.h" 19 | #include "Dialog.h" 20 | 21 | ULONG STDMETHODCALLTYPE MOleInPlaceFrame::AddRef(){ 22 | return m_Dialog->AddRef(); 23 | } 24 | 25 | ULONG STDMETHODCALLTYPE MOleInPlaceFrame::Release(){ 26 | return m_Dialog->Release(); 27 | } 28 | 29 | HRESULT STDMETHODCALLTYPE MOleInPlaceFrame::QueryInterface(REFIID riid, LPVOID *ppv){ 30 | return E_NOTIMPL; 31 | } 32 | HRESULT STDMETHODCALLTYPE MOleInPlaceFrame::GetWindow( HWND *phwnd){ 33 | *phwnd = m_Dialog->hwnd(); 34 | return(S_OK); 35 | } 36 | 37 | HRESULT STDMETHODCALLTYPE MOleInPlaceFrame::ContextSensitiveHelp( BOOL fEnterMode){ 38 | return E_NOTIMPL; 39 | } 40 | 41 | HRESULT STDMETHODCALLTYPE MOleInPlaceFrame::GetBorder( LPRECT lprectBorder){ 42 | return E_NOTIMPL; 43 | } 44 | HRESULT STDMETHODCALLTYPE MOleInPlaceFrame::RequestBorderSpace( LPCBORDERWIDTHS pborderwidths){ 45 | return E_NOTIMPL; 46 | } 47 | 48 | HRESULT STDMETHODCALLTYPE MOleInPlaceFrame::SetBorderSpace( LPCBORDERWIDTHS pborderwidths){ 49 | return E_NOTIMPL; 50 | } 51 | 52 | HRESULT STDMETHODCALLTYPE MOleInPlaceFrame::SetActiveObject(IOleInPlaceActiveObject *pActiveObject,LPCOLESTR pszObjName){ 53 | if (m_Dialog->m_ActiveObject != NULL){ 54 | m_Dialog->m_ActiveObject->Release(); 55 | } 56 | 57 | m_Dialog->m_ActiveObject = pActiveObject; 58 | 59 | if (m_Dialog->m_ActiveObject != NULL) 60 | m_Dialog->m_ActiveObject->AddRef(); 61 | 62 | return S_OK; 63 | } 64 | 65 | 66 | HRESULT STDMETHODCALLTYPE MOleInPlaceFrame::InsertMenus( HMENU hmenuShared,LPOLEMENUGROUPWIDTHS lpMenuWidths){ 67 | return E_NOTIMPL; 68 | } 69 | HRESULT STDMETHODCALLTYPE MOleInPlaceFrame::SetMenu( HMENU hmenuShared,HOLEMENU holemenu,HWND hwndActiveObject){ 70 | return S_OK; 71 | } 72 | 73 | HRESULT STDMETHODCALLTYPE MOleInPlaceFrame::RemoveMenus( HMENU hmenuShared){ 74 | return E_NOTIMPL; 75 | } 76 | 77 | HRESULT STDMETHODCALLTYPE MOleInPlaceFrame::SetStatusText( LPCOLESTR pszStatusText){ 78 | return S_OK; 79 | } 80 | 81 | HRESULT STDMETHODCALLTYPE MOleInPlaceFrame::EnableModeless(BOOL fEnable){ 82 | return S_OK; 83 | } 84 | 85 | HRESULT STDMETHODCALLTYPE MOleInPlaceFrame::TranslateAccelerator( LPMSG lpmsg, WORD wID){ 86 | return E_NOTIMPL; 87 | } 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /common/Dialog/MOleInPlaceFrame.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 "..\ComBase.h" 21 | 22 | class Dialog; 23 | 24 | class MOleInPlaceFrame: public CComBase{ 25 | public: 26 | Dialog* m_Dialog; 27 | virtual ULONG STDMETHODCALLTYPE AddRef(); 28 | 29 | virtual ULONG STDMETHODCALLTYPE Release(); 30 | 31 | virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppv); 32 | 33 | virtual HRESULT STDMETHODCALLTYPE GetWindow( HWND *phwnd); 34 | 35 | virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp( BOOL fEnterMode); 36 | 37 | virtual HRESULT STDMETHODCALLTYPE GetBorder( LPRECT lprectBorder); 38 | 39 | virtual HRESULT STDMETHODCALLTYPE RequestBorderSpace( LPCBORDERWIDTHS pborderwidths); 40 | 41 | virtual HRESULT STDMETHODCALLTYPE SetBorderSpace( LPCBORDERWIDTHS pborderwidths); 42 | 43 | virtual HRESULT STDMETHODCALLTYPE SetActiveObject(IOleInPlaceActiveObject *pActiveObject,LPCOLESTR pszObjName); 44 | 45 | virtual HRESULT STDMETHODCALLTYPE InsertMenus( HMENU hmenuShared,LPOLEMENUGROUPWIDTHS lpMenuWidths); 46 | 47 | virtual HRESULT STDMETHODCALLTYPE SetMenu( HMENU hmenuShared,HOLEMENU holemenu,HWND hwndActiveObject); 48 | 49 | virtual HRESULT STDMETHODCALLTYPE RemoveMenus( HMENU hmenuShared); 50 | 51 | virtual HRESULT STDMETHODCALLTYPE SetStatusText( LPCOLESTR pszStatusText); 52 | 53 | virtual HRESULT STDMETHODCALLTYPE EnableModeless(BOOL fEnable); 54 | 55 | virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator( LPMSG lpmsg, WORD wID); 56 | }; 57 | 58 | 59 | -------------------------------------------------------------------------------- /common/Dialog/MOleInPlaceSite.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 "MOleInPlaceSite.h" 19 | #include "Dialog.h" 20 | 21 | 22 | ULONG STDMETHODCALLTYPE MOleInPlaceSite::AddRef(){ 23 | return m_Dialog->AddRef(); 24 | } 25 | 26 | ULONG STDMETHODCALLTYPE MOleInPlaceSite::Release(){ 27 | return m_Dialog->Release(); 28 | } 29 | 30 | HRESULT STDMETHODCALLTYPE MOleInPlaceSite::QueryInterface(REFIID riid, LPVOID *ppv){ 31 | return E_NOTIMPL; 32 | } 33 | 34 | HRESULT STDMETHODCALLTYPE MOleInPlaceSite::GetWindow( HWND *phwnd){ 35 | *phwnd = m_Dialog->hwnd(); 36 | return(S_OK); 37 | } 38 | 39 | HRESULT STDMETHODCALLTYPE MOleInPlaceSite::ContextSensitiveHelp( BOOL fEnterMode){ 40 | return E_NOTIMPL; 41 | } 42 | 43 | HRESULT STDMETHODCALLTYPE MOleInPlaceSite::CanInPlaceActivate( ){ 44 | return S_OK; 45 | } 46 | 47 | HRESULT STDMETHODCALLTYPE MOleInPlaceSite::OnInPlaceActivate( ){ 48 | return S_OK; 49 | } 50 | 51 | HRESULT STDMETHODCALLTYPE MOleInPlaceSite::OnUIActivate( ){ 52 | return S_OK; 53 | } 54 | 55 | HRESULT STDMETHODCALLTYPE MOleInPlaceSite::GetWindowContext( IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect, 56 | LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo){ 57 | 58 | *ppFrame = (IOleInPlaceFrame *)&m_Dialog->m_OleInPlaceFrame; 59 | m_Dialog->m_OleInPlaceFrame.AddRef(); 60 | 61 | // We have no OLEINPLACEUIWINDOW 62 | *ppDoc = 0; 63 | 64 | // Fill in some other info for the browser 65 | lpFrameInfo->fMDIApp = FALSE; 66 | lpFrameInfo->hwndFrame = m_Dialog->hwnd(); 67 | lpFrameInfo->haccel = 0; 68 | lpFrameInfo->cAccelEntries = 0; 69 | 70 | // Give the browser the dimensions of where it can draw. We give it our entire window to fill. 71 | // We do this in InPlace_OnPosRectChange() which is called right when a window is first 72 | // created anyway, so no need to duplicate it here. 73 | // GetClientRect(lpFrameInfo->hwndFrame, lprcPosRect); 74 | // GetClientRect(lpFrameInfo->hwndFrame, lprcClipRect); 75 | 76 | return(S_OK); 77 | } 78 | 79 | HRESULT STDMETHODCALLTYPE MOleInPlaceSite::Scroll( SIZE scrollExtant){ 80 | return E_NOTIMPL; 81 | } 82 | 83 | HRESULT STDMETHODCALLTYPE MOleInPlaceSite::OnUIDeactivate( BOOL fUndoable){ 84 | return S_OK; 85 | } 86 | 87 | HRESULT STDMETHODCALLTYPE MOleInPlaceSite::OnInPlaceDeactivate( ){ 88 | return S_OK; 89 | } 90 | 91 | HRESULT STDMETHODCALLTYPE MOleInPlaceSite::DiscardUndoState( ){ 92 | return E_NOTIMPL; 93 | } 94 | 95 | HRESULT STDMETHODCALLTYPE MOleInPlaceSite::DeactivateAndUndo( ){ 96 | return E_NOTIMPL; 97 | } 98 | 99 | HRESULT STDMETHODCALLTYPE MOleInPlaceSite::OnPosRectChange( LPCRECT lprcPosRect){ 100 | IOleInPlaceObject *inplace; 101 | 102 | // We need to get the browser's IOleInPlaceObject object so we can call its SetObjectRects 103 | // function. 104 | if (!m_Dialog->m_BrowserObject->QueryInterface(IID_IOleInPlaceObject, (void**)&inplace)) 105 | { 106 | // Give the browser the dimensions of where it can draw. 107 | inplace->SetObjectRects(lprcPosRect, lprcPosRect); 108 | inplace->Release(); 109 | } 110 | 111 | return(S_OK); 112 | } 113 | 114 | -------------------------------------------------------------------------------- /common/Dialog/MOleInPlaceSite.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 "..\ComBase.h" 20 | 21 | class Dialog; 22 | 23 | class MOleInPlaceSite : public CComBase{ 24 | public: 25 | Dialog* m_Dialog; 26 | virtual ULONG STDMETHODCALLTYPE AddRef(); 27 | 28 | virtual ULONG STDMETHODCALLTYPE Release(); 29 | 30 | virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppv); 31 | 32 | virtual HRESULT STDMETHODCALLTYPE GetWindow( HWND *phwnd); 33 | 34 | virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp( BOOL fEnterMode); 35 | 36 | virtual HRESULT STDMETHODCALLTYPE CanInPlaceActivate( ); 37 | 38 | virtual HRESULT STDMETHODCALLTYPE OnInPlaceActivate( ); 39 | 40 | virtual HRESULT STDMETHODCALLTYPE OnUIActivate( ); 41 | 42 | virtual HRESULT STDMETHODCALLTYPE GetWindowContext( IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect, 43 | LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo); 44 | 45 | virtual HRESULT STDMETHODCALLTYPE Scroll( SIZE scrollExtant); 46 | 47 | virtual HRESULT STDMETHODCALLTYPE OnUIDeactivate( BOOL fUndoable); 48 | 49 | virtual HRESULT STDMETHODCALLTYPE OnInPlaceDeactivate( ); 50 | 51 | virtual HRESULT STDMETHODCALLTYPE DiscardUndoState( ); 52 | 53 | virtual HRESULT STDMETHODCALLTYPE DeactivateAndUndo( ); 54 | 55 | virtual HRESULT STDMETHODCALLTYPE OnPosRectChange( LPCRECT lprcPosRect); 56 | }; 57 | 58 | -------------------------------------------------------------------------------- /common/Dialog/WindowClass.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 "WindowClass.h" 19 | #include "..\LastError.h" 20 | 21 | WindowClass::~WindowClass(){ 22 | UnregisterClass(name,hinst); 23 | } 24 | 25 | WindowClass::WindowClass(TCHAR* _name, WNDPROC dlgProc, HINSTANCE _hinst){ 26 | hinst = _hinst; 27 | name = _name; 28 | 29 | WNDCLASSEX wcl; 30 | memset(&wcl, 0, sizeof(wcl)); 31 | 32 | wcl.cbSize = sizeof(wcl); 33 | //wcl.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; 34 | // wcl.style = CS_DBLCLKS; 35 | wcl.lpfnWndProc = dlgProc; 36 | wcl.hInstance = hinst; 37 | wcl.lpszClassName = name; 38 | wcl.hbrBackground = HBRUSH(COLOR_WINDOW + 1); 39 | // wcl.hIcon = IDI_APPLICATION; 40 | 41 | wclAtom = RegisterClassEx(&wcl); 42 | 43 | if (wclAtom == NULL){ 44 | LastError le; 45 | throw le.staticmessage(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /common/Dialog/WindowClass.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 "Windows.h" 21 | 22 | class WindowClass{ 23 | public: 24 | ATOM wclAtom; 25 | TCHAR* name; 26 | HINSTANCE hinst; 27 | 28 | ~WindowClass(); 29 | 30 | WindowClass(TCHAR* _name, WNDPROC dlgProc, HINSTANCE _hinst); 31 | }; 32 | 33 | 34 | -------------------------------------------------------------------------------- /common/ForegroundIdleHook.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 "ForegroundIdleHook.h" 19 | 20 | 21 | 22 | LRESULT CALLBACK ForegroundIdleHook::Handler( int code, WPARAM wParam, LPARAM lParam ){ 23 | ForegroundIdleHook* instance = ForegroundIdleHook::getInstance(); 24 | if (code == HC_ACTION){ 25 | instance->OnHandler(); 26 | 27 | // The regular hook works. 28 | // Hence remove timer handler from the handler list of timer 29 | if (instance->m_TimerHandler){ 30 | Timer::GetInstance()->Remove(instance->m_TimerHandler); 31 | delete instance->m_TimerHandler; 32 | instance->m_TimerHandler = NULL; 33 | } 34 | } 35 | return CallNextHookEx(instance->m_Hook, code, wParam, lParam); 36 | } 37 | 38 | void ForegroundIdleHook::OnHandler(){ 39 | EnterCriticalSection(&m_CriticalSection); 40 | if (!m_Handlers.empty()){ 41 | IdleHandler* handler = *m_Handlers.begin(); 42 | 43 | m_Handlers.erase(m_Handlers.begin()); 44 | 45 | handler->execute(); 46 | } 47 | LeaveCriticalSection(&m_CriticalSection); 48 | } 49 | 50 | ForegroundIdleHook::ForegroundIdleHook(){ 51 | m_TimerHandler = NULL; 52 | 53 | InitializeCriticalSection(&m_CriticalSection); 54 | 55 | m_Hook = SetWindowsHookEx(WH_FOREGROUNDIDLE, (HOOKPROC) Handler, 0, GetCurrentThreadId()); 56 | 57 | /* 58 | If hook initialization failes or in case of Wine it does not work at all 59 | use Timer to simulate necessary functionality. 60 | For example on Linux systems under Wine does not implement WH_FOREGROUNDIDLE 61 | */ 62 | 63 | class TimerBasedIdleHandler : public Timer::Handler{ 64 | private: 65 | ForegroundIdleHook& m_Fih; 66 | public: 67 | TimerBasedIdleHandler(ForegroundIdleHook& fih):m_Fih(fih){ 68 | } 69 | void execute() override{ 70 | // simulate system callback for WH_FOREGROUNDIDLE 71 | m_Fih.OnHandler(); // I don't care about right parameters 72 | 73 | // reschedule this instance 74 | Timer::GetInstance()->Add(this, 200); 75 | } 76 | }; 77 | 78 | m_TimerHandler = new TimerBasedIdleHandler(*this); 79 | Timer::GetInstance()->Add(m_TimerHandler, 200); 80 | } 81 | ForegroundIdleHook::~ForegroundIdleHook(){ 82 | if (m_Hook) 83 | UnhookWindowsHookEx(m_Hook); 84 | 85 | if (m_TimerHandler){ 86 | Timer::GetInstance()->Remove(m_TimerHandler); 87 | delete m_TimerHandler; 88 | } 89 | 90 | DeleteCriticalSection(&m_CriticalSection); 91 | } 92 | 93 | ForegroundIdleHook* ForegroundIdleHook::getInstance(){ 94 | static ForegroundIdleHook instance; 95 | 96 | return &instance; 97 | } 98 | 99 | void ForegroundIdleHook::remove(IdleHandler* h){ 100 | EnterCriticalSection(&m_CriticalSection); 101 | 102 | m_Handlers.erase(h); 103 | 104 | LeaveCriticalSection(&m_CriticalSection); 105 | } 106 | 107 | void ForegroundIdleHook::add(IdleHandler* h){ 108 | EnterCriticalSection(&m_CriticalSection); 109 | 110 | if (h) 111 | m_Handlers.insert(h); 112 | 113 | LeaveCriticalSection(&m_CriticalSection); 114 | } 115 | -------------------------------------------------------------------------------- /common/ForegroundIdleHook.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 | #include 21 | 22 | #include "Timer.h" 23 | 24 | class ForegroundIdleHook{ 25 | private: 26 | Timer::Handler* m_TimerHandler;// replacement for hook if OS does not support IdleHooks 27 | HHOOK m_Hook; 28 | CRITICAL_SECTION m_CriticalSection; 29 | 30 | static LRESULT CALLBACK Handler( int code, WPARAM wParam, LPARAM lParam ); 31 | void OnHandler(); 32 | 33 | ForegroundIdleHook(); 34 | ~ForegroundIdleHook(); 35 | 36 | public: 37 | class IdleHandler{ 38 | public: 39 | virtual void execute(){ 40 | // overload this method 41 | } 42 | }; 43 | 44 | static ForegroundIdleHook* getInstance(); 45 | 46 | void remove(IdleHandler* h); 47 | 48 | void add(IdleHandler* h); 49 | 50 | private: 51 | typedef std::set Handlers; 52 | Handlers m_Handlers; 53 | }; 54 | -------------------------------------------------------------------------------- /common/LastError.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 "LastError.h" 19 | #include "Strsafe.h" 20 | 21 | 22 | LastError::LastError(){ 23 | DWORD err = GetLastError(); 24 | 25 | m_Message = NULL; 26 | 27 | FormatMessage( 28 | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 29 | 0 , 30 | err, 31 | 0, 32 | (LPWSTR)&m_Message, 33 | 0, 34 | NULL 35 | ); 36 | } 37 | 38 | LastError::~LastError(){ 39 | if (m_Message) 40 | LocalFree(m_Message); 41 | } 42 | 43 | TCHAR* LastError::message(){ 44 | return m_Message; 45 | } 46 | 47 | TCHAR* LastError::staticmessage() { 48 | static TCHAR buf[1024]; 49 | buf[0] = 0; 50 | 51 | if (m_Message) 52 | StringCchCopy(buf, 1024, m_Message); 53 | 54 | return buf; 55 | } -------------------------------------------------------------------------------- /common/LastError.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 "windows.h" 21 | 22 | class LastError{ 23 | 24 | private: 25 | TCHAR* m_Message; 26 | public: 27 | LastError(); 28 | ~LastError(); 29 | 30 | TCHAR* message(); 31 | 32 | TCHAR* staticmessage(); 33 | 34 | typedef TCHAR* Message; 35 | operator Message(){ 36 | return message(); 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /common/Library.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 "Library.h" 19 | #include "Windows.h" 20 | #include "MyActiveSite.h" 21 | #include "..\Interfaces.h" 22 | 23 | #include "LastError.h" 24 | 25 | #include "System.h" 26 | 27 | Library::Library(BSTR* path):CComDispatch() 28 | { 29 | m_Handle = LoadLibrary(*path); 30 | } 31 | 32 | HMODULE Library::handle(){ 33 | return m_Handle; 34 | } 35 | 36 | Library::~Library() 37 | { 38 | if (m_Handle) 39 | FreeLibrary(m_Handle); 40 | } 41 | 42 | HRESULT STDMETHODCALLTYPE Library::alloc(unsigned int number, BSTR* result){ 43 | *result = SysAllocStringLen(NULL, number); 44 | return S_OK; 45 | } 46 | 47 | FARPROC Library::GetProc(BSTR functionName) const { 48 | char* _functionName; 49 | 50 | int newlen = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)functionName, SysStringLen(functionName), NULL,0, NULL, NULL); 51 | _functionName = new char[newlen+1]; 52 | int res = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)functionName, SysStringLen(functionName), _functionName, newlen+1, NULL,NULL); 53 | _functionName[res] = 0; 54 | 55 | FARPROC proc = GetProcAddress(m_Handle, (LPCSTR)_functionName); 56 | 57 | return proc; 58 | } 59 | 60 | HRESULT STDMETHODCALLTYPE Library::call(BSTR functionName, BSTR params, int* result){ 61 | #ifndef _M_X64 62 | FARPROC proc = GetProc(functionName); 63 | 64 | if (proc == NULL){ 65 | LastError errMsg; 66 | MyActiveSite::getInstance()->Throw(errMsg, __uuidof(ILibrary) ); 67 | 68 | return E_FAIL; 69 | } 70 | 71 | 72 | 73 | int paramlen = SysStringByteLen(params); 74 | 75 | /* 76 | copy params to stack 77 | */ 78 | 79 | char* buf; // pointer to the buffer on stack 80 | void* v_esp; // old stack pointer 81 | DWORD v_res; 82 | 83 | // reserve memory on stack 84 | __asm { 85 | mov v_esp, esp 86 | mov eax, paramlen 87 | sub esp, eax 88 | mov buf, esp 89 | } 90 | 91 | memcpy(buf, params, paramlen); 92 | 93 | /* 94 | make a call to the function 95 | */ 96 | 97 | __asm { 98 | call proc 99 | mov v_res, eax 100 | mov eax, paramlen 101 | mov esp, v_esp 102 | } 103 | 104 | *result = v_res; 105 | #else 106 | #pragma message(": warning: Library::call not available") 107 | #endif 108 | 109 | return S_OK; 110 | } 111 | 112 | template 113 | HRESULT write(BSTR dest,unsigned int pos,VARIANT value){ 114 | T* val = (T*)(((char*)dest)+pos); 115 | 116 | switch(value.vt){ 117 | case VT_BOOL: *val = (T)*(unsigned short*)&value.boolVal; break; 118 | case VT_UI1: *val = (T)*(unsigned char*)&value.bVal; break; 119 | case VT_I1: *val = (T)*(unsigned char*)&value.cVal; break; 120 | case VT_I2: *val = (T)*(unsigned short*)&value.iVal; break; 121 | case VT_I4: *val = (T)*(unsigned long*)&value.lVal; break; 122 | case VT_I8: *val = (T)*(unsigned long long*)&value.llVal; break; 123 | case VT_INT: *val = (T)*(unsigned int*)&value.intVal; break; 124 | case VT_R4: *val = (T)*(unsigned int*)&value.fltVal; break; 125 | case VT_R8: *val = (T)*(unsigned long long*)&value.dblVal; break; 126 | case VT_BSTR: *val = (T)*(unsigned __int32*)&value.bstrVal; break; 127 | case VT_DISPATCH:{ 128 | void* pint = NULL; 129 | value.pdispVal->QueryInterface(__uuidof(ICallBack), &pint); 130 | if (pint!=NULL){ 131 | *val = (T)(static_cast(value.pdispVal))->Proc(); 132 | value.pdispVal->Release(); 133 | }else 134 | *val = (T)value.pdispVal; 135 | } 136 | } 137 | 138 | return S_OK; 139 | } 140 | 141 | HRESULT STDMETHODCALLTYPE Library::writeByte(BSTR dest,unsigned int pos,VARIANT value){ 142 | return write(dest, pos, value); 143 | } 144 | 145 | HRESULT STDMETHODCALLTYPE Library::writeWord(BSTR dest,unsigned int pos,VARIANT value){ 146 | return write(dest, pos, value); 147 | } 148 | 149 | HRESULT STDMETHODCALLTYPE Library::writeDWord(BSTR dest,unsigned int pos,VARIANT value){ 150 | return write(dest, pos, value); 151 | } 152 | 153 | HRESULT STDMETHODCALLTYPE Library::writeInt64(BSTR dest,unsigned int pos,VARIANT value){ 154 | return write(dest, pos, value); 155 | } 156 | 157 | bool HasEnough(BSTR src,unsigned int srcPos,unsigned int size){ 158 | int actualSize = SysStringByteLen(src); 159 | 160 | bool result = ((actualSize - srcPos) - size) >= 0; 161 | 162 | return result; 163 | } 164 | 165 | HRESULT STDMETHODCALLTYPE Library::copy( BSTR dest,unsigned int destPos,BSTR src,unsigned int srcPos,unsigned int size){ 166 | if (!HasEnough(dest, destPos, size)){ 167 | MyActiveSite::getInstance()->Throw(TEXT("Not enough bytes in destination array"), __uuidof(ILibrary) ); 168 | return E_FAIL; 169 | } 170 | 171 | if (!HasEnough(src, srcPos, size)){ 172 | MyActiveSite::getInstance()->Throw(TEXT("Not enough bytes in source array"), __uuidof(ILibrary) ); 173 | return E_FAIL; 174 | } 175 | 176 | memcpy(((char*)dest) + destPos, ((char*)src) + srcPos, size); 177 | 178 | return S_OK; 179 | } 180 | 181 | HRESULT STDMETHODCALLTYPE Library::readByte( BSTR src,unsigned int pos, VARIANT *value){ 182 | if (!HasEnough(src, pos, 1)){ 183 | MyActiveSite::getInstance()->Throw(TEXT("Not enough bytes in source array"), __uuidof(ILibrary) ); 184 | return E_FAIL; 185 | } 186 | 187 | value->vt = VT_UI1; 188 | value->bVal = *((BYTE *)(((char*)src)+pos)); 189 | 190 | return S_OK; 191 | } 192 | 193 | HRESULT STDMETHODCALLTYPE Library::readWord( BSTR src,unsigned int pos, VARIANT *value){ 194 | if (!HasEnough(src, pos, 2)){ 195 | MyActiveSite::getInstance()->Throw(TEXT("Not enough bytes in source array"), __uuidof(ILibrary) ); 196 | return E_FAIL; 197 | } 198 | 199 | value->vt = VT_UI2; 200 | value->uiVal = *((USHORT *)(((char*)src)+pos)); 201 | 202 | return S_OK; 203 | } 204 | 205 | HRESULT STDMETHODCALLTYPE Library::readDWord( BSTR src,unsigned int pos,VARIANT *value){ 206 | if (!HasEnough(src, pos, 4)){ 207 | MyActiveSite::getInstance()->Throw(TEXT("Not enough bytes in source array"), __uuidof(ILibrary) ); 208 | return E_FAIL; 209 | } 210 | 211 | value->vt = VT_UI4; 212 | value->ulVal = *((ULONG *)(((char*)src)+pos)); 213 | 214 | return S_OK; 215 | } 216 | 217 | HRESULT STDMETHODCALLTYPE Library::readInt64( BSTR src,unsigned int pos,VARIANT *value){ 218 | if (!HasEnough(src, pos, 8)){ 219 | MyActiveSite::getInstance()->Throw(TEXT("Not enough bytes in source array"), __uuidof(ILibrary) ); 220 | return E_FAIL; 221 | } 222 | 223 | value->vt = VT_UI8; 224 | value->ullVal = *((ULONGLONG *)(((char*)src)+pos)); 225 | 226 | return S_OK; 227 | } 228 | 229 | HRESULT STDMETHODCALLTYPE Library::readBSTR( BSTR src,unsigned int pos, BSTR* value){ 230 | if (!HasEnough(src, pos, 4)){ 231 | MyActiveSite::getInstance()->Throw(TEXT("Not enough bytes in source array"), __uuidof(ILibrary) ); 232 | return E_FAIL; 233 | } 234 | 235 | *value = *((BSTR*)(((char*)src)+pos)); 236 | 237 | return S_OK; 238 | } 239 | 240 | -------------------------------------------------------------------------------- /common/Library.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 "..\Interfaces.h" 21 | 22 | #include "combase.h" 23 | #include "windows.h" 24 | #include 25 | 26 | class Library: public CComDispatch{ 27 | private: 28 | HMODULE m_Handle; 29 | 30 | FARPROC GetProc(BSTR functionName) const; 31 | 32 | public: 33 | Library(BSTR* path); 34 | ~Library(void); 35 | 36 | HMODULE handle(); 37 | 38 | HRESULT STDMETHODCALLTYPE alloc(unsigned int number, BSTR* dest); 39 | 40 | HRESULT STDMETHODCALLTYPE call(BSTR functionName, BSTR params, int* result); 41 | 42 | HRESULT STDMETHODCALLTYPE writeByte(BSTR dest,unsigned int pos,VARIANT value); 43 | 44 | HRESULT STDMETHODCALLTYPE writeWord(BSTR dest,unsigned int pos,VARIANT value); 45 | 46 | HRESULT STDMETHODCALLTYPE writeDWord(BSTR dest,unsigned int pos,VARIANT value); 47 | 48 | HRESULT STDMETHODCALLTYPE writeInt64(BSTR dest,unsigned int pos,VARIANT value); 49 | 50 | HRESULT STDMETHODCALLTYPE copy( BSTR dest,unsigned int destPos,BSTR src,unsigned int srcPos,unsigned int size); 51 | 52 | HRESULT STDMETHODCALLTYPE readByte( BSTR src,unsigned int pos, VARIANT *value); 53 | HRESULT STDMETHODCALLTYPE readWord( BSTR src,unsigned int pos, VARIANT *value); 54 | HRESULT STDMETHODCALLTYPE readDWord( BSTR src,unsigned int pos,VARIANT *value); 55 | HRESULT STDMETHODCALLTYPE readInt64( BSTR src,unsigned int pos,VARIANT *value); 56 | HRESULT STDMETHODCALLTYPE readBSTR( BSTR src,unsigned int pos, BSTR* value); 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /common/Menu.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 "Menu.h" 19 | #include "MyActiveSite.h" 20 | #include "LastError.h" 21 | 22 | 23 | #pragma region CMenuItem 24 | CMenuItem::CMenuItem(HMENU h, WORD id, ScriptObj* config):CAbstractMenuItem(){ 25 | m_ParentMenuHandle = h; 26 | m_Id_Handle =(HMENU)id; 27 | 28 | m_Config = config; 29 | 30 | VARIANT* textValue = m_Config->getProperty(TEXT("text"),VT_BSTR); 31 | BSTR text = NULL; 32 | 33 | if (textValue != NULL){ 34 | text = textValue->bstrVal; 35 | delete textValue; 36 | } 37 | 38 | if (text == NULL){ 39 | text = SysAllocString(TEXT("Menu Item")); 40 | } 41 | 42 | MENUITEMINFO mii; 43 | memset(&mii,0,sizeof(mii)); 44 | mii.cbSize = sizeof(mii); 45 | mii.fMask = MIIM_DATA | MIIM_STRING | MIIM_ID; 46 | mii.fType = MFT_STRING; 47 | mii.wID = (UINT)m_Id_Handle; 48 | mii.cch = SysStringLen(text); 49 | mii.dwTypeData = text; 50 | 51 | mii.dwItemData = (ULONG_PTR)this; 52 | this->AddRef();// this object must not be released after js engine release its reference 53 | 54 | BOOL res1 = InsertMenuItem( 55 | m_ParentMenuHandle, 56 | (UINT)-1, 57 | TRUE, 58 | &mii 59 | ); 60 | 61 | 62 | SysFreeString(text); 63 | } 64 | CMenuItem::~CMenuItem(){ 65 | delete m_Config; 66 | } 67 | 68 | void CMenuItem::call(){ 69 | if (m_Config == NULL) 70 | return; 71 | 72 | VARIANTARG mitem; 73 | mitem.vt = VT_DISPATCH; 74 | mitem.pdispVal = this; 75 | 76 | if(! m_Config->callMethod(TEXT("cmd"), &mitem, 1) ){ 77 | MyActiveSite::Throw(TEXT("Method 'cmd' not found"), __uuidof(IMenu)); 78 | } 79 | } 80 | 81 | CMenuItem* CMenuItem::GetInstance(HMENU hmenu, UINT itemPos){ 82 | MENUITEMINFO mii; 83 | mii.cbSize = sizeof(mii); 84 | mii.fMask = MIIM_ID | MIIM_DATA; 85 | BOOL res = GetMenuItemInfo(hmenu, itemPos, TRUE, &mii); 86 | 87 | if (!res) 88 | return NULL; 89 | 90 | if (0 == mii.dwItemData) 91 | return NULL; 92 | 93 | // here we have our menu item 94 | CMenuItem* mItem = (CMenuItem*)mii.dwItemData; 95 | 96 | return mItem; 97 | } 98 | 99 | #pragma endregion 100 | 101 | #pragma region CMenu 102 | 103 | CMenu::CMenu(HMENU parent, HWND hwnd):CAbstractMenuItem(){ 104 | createMenu(parent, -1, TEXT("text"), hwnd); 105 | } 106 | 107 | CMenu::CMenu(HMENU parent, int position, VARIANT cfg, HWND hwnd):CAbstractMenuItem(){ 108 | if (cfg.vt == VT_DISPATCH){ 109 | ScriptObj* dispCfg = MyActiveSite::getInstance()->WrapScriptObj(cfg.pdispVal); 110 | VARIANT* var = dispCfg->getProperty(TEXT("text"), VT_BSTR); 111 | if (var){ 112 | createMenu(parent, position, var->bstrVal); 113 | VariantClear(var); 114 | delete var; 115 | }else 116 | createMenu(parent, position, TEXT("text"), hwnd); 117 | 118 | m_Config = dispCfg; 119 | } else if (cfg.vt == VT_BSTR){ 120 | createMenu(parent, position, cfg.bstrVal, hwnd ); 121 | } 122 | 123 | } 124 | 125 | HMENU CMenu::getHandle(){ 126 | return m_Id_Handle; 127 | } 128 | 129 | void CMenu::createMenu(HMENU parent, int position, TCHAR* text, HWND menuBarWindow){ 130 | m_Hwnd = menuBarWindow; 131 | m_Config = NULL; 132 | m_Items = 0; 133 | m_ParentMenuHandle = parent; 134 | m_Id_Handle = ::CreatePopupMenu(); 135 | 136 | BOOL res; 137 | if (position==-1) 138 | res = ::AppendMenu(m_ParentMenuHandle, MF_POPUP, (UINT_PTR )m_Id_Handle, text); 139 | else 140 | res = ::InsertMenu(m_ParentMenuHandle, position, MF_BYPOSITION | MF_POPUP, (UINT_PTR )m_Id_Handle, text); 141 | 142 | MENUINFO mi; 143 | memset(&mi, 0, sizeof(mi)); 144 | mi.cbSize = sizeof(mi); 145 | mi.fMask = MIM_STYLE | MIM_MENUDATA; 146 | mi.dwStyle = MNS_NOTIFYBYPOS; 147 | mi.dwMenuData = (ULONG_PTR)this; 148 | this->AddRef(); 149 | 150 | res = SetMenuInfo( 151 | m_Id_Handle, 152 | &mi 153 | ); 154 | 155 | } 156 | 157 | CMenu* CMenu::GetInstance(HMENU hmenu){ 158 | MENUINFO mi; 159 | memset(&mi, 0, sizeof(mi)); 160 | mi.fMask =MIM_MENUDATA; 161 | mi.cbSize = sizeof(mi); 162 | 163 | BOOL res = GetMenuInfo(hmenu, &mi); 164 | if (!res) 165 | return NULL; 166 | 167 | if (!mi.dwMenuData) 168 | return NULL; 169 | 170 | CMenu* menu = (CMenu*)mi.dwMenuData; // hopefully it is our data :-) 171 | 172 | return menu; 173 | } 174 | 175 | void CMenu::oninitpopup(){ 176 | if (m_Config) 177 | m_Config->callMethod(TEXT("oninitpopup")); 178 | } 179 | 180 | CMenu::~CMenu(void){ 181 | int r = DestroyMenu(m_Id_Handle); 182 | } 183 | 184 | HRESULT STDMETHODCALLTYPE CMenu::addMenu( VARIANT cfg, IMenu **result){ 185 | CHECK_AND_FAIL; // menu item is removed! 186 | 187 | if (cfg.vt == VT_DISPATCH){ 188 | ScriptObj* dispCfg = MyActiveSite::getInstance()->WrapScriptObj(cfg.pdispVal); 189 | VARIANT* var = dispCfg->getProperty(TEXT("text"), VT_BSTR); 190 | if (!var) 191 | return S_OK; 192 | 193 | CMenu* menu = new CMenu(m_Id_Handle); 194 | menu->m_Config = dispCfg; 195 | *result = menu; 196 | 197 | (*result)->put_text(&var->bstrVal); 198 | (*result)->AddRef(); 199 | 200 | 201 | VariantClear(var); 202 | delete var; 203 | } else if (cfg.vt == VT_BSTR){ 204 | *result = new CMenu(m_Id_Handle); 205 | (*result)->put_text(&cfg.bstrVal); 206 | (*result)->AddRef(); 207 | } 208 | return S_OK; 209 | } 210 | 211 | HRESULT STDMETHODCALLTYPE CMenu::addItem(IDispatch *config, IMenuItem **result){ 212 | CHECK_AND_FAIL; // menu item is removed! 213 | 214 | if (config!=NULL){ 215 | *result = new CMenuItem(m_Id_Handle, m_Items, MyActiveSite::getInstance()->WrapScriptObj(config)); 216 | (*result)->AddRef(); 217 | m_Items++; 218 | } 219 | return S_OK; 220 | } 221 | 222 | HRESULT STDMETHODCALLTYPE CMenu::addSeparator( void){ 223 | CHECK_AND_FAIL; // menu item is removed! 224 | 225 | ::AppendMenu(m_Id_Handle, MF_SEPARATOR, m_Items, NULL); 226 | m_Items++; 227 | 228 | return S_OK; 229 | } 230 | 231 | HRESULT STDMETHODCALLTYPE CMenu::put_disabled( VARIANT_BOOL value){ 232 | 233 | CAbstractMenuItem::put_disabled(value); 234 | 235 | if (m_Hwnd) 236 | DrawMenuBar(m_Hwnd); 237 | 238 | return S_OK; 239 | } 240 | 241 | HRESULT STDMETHODCALLTYPE CMenu::put_text( BSTR *value){ 242 | CAbstractMenuItem::put_text(value); 243 | 244 | if (m_Hwnd) 245 | DrawMenuBar(m_Hwnd); 246 | 247 | return S_OK; 248 | } 249 | 250 | HRESULT STDMETHODCALLTYPE CMenu::put_checked( VARIANT_BOOL value){ 251 | CAbstractMenuItem::put_checked(value); 252 | 253 | if (m_Hwnd) 254 | DrawMenuBar(m_Hwnd); 255 | 256 | return S_OK; 257 | } 258 | 259 | #pragma endregion 260 | 261 | #pragma region ContextMenu 262 | CContextMenu::CContextMenu(VARIANT cfg, HWND window){ 263 | m_Menu = new CMenu(NULL, 0, cfg); 264 | m_Window = window; 265 | } 266 | 267 | CContextMenu::~CContextMenu(){ 268 | m_Menu->Release(); 269 | } 270 | 271 | HRESULT STDMETHODCALLTYPE CContextMenu::addMenu( VARIANT cfg, IMenu **result){ 272 | return m_Menu->addMenu(cfg, result); 273 | } 274 | 275 | HRESULT STDMETHODCALLTYPE CContextMenu::addItem( IDispatch *config, IMenuItem **result){ 276 | return m_Menu->addItem(config, result); 277 | } 278 | 279 | HRESULT STDMETHODCALLTYPE CContextMenu::addSeparator(){ 280 | return m_Menu->addSeparator(); 281 | } 282 | 283 | HRESULT STDMETHODCALLTYPE CContextMenu::show(){ 284 | POINT point; 285 | GetCursorPos(&point); 286 | 287 | // Show the menu and wait for input. 288 | // If the user selects an item, its WM_COMMAND is sent. 289 | int res = TrackPopupMenuEx(m_Menu->getHandle(), 290 | TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL, 291 | point.x, point.y, m_Window, NULL); 292 | 293 | if (!res){ 294 | LastError err; 295 | } 296 | 297 | return S_OK; 298 | } 299 | #pragma endregion -------------------------------------------------------------------------------- /common/Menu.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 | 22 | #include "combase.h" 23 | #include "..\Interfaces.h" 24 | #include "MyActiveSite.h" 25 | 26 | #define CHECK_AND_FAIL if (!CheckValidity()) return E_FAIL; 27 | 28 | template 29 | class CAbstractMenuItem : public CComDispatch{ 30 | protected: 31 | BOOL m_Removed; 32 | HMENU m_Id_Handle; 33 | HMENU m_ParentMenuHandle; 34 | 35 | UINT getMenuItemState(){ 36 | MENUITEMINFO mii; 37 | mii.cbSize = sizeof(mii); 38 | mii.fMask = MIIM_STATE; 39 | 40 | BOOL res = GetMenuItemInfo( 41 | m_ParentMenuHandle, 42 | (UINT)m_Id_Handle, 43 | FALSE, 44 | &mii 45 | ); 46 | if (!res){ 47 | DWORD err = GetLastError(); 48 | err = err; 49 | } 50 | 51 | return mii.fState; 52 | } 53 | 54 | bool CheckValidity(){ 55 | // allright 56 | if (!m_Removed) 57 | return true; 58 | 59 | // menu element removed 60 | MyActiveSite::Throw(TEXT("Any operations on removed Menu or MenuItem are not allowed!"), __uuidof(IMenu) ); 61 | 62 | return false; 63 | } 64 | 65 | CAbstractMenuItem():CComDispatch(){ 66 | m_Removed = FALSE; 67 | } 68 | public: 69 | virtual HRESULT STDMETHODCALLTYPE get_text( BSTR *result){ 70 | 71 | CHECK_AND_FAIL; // menu item is removed! 72 | 73 | MENUITEMINFO mii; 74 | mii.cbSize = sizeof(mii); 75 | mii.fMask = MIIM_STRING; 76 | mii.fType = MFT_STRING; 77 | mii.dwTypeData = 0; 78 | 79 | // get menu item length 80 | BOOL res=GetMenuItemInfo( 81 | m_ParentMenuHandle, 82 | (UINT)m_Id_Handle, 83 | FALSE, 84 | &mii 85 | ); 86 | 87 | 88 | *result = SysAllocStringLen(NULL, mii.cch); 89 | mii.cch++; 90 | 91 | mii.dwTypeData = *result; 92 | 93 | // get menu item 94 | res = GetMenuItemInfo( 95 | m_ParentMenuHandle, 96 | (UINT)m_Id_Handle, 97 | FALSE, 98 | &mii 99 | ); 100 | 101 | return S_OK; 102 | } 103 | 104 | virtual HRESULT STDMETHODCALLTYPE put_text( BSTR *value){ 105 | CHECK_AND_FAIL; // menu item is removed! 106 | 107 | MENUITEMINFO mii; 108 | mii.cbSize = sizeof(mii); 109 | mii.fMask = MIIM_STRING; 110 | mii.fType = MFT_STRING; 111 | 112 | mii.cch = SysStringLen(*value); 113 | 114 | mii.dwTypeData = *value; 115 | 116 | BOOL res = SetMenuItemInfo( 117 | m_ParentMenuHandle, 118 | (UINT)m_Id_Handle, 119 | FALSE, 120 | &mii 121 | ); 122 | 123 | return S_OK; 124 | } 125 | virtual HRESULT STDMETHODCALLTYPE get_checked( VARIANT_BOOL *result){ 126 | CHECK_AND_FAIL; // menu item is removed! 127 | 128 | UINT state = getMenuItemState(); 129 | *result = state & MFS_CHECKED; 130 | 131 | return S_OK; 132 | } 133 | 134 | virtual HRESULT STDMETHODCALLTYPE put_checked( VARIANT_BOOL value){ 135 | CHECK_AND_FAIL; // menu item is removed! 136 | 137 | UINT state = getMenuItemState(); 138 | 139 | MENUITEMINFO mii; 140 | mii.cbSize = sizeof(mii); 141 | mii.fMask = MIIM_STATE; 142 | UINT s1 = (state & ~MFS_CHECKED); 143 | mii.fState = s1 | ((value)? MFS_CHECKED : MFS_UNCHECKED); 144 | 145 | BOOL res = SetMenuItemInfo( 146 | m_ParentMenuHandle, 147 | (UINT)m_Id_Handle, 148 | FALSE, 149 | &mii 150 | ); 151 | 152 | return S_OK; 153 | } 154 | 155 | virtual HRESULT STDMETHODCALLTYPE get_disabled( VARIANT_BOOL *result){ 156 | CHECK_AND_FAIL; // menu item is removed! 157 | 158 | UINT state = getMenuItemState(); 159 | *result = state & MFS_DISABLED; 160 | return S_OK; 161 | } 162 | 163 | virtual HRESULT STDMETHODCALLTYPE put_disabled( VARIANT_BOOL value){ 164 | CHECK_AND_FAIL; // menu item is removed! 165 | 166 | UINT state = getMenuItemState(); 167 | 168 | MENUITEMINFO mii; 169 | mii.cbSize = sizeof(mii); 170 | mii.fMask = MIIM_STATE; 171 | mii.fState = (state & ~MFS_DISABLED) | ((value)? MFS_DISABLED : MFS_ENABLED); 172 | 173 | BOOL res = SetMenuItemInfo( 174 | m_ParentMenuHandle, 175 | (UINT)m_Id_Handle, 176 | FALSE, 177 | &mii 178 | ); 179 | 180 | return S_OK; 181 | } 182 | 183 | virtual HRESULT STDMETHODCALLTYPE remove(){ 184 | CHECK_AND_FAIL; // menu item is removed! 185 | 186 | BOOL res = DeleteMenu(m_ParentMenuHandle,(UINT)m_Id_Handle, MF_BYCOMMAND); 187 | if (res){ 188 | m_Removed = TRUE; 189 | Release(); // delete self reference 190 | } 191 | 192 | return S_OK; 193 | } 194 | }; 195 | 196 | class CMenuItem : public CAbstractMenuItem 197 | { 198 | private: 199 | ScriptObj* m_Config; 200 | 201 | public: 202 | static CMenuItem* GetInstance(HMENU hmenu, UINT itemPos); 203 | 204 | CMenuItem(HMENU h, WORD id, ScriptObj* config); 205 | 206 | ~CMenuItem(); 207 | 208 | void call(); 209 | }; 210 | 211 | class CMenu : public CAbstractMenuItem 212 | { 213 | protected: 214 | ScriptObj* m_Config; 215 | 216 | private: 217 | WORD m_Items; 218 | HWND m_Hwnd; 219 | 220 | public: 221 | static CMenu* GetInstance(HMENU hmenu); 222 | 223 | CMenu(HMENU parent, HWND menuBarWindow = 0); 224 | CMenu(HMENU parent, int position, VARIANT cfg, HWND menuBarWindow = 0); 225 | 226 | void createMenu(HMENU parent, int position, TCHAR* text, HWND menuBarWindow = 0); 227 | 228 | void oninitpopup(); 229 | 230 | ~CMenu(void); 231 | 232 | HMENU getHandle(); 233 | 234 | virtual HRESULT STDMETHODCALLTYPE addMenu( VARIANT cfg, IMenu **result); 235 | 236 | virtual HRESULT STDMETHODCALLTYPE addItem( IDispatch *config, IMenuItem **result); 237 | 238 | virtual HRESULT STDMETHODCALLTYPE addSeparator( void); 239 | 240 | virtual HRESULT STDMETHODCALLTYPE put_disabled( VARIANT_BOOL value); 241 | 242 | virtual HRESULT STDMETHODCALLTYPE put_text( BSTR *value); 243 | 244 | virtual HRESULT STDMETHODCALLTYPE put_checked( VARIANT_BOOL value); 245 | 246 | }; 247 | 248 | class CContextMenu: public CComDispatch{ 249 | private: 250 | CMenu* m_Menu; 251 | HWND m_Window; 252 | public: 253 | CContextMenu(VARIANT cfg, HWND window); 254 | 255 | ~CContextMenu(); 256 | 257 | virtual HRESULT STDMETHODCALLTYPE addMenu( VARIANT cfg, IMenu **result); 258 | 259 | virtual HRESULT STDMETHODCALLTYPE addItem( IDispatch *config, IMenuItem **result); 260 | 261 | virtual HRESULT STDMETHODCALLTYPE addSeparator( void); 262 | 263 | virtual HRESULT STDMETHODCALLTYPE show(void); 264 | }; -------------------------------------------------------------------------------- /common/MessageOnlyWindow.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 "Dialog\WindowClass.h" 21 | 22 | class MessageOnlyWindow{ 23 | private: 24 | HWND m_Hwnd; 25 | 26 | static LRESULT CALLBACK Proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ 27 | switch (message) 28 | { 29 | case WM_NCCREATE: 30 | return TRUE; 31 | case WM_CREATE: 32 | { 33 | CREATESTRUCT* cstruct = (CREATESTRUCT*)lParam; 34 | 35 | MessageOnlyWindow *instance =(MessageOnlyWindow *)(cstruct->lpCreateParams); 36 | instance->m_Hwnd = hwnd; 37 | ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LPARAM)instance); 38 | 39 | instance->MessageProc(message, wParam, lParam); 40 | 41 | return 0; 42 | } 43 | default : 44 | { 45 | MessageOnlyWindow *instance = (MessageOnlyWindow *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA)); 46 | if (!instance) 47 | return DefWindowProc(hwnd, message, wParam, lParam); 48 | 49 | return instance->MessageProc(message, wParam, lParam); 50 | } 51 | } 52 | } 53 | 54 | ATOM GetWindowClassAtom(){ 55 | // a trick to register a window class once 56 | static WindowClass wc(TEXT("MessageOnlyWindow"), WNDPROC(Proc), Statics::instance().hInstance); 57 | 58 | return wc.wclAtom; 59 | } 60 | 61 | public: 62 | MessageOnlyWindow(){ 63 | CreateWindowEx( 0, LPCWSTR(LOWORD(GetWindowClassAtom())), TEXT("dummy_name"), 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, this ); 64 | } 65 | 66 | virtual LRESULT MessageProc(UINT message, WPARAM wParam, LPARAM lParam){ 67 | return DefWindowProc(m_Hwnd, message, wParam, lParam); 68 | } 69 | 70 | HWND handle(){ 71 | return m_Hwnd; 72 | } 73 | }; -------------------------------------------------------------------------------- /common/MyActiveSite.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michaelxzhang/Npp-Highlighter/7d4cc7bccdccd1528f022749fe2b0d1bd0f3ad44/common/MyActiveSite.h -------------------------------------------------------------------------------- /common/ScriptedIdleHandler.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 "ScriptedIdleHandler.h" 19 | #include "MyActiveSite.h" 20 | 21 | ScriptedIdleHandler::ScriptedIdleHandler(IDispatchEx* obj){ 22 | m_Obj = obj; 23 | m_Obj->AddRef(); 24 | } 25 | void ScriptedIdleHandler::execute(){ 26 | MyActiveSite::callMethod(TEXT("cmd"), m_Obj); 27 | m_Obj->Release(); 28 | delete this; 29 | } 30 | -------------------------------------------------------------------------------- /common/ScriptedIdleHandler.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 "ForegroundIdleHook.h" 22 | 23 | class ScriptedIdleHandler : public ForegroundIdleHook::IdleHandler{ 24 | IDispatchEx* m_Obj; 25 | public: 26 | ScriptedIdleHandler(IDispatchEx* obj); 27 | void execute(); 28 | }; -------------------------------------------------------------------------------- /common/Scripting/EULA.txt: -------------------------------------------------------------------------------- 1 | THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS 2 | PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS 3 | ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES 4 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO 5 | EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR 6 | ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, 7 | CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF 8 | MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE 9 | POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION 10 | OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES 11 | SO THE FOREGOING LIMITATION MAY NOT APPLY. 12 | 13 | MICROSOFT DOES NOT WARRANT THAT THE FUNCTIONS FOR THE LICENSED SOFTWARE 14 | OR CODE CONTAINED IN THE KNOWLEDGE BASE WILL MEET YOUR REQUIREMENTS, OR 15 | THAT THE OPERATION OF THE LICENSED SOFTWARE OR CODE WILL BE UNINTERRUPTED 16 | OR ERROR-FREE, OR THAT DEFECTS IN THE LICENSED SOFTWARE OR CODE CAN BE 17 | CORRECTED. FURTHERMORE, MICROSOFT DOES NOT WARRANT OR MAKE ANY 18 | REPRESENTATIONS REGARDING THE USE OR THE RESULTS OF THE USE OF THE LICENSED 19 | SOFTWARE, CODE OR RELATED DOCUMENTATION IN TERMS OF THEIR CORRECTNESS, 20 | ACCURACY, RELIABILITY, OR OTHERWISE. NO ORAL OR WRITTEN INFORMATION OR ADVICE 21 | GIVEN BY MICROSOFT OR ITS AUTHORIZED REPRESENTATIVES SHALL CREATE A WARRANTY 22 | OR IN ANY WAY INCREASE THE SCOPE OF THIS WARRANTY. SHOULD THE LICENSED 23 | SOFTWARE OR CODE PROVE DEFECTIVE AFTER MICROSOFT HAS DELIVERED THE SAME, 24 | YOU, AND YOU ALONE, SHALL ASSUME THE ENTIRE COST ASSOCIATED WITH ALL 25 | NECESSARY SERVICING, REPAIR OR CORRECTION. 26 | 27 | -------------------------------------------------------------------------------- /common/Scripting/HostInfo.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * File: HostInfo.h 4 | * 5 | * Author: Joel Alley 6 | * 7 | * Date: June 4, 1998 8 | * 9 | * Description: This file contains the declaration of two interfaces 10 | * necessary for an ActiveX Script Host to change the LCID that 11 | * VBScript.dll uses for error messages. 12 | * 13 | * Modifications: 14 | ******************************************************************************/ 15 | #ifndef HOST_INFO_H_INCLUDED 16 | #define HOST_INFO_H_INCLUDED 17 | 18 | // {1D044690-8923-11d0-ABD2-00A0C911E8B2} 19 | const GUID IID_IHostInfoUpdate = 20 | { 0x1d044690, 0x8923, 0x11d0, { 0xab, 0xd2, 0x0, 0xa0, 0xc9, 0x11, 0xe8, 0xb2 } }; 21 | 22 | enum hostinfo 23 | { 24 | hostinfoLocale = 0, 25 | hostinfoCodePage = 1, 26 | hostinfoErrorLocale = 2 27 | }; 28 | 29 | class IHostInfoUpdate : public IUnknown 30 | { 31 | public: 32 | // *** IUnknown Methods *** 33 | STDMETHOD(QueryInterface)(REFIID riid, void **ppvObj) = 0; 34 | STDMETHOD_(ULONG,AddRef)(void) = 0; 35 | STDMETHOD_(ULONG,Release)(void) = 0; 36 | 37 | // *** IHostInfoUpdate Methods *** 38 | STDMETHOD(UpdateInfo)(hostinfo hostinfoNew) = 0; 39 | }; 40 | 41 | // {F8418AE0-9A5D-11d0-ABD4-00A0C911E8B2} 42 | const GUID IID_IHostInfoProvider = 43 | { 0xf8418ae0, 0x9a5d, 0x11d0, { 0xab, 0xd4, 0x0, 0xa0, 0xc9, 0x11, 0xe8, 0xb2 } }; 44 | 45 | class IHostInfoProvider : public IUnknown 46 | { 47 | 48 | public: 49 | 50 | // *** IUnknown Methods *** 51 | STDMETHOD(QueryInterface)(REFIID riid, void **ppvObj) = 0; 52 | STDMETHOD_(ULONG,AddRef)(void) = 0; 53 | STDMETHOD_(ULONG,Release)(void) = 0; 54 | 55 | // *** IHostInfoProvider Methods *** 56 | STDMETHOD(GetHostInfo)(hostinfo hostinfoRequest, void * * ppvInfo) = 0; 57 | }; 58 | 59 | #endif // HOST_INFO_H_INCLUDED 60 | -------------------------------------------------------------------------------- /common/Scripting/Multinfo.h: -------------------------------------------------------------------------------- 1 | /* this ALWAYS GENERATED file contains the definitions for the interfaces */ 2 | 3 | 4 | /* File created by MIDL compiler version 2.00.0102 */ 5 | /* at Fri Mar 29 16:59:57 1996 6 | */ 7 | //@@MIDL_FILE_HEADING( ) 8 | #include "rpc.h" 9 | #include "rpcndr.h" 10 | #ifndef COM_NO_WINDOWS_H 11 | #include "windows.h" 12 | #include "ole2.h" 13 | #endif /*COM_NO_WINDOWS_H*/ 14 | 15 | #ifndef __multinfo_h__ 16 | #define __multinfo_h__ 17 | 18 | #ifdef __cplusplus 19 | extern "C"{ 20 | #endif 21 | 22 | /* Forward Declarations */ 23 | 24 | #ifndef __IProvideClassInfo_FWD_DEFINED__ 25 | #define __IProvideClassInfo_FWD_DEFINED__ 26 | typedef interface IProvideClassInfo IProvideClassInfo; 27 | #endif /* __IProvideClassInfo_FWD_DEFINED__ */ 28 | 29 | 30 | #ifndef __IProvideClassInfo2_FWD_DEFINED__ 31 | #define __IProvideClassInfo2_FWD_DEFINED__ 32 | typedef interface IProvideClassInfo2 IProvideClassInfo2; 33 | #endif /* __IProvideClassInfo2_FWD_DEFINED__ */ 34 | 35 | 36 | #ifndef __IProvideMultipleClassInfo_FWD_DEFINED__ 37 | #define __IProvideMultipleClassInfo_FWD_DEFINED__ 38 | typedef interface IProvideMultipleClassInfo IProvideMultipleClassInfo; 39 | #endif /* __IProvideMultipleClassInfo_FWD_DEFINED__ */ 40 | 41 | 42 | /* header files for imported files */ 43 | #include "oaidl.h" 44 | 45 | void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t); 46 | void __RPC_USER MIDL_user_free( void __RPC_FAR * ); 47 | 48 | /**************************************** 49 | * Generated header for interface: __MIDL__intf_0000 50 | * at Fri Mar 29 16:59:57 1996 51 | * using MIDL 2.00.0102 52 | ****************************************/ 53 | /* [local] */ 54 | 55 | 56 | #ifndef _OLECTL_H_ 57 | #include 58 | #endif 59 | 60 | // {A7ABA9C1-8983-11cf-8F20-00805F2CD064} 61 | DEFINE_GUID(IID_IProvideMultipleClassInfo, 62 | 0xa7aba9c1, 0x8983, 0x11cf, 0x8f, 0x20, 0x0, 0x80, 0x5f, 0x2c, 0xd0, 0x64); 63 | 64 | 65 | extern RPC_IF_HANDLE __MIDL__intf_0053_v0_0_c_ifspec; 66 | extern RPC_IF_HANDLE __MIDL__intf_0053_v0_0_s_ifspec; 67 | 68 | #ifndef __IProvideMultipleClassInfo_INTERFACE_DEFINED__ 69 | #define __IProvideMultipleClassInfo_INTERFACE_DEFINED__ 70 | 71 | /**************************************** 72 | * Generated header for interface: IProvideMultipleClassInfo 73 | * at Fri Mar 29 16:59:57 1996 74 | * using MIDL 2.00.0102 75 | ****************************************/ 76 | /* [unique][uuid][object] */ 77 | 78 | 79 | #define MULTICLASSINFO_GETTYPEINFO 0x00000001 80 | #define MULTICLASSINFO_GETNUMRESERVEDDISPIDS 0x00000002 81 | #define MULTICLASSINFO_GETIIDPRIMARY 0x00000004 82 | #define MULTICLASSINFO_GETIIDSOURCE 0x00000008 83 | #define TIFLAGS_EXTENDDISPATCHONLY 0x00000001 84 | 85 | EXTERN_C const IID IID_IProvideMultipleClassInfo; 86 | 87 | #if defined(__cplusplus) && !defined(CINTERFACE) 88 | 89 | interface IProvideMultipleClassInfo : public IProvideClassInfo2 90 | { 91 | public: 92 | virtual HRESULT __stdcall GetMultiTypeInfoCount( 93 | /* [out] */ ULONG __RPC_FAR *pcti) = 0; 94 | 95 | virtual HRESULT __stdcall GetInfoOfIndex( 96 | /* [in] */ ULONG iti, 97 | /* [in] */ DWORD dwFlags, 98 | /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *pptiCoClass, 99 | /* [out] */ DWORD __RPC_FAR *pdwTIFlags, 100 | /* [out] */ ULONG __RPC_FAR *pcdispidReserved, 101 | /* [out] */ IID __RPC_FAR *piidPrimary, 102 | /* [out] */ IID __RPC_FAR *piidSource) = 0; 103 | 104 | }; 105 | 106 | #else /* C style interface */ 107 | 108 | typedef struct IProvideMultipleClassInfoVtbl 109 | { 110 | 111 | HRESULT ( __stdcall __RPC_FAR *QueryInterface )( 112 | IProvideMultipleClassInfo __RPC_FAR * This, 113 | /* [in] */ REFIID riid, 114 | /* [out] */ void __RPC_FAR *__RPC_FAR *ppvObject); 115 | 116 | ULONG ( __stdcall __RPC_FAR *AddRef )( 117 | IProvideMultipleClassInfo __RPC_FAR * This); 118 | 119 | ULONG ( __stdcall __RPC_FAR *Release )( 120 | IProvideMultipleClassInfo __RPC_FAR * This); 121 | 122 | HRESULT ( __stdcall __RPC_FAR *GetClassInfo )( 123 | IProvideMultipleClassInfo __RPC_FAR * This, 124 | /* [out] */ LPTYPEINFO __RPC_FAR *ppTI); 125 | 126 | HRESULT ( __stdcall __RPC_FAR *GetGUID )( 127 | IProvideMultipleClassInfo __RPC_FAR * This, 128 | /* [in] */ DWORD dwGuidKind, 129 | /* [out] */ GUID __RPC_FAR *pGUID); 130 | 131 | HRESULT ( __stdcall __RPC_FAR *GetMultiTypeInfoCount )( 132 | IProvideMultipleClassInfo __RPC_FAR * This, 133 | /* [out] */ ULONG __RPC_FAR *pcti); 134 | 135 | HRESULT ( __stdcall __RPC_FAR *GetInfoOfIndex )( 136 | IProvideMultipleClassInfo __RPC_FAR * This, 137 | /* [in] */ ULONG iti, 138 | /* [in] */ DWORD dwFlags, 139 | /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *pptiCoClass, 140 | /* [out] */ DWORD __RPC_FAR *pdwTIFlags, 141 | /* [out] */ ULONG __RPC_FAR *pcdispidReserved, 142 | /* [out] */ IID __RPC_FAR *piidPrimary, 143 | /* [out] */ IID __RPC_FAR *piidSource); 144 | 145 | } IProvideMultipleClassInfoVtbl; 146 | 147 | interface IProvideMultipleClassInfo 148 | { 149 | CONST_VTBL struct IProvideMultipleClassInfoVtbl __RPC_FAR *lpVtbl; 150 | }; 151 | 152 | 153 | 154 | #ifdef COBJMACROS 155 | 156 | 157 | #define IProvideMultipleClassInfo_QueryInterface(This,riid,ppvObject) \ 158 | (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) 159 | 160 | #define IProvideMultipleClassInfo_AddRef(This) \ 161 | (This)->lpVtbl -> AddRef(This) 162 | 163 | #define IProvideMultipleClassInfo_Release(This) \ 164 | (This)->lpVtbl -> Release(This) 165 | 166 | 167 | #define IProvideMultipleClassInfo_GetClassInfo(This,ppTI) \ 168 | (This)->lpVtbl -> GetClassInfo(This,ppTI) 169 | 170 | 171 | #define IProvideMultipleClassInfo_GetGUID(This,dwGuidKind,pGUID) \ 172 | (This)->lpVtbl -> GetGUID(This,dwGuidKind,pGUID) 173 | 174 | 175 | #define IProvideMultipleClassInfo_GetMultiTypeInfoCount(This,pcti) \ 176 | (This)->lpVtbl -> GetMultiTypeInfoCount(This,pcti) 177 | 178 | #define IProvideMultipleClassInfo_GetInfoOfIndex(This,iti,dwFlags,pptiCoClass,pdwTIFlags,pcdispidReserved,piidPrimary,piidSource) \ 179 | (This)->lpVtbl -> GetInfoOfIndex(This,iti,dwFlags,pptiCoClass,pdwTIFlags,pcdispidReserved,piidPrimary,piidSource) 180 | 181 | #endif /* COBJMACROS */ 182 | 183 | 184 | #endif /* C style interface */ 185 | 186 | 187 | 188 | HRESULT __stdcall IProvideMultipleClassInfo_GetMultiTypeInfoCount_Proxy( 189 | IProvideMultipleClassInfo __RPC_FAR * This, 190 | /* [out] */ ULONG __RPC_FAR *pcti); 191 | 192 | 193 | void __RPC_STUB IProvideMultipleClassInfo_GetMultiTypeInfoCount_Stub( 194 | IRpcStubBuffer *This, 195 | IRpcChannelBuffer *_pRpcChannelBuffer, 196 | PRPC_MESSAGE _pRpcMessage, 197 | DWORD *_pdwStubPhase); 198 | 199 | 200 | HRESULT __stdcall IProvideMultipleClassInfo_GetInfoOfIndex_Proxy( 201 | IProvideMultipleClassInfo __RPC_FAR * This, 202 | /* [in] */ ULONG iti, 203 | /* [in] */ DWORD dwFlags, 204 | /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *pptiCoClass, 205 | /* [out] */ DWORD __RPC_FAR *pdwTIFlags, 206 | /* [out] */ ULONG __RPC_FAR *pcdispidReserved, 207 | /* [out] */ IID __RPC_FAR *piidPrimary, 208 | /* [out] */ IID __RPC_FAR *piidSource); 209 | 210 | 211 | void __RPC_STUB IProvideMultipleClassInfo_GetInfoOfIndex_Stub( 212 | IRpcStubBuffer *This, 213 | IRpcChannelBuffer *_pRpcChannelBuffer, 214 | PRPC_MESSAGE _pRpcMessage, 215 | DWORD *_pdwStubPhase); 216 | 217 | 218 | 219 | #endif /* __IProvideMultipleClassInfo_INTERFACE_DEFINED__ */ 220 | 221 | 222 | /* Additional Prototypes for ALL interfaces */ 223 | 224 | /* end of Additional Prototypes */ 225 | 226 | #ifdef __cplusplus 227 | } 228 | #endif 229 | 230 | #endif 231 | -------------------------------------------------------------------------------- /common/Scripting/Readme.txt: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------- 2 | Readme.txt file for Scriptng.exe 3 | --------------------------------------------------------- 4 | 5 | This file describes the contents of Scriptng.exe, a self-extracting executable 6 | file that contains the headers and libraries necessary to create your own 7 | ActiveX Script hosts and engines. Its primary purpose is to provide the files 8 | required to add Active Debugging to a host or engine. 9 | 10 | Scriptng.exe contains the following files: 11 | 12 | --------------------------------------------------------- 13 | FileName Size 14 | --------------------------------------------------------- 15 | 16 | activdbg.h 323KB 17 | activscp.h 67KB 18 | ad1.lib 19KB 19 | ad1ex.h 39KB 20 | dbgprop.h 50KB 21 | Dispex.h 31KB 22 | HostInfo.h 2KB 23 | Multinfo.h 8KB 24 | Readme.txt 2KB 25 | 26 | REFERENCES 27 | ---------- 28 | 29 | For additional information about ActiveX Script hosts, please see the following 30 | articles in the Microsoft Knowledge Base: 31 | 32 | Q183698 Sample: Axsh.exe Demonstrates Implementing ActiveX Script Hosts 33 | 34 | Q168214 Sample: MFCAxs.exe Implements an ActiveX Script Host Using MFC 35 | 36 | For additional information about ActiveX Script engines, please see the following 37 | articles in the Microsoft Knowledge Base: 38 | 39 | Q216073 Sample: 4thScrpt.exe Demos Active Debug in ATL ActiveX Script Engine 40 | 41 | Q216271 Sample: SamScrpt.exe Demos Active Debug in C++ ActiveX Script Engine -------------------------------------------------------------------------------- /common/Statics.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 "Statics.h" 19 | #include "LastError.h" 20 | 21 | 22 | Statics::Statics(){ 23 | hInstance = 0; 24 | hWindow = 0; 25 | } 26 | 27 | ITypeLib* Statics::GetTypeLib(){ 28 | 29 | TCHAR dllpath[MAX_PATH]; 30 | GetModuleFileName(hInstance, dllpath, MAX_PATH); 31 | 32 | ITypeLib* result = NULL; 33 | HRESULT hr = LoadTypeLib(dllpath, &result); 34 | 35 | if (!SUCCEEDED(hr)){ 36 | LastError err; 37 | throw err.staticmessage(); 38 | } 39 | 40 | return result; 41 | } 42 | 43 | Statics& Statics::instance(){ 44 | static Statics s_instance; 45 | 46 | return s_instance; 47 | } 48 | -------------------------------------------------------------------------------- /common/Statics.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 | 22 | // This class loads type library for given dll. It works as proxy between consumer and the 23 | // real type library. It loads type library if there is at least one real consumer and releases it otherwise 24 | class Statics 25 | { 26 | public: 27 | HINSTANCE hInstance; 28 | HWND hWindow; 29 | 30 | Statics(); 31 | 32 | ITypeLib* GetTypeLib(); 33 | 34 | static Statics& instance(); 35 | }; -------------------------------------------------------------------------------- /common/SysStr.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 "oleauto.h" 21 | #include 22 | #include 23 | 24 | class SysStr{ 25 | private: 26 | BSTR m_Str; 27 | void Free(){ 28 | if (m_Str){ 29 | SysFreeString(m_Str); 30 | m_Str = NULL; 31 | } 32 | } 33 | 34 | public: 35 | BSTR Clone(){ 36 | if (!m_Str) 37 | return NULL; 38 | 39 | return SysAllocString(m_Str); 40 | } 41 | 42 | int Length(){ 43 | if (!m_Str) 44 | return -1; 45 | 46 | return SysStringLen(m_Str); 47 | } 48 | 49 | SysStr& Append(BSTR value){ 50 | if (!m_Str){ 51 | Set(value); 52 | return *this; 53 | } 54 | 55 | UINT len = SysStringLen(value); 56 | UINT newLen = len + Length(); 57 | 58 | SysReAllocStringLen(&m_Str, m_Str, newLen); 59 | 60 | StringCchCat(m_Str, newLen+1, value); 61 | 62 | return *this; 63 | } 64 | 65 | template 66 | SysStr& Append(const TCHAR (&value) [sz]) { 67 | if (!m_Str) { 68 | Set(value); 69 | return *this; 70 | } 71 | 72 | UINT newLen = sz + Length(); 73 | 74 | SysReAllocStringLen(&m_Str, m_Str, newLen); 75 | 76 | StringCchCat(m_Str, newLen + 1, value); 77 | 78 | return *this; 79 | } 80 | 81 | void Set(const TCHAR* value){ 82 | Free(); 83 | 84 | if (value) 85 | m_Str = SysAllocString(value); 86 | } 87 | 88 | SysStr(const TCHAR* value){ 89 | m_Str = NULL; 90 | 91 | Set(value); 92 | } 93 | 94 | SysStr(const SysStr& value) { 95 | m_Str = NULL; 96 | 97 | Set(value.m_Str); 98 | } 99 | 100 | BSTR* operator& () { return &m_Str; } 101 | 102 | ~SysStr(){ 103 | Free(); 104 | } 105 | 106 | operator const BSTR(){ 107 | return m_Str; 108 | } 109 | }; -------------------------------------------------------------------------------- /common/System.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 | 22 | #include "combase.h" 23 | #include "SysStr.h" 24 | #include "MyActiveSite.h" 25 | 26 | #include "..\Interfaces.h" 27 | 28 | #include "dialog\windowclass.h" 29 | #include "MessageOnlyWindow.h" 30 | 31 | 32 | class CallBack :public CComDispatch 33 | { 34 | private: 35 | unsigned int m_Stack; 36 | IDispatchEx* m_Cfg; 37 | unsigned int m_Num; 38 | 39 | 40 | CallBack(unsigned int stacksize, IDispatchEx* cfg, unsigned int num); 41 | 42 | DWORD Call(void* ebp); 43 | 44 | static CallBack** GetCallBack(unsigned int index); 45 | 46 | typedef DWORD (WINAPI CBP)(void); 47 | 48 | public: 49 | static CallBack* RegisterCallBack( IDispatchEx *cfg, unsigned int stacksize); 50 | 51 | ~CallBack(); 52 | 53 | CBP* Proc(); 54 | 55 | template 56 | static DWORD WINAPI CallBackProc(){ 57 | #ifndef _M_X64 58 | void* v_ebp; // base pointer, points to actual parameters of called callback function 59 | 60 | __asm { 61 | mov v_ebp, ebp 62 | } 63 | 64 | CallBack* cb = *GetCallBack(NUM); 65 | return cb->Call(v_ebp); // provide actual parameters 66 | #else 67 | #pragma message(": warning: Library::call not available") 68 | return 0; 69 | #endif 70 | 71 | }; 72 | }; 73 | 74 | 75 | 76 | class System: public CComDispatch, public MessageOnlyWindow 77 | { 78 | private: 79 | SysStr m_ScriptFullName; 80 | 81 | int m_SystemHotKeysCount; 82 | 83 | typedef std::vector HotKeyHandlers; 84 | 85 | HotKeyHandlers m_SystemHotKeysHandler; 86 | 87 | MyActiveSite& m_ActiveSite; 88 | public: 89 | System(TCHAR* scriptFullName, MyActiveSite& activeSite); 90 | virtual ~System(void); 91 | 92 | static WORD getKeyCode(ScriptObj* cfgEx); 93 | static int getAcceleratorModifier(ScriptObj* cfgEx); 94 | 95 | LRESULT MessageProc(UINT message, WPARAM wp, LPARAM lp) override; 96 | 97 | HRESULT STDMETHODCALLTYPE decodeFrom( int codepage,BSTR *value,BSTR *result); 98 | 99 | HRESULT STDMETHODCALLTYPE encodeTo( int codepage,BSTR *value,BSTR *result); 100 | 101 | HRESULT STDMETHODCALLTYPE addSystemHotKey(IDispatch* cfg); 102 | 103 | 104 | HRESULT STDMETHODCALLTYPE createDialog(IDispatch* cfg, IDialog** result); 105 | HRESULT STDMETHODCALLTYPE addIdleHandler(IDispatch* cfg); 106 | HRESULT STDMETHODCALLTYPE addScript(BSTR* value, VARIANT* name); 107 | 108 | HRESULT STDMETHODCALLTYPE setTimeout(IDispatch* cfg); 109 | 110 | HRESULT STDMETHODCALLTYPE put_clipBoard( BSTR *value); 111 | 112 | HRESULT STDMETHODCALLTYPE get_clipBoard( BSTR *result); 113 | 114 | HRESULT STDMETHODCALLTYPE loadLibrary(BSTR* libraryPath, ILibrary** result); 115 | 116 | HRESULT STDMETHODCALLTYPE registerCallBack( IDispatch *cfg, unsigned int stacksize, ICallBack **result); 117 | 118 | HRESULT STDMETHODCALLTYPE get_scriptFullName( BSTR *result); 119 | 120 | HRESULT STDMETHODCALLTYPE showNotification(IDispatch* cfg); 121 | 122 | }; 123 | -------------------------------------------------------------------------------- /common/Timer.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 "Timer.h" 19 | #include "Windows.h" 20 | #include "..\Interfaces.h" 21 | 22 | #include "LastError.h" 23 | 24 | Timer::Timer(void) 25 | { 26 | } 27 | 28 | void Timer::Add(Handler* handler, int millis){ 29 | static TCHAR exceptionBuf[100]; 30 | 31 | if (millis < USER_TIMER_MINIMUM){ 32 | StringCbPrintf(exceptionBuf, sizeof(exceptionBuf), TEXT("The millis value %d should be greater than %d"), millis, USER_TIMER_MINIMUM); 33 | throw exceptionBuf; 34 | } 35 | 36 | if (millis > USER_TIMER_MAXIMUM){ 37 | StringCbPrintf(exceptionBuf, sizeof(exceptionBuf), TEXT("The millis value %d should be less than %d"), millis, USER_TIMER_MAXIMUM); 38 | throw exceptionBuf; 39 | } 40 | 41 | 42 | UINT_PTR timerId = SetTimer(NULL, NULL, millis, Timer::TimerProc); 43 | if (timerId == NULL){ 44 | LastError errMsg; 45 | throw errMsg.staticmessage(); 46 | } 47 | 48 | m_Handlers.insert(Handlers::value_type(timerId, handler)); 49 | } 50 | 51 | void Timer::Remove(Handler* handler){ 52 | for(Handlers::iterator it=m_Handlers.begin(); it!=m_Handlers.end(); ){ 53 | Handlers::iterator current = it; 54 | ++it; 55 | 56 | if (current->second == handler) 57 | m_Handlers.erase(current); 58 | } 59 | } 60 | 61 | Timer::~Timer(void){ 62 | } 63 | 64 | void Timer::TimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime){ 65 | KillTimer(NULL, idEvent); 66 | 67 | Timer* t = GetInstance(); 68 | 69 | Handlers::iterator findIt = t->m_Handlers.find(idEvent); 70 | 71 | if (findIt == t->m_Handlers.end()) 72 | return; 73 | 74 | Handler* cfg = findIt->second; 75 | 76 | t->m_Handlers.erase(findIt); 77 | 78 | cfg->execute(); 79 | } 80 | 81 | Timer* Timer::GetInstance(){ 82 | static Timer t; 83 | return &t; 84 | } -------------------------------------------------------------------------------- /common/Timer.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 "windows.h" 20 | #include 21 | #include 22 | 23 | #include "MyActiveSite.h" 24 | 25 | class Timer{ 26 | public: 27 | class Handler{ 28 | public: 29 | virtual void execute(){ 30 | // overload this method 31 | } 32 | }; 33 | 34 | private: 35 | typedef std::map Handlers; 36 | 37 | Handlers m_Handlers; 38 | 39 | public: 40 | Timer(void); 41 | ~Timer(void); 42 | 43 | static void CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime); 44 | 45 | void Add(Handler* handler, int millis); 46 | void Remove(Handler* handler); 47 | 48 | static Timer* GetInstance(); 49 | }; 50 | -------------------------------------------------------------------------------- /common/common.idl: -------------------------------------------------------------------------------- 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 | [ 20 | uuid(0614FB00-6702-11d4-B0B7-0050BABFC800), 21 | oleautomation, 22 | helpstring("Represents a menu item with command.") 23 | ] 24 | interface IMenuItem : IDispatch 25 | { 26 | 27 | [propget, helpstring("Text of menu item")] 28 | HRESULT text([out,retval] BSTR* result); 29 | [propput] HRESULT text([in] BSTR* value); 30 | 31 | [propget, helpstring("Value indicating whether a check mark appears next to the text of the menu item.")] 32 | HRESULT checked([out,retval] VARIANT_BOOL* result); 33 | [propput] HRESULT checked([in] VARIANT_BOOL value); 34 | 35 | [propget, helpstring("Value indicating whether the menu item can respond to user interaction.")] 36 | HRESULT disabled([out,retval] VARIANT_BOOL* result); 37 | [propput] HRESULT disabled([in] VARIANT_BOOL value); 38 | 39 | [helpstring("Removes the menu item from it's parent.")] 40 | HRESULT remove(); 41 | }; 42 | 43 | 44 | [ 45 | uuid(0614FB00-6702-11d4-B0B7-0050BABFC801), 46 | oleautomation, 47 | helpstring("Represents a submenu.") 48 | ] 49 | interface IMenu : IMenuItem 50 | { 51 | [helpstring("Appends a new menu and returns its. cfg = {text:'my menu', oninitpopup:function(){}}")] 52 | HRESULT addMenu([in]VARIANT cfg, [out, retval]IMenu** result);// no cmd, text only 53 | 54 | [helpstring("Appends a new menu item to the menu. Returns new menu item object. cfg = {text:'My Menu', cmd:function(){}}")] 55 | HRESULT addItem([in]IDispatch* cfg, [out, retval]IMenuItem** result); // {text:"",cmd:function(){}} 56 | 57 | [helpstring("Appends a separator to the menu.")] 58 | HRESULT addSeparator(); 59 | 60 | }; 61 | 62 | [ 63 | uuid(0614FB00-6702-11d4-B0B7-0050BABFC802), 64 | oleautomation, 65 | helpstring("Represents a context menu.") 66 | ] 67 | interface ICtxMenu : IDispatch 68 | { 69 | [helpstring("Appends a new menu and returns its. cfg = {text:'my menu', oninitpopup:function(){}}")] 70 | HRESULT addMenu([in]VARIANT cfg, [out, retval]IMenu** result);// no cmd, text only 71 | 72 | [helpstring("Appends a new menu item to the menu. Returns new menu item object. cfg = {text:'My Menu', cmd:function(){}}")] 73 | HRESULT addItem([in]IDispatch* cfg, [out, retval]IMenuItem** result); // {text:"",cmd:function(){}} 74 | 75 | [helpstring("Appends a separator to the menu.")] 76 | HRESULT addSeparator(); 77 | 78 | [helpstring("Shows menu")] 79 | HRESULT show(); 80 | }; 81 | 82 | [ 83 | uuid(0614FB00-6702-11d4-B0B7-0050BABFC905), 84 | oleautomation, 85 | helpstring("Represents a HTML based dialog window.") 86 | ] 87 | interface IDialog : IDispatch 88 | { 89 | [propget, helpstring("Value indicating whether the dialog is visible.")] 90 | HRESULT visible([out,retval] VARIANT_BOOL * result); 91 | [propput] HRESULT visible([in] VARIANT_BOOL value); 92 | 93 | [propget, helpstring("Height of dialog window.")] 94 | HRESULT height([out,retval] int* result); 95 | [propput] HRESULT height([in] int value); 96 | 97 | [propget, helpstring("Width of dialog window.")] 98 | HRESULT width([out,retval] int* result); 99 | [propput] HRESULT width([in] int value); 100 | 101 | [propget, helpstring("Height of client area of dialog window.")] 102 | HRESULT clientHeight([out,retval] int* result); 103 | [propput] HRESULT clientHeight([in] int value); 104 | 105 | [propget, helpstring("Width of client area of dialog window.")] 106 | HRESULT clientWidth([out,retval] int* result); 107 | [propput] HRESULT clientWidth([in] int value); 108 | 109 | [propget, helpstring("Distance, in pixels, between the top edge of the dialog window and the top edge of screen.")] 110 | HRESULT top([out,retval] int* result); 111 | [propput] HRESULT top([in] int value); 112 | 113 | [propget, helpstring("Distance, in pixels, between the left edge of the dialog window and the left edge of screen.")] 114 | HRESULT left([out,retval] int* result); 115 | [propput] HRESULT left([in] int value); 116 | 117 | [propget, helpstring("Title of the dialog window.")] 118 | HRESULT title([out,retval] BSTR* result); 119 | [propput] HRESULT title([in] BSTR* value); 120 | 121 | [propget, helpstring("DOM Document that is the representation of client area of dialog window.")] 122 | HRESULT document([out,retval] IDispatch** result); 123 | 124 | [helpstring("Hides and prepares the dialog window to be destroyed.")] 125 | HRESULT close(); 126 | 127 | [propget, helpstring("Window handle of dialog.")] 128 | HRESULT handle([out,retval] int* result); 129 | 130 | [helpstring("Sets window into the foreground and activates it.")] 131 | HRESULT foreground(); 132 | }; 133 | 134 | 135 | 136 | 137 | [ 138 | uuid(0614FB00-6702-11d4-B0B7-0050BABFC907), 139 | oleautomation, 140 | helpstring("Collection of methods to make calls of exported functions of specified" 141 | " dynamic-link library.") 142 | ] 143 | interface ILibrary : IDispatch 144 | { 145 | [helpstring("Allocates specified number of bytes.")] 146 | HRESULT alloc([in]unsigned int number, [out,retval]BSTR* dest); 147 | 148 | 149 | [helpstring("Calls specified function.")] 150 | HRESULT call([in]BSTR functionName,[in]BSTR params, [out, retval]int* result); 151 | 152 | [helpstring("Writes BYTE from value to dest beginning at pos.")] 153 | HRESULT writeByte([in]BSTR dest, [in]unsigned int pos, [in]VARIANT value); 154 | 155 | [helpstring("Writes WORD from value to dest beginning at pos.")] 156 | HRESULT writeWord([in]BSTR dest, [in]unsigned int pos, [in]VARIANT value); 157 | 158 | [helpstring("Writes DWORD from value to dest beginning at pos.")] 159 | HRESULT writeDWord([in]BSTR dest, [in]unsigned int pos, [in]VARIANT value); 160 | 161 | [helpstring("Writes INT64 from value to dest beginning at pos.")] 162 | HRESULT writeInt64([in]BSTR dest, [in]unsigned int pos, [in]VARIANT value); 163 | 164 | [helpstring("Reads BYTE from src beginning at pos.")] 165 | HRESULT readByte([in]BSTR src, [in]unsigned int pos, [out, retval]VARIANT* result); 166 | 167 | [helpstring("Reads WORD from src beginning at pos.")] 168 | HRESULT readWord([in]BSTR src, [in]unsigned int pos, [out, retval]VARIANT* result); 169 | 170 | [helpstring("Reads DWORD from src beginning at pos.")] 171 | HRESULT readDWord([in]BSTR src, [in]unsigned int pos, [out, retval]VARIANT* result); 172 | 173 | [helpstring("Reads INT64 from src beginning at pos.")] 174 | HRESULT readInt64([in]BSTR src, [in]unsigned int pos, [out, retval]VARIANT* result); 175 | 176 | [helpstring("Reads (4 Bytes) from src beginning at pos and interprets it as BSTR.")] 177 | HRESULT readBSTR([in]BSTR src, [in]unsigned int pos, [out, retval]BSTR* result); 178 | 179 | 180 | [helpstring("Copies bytes from src to dest beginning at pos.")] 181 | HRESULT copy([in]BSTR dest, [in]unsigned int destPos, [in]BSTR src, [in]unsigned int srcPos, [in]unsigned int size); 182 | 183 | }; 184 | 185 | [ 186 | uuid(0614FB00-6702-11d4-B0B7-0050BABFC908), 187 | oleautomation, 188 | helpstring("Represents one of 12 possible callback functions") 189 | ] 190 | interface ICallBack : IDispatch 191 | { 192 | } 193 | 194 | 195 | [ 196 | uuid(0614FB00-6702-11d4-B0B7-0050BABFC909), 197 | oleautomation, 198 | helpstring("Collection of system functions. Methods of this interface are globally available. It means " 199 | "you can omit keyword 'System' to access to its methods.") 200 | ] 201 | interface ISystem : IDispatch 202 | { 203 | [helpstring("Decodes source string encoded by codepage.")] 204 | HRESULT decodeFrom([in]int codepage, [in]BSTR* src, [out,retval]BSTR* dest); 205 | 206 | [helpstring("Encodes source string by codepage.")] 207 | HRESULT encodeTo([in]int codepage, [in]BSTR* src, [out,retval]BSTR* result); 208 | 209 | [helpstring("Adds new system wide hot key combination. cfg = {ctrl:true, shift:false, alt:true, key:'a', cmd: function(){}}. " 210 | "The cfg.key property can be a character or number. You find valid numbers (virtual-key codes) on" 211 | " MSDN")] 212 | HRESULT addSystemHotKey([in]IDispatch* cfg); 213 | 214 | [helpstring("Creates new dialog window described by cfg object. cfg = {onbeforeclose:function(){return true; // or false for cancel }, onclose:function(){}}. See dialog.js for example.")] 215 | HRESULT createDialog([in]IDispatch* cfg, [out, retval]IDialog** result); 216 | 217 | [helpstring("Adds new idle handler. The cmd callback function of cfg will be called once if the application has nothing to do. Be aware, what you do in a handle, it can lead to a deadlock.")] 218 | HRESULT addIdleHandler([in]IDispatch* cfg); 219 | 220 | [helpstring("Runs the given javascript expression. Prefer this function to javascript's eval. " 221 | "It allows you to get the script position in case of errors.")] 222 | HRESULT addScript( [in]BSTR* value, [in, optional] VARIANT* name); 223 | 224 | [helpstring("Appends a new timer to the queue. cfg = {millis:1234, cmd:function(){}}")] 225 | HRESULT setTimeout([in]IDispatch* cfg); 226 | 227 | [propget, helpstring("Text data on the Clipboard.")] 228 | HRESULT clipBoard([out,retval] BSTR* result); 229 | [propput] HRESULT clipBoard([in] BSTR* value); 230 | 231 | [helpstring("Loads given dll.")] 232 | HRESULT loadLibrary([in]BSTR* libraryPath, [out, retval]ILibrary** result); 233 | 234 | [helpstring("Registers cfg = {cmd:function(stackbuffer){}} as next callback function." 235 | "It is possible to register only 12 callback functions at the same time.")] 236 | HRESULT registerCallBack([in]IDispatch* cfg, [in]unsigned int stacksize, [out, retval]ICallBack** result); 237 | 238 | [propget, helpstring("Full path of start script file.")] 239 | HRESULT scriptFullName([out,retval] BSTR* result); 240 | 241 | [helpstring("Creates and shows user notification in system tray. cfg = {title='My Title', msg='long message'}")] 242 | HRESULT showNotification([in]IDispatch* cfg); 243 | }; 244 | 245 | -------------------------------------------------------------------------------- /editor/DockableDialog.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 19 | 20 | #include "..\common\Statics.h" 21 | 22 | #include "..\npp\PluginDefinition.h" 23 | #include "..\npp\dockingResource.h" 24 | #include "DockableDialog.h" 25 | 26 | 27 | // Because of wrong architecture of Notepad++ it is necessary 28 | // to destroy Strings given to docable dialog manager after destoroying 29 | // of it self. Hence we don't destroy them at all. To reduce memory consumption 30 | // create cache. 31 | class StringCache{ 32 | struct StringCmp{ 33 | bool operator()(TCHAR* left, TCHAR* right) const { 34 | int result = StrCmp(left, right); 35 | return result < 0; 36 | } 37 | }; 38 | typedef std::set Cache; 39 | Cache m_Cache; 40 | public: 41 | TCHAR* GetCached(TCHAR* value){ 42 | Cache::iterator findIt = m_Cache.find(value); 43 | if (findIt != m_Cache.end()) 44 | return *findIt; 45 | 46 | // create a copy of value and put it to the cache 47 | TCHAR* copy = StrDup(value); // uses LocalAlloc 48 | m_Cache.insert(copy); 49 | 50 | return copy; 51 | } 52 | ~StringCache(){ 53 | for(Cache::iterator it = m_Cache.begin(); it!=m_Cache.end(); ++it){ 54 | LocalFree(*it); 55 | } 56 | } 57 | }; 58 | 59 | StringCache CachedStrings; 60 | 61 | #define CHARS_IN(a) sizeof(a)/sizeof(TCHAR) 62 | 63 | #define DD_AFTER_REGISTERASDOCKABLE WM_USER+1 // sent to control after 64 | 65 | DockableDialog::DockableDialog(ScriptObj* cfg, HWND parent): Dialog(cfg, parent),CComDispatch(),m_Modul(TEXT("jN.dll,")), m_Name(TEXT("jN")) 66 | { 67 | StringCchCopy(m_Info,CHARS_IN(m_Info), TEXT("")); 68 | 69 | VARIANT* textValue = m_Cfg->getProperty(TEXT("name"), VT_BSTR); 70 | if (textValue != NULL){ 71 | m_Name.Set(textValue->bstrVal); 72 | m_Modul.Append(textValue->bstrVal); 73 | VariantClear(textValue); 74 | delete textValue; 75 | } 76 | } 77 | 78 | 79 | void DockableDialog::BeforeCreate(){ 80 | m_Style = WS_CHILD; 81 | m_ExStyle = WS_EX_CLIENTEDGE; 82 | } 83 | 84 | void DockableDialog::AfterCreate(){ 85 | // Nothing to do override standard behavior 86 | RegisterAsDockable(); 87 | } 88 | 89 | int DockableDialog::GetDockingFlags(){ 90 | int result = DWS_DF_CONT_BOTTOM; 91 | 92 | VARIANT* dockingText = m_Cfg->getProperty(TEXT("docking"), VT_BSTR); 93 | if (dockingText){ 94 | if (0 == StrCmp(TEXT("top"),dockingText->bstrVal)) 95 | result = DWS_DF_CONT_TOP; 96 | else if (0 == StrCmp(TEXT("right"),dockingText->bstrVal)) 97 | result = DWS_DF_CONT_RIGHT; 98 | else if (0 == StrCmp(TEXT("bottom"),dockingText->bstrVal)) 99 | result = DWS_DF_CONT_BOTTOM; 100 | else if (0 == StrCmp(TEXT("left"),dockingText->bstrVal)) 101 | result = DWS_DF_CONT_LEFT; 102 | else if (0 == StrCmp(TEXT("floating"),dockingText->bstrVal)) 103 | result = DWS_DF_FLOATING; 104 | 105 | 106 | VariantClear(dockingText); 107 | delete dockingText; 108 | } 109 | return result; 110 | } 111 | void DockableDialog::RegisterAsDockable(){ 112 | int mask = GetDockingFlags() | DWS_ICONTAB | DWS_ADDINFO; 113 | 114 | memset(&m_Data,0,sizeof(m_Data)); 115 | 116 | m_Data.dlgID = 0; //Nr of menu item to assign (!= _cmdID, beware) 117 | m_Data.hIconTab = (HICON) LoadImage(Statics::instance().hInstance, MAKEINTRESOURCE(1),IMAGE_ICON, 0,0,LR_CREATEDIBSECTION|LR_SHARED|LR_LOADTRANSPARENT); //icon to use 118 | m_Data.pszAddInfo = m_Info; //Titlebar info pointer 119 | m_Data.pszModuleName = CachedStrings.GetCached( m_Modul ); //name of the dll 120 | m_Data.pszName = CachedStrings.GetCached( m_Name ); //Name for titlebar 121 | m_Data.uMask = mask; //Flags to use (see docking.h) 122 | m_Data.hClient = m_Hwnd; //HWND Handle of window this dock belongs to 123 | m_Data.iPrevCont = -1; 124 | 125 | SendMessage(nppData._nppHandle, NPPM_DMMREGASDCKDLG, 0, (LPARAM)&m_Data); //Register it 126 | 127 | // update ui 128 | SendMessage(m_Hwnd, DD_AFTER_REGISTERASDOCKABLE, 0, 0); 129 | } 130 | void DockableDialog::ResetUI(){ 131 | //Registering as dockable breaks window styles, reset them 132 | 133 | LONG_PTR oldStyle = ::GetWindowLongPtr(m_Hwnd, GWL_STYLE); 134 | ::SetWindowLongPtr(m_Hwnd, GWL_STYLE, m_Style | oldStyle); 135 | ::SetWindowLongPtr(m_Hwnd, GWL_EXSTYLE, m_ExStyle); 136 | 137 | SetWindowPos(m_Hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED| SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); 138 | UpdateWindow(m_Hwnd); 139 | } 140 | 141 | void DockableDialog::UpdateInfo(){ 142 | m_Data.pszAddInfo = m_Info; 143 | m_Data.pszName = m_Name; 144 | 145 | SendMessage(m_Hwnd, NPPM_DMMUPDATEDISPINFO, 0, (LPARAM)m_Hwnd); 146 | } 147 | 148 | LRESULT CALLBACK DockableDialog::MessageProc(UINT message, WPARAM wParam, LPARAM lParam){ 149 | switch(message){ 150 | case DD_AFTER_REGISTERASDOCKABLE:{ 151 | ResetUI(); 152 | return TRUE; 153 | } 154 | case WM_NOTIFY:{ 155 | NMHDR nmh = (NMHDR) *((NMHDR*)lParam); 156 | if (nmh.hwndFrom == nppData._nppHandle) { 157 | if (nmh.code == DMN_CLOSE) { 158 | ::PostMessage(m_Hwnd, WM_CLOSE, 0, 0); 159 | return TRUE; 160 | } else if ((nmh.code & DMN_DOCK) == DMN_DOCK && (nmh.code & DMN_FLOAT) != DMN_FLOAT) {// only if just docked 161 | PostMessage(m_Hwnd, DD_AFTER_REGISTERASDOCKABLE,0,0); 162 | return TRUE; 163 | } 164 | } 165 | break; 166 | } 167 | case WM_ERASEBKGND: 168 | return TRUE; 169 | //case WM_SETFOCUS: { 170 | // //Why restore focus here? This window should never be able to get focus in the first place 171 | // HWND hPrev = (HWND)wParam; 172 | // if (hPrev != NULL) 173 | // ::SetFocus(hPrev); 174 | // break; 175 | //} 176 | } 177 | return Dialog::MessageProc(message, wParam, lParam); 178 | } 179 | 180 | HRESULT STDMETHODCALLTYPE DockableDialog::get_title( BSTR* result){ 181 | *result = SysAllocString(m_Info); 182 | 183 | return S_OK; 184 | } 185 | 186 | HRESULT STDMETHODCALLTYPE DockableDialog::put_title( BSTR* value){ 187 | StringCchCopy(m_Info, CHARS_IN(m_Info), *value); 188 | 189 | UpdateInfo(); 190 | return S_OK; 191 | } 192 | 193 | 194 | HRESULT STDMETHODCALLTYPE DockableDialog::get_visible( VARIANT_BOOL *result){ 195 | if (isCreated()) 196 | *result = IsWindowVisible(m_Hwnd); 197 | 198 | return S_OK; 199 | } 200 | 201 | HRESULT STDMETHODCALLTYPE DockableDialog::put_visible( VARIANT_BOOL value){ 202 | ::SendMessage(nppData._nppHandle, value ? NPPM_DMMSHOW : NPPM_DMMHIDE, 0, (LPARAM)m_Hwnd); 203 | return S_OK; 204 | } 205 | -------------------------------------------------------------------------------- /editor/DockableDialog.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 "Common\Dialog\Dialog.h" 21 | #include "Common\SysStr.h" 22 | 23 | #include "..\npp\Docking.h" 24 | 25 | class DockableDialog:public Dialog{ 26 | protected: 27 | void BeforeCreate() override; 28 | void AfterCreate() override; 29 | private: 30 | tTbData m_Data; 31 | 32 | SysStr m_Name; 33 | TCHAR m_Info[256]; 34 | SysStr m_Modul; 35 | 36 | void RegisterAsDockable(); 37 | void UpdateInfo(); 38 | void ResetUI(); 39 | 40 | int GetDockingFlags(); 41 | 42 | LRESULT CALLBACK MessageProc(UINT message, WPARAM wParam, LPARAM lParam) override; 43 | public: 44 | DockableDialog(ScriptObj* cfg, HWND parent); 45 | 46 | virtual HRESULT STDMETHODCALLTYPE get_title( BSTR* result) override; 47 | 48 | virtual HRESULT STDMETHODCALLTYPE put_title( BSTR* value) override; 49 | 50 | virtual HRESULT STDMETHODCALLTYPE get_visible( VARIANT_BOOL *result) override; 51 | 52 | virtual HRESULT STDMETHODCALLTYPE put_visible( VARIANT_BOOL value) override; 53 | 54 | }; -------------------------------------------------------------------------------- /editor/Editor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michaelxzhang/Npp-Highlighter/7d4cc7bccdccd1528f022749fe2b0d1bd0f3ad44/editor/Editor.h -------------------------------------------------------------------------------- /editor/editor.idl: -------------------------------------------------------------------------------- 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 | [ 20 | uuid(1358E572-3208-4A69-9F66-6D4B8B841EE1), 21 | version(1.0), 22 | helpstring("jN is a Notepad++ plugin. It helps you to script your favorite Text editor with your favorite programming language!") 23 | ] 24 | library jN 25 | { 26 | importlib("stdole32.tlb"); 27 | importlib("stdole2.tlb"); 28 | 29 | 30 | #include "..\common\common.idl" 31 | 32 | [ 33 | uuid(0614FB00-6702-11d4-B0B7-0050BABFC900), 34 | oleautomation, 35 | helpstring("Represents line of View") 36 | ] 37 | interface IViewLine : IDispatch 38 | { 39 | [propget, helpstring("Line number")] 40 | HRESULT number([out,retval] int* value); 41 | 42 | [propget, helpstring("Character position of line beginning in document")] 43 | HRESULT start([out,retval] int* value); 44 | 45 | [propget, helpstring("Character position of line end in document")] 46 | HRESULT end([out,retval] int* value); 47 | 48 | [propget, helpstring("Byte position of line beginning. Faster than 'start' property.")] 49 | HRESULT byteStart([out,retval] int* value); 50 | 51 | [propget, helpstring("Byte position of line end including any line end characters. Faster than 'end' property.")] 52 | HRESULT byteEnd([out,retval] int* value); 53 | 54 | [helpstring("Line text including any line end characters. The setting of line text changes the text selection.")] 55 | [propget] HRESULT text([out,retval] BSTR* result); 56 | [propput] HRESULT text([in] BSTR* value); 57 | } 58 | 59 | [ 60 | uuid(0614FB00-6702-11d4-B0B7-0050BABFC901), 61 | oleautomation, 62 | helpstring("Represents lines of View") 63 | ] 64 | interface IViewLines : IDispatch 65 | { 66 | [helpstring("Returns the line object with specified number.")] 67 | HRESULT get([in]int line, [out,retval] IViewLine** result); 68 | 69 | [propget,helpstring("The count of lines.")] 70 | HRESULT count([out, retval] int* result); 71 | 72 | [helpstring("The current line of view.")] 73 | [propget] HRESULT current([out, retval] int* result); 74 | [propput] HRESULT current([in] int value); 75 | } 76 | 77 | [ 78 | uuid(0614FB00-6702-11d4-B0B7-0050BABFC902), 79 | oleautomation , 80 | helpstring("Represents an editor view.") 81 | ] 82 | interface IView : IDispatch 83 | { 84 | [propget, helpstring("The text of view.")] 85 | HRESULT text([out,retval] BSTR* result); 86 | [propput] HRESULT text([in] BSTR* value); 87 | 88 | [propget, helpstring("Array of the file names opened in the view.")] 89 | HRESULT files([out,retval] IDispatch** array); 90 | 91 | [propget, helpstring("Current file in the view.")] 92 | HRESULT file([out,retval] int* value); 93 | [propput] HRESULT file([in] int value); 94 | 95 | [propget, helpstring("Selected text in the view.")] 96 | HRESULT selection([out,retval] BSTR* value); 97 | [propput] HRESULT selection([in] BSTR* value); 98 | 99 | [propget, helpstring("Code page of current file.")] 100 | HRESULT codepage([out,retval] int* value); 101 | [propput] HRESULT codepage([in] int value); 102 | 103 | [propget, helpstring("Language of the currently active document. It is an index in Editor.langs")] 104 | HRESULT lang([out, retval] int* result); 105 | [propput] HRESULT lang([in] int value); 106 | 107 | [propget, helpstring("The current line of view.")] 108 | HRESULT line([out, retval] int* result); 109 | [propput] HRESULT line([in] int value); 110 | 111 | [propget, helpstring("Lines object of view.")] 112 | HRESULT lines([out, retval] IViewLines** result); 113 | 114 | [propget, helpstring("Character position in document.")] 115 | HRESULT pos([out, retval] int* result); 116 | [propput] HRESULT pos([in] int value); 117 | 118 | [propget, helpstring("Byte position in document.")] 119 | HRESULT bytePos([out, retval] int* result); 120 | [propput] HRESULT bytePos([in] int value); 121 | 122 | [propget, helpstring("Column position.")] 123 | HRESULT column([out, retval] int* result); 124 | 125 | [propget, helpstring("Character position of anchor.")] 126 | HRESULT anchor([out, retval] int* result); 127 | [propput] HRESULT anchor([in] int value); 128 | 129 | [propget, helpstring("Byte position of anchor.")] 130 | HRESULT byteAnchor([out, retval] int* result); 131 | [propput] HRESULT byteAnchor([in] int value); 132 | 133 | [propget, helpstring("Value indicating whether the navigation bar is visible.")] 134 | HRESULT navBarHidden([out,retval] VARIANT_BOOL* result); 135 | [propput] HRESULT navBarHidden([in] VARIANT_BOOL value); 136 | 137 | [propget, helpstring("Value indicating which of 32 indicators are shown in navigation bar.")] 138 | HRESULT navBarIndicatorMask([out,retval] dword* result); 139 | [propput] HRESULT navBarIndicatorMask([in] dword value); 140 | 141 | [propget, helpstring("Window handle of view.")] 142 | HRESULT handle([out,retval] int* result); 143 | 144 | }; 145 | 146 | [ 147 | uuid(0614FB00-6702-11d4-B0B7-0050BABFC906), 148 | oleautomation, 149 | helpstring("Represents the Notepad++. Methods of this interface are globally available. It means " 150 | "you can omit keyword 'Editor' to access to its methods.") 151 | ] 152 | interface IEditor : IDispatch 153 | { 154 | [propget, helpstring("The always visible view of editor. It is the left view.")] 155 | HRESULT firstView([out,retval] IView** result); 156 | 157 | [propget, helpstring("The view with currently active document.")] 158 | HRESULT currentView([out,retval] IView** result); 159 | 160 | [propget, helpstring("The right view of editor.")] 161 | HRESULT secondView([out,retval] IView** result); 162 | 163 | [helpstring("Displays a dialog box containing an application-defined message.")] 164 | HRESULT alert([in] BSTR* value); 165 | 166 | [helpstring("Saves all the opened files.")] 167 | HRESULT saveAll(); 168 | 169 | [propget, helpstring("Array of languages source code can be written in.")] 170 | HRESULT langs([out,retval] IDispatch** result); 171 | 172 | [propget, helpstring("Plugin directory of Notepad++.")] 173 | HRESULT pluginConfigDir([out,retval] BSTR* result); 174 | 175 | [propget, helpstring("Directory of Notepad++.")] 176 | HRESULT nppDir([out,retval] BSTR* result); 177 | 178 | [propget, helpstring("Value indicating whether the tab bar is hidden.")] 179 | HRESULT tabBarHidden([out,retval] VARIANT_BOOL * result); 180 | [propput] HRESULT tabBarHidden([in] VARIANT_BOOL value); 181 | 182 | [propget, helpstring("Value indicating whether the tool bar is hidden.")] 183 | HRESULT toolBarHidden([out,retval] VARIANT_BOOL* result); 184 | [propput] HRESULT toolBarHidden([in] VARIANT_BOOL value); 185 | 186 | [propget, helpstring("Value indicating whether the main menu is hidden.")] 187 | HRESULT menuHidden([out,retval] VARIANT_BOOL* result); 188 | [propput] HRESULT menuHidden([in] VARIANT_BOOL value); 189 | 190 | [propget, helpstring("Value indicating whether the status bar is hidden.")] 191 | HRESULT statusBarHidden([out,retval] VARIANT_BOOL* result); 192 | [propput] HRESULT statusBarHidden([in] VARIANT_BOOL value); 193 | 194 | [helpstring("Opens the file specified by the given file path.")] 195 | HRESULT open([in] BSTR* filePath); 196 | 197 | [helpstring("Appends new menu to the main window. Returns object representing the new menu. See IMenu.addMenu about cfg.")] 198 | HRESULT addMenu([in]VARIANT cfg, [out, retval]IMenu** result);// no cmd, text only 199 | 200 | [helpstring("Runs a specified build-in menu command of Notepad++.")] 201 | HRESULT runMenuCmd([in]int cmd); 202 | 203 | [helpstring("Sets new listener object with a lot of callback functions representing event handler. See start.js")] 204 | HRESULT setListener([in]IDispatch* cfg); 205 | 206 | [helpstring("Creates new dockable window described by cfg object. cfg = {name:'Tab name', docking:'(top|bottom|left|right|floating)', onbeforeclose:function(){return true; // false - hides the window, but avoids its destroing }, onclose:function(){}}.")] 207 | HRESULT createDockable([in]IDispatch* cfg, [out, retval]IDialog** result); 208 | 209 | [propget, helpstring("Window handle of Editor.")] 210 | HRESULT handle([out,retval] int* result); 211 | 212 | [helpstring("Adds new application wide hot key combination. For cfg see addSystemHotKey method.")] 213 | HRESULT addHotKey([in]IDispatch* cfg); 214 | 215 | [helpstring("Creates an empty context menu. cfg = {oninitpopup:function(){}}")] 216 | HRESULT createContextMenu([in]VARIANT cfg, [out, retval]ICtxMenu** result); 217 | }; 218 | 219 | }; 220 | -------------------------------------------------------------------------------- /editor/view/EditorView.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 | 22 | #include "common\combase.h" 23 | #include "common\ForegroundIdleHook.h" 24 | 25 | #include "Interfaces.h" 26 | 27 | #include "npp\PluginDefinition.h" 28 | 29 | #include "SCIView.h" 30 | #include "IndicatorPanel.h" 31 | #include "common\MyActiveSite.h" 32 | 33 | #define m_Handle (((m_Id-1)==0)? nppData._scintillaMainHandle : nppData._scintillaSecondHandle) 34 | 35 | class CEditor; 36 | 37 | class CEditorView : public CComDispatch, public SCIView 38 | { 39 | public: 40 | ScriptObj* m_Listener; 41 | 42 | CEditorView(int id); 43 | ~CEditorView(void){ 44 | }; 45 | 46 | LRESULT OnMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); 47 | int m_Id; 48 | 49 | IndicatorPanel m_IndPanel; 50 | 51 | void DoMessage(SCNotification* eventArgs); 52 | 53 | 54 | #pragma region Helper methods 55 | BSTR adjustFromCodePage(char* buf, int len); 56 | char* adjustToCodePage(BSTR str); 57 | 58 | int posToBytePos(int value); 59 | int bytePosToPos(int pos); 60 | 61 | private: 62 | 63 | LRESULT getBufferId(); 64 | void setIndicatorLinesUpdater(int begin, int end); 65 | 66 | #pragma endregion 67 | 68 | 69 | 70 | #pragma region IView implementation 71 | public : 72 | virtual HRESULT STDMETHODCALLTYPE get_text( BSTR *result); 73 | 74 | virtual HRESULT STDMETHODCALLTYPE put_text(BSTR *value); 75 | 76 | virtual HRESULT STDMETHODCALLTYPE get_files( long *value); 77 | 78 | virtual HRESULT STDMETHODCALLTYPE get_selection( BSTR *value); 79 | 80 | virtual HRESULT STDMETHODCALLTYPE put_selection(BSTR *value); 81 | 82 | virtual HRESULT STDMETHODCALLTYPE get_codepage(int *value); 83 | 84 | virtual HRESULT STDMETHODCALLTYPE put_codepage(int value); 85 | 86 | virtual HRESULT STDMETHODCALLTYPE get_files(IDispatch **result); 87 | 88 | virtual HRESULT STDMETHODCALLTYPE get_file(int *value); 89 | 90 | virtual HRESULT STDMETHODCALLTYPE put_file( int value); 91 | 92 | virtual HRESULT STDMETHODCALLTYPE get_lang( int *result); 93 | 94 | virtual HRESULT STDMETHODCALLTYPE put_lang( int value); 95 | 96 | virtual HRESULT STDMETHODCALLTYPE get_line( int *result); 97 | 98 | virtual HRESULT STDMETHODCALLTYPE put_line( int value); 99 | 100 | virtual HRESULT STDMETHODCALLTYPE get_pos( int *result); 101 | 102 | virtual HRESULT STDMETHODCALLTYPE put_pos( int value); 103 | 104 | virtual HRESULT STDMETHODCALLTYPE get_bytePos( int *result); 105 | 106 | virtual HRESULT STDMETHODCALLTYPE put_bytePos( int value); 107 | 108 | virtual HRESULT STDMETHODCALLTYPE get_column( int *result); 109 | 110 | virtual HRESULT STDMETHODCALLTYPE get_anchor( int *result); 111 | 112 | virtual HRESULT STDMETHODCALLTYPE put_anchor(int value); 113 | 114 | virtual HRESULT STDMETHODCALLTYPE get_byteAnchor( int *result); 115 | 116 | virtual HRESULT STDMETHODCALLTYPE put_byteAnchor(int value); 117 | 118 | 119 | virtual HRESULT STDMETHODCALLTYPE get_lineCount(int* line); 120 | 121 | virtual HRESULT STDMETHODCALLTYPE get_lines(IViewLines** result); 122 | 123 | virtual HRESULT STDMETHODCALLTYPE get_navBarHidden( VARIANT_BOOL *result); 124 | 125 | virtual HRESULT STDMETHODCALLTYPE put_navBarHidden( VARIANT_BOOL value); 126 | 127 | virtual HRESULT STDMETHODCALLTYPE get_navBarIndicatorMask( DWORD *result); 128 | 129 | virtual HRESULT STDMETHODCALLTYPE put_navBarIndicatorMask( DWORD value); 130 | 131 | virtual HRESULT STDMETHODCALLTYPE get_handle(int *result); 132 | 133 | #pragma endregion 134 | 135 | }; 136 | -------------------------------------------------------------------------------- /editor/view/IndicatorPanel.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 | 22 | #include "common\ForegroundIdleHook.h" 23 | #include "SCIView.h" 24 | 25 | #define INDICATOR_MODIFIED 0 26 | #define INDICATOR_SEARCH 1 27 | 28 | class IndicatorPanel 29 | { 30 | struct LineMask{ 31 | DWORD line; 32 | DWORD mask; 33 | }; 34 | 35 | typedef std::vector LineMasks; 36 | 37 | LineMasks m_Indicators; 38 | LineMasks m_PixelIndicators; 39 | 40 | RECT m_PanelRect_absolute; 41 | RECT m_PanelRect; 42 | RECT m_UnderScroll; 43 | 44 | SCIView* m_View; 45 | 46 | const static int m_PanelWidth = 14; 47 | 48 | 49 | bool m_linemodified = false; 50 | size_t m_totallines = 0; //real total lines 51 | size_t m_virtual_totallines = 0; //total visual lines, used for calculate if the real line number less than the line number the current view could hold 52 | //std::set m_set_modified_linenum; 53 | ULONG_PTR m_current_bufferid; 54 | size_t m_current_linenum = 0; 55 | 56 | long m_draw_height = 0; 57 | long m_topOffset = 0; 58 | public: 59 | DWORD* pixelIndicators; 60 | int m_PixelIndicatorsLen; 61 | 62 | void ClearIndicators(int begin, int end); 63 | 64 | void GetIndicatorLines(int begin, int end); 65 | 66 | void GetIndicatorPixels(); 67 | 68 | void paintIndicators(); 69 | 70 | void paintIndicators(HDC hdc); 71 | 72 | COLORREF getColorForMask(DWORD mask); 73 | 74 | bool fileModified(int pos); 75 | bool fileLinesAddedDeleted(int pos, int lines_added); 76 | bool fileDoubleClicked(); 77 | bool fileSingleClicked(); 78 | bool fileclose(); 79 | void updateSelectedIndicator(HDC hdc); 80 | void updateChangedIndicator(HDC hdc); 81 | bool movescrollbarto(int x, int y); 82 | static bool hasStyle(HWND hwnd, int style); 83 | 84 | LRESULT OnNCCalcSize(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); 85 | LRESULT OnNCPaint(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); 86 | 87 | DWORD m_IndicatorMask; 88 | bool m_Disabled; 89 | 90 | public: 91 | 92 | DWORD GetIndicatorMask(); 93 | void SetIndicatorMask(DWORD value); 94 | 95 | void SetDisabled(bool value); 96 | bool GetDisabled(); 97 | 98 | IndicatorPanel(SCIView* m_View); 99 | ~IndicatorPanel(void); 100 | 101 | class IndicatorLinesUpdater : public ForegroundIdleHook::IdleHandler{ 102 | public: 103 | IndicatorPanel* m_IndPanel; 104 | IndicatorLinesUpdater(IndicatorPanel* indPanel){ 105 | m_IndPanel = indPanel; 106 | m_Begin = -1; 107 | m_End = -1; 108 | }; 109 | 110 | int m_Begin; 111 | int m_End; 112 | 113 | void execute(){ 114 | if (m_IndPanel->m_Disabled) 115 | return; 116 | 117 | m_IndPanel->GetIndicatorLines(m_Begin, m_End); 118 | m_IndPanel->RedrawIndicatorPanel(); 119 | ForegroundIdleHook::getInstance()->add( &m_IndPanel->m_IndicPixelsUp); 120 | 121 | m_Begin = -1; 122 | m_End = -1; 123 | }; 124 | }; 125 | 126 | class IndicatorPixelsUpdater : public ForegroundIdleHook::IdleHandler{ 127 | public: 128 | IndicatorPanel* m_IndPanel; 129 | IndicatorPixelsUpdater(IndicatorPanel* indPanel){m_IndPanel = indPanel;}; 130 | void execute(){ 131 | if (m_IndPanel->m_Disabled) 132 | return; 133 | 134 | /*m_IndPanel->GetIndicatorPixels(); 135 | if (m_IndPanel->m_PixelIndicatorsLen > 0) 136 | { 137 | m_IndPanel->RedrawIndicatorPanel(); //m_View->paintIndicators(); 138 | }*/ 139 | }; 140 | }; 141 | 142 | 143 | IndicatorPixelsUpdater m_IndicPixelsUp; 144 | IndicatorLinesUpdater m_IndicLinesUp; 145 | 146 | void RedrawIndicatorPanel(); 147 | 148 | }; 149 | -------------------------------------------------------------------------------- /editor/view/SCIView.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 "SCIView.h" 19 | 20 | SCIView::SCIView(HWND handle) 21 | { 22 | m_Handle = handle; 23 | // retrieve Sci Pointer and Function, for direct calls 24 | m_SciFn = (sptr_t(*)(sptr_t, unsigned int, uptr_t, sptr_t))SendMessage(handle,SCI_GETDIRECTFUNCTION,0,0); 25 | m_SciPtr = SendMessage(handle,SCI_GETDIRECTPOINTER,0,0); 26 | 27 | LRESULT eventmask = sci(SCI_GETMODEVENTMASK, 0,0); 28 | eventmask |= SC_MOD_CHANGEFOLD|SC_MOD_DELETETEXT; 29 | sci(SCI_SETMODEVENTMASK, eventmask, 0); 30 | 31 | // save this pointer, to be able get it again in static functions 32 | SetProp(m_Handle, TEXT("SCIView Pointer"), (HANDLE)this); 33 | 34 | // subclassing of scintilla 35 | sciOldWndProc =(WNDPROC)GetWindowLongPtr(m_Handle, GWLP_WNDPROC); 36 | SetProp(m_Handle, TEXT("SCIView WndProc"), (HANDLE)sciOldWndProc); 37 | 38 | SetWindowLongPtr(m_Handle, GWLP_WNDPROC, (LONG_PTR) sciPluginMessageProc); 39 | } 40 | 41 | SCIView::~SCIView(void) 42 | { 43 | RemoveProp(m_Handle, TEXT("SCIView Pointer")); 44 | } 45 | 46 | LRESULT SCIView::sci(unsigned int cmd, uptr_t wParam, sptr_t lParam){ 47 | return m_SciFn(m_SciPtr, cmd, wParam, lParam); 48 | } 49 | 50 | LRESULT SCIView::CallOldWndProc(UINT message, WPARAM wParam, LPARAM lParam){ 51 | return CallWindowProc(sciOldWndProc,m_Handle,message,wParam,lParam); 52 | } 53 | 54 | LRESULT SCIView::OnMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ 55 | return CallOldWndProc(message,wParam,lParam); 56 | } 57 | 58 | LRESULT CALLBACK SCIView::sciPluginMessageProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ 59 | SCIView* self = (SCIView*)GetProp(hwnd, TEXT("SCIView Pointer")); 60 | if (self == NULL){ 61 | WNDPROC old = (WNDPROC)GetProp(hwnd, TEXT("SCIView WndProc")); 62 | 63 | return CallWindowProc(old,hwnd,message,wParam,lParam); 64 | } 65 | 66 | return self->OnMessage(hwnd, message, wParam, lParam); 67 | } 68 | -------------------------------------------------------------------------------- /editor/view/SCIView.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 | #include "npp\Scintilla.h" 21 | 22 | class SCIView 23 | { 24 | private: 25 | sptr_t(*m_SciFn)(sptr_t, unsigned int, uptr_t, sptr_t); 26 | sptr_t m_SciPtr; 27 | 28 | public: 29 | HWND m_Handle; 30 | SCIView(HWND handle); 31 | ~SCIView(void); 32 | 33 | LRESULT sci(unsigned int cmd, uptr_t wParam, sptr_t lParam); 34 | 35 | // subclassing for scintilla 36 | WNDPROC sciOldWndProc; 37 | static LRESULT CALLBACK sciPluginMessageProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); 38 | 39 | LRESULT CallOldWndProc(UINT message, WPARAM wParam, LPARAM lParam); 40 | virtual LRESULT OnMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); 41 | }; 42 | -------------------------------------------------------------------------------- /editor/view/ViewLine.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 "ViewLine.h" 19 | #include "EditorView.h" 20 | #include "common\MyActiveSite.h" 21 | 22 | #define CHECK_AND_FAIL if (!CheckValidity()) return E_FAIL; 23 | 24 | ViewLine::ViewLine(int number, CEditorView* v):CComDispatch(){ 25 | m_View = v; 26 | m_number = number; 27 | 28 | m_View->AddRef(); 29 | } 30 | 31 | ViewLine::~ViewLine(void) 32 | { 33 | m_View->Release(); 34 | } 35 | 36 | bool ViewLine::CheckValidity(){ 37 | int count = m_View->sci(SCI_GETLINECOUNT, 0, 0); 38 | 39 | // allright 40 | if (m_number < count) 41 | return true; 42 | 43 | // number out of range 44 | TCHAR buf[100]; 45 | StringCbPrintf(buf, sizeof(buf), TEXT("Line number %d out of range [0..%d)"), m_number, count); 46 | 47 | MyActiveSite::Throw(buf, __uuidof(IViewLine) ); 48 | 49 | return false; 50 | } 51 | 52 | long ViewLine::Length(){ 53 | return m_View->sci(SCI_LINELENGTH, m_number, 0); 54 | } 55 | 56 | HRESULT STDMETHODCALLTYPE ViewLine::get_number(int *value){ 57 | *value = m_number; 58 | return S_OK; 59 | } 60 | 61 | HRESULT STDMETHODCALLTYPE ViewLine::get_start( int *value){ 62 | int bp; 63 | 64 | if(FAILED(get_byteStart(&bp))) 65 | return E_FAIL; 66 | 67 | if (bp>=0) 68 | *value = m_View->bytePosToPos(bp); 69 | 70 | return S_OK; 71 | } 72 | 73 | HRESULT STDMETHODCALLTYPE ViewLine::get_end( int *value){ 74 | 75 | int bp; 76 | 77 | if (FAILED(get_byteEnd(&bp))) 78 | return E_FAIL; 79 | 80 | if (bp>=0) 81 | *value = m_View->bytePosToPos(bp); 82 | 83 | return S_OK; 84 | } 85 | 86 | HRESULT STDMETHODCALLTYPE ViewLine::get_byteStart( int *value){ 87 | 88 | CHECK_AND_FAIL; 89 | 90 | *value = m_View->sci(SCI_POSITIONFROMLINE,m_number,0); 91 | 92 | return S_OK; 93 | } 94 | 95 | HRESULT STDMETHODCALLTYPE ViewLine::get_byteEnd( int *value){ 96 | 97 | CHECK_AND_FAIL; 98 | 99 | int byteStart; 100 | get_byteStart(&byteStart); 101 | 102 | *value = byteStart + Length(); 103 | 104 | return S_OK; 105 | } 106 | 107 | HRESULT STDMETHODCALLTYPE ViewLine::get_text( BSTR *result){ 108 | 109 | CHECK_AND_FAIL; 110 | 111 | LRESULT len = Length(); 112 | char* buf = new char[len+1]; 113 | buf[len] = 0; 114 | 115 | m_View->sci(SCI_GETLINE, m_number, (LPARAM)buf); 116 | 117 | *result = m_View->adjustFromCodePage(buf, -1); 118 | 119 | delete[] buf; 120 | 121 | return S_OK; 122 | } 123 | 124 | HRESULT STDMETHODCALLTYPE ViewLine::put_text( BSTR *value){ 125 | 126 | CHECK_AND_FAIL; 127 | 128 | int start, end; 129 | 130 | get_byteStart(&start); 131 | get_byteEnd(&end); 132 | 133 | m_View->put_bytePos(start); 134 | m_View->put_byteAnchor(end); 135 | 136 | m_View->put_selection(value); 137 | 138 | return S_OK ; 139 | } 140 | -------------------------------------------------------------------------------- /editor/view/ViewLine.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 "common\ComBase.h" 20 | #include "Interfaces.h" 21 | 22 | class CEditorView; 23 | 24 | class ViewLine: public CComDispatch 25 | { 26 | private: 27 | CEditorView* m_View; 28 | int m_number; 29 | bool CheckValidity(); 30 | long Length(); 31 | public: 32 | ViewLine(int number, CEditorView* v); 33 | ~ViewLine(void); 34 | 35 | HRESULT STDMETHODCALLTYPE get_number(int *value); 36 | 37 | HRESULT STDMETHODCALLTYPE get_start( int *value); 38 | 39 | HRESULT STDMETHODCALLTYPE get_end( int *value); 40 | 41 | HRESULT STDMETHODCALLTYPE get_byteStart( int *value); 42 | 43 | HRESULT STDMETHODCALLTYPE get_byteEnd( int *value); 44 | 45 | HRESULT STDMETHODCALLTYPE get_text( BSTR *result); 46 | 47 | HRESULT STDMETHODCALLTYPE put_text( BSTR *value); 48 | 49 | }; 50 | -------------------------------------------------------------------------------- /editor/view/ViewLines.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 "ViewLines.h" 19 | #include "ViewLine.h" 20 | 21 | #include "EditorView.h" 22 | #include "common\MyActiveSite.h" 23 | 24 | ViewLines::~ViewLines(){ 25 | m_View->Release(); 26 | } 27 | 28 | ViewLines::ViewLines(CEditorView* v):CComDispatch(){ 29 | m_View = v; 30 | m_View->AddRef(); 31 | } 32 | 33 | HRESULT STDMETHODCALLTYPE ViewLines::get( int line, IViewLine **result){ 34 | *result = new ViewLine(line, m_View); 35 | 36 | return S_OK; 37 | } 38 | 39 | HRESULT STDMETHODCALLTYPE ViewLines::get_count(int* result){ 40 | *result = m_View->sci(SCI_GETLINECOUNT, 0, 0); 41 | return S_OK; 42 | } 43 | 44 | 45 | HRESULT STDMETHODCALLTYPE ViewLines::get_current( int *result){ 46 | int pos = m_View->sci(SCI_GETCURRENTPOS,0,0); 47 | *result = m_View->sci(SCI_LINEFROMPOSITION,pos,0); 48 | return S_OK; 49 | } 50 | 51 | HRESULT STDMETHODCALLTYPE ViewLines::put_current(int value){ 52 | int count = m_View->sci(SCI_GETLINECOUNT, 0, 0); 53 | if (value >= count || value < 0){ 54 | TCHAR buf[100]; 55 | StringCbPrintf(buf, sizeof(buf), TEXT("Line number %d out of range [0..%d)"), value, count); 56 | 57 | MyActiveSite::Throw(buf, __uuidof(IViewLine) ); 58 | 59 | return E_FAIL; 60 | } 61 | 62 | m_View->sci(SCI_GOTOLINE,value,0); 63 | return S_OK; 64 | } 65 | -------------------------------------------------------------------------------- /editor/view/ViewLines.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 "common\ComBase.h" 21 | #include "Interfaces.h" 22 | 23 | 24 | class CEditorView; 25 | 26 | class ViewLines : public CComDispatch{ 27 | CEditorView* m_View; 28 | public: 29 | 30 | ViewLines(CEditorView* v); 31 | ~ViewLines(); 32 | 33 | virtual HRESULT STDMETHODCALLTYPE get( int line, IViewLine** result); 34 | 35 | virtual HRESULT STDMETHODCALLTYPE get_count(int* result); 36 | 37 | virtual HRESULT STDMETHODCALLTYPE get_current( int *result); 38 | 39 | virtual HRESULT STDMETHODCALLTYPE put_current(int value); 40 | 41 | }; -------------------------------------------------------------------------------- /jN.9.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26014.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jN", "jN.vcxproj", "{1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Debug|Win32.Build.0 = Debug|Win32 18 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Debug|x64.ActiveCfg = Debug|x64 19 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Debug|x64.Build.0 = Debug|x64 20 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Release|Win32.ActiveCfg = Release|Win32 21 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Release|Win32.Build.0 = Release|Win32 22 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Release|x64.ActiveCfg = Release|x64 23 | {1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /jN.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michaelxzhang/Npp-Highlighter/7d4cc7bccdccd1528f022749fe2b0d1bd0f3ad44/jN.bmp -------------------------------------------------------------------------------- /jN.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michaelxzhang/Npp-Highlighter/7d4cc7bccdccd1528f022749fe2b0d1bd0f3ad44/jN.cpp -------------------------------------------------------------------------------- /jN.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michaelxzhang/Npp-Highlighter/7d4cc7bccdccd1528f022749fe2b0d1bd0f3ad44/jN.ico -------------------------------------------------------------------------------- /jN.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx 7 | 8 | 9 | {ae1b0d1b-163e-404d-844f-c0d040ef20da} 10 | 11 | 12 | {8613817a-899d-489c-8004-fa6834d838cd} 13 | 14 | 15 | {8efc3e52-5bcd-4bf2-911c-9acbefb0a3e3} 16 | 17 | 18 | {9f0c42e6-271b-41d1-a03c-fa1c3e779ded} 19 | 20 | 21 | {dab95eaa-a7a5-4760-957e-cc07e80025da} 22 | 23 | 24 | {15109821-36a3-449e-804a-151808756221} 25 | 26 | 27 | {0daec937-0605-413a-9a46-50c37533ee43} 28 | 29 | 30 | 31 | 32 | Misc 33 | 34 | 35 | Npp 36 | 37 | 38 | Editor 39 | 40 | 41 | Editor 42 | 43 | 44 | Editor\View 45 | 46 | 47 | Editor\View 48 | 49 | 50 | Editor\View 51 | 52 | 53 | Editor\View 54 | 55 | 56 | Editor\View 57 | 58 | 59 | Common 60 | 61 | 62 | Common 63 | 64 | 65 | Common 66 | 67 | 68 | Common 69 | 70 | 71 | Common 72 | 73 | 74 | Common 75 | 76 | 77 | Common 78 | 79 | 80 | Common 81 | 82 | 83 | Common\Hooks 84 | 85 | 86 | Common\Hooks 87 | 88 | 89 | Common\Hooks\Handler 90 | 91 | 92 | Common\Dialog 93 | 94 | 95 | Common\Dialog 96 | 97 | 98 | Common\Dialog 99 | 100 | 101 | Common\Dialog 102 | 103 | 104 | Common\Dialog 105 | 106 | 107 | Common\Dialog 108 | 109 | 110 | 111 | 112 | Misc 113 | 114 | 115 | 116 | 117 | Misc 118 | 119 | 120 | 121 | 122 | Npp 123 | 124 | 125 | Npp 126 | 127 | 128 | Npp 129 | 130 | 131 | Npp 132 | 133 | 134 | Npp 135 | 136 | 137 | Npp 138 | 139 | 140 | Npp 141 | 142 | 143 | Editor 144 | 145 | 146 | Editor 147 | 148 | 149 | Editor\View 150 | 151 | 152 | Editor\View 153 | 154 | 155 | Editor\View 156 | 157 | 158 | Editor\View 159 | 160 | 161 | Editor\View 162 | 163 | 164 | Common 165 | 166 | 167 | Common 168 | 169 | 170 | Common 171 | 172 | 173 | Common 174 | 175 | 176 | Common 177 | 178 | 179 | Common 180 | 181 | 182 | Common 183 | 184 | 185 | Common 186 | 187 | 188 | Common 189 | 190 | 191 | Common 192 | 193 | 194 | Common 195 | 196 | 197 | Common 198 | 199 | 200 | Common\Hooks 201 | 202 | 203 | Common\Hooks 204 | 205 | 206 | Common\Hooks\Handler 207 | 208 | 209 | Common\Dialog 210 | 211 | 212 | Common\Dialog 213 | 214 | 215 | Common\Dialog 216 | 217 | 218 | Common\Dialog 219 | 220 | 221 | Common\Dialog 222 | 223 | 224 | Common\Dialog 225 | 226 | 227 | 228 | 229 | 230 | Editor 231 | 232 | 233 | Common 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | Misc 242 | 243 | 244 | Misc 245 | 246 | 247 | 248 | 249 | 250 | -------------------------------------------------------------------------------- /jN.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | NativeOnly 5 | WindowsLocalDebugger 6 | $(ProjectDir) 7 | 8 | -------------------------------------------------------------------------------- /npp/Docking.h: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of Function List Plugin for Notepad++ 3 | Copyright (C)2005 Jens Lorenz 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (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, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #ifndef DOCKING_H 21 | #define DOCKING_H 22 | 23 | // ATTENTION : It's a part of interface header, so don't include the others header here 24 | 25 | // styles for containers 26 | #define CAPTION_TOP TRUE 27 | #define CAPTION_BOTTOM FALSE 28 | 29 | // defines for docking manager 30 | #define CONT_LEFT 0 31 | #define CONT_RIGHT 1 32 | #define CONT_TOP 2 33 | #define CONT_BOTTOM 3 34 | #define DOCKCONT_MAX 4 35 | 36 | // mask params for plugins of internal dialogs 37 | #define DWS_ICONTAB 0x00000001 // Icon for tabs are available 38 | #define DWS_ICONBAR 0x00000002 // Icon for icon bar are available (currently not supported) 39 | #define DWS_ADDINFO 0x00000004 // Additional information are in use 40 | #define DWS_PARAMSALL (DWS_ICONTAB|DWS_ICONBAR|DWS_ADDINFO) 41 | 42 | // default docking values for first call of plugin 43 | #define DWS_DF_CONT_LEFT (CONT_LEFT << 28) // default docking on left 44 | #define DWS_DF_CONT_RIGHT (CONT_RIGHT << 28) // default docking on right 45 | #define DWS_DF_CONT_TOP (CONT_TOP << 28) // default docking on top 46 | #define DWS_DF_CONT_BOTTOM (CONT_BOTTOM << 28) // default docking on bottom 47 | #define DWS_DF_FLOATING 0x80000000 // default state is floating 48 | 49 | 50 | typedef struct { 51 | HWND hClient; // client Window Handle 52 | TCHAR *pszName; // name of plugin (shown in window) 53 | int dlgID; // a funcItem provides the function pointer to start a dialog. Please parse here these ID 54 | 55 | // user modifications 56 | UINT uMask; // mask params: look to above defines 57 | HICON hIconTab; // icon for tabs 58 | TCHAR *pszAddInfo; // for plugin to display additional informations 59 | 60 | // internal data, do not use !!! 61 | RECT rcFloat; // floating position 62 | int iPrevCont; // stores the privious container (toggling between float and dock) 63 | const TCHAR* pszModuleName; // it's the plugin file name. It's used to identify the plugin 64 | } tTbData; 65 | 66 | 67 | typedef struct { 68 | HWND hWnd; // the docking manager wnd 69 | RECT rcRegion[DOCKCONT_MAX]; // position of docked dialogs 70 | } tDockMgr; 71 | 72 | 73 | #define HIT_TEST_THICKNESS 20 74 | #define SPLITTER_WIDTH 4 75 | 76 | 77 | #endif // DOCKING_H 78 | -------------------------------------------------------------------------------- /npp/PluginDefinition.cpp: -------------------------------------------------------------------------------- 1 | //this file is part of notepad++ 2 | //Copyright (C)2003 Don HO 3 | // 4 | //This program is free software; you can redistribute it and/or 5 | //modify it under the terms of the GNU General Public License 6 | //as published by the Free Software Foundation; either 7 | //version 2 of the License, or (at your option) any later version. 8 | // 9 | //This program is distributed in the hope that it will be useful, 10 | //but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | //GNU General Public License for more details. 13 | // 14 | //You should have received a copy of the GNU General Public License 15 | //along with this program; if not, write to the Free Software 16 | //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | #include "PluginDefinition.h" 18 | #include "common\statics.h" 19 | 20 | // 21 | // The plugin data that Notepad++ needs 22 | // 23 | FuncItem funcItem[nbFunc]; 24 | 25 | // 26 | // The data of Notepad++ that you can use in your plugin commands 27 | // 28 | static const TCHAR* txtAbout = TEXT("About"); 29 | 30 | class CEditor; 31 | extern CEditor* g_editor; 32 | 33 | void about(){ 34 | /* 35 | If we had dockable visible at last closing of N++, tries N++ to create it at next start 36 | by sending this command. Because we dont have special menu entry uses DockableDialog the same 37 | MenuCmdId while registering of new dockable dialog instances. 38 | 39 | g_editor == NULL helps us to detect this issue :-) 40 | */ 41 | 42 | if (g_editor == NULL) 43 | return; 44 | 45 | TCHAR buf[1024]; 46 | int r = LoadString(Statics::instance().hInstance, 1, buf, sizeof(buf)); 47 | MessageBox(nppData._nppHandle, buf, txtAbout, MB_OK|MB_ICONINFORMATION); 48 | } 49 | 50 | // 51 | // This function help you to initialize your plugin commands 52 | // 53 | bool setCommand(size_t index,const TCHAR *cmdName, PFUNCPLUGINCMD pFunc, ShortcutKey *sk, bool check0nInit) 54 | { 55 | if (index >= nbFunc) 56 | return false; 57 | 58 | if (!pFunc) 59 | return false; 60 | 61 | lstrcpy(funcItem[index]._itemName, cmdName); 62 | funcItem[index]._pFunc = pFunc; 63 | funcItem[index]._init2Check = check0nInit; 64 | funcItem[index]._pShKey = sk; 65 | 66 | return true; 67 | } 68 | 69 | 70 | 71 | // 72 | // Here you can do the clean up, save the parameters (if any) for the next session 73 | // 74 | void pluginCleanUp() 75 | { 76 | // mysite->Release(); 77 | } 78 | 79 | // 80 | // Initialization of your plugin commands 81 | // You should fill your plugins commands here 82 | void commandMenuInit() 83 | { 84 | 85 | //--------------------------------------------// 86 | //-- STEP 3. CUSTOMIZE YOUR PLUGIN COMMANDS --// 87 | //--------------------------------------------// 88 | // with function : 89 | // setCommand(int index, // zero based number to indicate the order of command 90 | // TCHAR *commandName, // the command name that you want to see in plugin menu 91 | // PFUNCPLUGINCMD functionPointer, // the symbol of function (function pointer) associated with this command. The body should be defined below. See Step 4. 92 | // ShortcutKey *shortcut, // optional. Define a shortcut to trigger this command 93 | // bool check0nInit // optional. Make this menu item be checked visually 94 | // ); 95 | setCommand(0, txtAbout, about, NULL, false); 96 | } 97 | 98 | 99 | 100 | // 101 | // Here you can do the clean up (especially for the shortcut) 102 | // 103 | void commandMenuCleanUp() 104 | { 105 | // Don't forget to deallocate your shortcut here 106 | } 107 | -------------------------------------------------------------------------------- /npp/PluginDefinition.h: -------------------------------------------------------------------------------- 1 | //this file is part of notepad++ 2 | //Copyright (C)2003 Don HO 3 | // 4 | //This program is free software; you can redistribute it and/or 5 | //modify it under the terms of the GNU General Public License 6 | //as published by the Free Software Foundation; either 7 | //version 2 of the License, or (at your option) any later version. 8 | // 9 | //This program is distributed in the hope that it will be useful, 10 | //but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | //GNU General Public License for more details. 13 | // 14 | //You should have received a copy of the GNU General Public License 15 | //along with this program; if not, write to the Free Software 16 | //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | #ifndef PLUGINDEFINITION_H 19 | #define PLUGINDEFINITION_H 20 | 21 | // 22 | // All difinitions of plugin interface 23 | // 24 | #include "PluginInterface.h" 25 | 26 | //-------------------------------------// 27 | //-- STEP 1. DEFINE YOUR PLUGIN NAME --// 28 | //-------------------------------------// 29 | // Here define your plugin name 30 | // 31 | const TCHAR NPP_PLUGIN_NAME[] = TEXT("Npp-Highlighter"); 32 | 33 | //-----------------------------------------------// 34 | //-- STEP 2. DEFINE YOUR PLUGIN COMMAND NUMBER --// 35 | //-----------------------------------------------// 36 | // 37 | // Here define the number of your plugin commands 38 | // 39 | const int nbFunc = 1; 40 | 41 | 42 | // 43 | // Initialization of your plugin data 44 | // It will be called while plugin loading 45 | // 46 | void pluginInit(HANDLE hModule); 47 | 48 | // 49 | // Cleaning of your plugin 50 | // It will be called while plugin unloading 51 | // 52 | void pluginCleanUp(); 53 | 54 | // 55 | //Initialization of your plugin commands 56 | // 57 | void commandMenuInit(); 58 | 59 | // 60 | //Clean up your plugin commands allocation (if any) 61 | // 62 | void commandMenuCleanUp(); 63 | 64 | extern NppData nppData; 65 | 66 | #define NPPM(Message, wP, lP) ::SendMessage(nppData._nppHandle, NPPM_##Message, (WPARAM)wP, (LPARAM)lP) 67 | 68 | 69 | #endif //PLUGINDEFINITION_H 70 | -------------------------------------------------------------------------------- /npp/PluginInterface.h: -------------------------------------------------------------------------------- 1 | // This file is part of Notepad++ project 2 | // Copyright (C)2003 Don HO 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either 7 | // version 2 of the License, or (at your option) any later version. 8 | // 9 | // Note that the GPL places important restrictions on "derived works", yet 10 | // it does not provide a detailed definition of that term. To avoid 11 | // misunderstandings, we consider an application to constitute a 12 | // "derivative work" for the purpose of this license if it does any of the 13 | // following: 14 | // 1. Integrates source code from Notepad++. 15 | // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable 16 | // installer, such as those produced by InstallShield. 17 | // 3. Links to a library or executes a program that does any of the above. 18 | // 19 | // This program is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU General Public License 25 | // along with this program; if not, write to the Free Software 26 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 | 28 | 29 | #ifndef PLUGININTERFACE_H 30 | #define PLUGININTERFACE_H 31 | 32 | #ifndef SCINTILLA_H 33 | #include "Scintilla.h" 34 | #endif //SCINTILLA_H 35 | 36 | #ifndef NOTEPAD_PLUS_MSGS_H 37 | #include "Notepad_plus_msgs.h" 38 | #endif //NOTEPAD_PLUS_MSGS_H 39 | 40 | const int nbChar = 64; 41 | 42 | typedef const TCHAR * (__cdecl * PFUNCGETNAME)(); 43 | 44 | struct NppData 45 | { 46 | HWND _nppHandle; 47 | HWND _scintillaMainHandle; 48 | HWND _scintillaSecondHandle; 49 | }; 50 | 51 | typedef void (__cdecl * PFUNCSETINFO)(NppData); 52 | typedef void (__cdecl * PFUNCPLUGINCMD)(); 53 | typedef void (__cdecl * PBENOTIFIED)(SCNotification *); 54 | typedef LRESULT (__cdecl * PMESSAGEPROC)(UINT Message, WPARAM wParam, LPARAM lParam); 55 | 56 | 57 | struct ShortcutKey 58 | { 59 | bool _isCtrl; 60 | bool _isAlt; 61 | bool _isShift; 62 | UCHAR _key; 63 | }; 64 | 65 | struct FuncItem 66 | { 67 | TCHAR _itemName[nbChar]; 68 | PFUNCPLUGINCMD _pFunc; 69 | int _cmdID; 70 | bool _init2Check; 71 | ShortcutKey *_pShKey; 72 | }; 73 | 74 | typedef FuncItem * (__cdecl * PFUNCGETFUNCSARRAY)(int *); 75 | 76 | // You should implement (or define an empty function body) those functions which are called by Notepad++ plugin manager 77 | extern "C" __declspec(dllexport) void setInfo(NppData); 78 | extern "C" __declspec(dllexport) const TCHAR * getName(); 79 | extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *); 80 | extern "C" __declspec(dllexport) void beNotified(SCNotification *); 81 | extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam, LPARAM lParam); 82 | 83 | // This API return always true now, since Notepad++ isn't compiled in ANSI mode anymore 84 | extern "C" __declspec(dllexport) BOOL isUnicode(); 85 | 86 | 87 | #endif //PLUGININTERFACE_H 88 | -------------------------------------------------------------------------------- /npp/dockingResource.h: -------------------------------------------------------------------------------- 1 | //this file is part of docking functionality for Notepad++ 2 | //Copyright (C)2006 Jens Lorenz 3 | // 4 | //This program is free software; you can redistribute it and/or 5 | //modify it under the terms of the GNU General Public License 6 | //as published by the Free Software Foundation; either 7 | //version 2 of the License, or (at your option) any later version. 8 | // 9 | //This program is distributed in the hope that it will be useful, 10 | //but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | //GNU General Public License for more details. 13 | // 14 | //You should have received a copy of the GNU General Public License 15 | //along with this program; if not, write to the Free Software 16 | //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | #ifndef DOCKING_RESOURCE_H 19 | #define DOCKING_RESOURCE_H 20 | 21 | #define IDD_PLUGIN_DLG 103 22 | #define IDC_EDIT1 1000 23 | 24 | 25 | #define IDB_CLOSE_DOWN 137 26 | #define IDB_CLOSE_UP 138 27 | #define IDD_CONTAINER_DLG 139 28 | 29 | #define IDC_TAB_CONT 1027 30 | #define IDC_CLIENT_TAB 1028 31 | #define IDC_BTN_CAPTION 1050 32 | 33 | #define DMM_MSG 0x5000 34 | #define DMM_CLOSE (DMM_MSG + 1) 35 | #define DMM_DOCK (DMM_MSG + 2) 36 | #define DMM_FLOAT (DMM_MSG + 3) 37 | #define DMM_DOCKALL (DMM_MSG + 4) 38 | #define DMM_FLOATALL (DMM_MSG + 5) 39 | #define DMM_MOVE (DMM_MSG + 6) 40 | #define DMM_UPDATEDISPINFO (DMM_MSG + 7) 41 | #define DMM_GETIMAGELIST (DMM_MSG + 8) 42 | #define DMM_GETICONPOS (DMM_MSG + 9) 43 | #define DMM_DROPDATA (DMM_MSG + 10) 44 | #define DMM_MOVE_SPLITTER (DMM_MSG + 11) 45 | #define DMM_CANCEL_MOVE (DMM_MSG + 12) 46 | #define DMM_LBUTTONUP (DMM_MSG + 13) 47 | 48 | #define DMN_FIRST 1050 49 | #define DMN_CLOSE (DMN_FIRST + 1) 50 | //nmhdr.code = DWORD(DMN_CLOSE, 0)); 51 | //nmhdr.hwndFrom = hwndNpp; 52 | //nmhdr.idFrom = ctrlIdNpp; 53 | 54 | #define DMN_DOCK (DMN_FIRST + 2) 55 | #define DMN_FLOAT (DMN_FIRST + 3) 56 | //nmhdr.code = DWORD(DMN_XXX, int newContainer); 57 | //nmhdr.hwndFrom = hwndNpp; 58 | //nmhdr.idFrom = ctrlIdNpp; 59 | 60 | 61 | 62 | #endif //DOCKING_RESOURCE_H 63 | 64 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | ******** Rebuild entire solution after every *.idl modifying!!! -------------------------------------------------------------------------------- /res.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michaelxzhang/Npp-Highlighter/7d4cc7bccdccd1528f022749fe2b0d1bd0f3ad44/res.rc --------------------------------------------------------------------------------