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

Commit 568ee41

Browse files
committed
C#-ified code
1 parent 2e4df5c commit 568ee41

File tree

3 files changed

+28
-25
lines changed

3 files changed

+28
-25
lines changed

Demo Plugin/NppManagedPluginDemo/Demo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ static internal void OnCharAdded(char newChar)
3737
{
3838
}
3939

40-
public static void OnNotification(SCNotification notification)
40+
public static void OnNotification(ScNotification notification)
4141
{
42-
if (notification.nmhdr.code == (uint)SciMsg.SCN_CHARADDED)
42+
if (notification.Header.code == (uint)SciMsg.SCN_CHARADDED)
4343
{
4444
Kbg.Demo.Namespace.Main.doInsertHtmlCloseTag((char)notification.Character);
4545
}

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

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,41 @@ namespace Kbg.NppPluginNET.PluginInfrastructure
1616
/// but most clients of Scintilla.h do not have this type visible.
1717
/// </summary>
1818
[StructLayout(LayoutKind.Sequential)]
19-
public struct Sci_NotifyHeader
19+
public struct ScNotificationHeader
2020
{
2121
public IntPtr hwndFrom; //! environment specific window handle/pointer
2222
public uint idFrom; //! CtrlID of the window issuing the notification
2323
public uint code; //! The SCN_* notification code
2424
}
2525

2626
[StructLayout(LayoutKind.Sequential)]
27-
public struct SCNotification
27+
public struct ScNotification
2828
{
29-
public Sci_NotifyHeader nmhdr;
29+
public ScNotificationHeader Header;
3030
private int position; /* SCN_STYLENEEDED, SCN_DOUBLECLICK, SCN_MODIFIED, SCN_MARGINCLICK, SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, SCN_CALLTIPCLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION */
3131
public int character; /* SCN_CHARADDED, SCN_KEY, SCN_AUTOCCOMPLETE, SCN_AUTOCSELECTION, SCN_USERLISTSELECTION */
32-
public int modifiers; /* SCN_KEY, SCN_DOUBLECLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE */
33-
public int modificationType; /* SCN_MODIFIED */
34-
public IntPtr text; /* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_URIDROPPED */
35-
public int length; /* SCN_MODIFIED */
36-
public int linesAdded; /* SCN_MODIFIED */
37-
public int message; /* SCN_MACRORECORD */
32+
public int Mmodifiers; /* SCN_KEY, SCN_DOUBLECLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE */
33+
public int ModificationType; /* SCN_MODIFIED */
34+
public IntPtr TextPointer; /* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_URIDROPPED */
35+
public int Length; /* SCN_MODIFIED */
36+
public int LinesAdded; /* SCN_MODIFIED */
37+
public int Message; /* SCN_MACRORECORD */
3838
public uint wParam; /* SCN_MACRORECORD */
3939
public int lParam; /* SCN_MACRORECORD */
40-
public int line; /* SCN_MODIFIED */
41-
public int foldLevelNow; /* SCN_MODIFIED */
42-
public int foldLevelPrev; /* SCN_MODIFIED */
43-
public int margin; /* SCN_MARGINCLICK */
44-
public int listType; /* SCN_USERLISTSELECTION */
45-
public int x; /* SCN_DWELLSTART, SCN_DWELLEND */
46-
public int y; /* SCN_DWELLSTART, SCN_DWELLEND */
47-
public int token; /* SCN_MODIFIED with SC_MOD_CONTAINER */
48-
public int annotationLinesAdded;/* SC_MOD_CHANGEANNOTATION */
49-
public int updated; /* SCN_UPDATEUI */
50-
public int listCompletionMethod; /* SCN_AUTOCSELECTION, SCN_AUTOCCOMPLETED, SCN_USERLISTSELECTION */
40+
/// <summary>
41+
/// 0-based index
42+
/// </summary>
43+
public int LineNumber; /* SCN_MODIFIED */
44+
public int FoldLevelNow; /* SCN_MODIFIED */
45+
public int FoldLevelPrev; /* SCN_MODIFIED */
46+
public int Margin; /* SCN_MARGINCLICK */
47+
public int ListType; /* SCN_USERLISTSELECTION */
48+
public int X; /* SCN_DWELLSTART, SCN_DWELLEND */
49+
public int Y; /* SCN_DWELLSTART, SCN_DWELLEND */
50+
public int Token; /* SCN_MODIFIED with SC_MOD_CONTAINER */
51+
public int AnnotationLinesAdded;/* SC_MOD_CHANGEANNOTATION */
52+
public int Updated; /* SCN_UPDATEUI */
53+
public int ListCompletionMethod; /* SCN_AUTOCSELECTION, SCN_AUTOCCOMPLETED, SCN_USERLISTSELECTION */
5154

5255
/// <summary>
5356
/// SCN_STYLENEEDED, SCN_DOUBLECLICK, SCN_MODIFIED, SCN_MARGINCLICK, SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, SCN_CALLTIPCLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ static IntPtr getName()
4545
[DllExport(CallingConvention = CallingConvention.Cdecl)]
4646
static void beNotified(IntPtr notifyCode)
4747
{
48-
SCNotification notification = (SCNotification)Marshal.PtrToStructure(notifyCode, typeof(SCNotification));
49-
if (notification.nmhdr.code == (uint)NppMsg.NPPN_TBMODIFICATION)
48+
ScNotification notification = (ScNotification)Marshal.PtrToStructure(notifyCode, typeof(ScNotification));
49+
if (notification.Header.code == (uint)NppMsg.NPPN_TBMODIFICATION)
5050
{
5151
PluginBase._funcItems.RefreshItems();
5252
Main.SetToolBarIcon();
5353
}
54-
else if (notification.nmhdr.code == (uint)NppMsg.NPPN_SHUTDOWN)
54+
else if (notification.Header.code == (uint)NppMsg.NPPN_SHUTDOWN)
5555
{
5656
Main.PluginCleanUp();
5757
Marshal.FreeHGlobal(_ptrPluginName);

0 commit comments

Comments
 (0)