Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Move to .NET Core #534

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/ScintillaNET/LineCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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;

Expand Down
10 changes: 5 additions & 5 deletions src/ScintillaNET/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1866,25 +1866,25 @@ 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;
public int listType;
public int x;
public int y;
public int token;
public int annotationLinesAdded;
public IntPtr annotationLinesAdded;
public int updated;
public int listCompletionMethod;
}
Expand Down
30 changes: 15 additions & 15 deletions src/ScintillaNET/Scintilla.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -2066,19 +2066,19 @@ 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;
}
}

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);
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -2765,19 +2765,19 @@ 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:
ScnDoubleClick(ref scn);
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:
Expand Down
Loading