From b81eeeb1020351aba519cd548afad2e701862c2f Mon Sep 17 00:00:00 2001 From: toehead2001 Date: Mon, 15 Apr 2019 13:28:09 -0600 Subject: [PATCH 1/4] Update types in the SCNotification struct --- src/ScintillaNET/LineCollection.cs | 25 +++++++++++++------------ src/ScintillaNET/NativeMethods.cs | 10 +++++----- src/ScintillaNET/Scintilla.cs | 30 +++++++++++++++--------------- 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/ScintillaNET/LineCollection.cs b/src/ScintillaNET/LineCollection.cs index 9f83baa..fb81b20 100644 --- a/src/ScintillaNET/LineCollection.cs +++ b/src/ScintillaNET/LineCollection.cs @@ -341,10 +341,11 @@ internal void RebuildLineData() // Fake an insert notification var scn = new NativeMethods.SCNotification(); - scn.linesAdded = scintilla.DirectMessage(NativeMethods.SCI_GETLINECOUNT).ToInt32() - 1; - scn.position = 0; - scn.length = scintilla.DirectMessage(NativeMethods.SCI_GETLENGTH).ToInt32(); - scn.text = scintilla.DirectMessage(NativeMethods.SCI_GETRANGEPOINTER, new IntPtr(scn.position), new IntPtr(scn.length)); + var adjustedLines = scintilla.DirectMessage(NativeMethods.SCI_GETLINECOUNT).ToInt32() - 1; + scn.linesAdded = new IntPtr(adjustedLines); + scn.position = IntPtr.Zero; + scn.length = scintilla.DirectMessage(NativeMethods.SCI_GETLENGTH); + scn.text = scintilla.DirectMessage(NativeMethods.SCI_GETRANGEPOINTER, scn.position, scn.length); TrackInsertText(scn); } @@ -374,11 +375,11 @@ private void ScnModified(NativeMethods.SCNotification scn) private void TrackDeleteText(NativeMethods.SCNotification scn) { - var startLine = scintilla.DirectMessage(NativeMethods.SCI_LINEFROMPOSITION, new IntPtr(scn.position)).ToInt32(); - if (scn.linesAdded == 0) + var startLine = scintilla.DirectMessage(NativeMethods.SCI_LINEFROMPOSITION, scn.position).ToInt32(); + if (scn.linesAdded == IntPtr.Zero) { // That was easy - var delta = GetCharCount(scn.text, scn.length, scintilla.Encoding); + var delta = GetCharCount(scn.text, scn.length.ToInt32(), scintilla.Encoding); AdjustLineLength(startLine, delta * -1); } else @@ -388,7 +389,7 @@ private void TrackDeleteText(NativeMethods.SCNotification scn) var lineByteLength = scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(startLine)).ToInt32(); AdjustLineLength(startLine, GetCharCount(lineByteStart, lineByteLength) - CharLineLength(startLine)); - var linesRemoved = scn.linesAdded * -1; + var linesRemoved = scn.linesAdded.ToInt32() * -1; for (int i = 0; i < linesRemoved; i++) { // Deleted line @@ -399,11 +400,11 @@ private void TrackDeleteText(NativeMethods.SCNotification scn) private void TrackInsertText(NativeMethods.SCNotification scn) { - var startLine = scintilla.DirectMessage(NativeMethods.SCI_LINEFROMPOSITION, new IntPtr(scn.position)).ToInt32(); - if (scn.linesAdded == 0) + var startLine = scintilla.DirectMessage(NativeMethods.SCI_LINEFROMPOSITION, scn.position).ToInt32(); + if (scn.linesAdded == IntPtr.Zero) { // That was easy - var delta = GetCharCount(scn.position, scn.length); + var delta = GetCharCount(scn.position.ToInt32(), scn.length.ToInt32()); AdjustLineLength(startLine, delta); } else @@ -416,7 +417,7 @@ private void TrackInsertText(NativeMethods.SCNotification scn) lineByteLength = scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(startLine)).ToInt32(); AdjustLineLength(startLine, GetCharCount(lineByteStart, lineByteLength) - CharLineLength(startLine)); - for (int i = 1; i <= scn.linesAdded; i++) + for (int i = 1; i <= scn.linesAdded.ToInt32(); i++) { var line = startLine + i; diff --git a/src/ScintillaNET/NativeMethods.cs b/src/ScintillaNET/NativeMethods.cs index 5b3df1f..55a8ea9 100644 --- a/src/ScintillaNET/NativeMethods.cs +++ b/src/ScintillaNET/NativeMethods.cs @@ -1866,17 +1866,17 @@ public struct Sci_TextRange public struct SCNotification { public Sci_NotifyHeader nmhdr; - public int position; + public IntPtr position; public int ch; public int modifiers; public int modificationType; public IntPtr text; - public int length; - public int linesAdded; + public IntPtr length; + public IntPtr linesAdded; public int message; public IntPtr wParam; public IntPtr lParam; - public int line; + public IntPtr line; public int foldLevelNow; public int foldLevelPrev; public int margin; @@ -1884,7 +1884,7 @@ public struct SCNotification public int x; public int y; public int token; - public int annotationLinesAdded; + public IntPtr annotationLinesAdded; public int updated; public int listCompletionMethod; } diff --git a/src/ScintillaNET/Scintilla.cs b/src/ScintillaNET/Scintilla.cs index d71b722..b586544 100644 --- a/src/ScintillaNET/Scintilla.cs +++ b/src/ScintillaNET/Scintilla.cs @@ -2036,14 +2036,14 @@ public void RotateSelection() private void ScnDoubleClick(ref NativeMethods.SCNotification scn) { var keys = Keys.Modifiers & (Keys)(scn.modifiers << 16); - var eventArgs = new DoubleClickEventArgs(this, keys, scn.position, scn.line); + var eventArgs = new DoubleClickEventArgs(this, keys, scn.position.ToInt32(), scn.line.ToInt32()); OnDoubleClick(eventArgs); } private void ScnHotspotClick(ref NativeMethods.SCNotification scn) { var keys = Keys.Modifiers & (Keys)(scn.modifiers << 16); - var eventArgs = new HotspotClickEventArgs(this, keys, scn.position); + var eventArgs = new HotspotClickEventArgs(this, keys, scn.position.ToInt32()); switch (scn.nmhdr.code) { case NativeMethods.SCN_HOTSPOTCLICK: @@ -2066,11 +2066,11 @@ private void ScnIndicatorClick(ref NativeMethods.SCNotification scn) { case NativeMethods.SCN_INDICATORCLICK: var keys = Keys.Modifiers & (Keys)(scn.modifiers << 16); - OnIndicatorClick(new IndicatorClickEventArgs(this, keys, scn.position)); + OnIndicatorClick(new IndicatorClickEventArgs(this, keys, scn.position.ToInt32())); break; case NativeMethods.SCN_INDICATORRELEASE: - OnIndicatorRelease(new IndicatorReleaseEventArgs(this, scn.position)); + OnIndicatorRelease(new IndicatorReleaseEventArgs(this, scn.position.ToInt32())); break; } } @@ -2078,7 +2078,7 @@ private void ScnIndicatorClick(ref NativeMethods.SCNotification scn) private void ScnMarginClick(ref NativeMethods.SCNotification scn) { var keys = Keys.Modifiers & (Keys)(scn.modifiers << 16); - var eventArgs = new MarginClickEventArgs(this, keys, scn.position, scn.margin); + var eventArgs = new MarginClickEventArgs(this, keys, scn.position.ToInt32(), scn.margin); if (scn.nmhdr.code == NativeMethods.SCN_MARGINCLICK) OnMarginClick(eventArgs); @@ -2094,7 +2094,7 @@ private void ScnModified(ref NativeMethods.SCNotification scn) if ((scn.modificationType & NativeMethods.SC_MOD_INSERTCHECK) > 0) { - var eventArgs = new InsertCheckEventArgs(this, scn.position, scn.length, scn.text); + var eventArgs = new InsertCheckEventArgs(this, scn.position.ToInt32(), scn.length.ToInt32(), scn.text); OnInsertCheck(eventArgs); cachedPosition = eventArgs.CachedPosition; @@ -2106,7 +2106,7 @@ private void ScnModified(ref NativeMethods.SCNotification scn) if ((scn.modificationType & (NativeMethods.SC_MOD_BEFOREDELETE | NativeMethods.SC_MOD_BEFOREINSERT)) > 0) { var source = (ModificationSource)(scn.modificationType & sourceMask); - var eventArgs = new BeforeModificationEventArgs(this, source, scn.position, scn.length, scn.text); + var eventArgs = new BeforeModificationEventArgs(this, source, scn.position.ToInt32(), scn.length.ToInt32(), scn.text); eventArgs.CachedPosition = cachedPosition; eventArgs.CachedText = cachedText; @@ -2127,7 +2127,7 @@ private void ScnModified(ref NativeMethods.SCNotification scn) if ((scn.modificationType & (NativeMethods.SC_MOD_DELETETEXT | NativeMethods.SC_MOD_INSERTTEXT)) > 0) { var source = (ModificationSource)(scn.modificationType & sourceMask); - var eventArgs = new ModificationEventArgs(this, source, scn.position, scn.length, scn.text, scn.linesAdded); + var eventArgs = new ModificationEventArgs(this, source, scn.position.ToInt32(), scn.length.ToInt32(), scn.text, scn.linesAdded.ToInt32()); eventArgs.CachedPosition = cachedPosition; eventArgs.CachedText = cachedText; @@ -2152,7 +2152,7 @@ private void ScnModified(ref NativeMethods.SCNotification scn) if ((scn.modificationType & NativeMethods.SC_MOD_CHANGEANNOTATION) > 0) { - var eventArgs = new ChangeAnnotationEventArgs(scn.line); + var eventArgs = new ChangeAnnotationEventArgs(scn.line.ToInt32()); OnChangeAnnotation(eventArgs); } } @@ -2724,7 +2724,7 @@ private void WmReflectNotify(ref Message m) break; case NativeMethods.SCN_STYLENEEDED: - OnStyleNeeded(new StyleNeededEventArgs(this, scn.position)); + OnStyleNeeded(new StyleNeededEventArgs(this, scn.position.ToInt32())); break; case NativeMethods.SCN_SAVEPOINTLEFT: @@ -2749,11 +2749,11 @@ private void WmReflectNotify(ref Message m) break; case NativeMethods.SCN_AUTOCSELECTION: - OnAutoCSelection(new AutoCSelectionEventArgs(this, scn.position, scn.text, scn.ch, (ListCompletionMethod)scn.listCompletionMethod)); + OnAutoCSelection(new AutoCSelectionEventArgs(this, scn.position.ToInt32(), scn.text, scn.ch, (ListCompletionMethod)scn.listCompletionMethod)); break; case NativeMethods.SCN_AUTOCCOMPLETED: - OnAutoCCompleted(new AutoCSelectionEventArgs(this, scn.position, scn.text, scn.ch, (ListCompletionMethod)scn.listCompletionMethod)); + OnAutoCCompleted(new AutoCSelectionEventArgs(this, scn.position.ToInt32(), scn.text, scn.ch, (ListCompletionMethod)scn.listCompletionMethod)); break; case NativeMethods.SCN_AUTOCCANCELLED: @@ -2765,11 +2765,11 @@ private void WmReflectNotify(ref Message m) break; case NativeMethods.SCN_DWELLSTART: - OnDwellStart(new DwellEventArgs(this, scn.position, scn.x, scn.y)); + OnDwellStart(new DwellEventArgs(this, scn.position.ToInt32(), scn.x, scn.y)); break; case NativeMethods.SCN_DWELLEND: - OnDwellEnd(new DwellEventArgs(this, scn.position, scn.x, scn.y)); + OnDwellEnd(new DwellEventArgs(this, scn.position.ToInt32(), scn.x, scn.y)); break; case NativeMethods.SCN_DOUBLECLICK: @@ -2777,7 +2777,7 @@ private void WmReflectNotify(ref Message m) break; case NativeMethods.SCN_NEEDSHOWN: - OnNeedShown(new NeedShownEventArgs(this, scn.position, scn.length)); + OnNeedShown(new NeedShownEventArgs(this, scn.position.ToInt32(), scn.length.ToInt32())); break; case NativeMethods.SCN_HOTSPOTCLICK: From c87ab22f6c18782269ce0b44bc717a80d3f582ba Mon Sep 17 00:00:00 2001 From: Patrick Hofman Date: Wed, 21 Jun 2023 15:58:10 +0200 Subject: [PATCH 2/4] Port project to .NET Core [ER]. --- src/ScintillaNET/ScintillaNET.csproj | 143 ++++++++------------------- 1 file changed, 41 insertions(+), 102 deletions(-) diff --git a/src/ScintillaNET/ScintillaNET.csproj b/src/ScintillaNET/ScintillaNET.csproj index 5a7e096..df5ade9 100644 --- a/src/ScintillaNET/ScintillaNET.csproj +++ b/src/ScintillaNET/ScintillaNET.csproj @@ -1,18 +1,39 @@ - - - + + - Debug - AnyCPU - {22AE2386-60F1-476E-9303-61CDB0AAC4CF} - Library - Properties - ScintillaNET + net48;net6.0-windows + false + Debug;Release + Auto ScintillaNET - v4.0 - 512 - Client + ScintillaNET + latest + true + + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + true full @@ -24,6 +45,7 @@ bin\Debug\ScintillaNET.xml true + pdbonly true @@ -34,6 +56,7 @@ bin\Release\ScintillaNET.xml true + bin\Signed\ TRACE @@ -45,7 +68,8 @@ ..\ScintillaNET.snk prompt - + + @@ -56,97 +80,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Component - - - - - - - - - - - - - - - - - - - - - - + + @@ -163,9 +102,9 @@ - + - xcopy "$(ProjectDir)..\..\LICENSE" "$(TargetDir)" /D /F /K /R /Y + + xcopy "$(ProjectDir)..\..\LICENSE" "$(TargetDir)" /D /F /K /R /Y \ No newline at end of file