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

Commit a9c4474

Browse files
authored
Merge pull request #22 from lipnitsk/master
Fix code to support 64-bit
2 parents c984e36 + df11d42 commit a9c4474

File tree

4 files changed

+96
-57
lines changed

4 files changed

+96
-57
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -878,14 +878,14 @@ public interface IScintillaGateway
878878
int GetTextLength();
879879

880880
/// <summary>Retrieve a pointer to a function that processes messages for this Scintilla. (Scintilla feature 2184)</summary>
881-
int GetDirectFunction();
881+
IntPtr GetDirectFunction();
882882

883883
/// <summary>
884884
/// Retrieve a pointer value to use as the first argument when calling
885885
/// the function returned by GetDirectFunction.
886886
/// (Scintilla feature 2185)
887887
/// </summary>
888-
int GetDirectPointer();
888+
IntPtr GetDirectPointer();
889889

890890
/// <summary>Set to overtype (true) or insert mode. (Scintilla feature 2186)</summary>
891891
void SetOvertype(bool overtype);
@@ -1503,10 +1503,10 @@ public interface IScintillaGateway
15031503
void SetViewEOL(bool visible);
15041504

15051505
/// <summary>Retrieve a pointer to the document object. (Scintilla feature 2357)</summary>
1506-
int GetDocPointer();
1506+
IntPtr GetDocPointer();
15071507

15081508
/// <summary>Change the document object used. (Scintilla feature 2358)</summary>
1509-
void SetDocPointer(int pointer);
1509+
void SetDocPointer(IntPtr pointer);
15101510

15111511
/// <summary>Set which document modification events are sent to the container. (Scintilla feature 2359)</summary>
15121512
void SetModEventMask(int mask);
@@ -1985,15 +1985,15 @@ public interface IScintillaGateway
19851985
/// characters in the document.
19861986
/// (Scintilla feature 2520)
19871987
/// </summary>
1988-
int GetCharacterPointer();
1988+
IntPtr GetCharacterPointer();
19891989

19901990
/// <summary>
19911991
/// Return a read-only pointer to a range of characters in the document.
19921992
/// May move the gap so that the range is contiguous, but will only move up
19931993
/// to rangeLength bytes.
19941994
/// (Scintilla feature 2643)
19951995
/// </summary>
1996-
int GetRangePointer(int position, int rangeLength);
1996+
IntPtr GetRangePointer(int position, int rangeLength);
19971997

19981998
/// <summary>
19991999
/// Return a position which, to avoid performance costs, should not be within

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

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,21 +1801,19 @@ public int GetTextLength()
18011801
}
18021802

18031803
/// <summary>Retrieve a pointer to a function that processes messages for this Scintilla. (Scintilla feature 2184)</summary>
1804-
public int GetDirectFunction()
1804+
public IntPtr GetDirectFunction()
18051805
{
1806-
IntPtr res = Win32.SendMessage(scintilla, SciMsg.SCI_GETDIRECTFUNCTION, Unused, Unused);
1807-
return (int) res;
1806+
return Win32.SendMessage(scintilla, SciMsg.SCI_GETDIRECTFUNCTION, Unused, Unused);
18081807
}
18091808

18101809
/// <summary>
18111810
/// Retrieve a pointer value to use as the first argument when calling
18121811
/// the function returned by GetDirectFunction.
18131812
/// (Scintilla feature 2185)
18141813
/// </summary>
1815-
public int GetDirectPointer()
1814+
public IntPtr GetDirectPointer()
18161815
{
1817-
IntPtr res = Win32.SendMessage(scintilla, SciMsg.SCI_GETDIRECTPOINTER, Unused, Unused);
1818-
return (int) res;
1816+
return Win32.SendMessage(scintilla, SciMsg.SCI_GETDIRECTPOINTER, Unused, Unused);
18191817
}
18201818

18211819
/// <summary>Set to overtype (true) or insert mode. (Scintilla feature 2186)</summary>
@@ -2992,14 +2990,13 @@ public void SetViewEOL(bool visible)
29922990
}
29932991

29942992
/// <summary>Retrieve a pointer to the document object. (Scintilla feature 2357)</summary>
2995-
public int GetDocPointer()
2993+
public IntPtr GetDocPointer()
29962994
{
2997-
IntPtr res = Win32.SendMessage(scintilla, SciMsg.SCI_GETDOCPOINTER, Unused, Unused);
2998-
return (int) res;
2995+
return Win32.SendMessage(scintilla, SciMsg.SCI_GETDOCPOINTER, Unused, Unused);
29992996
}
30002997

30012998
/// <summary>Change the document object used. (Scintilla feature 2358)</summary>
3002-
public void SetDocPointer(int pointer)
2999+
public void SetDocPointer(IntPtr pointer)
30033000
{
30043001
IntPtr res = Win32.SendMessage(scintilla, SciMsg.SCI_SETDOCPOINTER, Unused, pointer);
30053002
}
@@ -3936,10 +3933,9 @@ public void CopyAllowLine()
39363933
/// characters in the document.
39373934
/// (Scintilla feature 2520)
39383935
/// </summary>
3939-
public int GetCharacterPointer()
3936+
public IntPtr GetCharacterPointer()
39403937
{
3941-
IntPtr res = Win32.SendMessage(scintilla, SciMsg.SCI_GETCHARACTERPOINTER, Unused, Unused);
3942-
return (int) res;
3938+
return Win32.SendMessage(scintilla, SciMsg.SCI_GETCHARACTERPOINTER, Unused, Unused);
39433939
}
39443940

39453941
/// <summary>
@@ -3948,10 +3944,9 @@ public int GetCharacterPointer()
39483944
/// to rangeLength bytes.
39493945
/// (Scintilla feature 2643)
39503946
/// </summary>
3951-
public int GetRangePointer(int position, int rangeLength)
3947+
public IntPtr GetRangePointer(int position, int rangeLength)
39523948
{
3953-
IntPtr res = Win32.SendMessage(scintilla, SciMsg.SCI_GETRANGEPOINTER, position, rangeLength);
3954-
return (int) res;
3949+
return Win32.SendMessage(scintilla, SciMsg.SCI_GETRANGEPOINTER, position, rangeLength);
39553950
}
39563951

39573952
/// <summary>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public struct ScNotificationHeader
2626
/// <summary>
2727
/// CtrlID of the window issuing the notification
2828
/// </summary>
29-
public uint IdFrom;
29+
public IntPtr IdFrom;
3030

3131
/// <summary>
3232
/// The SCN_* notification Code
@@ -46,8 +46,8 @@ public struct ScNotification
4646
public int Length; /* SCN_MODIFIED */
4747
public int LinesAdded; /* SCN_MODIFIED */
4848
public int Message; /* SCN_MACRORECORD */
49-
public uint wParam; /* SCN_MACRORECORD */
50-
public int lParam; /* SCN_MACRORECORD */
49+
public IntPtr wParam; /* SCN_MACRORECORD */
50+
public IntPtr lParam; /* SCN_MACRORECORD */
5151

5252
/// <summary>
5353
/// 0-based index

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

Lines changed: 76 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class Win32
1515
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
1616
/// </summary>
1717
[DllImport("user32")]
18-
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, NppMenuCmd lParam);
18+
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
1919

2020
/// <summary>
2121
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
@@ -24,7 +24,7 @@ public class Win32
2424
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
2525
/// </summary>
2626
[DllImport("user32")]
27-
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, IntPtr lParam);
27+
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lParam);
2828

2929
/// <summary>
3030
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
@@ -33,7 +33,7 @@ public class Win32
3333
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
3434
/// </summary>
3535
[DllImport("user32")]
36-
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
36+
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
3737

3838
/// <summary>
3939
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
@@ -42,123 +42,167 @@ public class Win32
4242
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
4343
/// </summary>
4444
[DllImport("user32")]
45-
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, out int lParam);
45+
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, out IntPtr lParam);
4646

4747
/// <summary>
4848
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
4949
/// <see cref="ScintillaGateway"/> or <see cref="NotepadPPGateway"/>.
5050
/// If gateways are missing or incomplete, please help extend them and send your code to the project
5151
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
5252
/// </summary>
53-
[DllImport("user32")]
54-
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, int lParam);
53+
public static IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, NppMenuCmd lParam)
54+
{
55+
return SendMessage(hWnd, (UInt32)Msg, new IntPtr(wParam), new IntPtr((uint)lParam));
56+
}
57+
5558
/// <summary>
5659
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
5760
/// <see cref="ScintillaGateway"/> or <see cref="NotepadPPGateway"/>.
5861
/// If gateways are missing or incomplete, please help extend them and send your code to the project
5962
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
6063
/// </summary>
64+
public static IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, IntPtr lParam)
65+
{
66+
return SendMessage(hWnd, (UInt32)Msg, new IntPtr(wParam), lParam);
67+
}
6168

6269
/// <summary>
6370
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
6471
/// <see cref="ScintillaGateway"/> or <see cref="NotepadPPGateway"/>.
6572
/// If gateways are missing or incomplete, please help extend them and send your code to the project
6673
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
6774
/// </summary>
68-
[DllImport("user32")]
69-
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, ref LangType lParam);
75+
public static IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam)
76+
{
77+
return SendMessage(hWnd, (UInt32)Msg, new IntPtr(wParam), new IntPtr(lParam));
78+
}
7079

7180
/// <summary>
7281
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
7382
/// <see cref="ScintillaGateway"/> or <see cref="NotepadPPGateway"/>.
7483
/// If gateways are missing or incomplete, please help extend them and send your code to the project
7584
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
7685
/// </summary>
77-
[DllImport("user32")]
78-
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lParam);
86+
public static IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, out int lParam)
87+
{
88+
IntPtr outVal;
89+
IntPtr retval = SendMessage(hWnd, (UInt32)Msg, new IntPtr(wParam), out outVal);
90+
lParam = outVal.ToInt32();
91+
return retval;
92+
}
7993

8094
/// <summary>
8195
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
8296
/// <see cref="ScintillaGateway"/> or <see cref="NotepadPPGateway"/>.
8397
/// If gateways are missing or incomplete, please help extend them and send your code to the project
8498
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
8599
/// </summary>
86-
[DllImport("user32")]
87-
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
100+
public static IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, int lParam)
101+
{
102+
return SendMessage(hWnd, (UInt32)Msg, wParam, new IntPtr(lParam));
103+
}
88104

89105
/// <summary>
90106
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
91107
/// <see cref="ScintillaGateway"/> or <see cref="NotepadPPGateway"/>.
92108
/// If gateways are missing or incomplete, please help extend them and send your code to the project
93109
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
94110
/// </summary>
95-
[DllImport("user32")]
96-
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
111+
public static IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lParam)
112+
{
113+
return SendMessage(hWnd, (UInt32)Msg, new IntPtr(wParam), lParam);
114+
}
97115

98116
/// <summary>
99117
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
100118
/// <see cref="ScintillaGateway"/> or <see cref="NotepadPPGateway"/>.
101119
/// If gateways are missing or incomplete, please help extend them and send your code to the project
102120
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
103121
/// </summary>
104-
[DllImport("user32")]
105-
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lParam);
106-
122+
public static IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam)
123+
{
124+
return SendMessage(hWnd, (UInt32)Msg, new IntPtr(wParam), lParam);
125+
}
107126

108-
// TODO KBG Experimental
109127
/// <summary>
110128
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
111129
/// <see cref="ScintillaGateway"/> or <see cref="NotepadPPGateway"/>.
112130
/// If gateways are missing or incomplete, please help extend them and send your code to the project
113131
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
114132
/// </summary>
115-
[DllImport("user32")]
116-
public static extern IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, IntPtr wParam, IntPtr lParam);
133+
public static IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, IntPtr wParam, int lParam)
134+
{
135+
return SendMessage(hWnd, (UInt32)Msg, wParam, new IntPtr(lParam));
136+
}
137+
117138
/// <summary>
118139
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
119140
/// <see cref="ScintillaGateway"/> or <see cref="NotepadPPGateway"/>.
120141
/// If gateways are missing or incomplete, please help extend them and send your code to the project
121142
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
122143
/// </summary>
123-
[DllImport("user32")]
124-
public static extern IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, IntPtr wParam, int lParam);
125-
144+
public static IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, int wParam, IntPtr lParam)
145+
{
146+
return SendMessage(hWnd, (UInt32)Msg, new IntPtr(wParam), lParam);
147+
}
126148

127149
/// <summary>
128150
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
129151
/// <see cref="ScintillaGateway"/> or <see cref="NotepadPPGateway"/>.
130152
/// If gateways are missing or incomplete, please help extend them and send your code to the project
131153
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
132154
/// </summary>
133-
[DllImport("user32")]
134-
public static extern IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, int wParam, IntPtr lParam);
155+
public static IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, int wParam, string lParam)
156+
{
157+
return SendMessage(hWnd, (UInt32)Msg, new IntPtr(wParam), lParam);
158+
}
135159

136160
/// <summary>
137161
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
138162
/// <see cref="ScintillaGateway"/> or <see cref="NotepadPPGateway"/>.
139163
/// If gateways are missing or incomplete, please help extend them and send your code to the project
140164
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
141165
/// </summary>
142-
[DllImport("user32")]
143-
public static extern IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, int wParam, string lParam);
166+
public static IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, int wParam, [MarshalAs(UnmanagedType.LPStr)] StringBuilder lParam)
167+
{
168+
return SendMessage(hWnd, (UInt32)Msg, new IntPtr(wParam), lParam);
169+
}
144170

145171
/// <summary>
146172
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
147173
/// <see cref="ScintillaGateway"/> or <see cref="NotepadPPGateway"/>.
148174
/// If gateways are missing or incomplete, please help extend them and send your code to the project
149175
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
150176
/// </summary>
151-
[DllImport("user32")]
152-
public static extern IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, int wParam, [MarshalAs(UnmanagedType.LPStr)] StringBuilder lParam);
177+
public static IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, int wParam, int lParam)
178+
{
179+
return SendMessage(hWnd, (UInt32)Msg, new IntPtr(wParam), new IntPtr(lParam));
180+
}
153181

154182
/// <summary>
155183
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
156184
/// <see cref="ScintillaGateway"/> or <see cref="NotepadPPGateway"/>.
157185
/// If gateways are missing or incomplete, please help extend them and send your code to the project
158186
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
159187
/// </summary>
160-
[DllImport("user32")]
161-
public static extern IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, int wParam, int lParam);
188+
public static IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, IntPtr wParam, IntPtr lParam)
189+
{
190+
return SendMessage(hWnd, (UInt32)Msg, wParam, lParam);
191+
}
192+
193+
/// <summary>
194+
/// You should try to avoid calling this method in your plugin code. Rather use one of the gateways such as
195+
/// <see cref="ScintillaGateway"/> or <see cref="NotepadPPGateway"/>.
196+
/// If gateways are missing or incomplete, please help extend them and send your code to the project
197+
/// at https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net
198+
/// </summary>
199+
public static IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, ref LangType lParam)
200+
{
201+
IntPtr outVal;
202+
IntPtr retval = SendMessage(hWnd, (UInt32)Msg, new IntPtr(wParam), out outVal);
203+
lParam = (LangType)outVal;
204+
return retval;
205+
}
162206

163207
public const int MAX_PATH = 260;
164208

@@ -186,4 +230,4 @@ public class Win32
186230
[DllImport("kernel32")]
187231
public static extern void OutputDebugString(string lpOutputString);
188232
}
189-
}
233+
}

0 commit comments

Comments
 (0)