Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 4c83dc8

Browse files
committed
Merge pull request #3 from kbilsted/topic/incorporate_ufo_v.0.7
Topic/incorporate ufo v.0.7
2 parents 5572c2f + 7dc23c2 commit 4c83dc8

File tree

7 files changed

+153
-26
lines changed

7 files changed

+153
-26
lines changed

README.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
1-
# NppPlugin .NET package for VS2015
1+
# NppPlugin .NET package for VS2015 and beyond...
22

3-
## Fork information
4-
This is a fork of UFO's plugin package http://sourceforge.net/projects/sourcecookifier/files/other%20plugins/NppPlugin.NET.v0.5.zip/download which seems abandoned (and only supports up to visual studio 2010).
3+
This is a fork of UFO's plugin package updated for VS2015
54

65

76

87
## Content information
98
This package contains two folders:
109

11-
1) Visual Studio Project Template C#:
12-
A VS template for very fast and even easier building of .NET plugins for Notepad++.
10+
1. Templates:
11+
Simple templates for very fast and even easier building of .NET plugins for Notepad++.
1312
Setting up a plugin for N++ has never ever been as easy as with this package.
14-
Please See its containing text file for further information.
13+
Please see the containing txt files for further installation information.
1514

16-
2) Demo Plugin:
15+
16+
2. Demo:
1717
An example .NET plugin for Notepad++, build upon the template above.
18-
It demonstrates the same functionality as the original demo plugin by Don HO:
19-
http://notepad-plus.sourceforge.net/commun/pluginDemoTemplate/NppPluginTemplate.zip
20-
I don't know if I've added new bugs, but I've corrected some small mistakes which
21-
are in the original demo. I've also added example code for registering icons for
22-
the tab of a dockable dialog and for Notepad++'s tool bar (and how to toggle its
23-
state).
18+
It demonstrates the same functionality as the original demo plugin by Don Ho:
19+
http://download.tuxfamily.org/nppplugins/NppPluginDemo/NppPluginDemo.zip
2420

21+
22+
23+
## Credits
24+
For the main work on the plugin package
25+
* UFO
26+
* v0.5 http://sourceforge.net/projects/sourcecookifier/files/other%20plugins/NppPlugin.NET.v0.5.zip/download
27+
* and v0.7 https://bitbucket.org/uph0/npppluginnet
2528

26-
## Requirements:
29+
All credits for the used DllExport technique to following guys:
30+
* Dark Daskin: http://www.codeproject.com/KB/dotnet/DllExporter.aspx
31+
* Robert Giesecke: http://sites.google.com/site/robertgiesecke/Home/uploads/csharpprojecttemplateforunmanagedexports https://www.nuget.org/packages/UnmanagedExports
2732

33+
34+
## Requirements:
2835
* works with .NET Runtime 2.0 and above
2936
* UNICODE only! ANSI is doable, but not supported so far
3037

31-
please feel free to contribute!
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,49 @@
1-
<Project
2-
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<UsingTask TaskName="NppPlugin.DllExport.MSBuild.DllExportTask"
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<PropertyGroup>
5+
<PostBuildEventDependsOn>
6+
$(PostBuildEventDependsOn);
7+
NppPluginDllExport
8+
</PostBuildEventDependsOn>
9+
</PropertyGroup>
10+
11+
<PropertyGroup>
12+
<BuildDependsOn>
13+
$(BuildDependsOn);
14+
NppPluginDllExport
15+
</BuildDependsOn>
16+
</PropertyGroup>
17+
18+
<UsingTask TaskName="NppPlugin.DllExport.MSBuild.DllExportAppDomainIsolatedTask"
419
AssemblyFile="NppPlugin.DllExport.MSBuild.dll"/>
5-
<Target Name="AfterBuild"
6-
DependsOnTargets="GetFrameworkPaths"
7-
>
8-
<DllExportTask Platform="$(Platform)"
20+
21+
<Target Name="NppPluginDllExport"
22+
DependsOnTargets="GetFrameworkPaths">
23+
24+
<!--
25+
These properties can still be applied to the task, but upon installation of a
26+
new version of the nuget package, the properties
27+
DllExportAttributeAssemblyName and DllExportAttributeAssemblyName will be removed from the project.
28+
So, if you want to provide an alternative attribute name, the you have to name the property in your project file differently.
29+
30+
e.g.:
31+
DllExportAttributeAssemblyName="$(MyDllExportAttributeAssemblyName)"
32+
DllExportAttributeFullName="$(MyDllExportAttributeFullName)"
33+
-->
34+
<PropertyGroup>
35+
<DllExportLeaveIntermediateFiles Condition="'$(DllExportLeaveIntermediateFiles)'==''">
36+
false
37+
</DllExportLeaveIntermediateFiles>
38+
39+
40+
</PropertyGroup>
41+
42+
<DllExportAppDomainIsolatedTask Platform="$(Platform)"
943
PlatformTarget="$(PlatformTarget)"
1044
CpuType="$(CpuType)"
1145
EmitDebugSymbols="$(DebugSymbols)"
12-
DllExportAttributeAssemblyName="$(DllExportAttributeAssemblyName)"
13-
DllExportAttributeFullName="$(DllExportAttributeFullName)"
46+
LeaveIntermediateFiles="$(DllExportLeaveIntermediateFiles)"
1447
Timeout="$(DllExportTimeout)"
1548
KeyContainer="$(KeyContainerName)$(AssemblyKeyContainerName)"
1649
KeyFile="$(KeyOriginatorFile)"
@@ -19,6 +52,8 @@
1952
FrameworkPath="$(TargetedFrameworkDir);$(TargetFrameworkDirectory)"
2053
LibToolPath="$(DevEnvDir)\..\..\VC\bin"
2154
LibToolDllPath="$(DevEnvDir)"
22-
SdkPath="$(SDK40ToolsPath)"/>
55+
TargetFrameworkVersion="$(TargetFrameworkVersion)"
56+
SdkPath="$(SDK40ToolsPath)"
57+
SkipOnAnyCpu="$(NoDllExportsForAnyCpu)"/>
2358
</Target>
2459
</Project>

Visual Studio Project Template C#/NppPlugin.vstemplate

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<ProjectItem ReplaceParameters="false" TargetFileName="star.png">star.png</ProjectItem>
3838
<ProjectItem ReplaceParameters="false" TargetFileName="star_bmp.bmp">star_bmp.bmp</ProjectItem>
3939
</Folder>
40-
<ProjectItem ReplaceParameters="true" TargetFileName="Main.cs">Main.cs</ProjectItem>
40+
<ProjectItem ReplaceParameters="true" TargetFileName="Main.cs" OpenInEditor="true">Main.cs</ProjectItem>
4141
<ProjectItem ReplaceParameters="false" TargetFileName="NppPluginNETBase.cs">NppPluginNETBase.cs</ProjectItem>
4242
<ProjectItem ReplaceParameters="false" TargetFileName="NppPluginNETHelper.cs">NppPluginNETHelper.cs</ProjectItem>
4343
<ProjectItem ReplaceParameters="true" TargetFileName="UnmanagedExports.cs">UnmanagedExports.cs</ProjectItem>

Visual Studio Project Template C#/NppPluginNETHelper.cs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Text;
33
using System.Windows.Forms;
44
using System.Collections.Generic;
5+
using System.Drawing;
56
using System.Runtime.InteropServices;
67

78
namespace Kbg.NppPluginNET
@@ -201,10 +202,17 @@ public enum LangType
201202
L_ASM, L_DIFF, L_PROPS, L_PS, L_RUBY, L_SMALLTALK, L_VHDL, L_KIX, L_AU3,
202203
L_CAML, L_ADA, L_VERILOG, L_MATLAB, L_HASKELL, L_INNO, L_SEARCHRESULT,
203204
L_CMAKE, L_YAML, L_COBOL, L_GUI4CLI, L_D, L_POWERSHELL, L_R, L_JSP,
205+
L_COFFEESCRIPT,
204206
// The end of enumated language type, so it should be always at the end
205207
L_EXTERNAL
206208
}
207209

210+
public enum winVer
211+
{
212+
WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K,
213+
WV_XP, WV_S2003, WV_XPX64, WV_VISTA, WV_WIN7, WV_WIN8, WV_WIN81
214+
}
215+
208216
[Flags]
209217
public enum NppMsg : uint
210218
{
@@ -257,6 +265,9 @@ public enum NppMsg : uint
257265

258266
NPPM_GETMENUHANDLE = (NPPMSG + 25),
259267
NPPPLUGINMENU = 0,
268+
NPPMAINMENU = 1,
269+
// INT NPPM_GETMENUHANDLE(INT menuChoice, 0)
270+
// Return: menu handle (HMENU) of choice (plugin menu handle or Notepad++ main menu handle)
260271

261272
NPPM_ENCODESCI = (NPPMSG + 26),
262273
//ascii file to unicode
@@ -366,6 +377,7 @@ public enum NppMsg : uint
366377
NPPM_GETPOSFROMBUFFERID = (NPPMSG + 57),
367378
// INT NPPM_GETPOSFROMBUFFERID(INT bufferID, 0)
368379
// Return VIEW|INDEX from a buffer ID. -1 if the bufferID non existing
380+
// if priorityView set to SUB_VIEW, then SUB_VIEW will be search firstly
369381
//
370382
// VIEW takes 2 highest bits and INDEX (0 based) takes the rest (30 bits)
371383
// Here's the values for the view :
@@ -380,49 +392,58 @@ public enum NppMsg : uint
380392
// allocate fullFilePath with the return values + 1, then call it again to get full path file name
381393

382394
NPPM_GETBUFFERIDFROMPOS = (NPPMSG + 59),
395+
// INT NPPM_GETBUFFERIDFROMPOS(INT index, INT iView)
383396
//wParam: Position of document
384397
//lParam: View to use, 0 = Main, 1 = Secondary
385398
//Returns 0 if invalid
386399

387400
NPPM_GETCURRENTBUFFERID = (NPPMSG + 60),
401+
// INT NPPM_GETCURRENTBUFFERID(0, 0)
388402
//Returns active Buffer
389403

390404
NPPM_RELOADBUFFERID = (NPPMSG + 61),
405+
// VOID NPPM_RELOADBUFFERID(0, 0)
391406
//Reloads Buffer
392407
//wParam: Buffer to reload
393408
//lParam: 0 if no alert, else alert
394409

395410

396411
NPPM_GETBUFFERLANGTYPE = (NPPMSG + 64),
412+
// INT NPPM_GETBUFFERLANGTYPE(INT bufferID, 0)
397413
//wParam: BufferID to get LangType from
398414
//lParam: 0
399415
//Returns as int, see LangType. -1 on error
400416

401417
NPPM_SETBUFFERLANGTYPE = (NPPMSG + 65),
418+
// BOOL NPPM_SETBUFFERLANGTYPE(INT bufferID, INT langType)
402419
//wParam: BufferID to set LangType of
403420
//lParam: LangType
404421
//Returns TRUE on success, FALSE otherwise
405422
//use int, see LangType for possible values
406423
//L_USER and L_EXTERNAL are not supported
407424

408425
NPPM_GETBUFFERENCODING = (NPPMSG + 66),
426+
// INT NPPM_GETBUFFERENCODING(INT bufferID, 0)
409427
//wParam: BufferID to get encoding from
410428
//lParam: 0
411429
//returns as int, see UniMode. -1 on error
412430

413431
NPPM_SETBUFFERENCODING = (NPPMSG + 67),
432+
// BOOL NPPM_SETBUFFERENCODING(INT bufferID, INT encoding)
414433
//wParam: BufferID to set encoding of
415434
//lParam: format
416435
//Returns TRUE on success, FALSE otherwise
417436
//use int, see UniMode
418437
//Can only be done on new, unedited files
419438

420439
NPPM_GETBUFFERFORMAT = (NPPMSG + 68),
440+
// INT NPPM_GETBUFFERFORMAT(INT bufferID, 0)
421441
//wParam: BufferID to get format from
422442
//lParam: 0
423443
//returns as int, see formatType. -1 on error
424444

425445
NPPM_SETBUFFERFORMAT = (NPPMSG + 69),
446+
// BOOL NPPM_SETBUFFERFORMAT(INT bufferID, INT format)
426447
//wParam: BufferID to set format of
427448
//lParam: format
428449
//Returns TRUE on success, FALSE otherwise
@@ -503,6 +524,51 @@ public enum NppMsg : uint
503524
// Allocates a marker number to a plugin
504525
// Returns: TRUE if successful, FALSE otherwise. startNumber will also be set to 0 if unsuccessful
505526

527+
NPPM_GETLANGUAGENAME = (NPPMSG + 83),
528+
// INT NPPM_GETLANGUAGENAME(int langType, TCHAR *langName)
529+
// Get programing language name from the given language type (LangType)
530+
// Return value is the number of copied character / number of character to copy (\0 is not included)
531+
// You should call this function 2 times - the first time you pass langName as NULL to get the number of characters to copy.
532+
// You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGENAME function the 2nd time
533+
// by passing allocated buffer as argument langName
534+
535+
NPPM_GETLANGUAGEDESC = (NPPMSG + 84),
536+
// INT NPPM_GETLANGUAGEDESC(int langType, TCHAR *langDesc)
537+
// Get programing language short description from the given language type (LangType)
538+
// Return value is the number of copied character / number of character to copy (\0 is not included)
539+
// You should call this function 2 times - the first time you pass langDesc as NULL to get the number of characters to copy.
540+
// You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGEDESC function the 2nd time
541+
// by passing allocated buffer as argument langDesc
542+
543+
NPPM_SHOWDOCSWITCHER = (NPPMSG + 85),
544+
// VOID NPPM_ISDOCSWITCHERSHOWN(0, BOOL toShowOrNot)
545+
// Send this message to show or hide doc switcher.
546+
// if toShowOrNot is TRUE then show doc switcher, otherwise hide it.
547+
548+
NPPM_ISDOCSWITCHERSHOWN = (NPPMSG + 86),
549+
// BOOL NPPM_ISDOCSWITCHERSHOWN(0, 0)
550+
// Check to see if doc switcher is shown.
551+
552+
NPPM_GETAPPDATAPLUGINSALLOWED = (NPPMSG + 87),
553+
// BOOL NPPM_GETAPPDATAPLUGINSALLOWED(0, 0)
554+
// Check to see if loading plugins from "%APPDATA%\Notepad++\plugins" is allowed.
555+
556+
NPPM_GETCURRENTVIEW = (NPPMSG + 88),
557+
// INT NPPM_GETCURRENTVIEW(0, 0)
558+
// Return: current edit view of Notepad++. Only 2 possible values: 0 = Main, 1 = Secondary
559+
560+
NPPM_DOCSWITCHERDISABLECOLUMN = (NPPMSG + 89),
561+
// VOID NPPM_DOCSWITCHERDISABLECOLUMN(0, BOOL disableOrNot)
562+
// Disable or enable extension column of doc switcher
563+
564+
NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR = (NPPMSG + 90),
565+
// INT NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR(0, 0)
566+
// Return: current editor default foreground color. You should convert the returned value in COLORREF
567+
568+
NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR = (NPPMSG + 91),
569+
// INT NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR(0, 0)
570+
// Return: current editor default background color. You should convert the returned value in COLORREF
571+
506572
RUNCOMMAND_USER = (0x400/*WM_USER*/ + 3000),
507573
NPPM_GETFULLCURRENTPATH = (RUNCOMMAND_USER + FULL_CURRENT_PATH),
508574
NPPM_GETCURRENTDIRECTORY = (RUNCOMMAND_USER + CURRENT_DIRECTORY),
@@ -2082,6 +2148,8 @@ public class Win32
20822148
public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
20832149
[DllImport("user32")]
20842150
public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
2151+
[DllImport("user32")]
2152+
public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lParam);
20852153

20862154
[DllImport("user32")]
20872155
public static extern IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, int wParam, IntPtr lParam);
@@ -2107,6 +2175,12 @@ public class Win32
21072175
public static extern int CheckMenuItem(IntPtr hmenu, int uIDCheckItem, int uCheck);
21082176

21092177
public const int WM_CREATE = 1;
2178+
2179+
[DllImport("user32")]
2180+
public static extern bool ClientToScreen(IntPtr hWnd, ref Point lpPoint);
2181+
2182+
[DllImport("kernel32")]
2183+
public static extern void OutputDebugString(string lpOutputString);
21102184
}
21112185

21122186
public class ClikeStringArray : IDisposable
@@ -2127,6 +2201,18 @@ public ClikeStringArray(int num, int stringCapacity)
21272201
}
21282202
Marshal.WriteIntPtr((IntPtr)((int)_nativeArray + (num * IntPtr.Size)), IntPtr.Zero);
21292203
}
2204+
public ClikeStringArray(List<string> lstStrings)
2205+
{
2206+
_nativeArray = Marshal.AllocHGlobal((lstStrings.Count + 1) * IntPtr.Size);
2207+
_nativeItems = new List<IntPtr>();
2208+
for (int i = 0; i < lstStrings.Count; i++)
2209+
{
2210+
IntPtr item = Marshal.StringToHGlobalUni(lstStrings[i]);
2211+
Marshal.WriteIntPtr((IntPtr)((int)_nativeArray + (i * IntPtr.Size)), item);
2212+
_nativeItems.Add(item);
2213+
}
2214+
Marshal.WriteIntPtr((IntPtr)((int)_nativeArray + (lstStrings.Count * IntPtr.Size)), IntPtr.Zero);
2215+
}
21302216

21312217
public IntPtr NativePointer { get { return _nativeArray; } }
21322218
public List<string> ManagedStringsAnsi { get { return _getManagedItems(false); } }

0 commit comments

Comments
 (0)