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

Commit c9310d4

Browse files
committed
Extract NotepadPPGateway.cs
1 parent 426f918 commit c9310d4

File tree

5 files changed

+56
-43
lines changed

5 files changed

+56
-43
lines changed

Demo Plugin/NppManagedPluginDemo/NppManagedPluginDemo.VS2015.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
<Compile Include="..\..\Visual Studio Project Template C#\PluginInfrastructure\ClikeStringArray.cs">
5353
<Link>PluginInfrastructure\ClikeStringArray.cs</Link>
5454
</Compile>
55+
<Compile Include="..\..\Visual Studio Project Template C#\PluginInfrastructure\NotepadPPGateway.cs">
56+
<Link>PluginInfrastructure\NotepadPPGateway.cs</Link>
57+
</Compile>
5558
<Compile Include="..\..\Visual Studio Project Template C#\PluginInfrastructure\Preference_h.cs">
5659
<Link>PluginInfrastructure\Preference_h.cs</Link>
5760
</Compile>

Visual Studio Project Template C#/$projectname$.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<Compile Include="PluginInfrastructure\Win32.cs" />
5454
<Compile Include="Main.cs" />
5555
<Compile Include="PluginInfrastructure\GatewayDomain.cs" />
56+
<Compile Include="PluginInfrastructure\NotepadPPGateway.cs" />
5657
<Compile Include="PluginInfrastructure\ScintillaGateway.cs" />
5758
<Compile Include="PluginInfrastructure\IScintillaGateway.cs" />
5859
<Compile Include="PluginInfrastructure\NppPluginNETBase.cs" />

Visual Studio Project Template C#/PluginInfrastructure/IScintillaGateway.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44

55
namespace Kbg.NppPluginNET
66
{
7-
public interface INotepadPPGateway
8-
{
9-
void FileNew();
10-
11-
string GetCurrentFilePath();
12-
unsafe string GetFilePath(int bufferId);
13-
void SetCurrentLanguage(LangType language);
14-
}
157

168
/// <summary>
179
/// This it the plugin-writers primary interface to Notepad++/Scintilla.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// NPP plugin platform for .Net v0.91.57 by Kasper B. Graversen etc.
2+
using System;
3+
using System.Text;
4+
using Kbg.NppPluginNET.PluginInfrastructure;
5+
6+
namespace Kbg.NppPluginNET
7+
{
8+
public interface INotepadPPGateway
9+
{
10+
void FileNew();
11+
12+
string GetCurrentFilePath();
13+
unsafe string GetFilePath(int bufferId);
14+
void SetCurrentLanguage(LangType language);
15+
}
16+
17+
public class NotepadPPGateway : INotepadPPGateway
18+
{
19+
private const int Unused = 0;
20+
21+
public void FileNew()
22+
{
23+
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_MENUCOMMAND, Unused, NppMenuCmd.IDM_FILE_NEW);
24+
}
25+
26+
/// <summary>
27+
/// Gets the path of the current document.
28+
/// </summary>
29+
public string GetCurrentFilePath()
30+
{
31+
var path = new StringBuilder(2000);
32+
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETFULLCURRENTPATH, 0, path);
33+
return path.ToString();
34+
}
35+
36+
/// <summary>
37+
/// Gets the path of the current document.
38+
/// </summary>
39+
public unsafe string GetFilePath(int bufferId)
40+
{
41+
var path = new StringBuilder(2000);
42+
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETFULLPATHFROMBUFFERID, bufferId, path);
43+
return path.ToString();
44+
}
45+
46+
public void SetCurrentLanguage(LangType language)
47+
{
48+
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_SETCURRENTLANGTYPE, Unused, (int) language);
49+
}
50+
}
51+
52+
}

Visual Studio Project Template C#/PluginInfrastructure/ScintillaGateway.cs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,6 @@
55

66
namespace Kbg.NppPluginNET
77
{
8-
public class NotepadPPGateway : INotepadPPGateway
9-
{
10-
private const int Unused = 0;
11-
12-
public void FileNew()
13-
{
14-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_MENUCOMMAND, Unused, NppMenuCmd.IDM_FILE_NEW);
15-
}
16-
17-
/// <summary>
18-
/// Gets the path of the current document.
19-
/// </summary>
20-
public string GetCurrentFilePath()
21-
{
22-
var path = new StringBuilder(2000);
23-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETFULLCURRENTPATH, 0, path);
24-
return path.ToString();
25-
}
26-
27-
/// <summary>
28-
/// Gets the path of the current document.
29-
/// </summary>
30-
public unsafe string GetFilePath(int bufferId)
31-
{
32-
var path = new StringBuilder(2000);
33-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_GETFULLPATHFROMBUFFERID, bufferId, path);
34-
return path.ToString();
35-
}
36-
37-
public void SetCurrentLanguage(LangType language)
38-
{
39-
Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_SETCURRENTLANGTYPE, Unused, (int) language);
40-
}
41-
}
42-
438
/// <summary>
449
/// This it the plugin-writers primary interface to Notepad++/Scintilla.
4510
/// It takes away all the complexity with command numbers and Int-pointer casting.

0 commit comments

Comments
 (0)