Exemplo n.º 1
0
        private void TrackInsertText(NativeMethods.SCNotification scn)
        {
            var startLine = scintilla.DirectMessage(NativeMethods.SCI_LINEFROMPOSITION, new IntPtr(scn.position)).ToInt32();

            if (scn.linesAdded == 0)
            {
                // That was easy
                var delta = GetCharCount(scn.position, scn.length);
                AdjustLineLength(startLine, delta);
            }
            else
            {
                var lineByteStart  = 0;
                var lineByteLength = 0;

                // Adjust existing line
                lineByteStart  = scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(startLine)).ToInt32();
                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++)
                {
                    var line = startLine + i;

                    // Insert new line
                    lineByteStart += lineByteLength;
                    lineByteLength = scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(line)).ToInt32();
                    InsertPerLine(line, GetCharCount(lineByteStart, lineByteLength));
                }
            }
        }
Exemplo n.º 2
0
        private void TrackDeleteText(NativeMethods.SCNotification scn)
        {
            var startLine = scintilla.DirectMessage(NativeMethods.SCI_LINEFROMPOSITION, new IntPtr(scn.position)).ToInt32();

            if (scn.linesAdded == 0)
            {
                // That was easy
                var delta = GetCharCount(scn.text, scn.length, scintilla.Encoding);
                AdjustLineLength(startLine, delta * -1);
            }
            else
            {
                // Adjust the existing line
                var lineByteStart  = scintilla.DirectMessage(NativeMethods.SCI_POSITIONFROMLINE, new IntPtr(startLine)).ToInt32();
                var lineByteLength = scintilla.DirectMessage(NativeMethods.SCI_LINELENGTH, new IntPtr(startLine)).ToInt32();
                AdjustLineLength(startLine, GetCharCount(lineByteStart, lineByteLength) - CharLineLength(startLine));

                var linesRemoved = scn.linesAdded * -1;
                for (int i = 0; i < linesRemoved; i++)
                {
                    // Deleted line
                    DeletePerLine(startLine + 1);
                }
            }
        }
Exemplo n.º 3
0
        private void ScnModified(NativeMethods.SCNotification scn)
        {
            if ((scn.modificationType & NativeMethods.SC_MOD_DELETETEXT) > 0)
            {
                TrackDeleteText(scn);
            }

            if ((scn.modificationType & NativeMethods.SC_MOD_INSERTTEXT) > 0)
            {
                TrackInsertText(scn);
            }
        }
Exemplo n.º 4
0
        internal void RebuildLineData()
        {
            stepLine   = 0;
            stepLength = 0;

            perLineData = new GapBuffer <PerLine>();
            perLineData.Add(new PerLine {
                Start = 0
            });
            perLineData.Add(new PerLine {
                Start = 0
            });                                         // Terminal

            // 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));
            TrackInsertText(scn);
        }
Exemplo n.º 5
0
 public SCNotificationEventArgs(NativeMethods.SCNotification scn)
 {
     this.SCNotification = scn;
 }
Exemplo n.º 6
0
        private void WmReflectNotify(ref Message m)
        {
            // A standard Windows notification and a Scintilla notification header are compatible
            NativeMethods.SCNotification scn = (NativeMethods.SCNotification)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.SCNotification));
            if (scn.nmhdr.code >= NativeMethods.SCN_STYLENEEDED && scn.nmhdr.code <= NativeMethods.SCN_AUTOCCOMPLETED)
            {
                HandleScintillaMessage(scn.nmhdr.code, (char)scn.ch, (int)scn.position, scn.margin);
                //var handler = Events[scNotificationEventKey] as EventHandler<SCNotificationEventArgs>;
                //if (handler != null)
                //    handler(this, new SCNotificationEventArgs(scn));

                //switch (scn.nmhdr.code)
                //{
                //    //case NativeMethods.SCN_PAINTED:
                //    //    OnPainted(EventArgs.Empty);
                //    //    break;

                //    case NativeMethods.SCN_MODIFIED:
                //        //ScnModified(ref scn);
                //        break;

                //    //case NativeMethods.SCN_MODIFYATTEMPTRO:
                //    //    OnModifyAttempt(EventArgs.Empty);
                //    //    break;

                //    //case NativeMethods.SCN_STYLENEEDED:
                //    //    OnStyleNeeded(new StyleNeededEventArgs(this, scn.position));
                //    //    break;

                //    //case NativeMethods.SCN_SAVEPOINTLEFT:
                //    //    OnSavePointLeft(EventArgs.Empty);
                //    //    break;

                //    //case NativeMethods.SCN_SAVEPOINTREACHED:
                //    //    OnSavePointReached(EventArgs.Empty);
                //    //    break;

                //    case NativeMethods.SCN_MARGINCLICK:
                //    case NativeMethods.SCN_MARGINRIGHTCLICK:
                //        //ScnMarginClick(ref scn);
                //        break;

                //    //case NativeMethods.SCN_UPDATEUI:
                //    //    OnUpdateUI(new UpdateUIEventArgs((UpdateChange)scn.updated));
                //    //    break;

                //    case NativeMethods.SCN_CHARADDED:
                //        //OnCharAdded(new CharAddedEventArgs(scn.ch));
                //        break;

                //    //case NativeMethods.SCN_AUTOCSELECTION:
                //    //    OnAutoCSelection(new AutoCSelectionEventArgs(this, scn.position, 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));
                //    //    break;

                //    //case NativeMethods.SCN_AUTOCCANCELLED:
                //    //    OnAutoCCancelled(EventArgs.Empty);
                //    //    break;

                //    //case NativeMethods.SCN_AUTOCCHARDELETED:
                //    //    OnAutoCCharDeleted(EventArgs.Empty);
                //    //    break;

                //    //case NativeMethods.SCN_DWELLSTART:
                //    //    OnDwellStart(new DwellEventArgs(this, scn.position, scn.x, scn.y));
                //    //    break;

                //    //case NativeMethods.SCN_DWELLEND:
                //    //    OnDwellEnd(new DwellEventArgs(this, scn.position, 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));
                //    //    break;

                //    //case NativeMethods.SCN_HOTSPOTCLICK:
                //    //case NativeMethods.SCN_HOTSPOTDOUBLECLICK:
                //    //case NativeMethods.SCN_HOTSPOTRELEASECLICK:
                //    //    ScnHotspotClick(ref scn);
                //    //    break;

                //    //case NativeMethods.SCN_INDICATORCLICK:
                //    //case NativeMethods.SCN_INDICATORRELEASE:
                //    //    ScnIndicatorClick(ref scn);
                //    //    break;

                //    //case NativeMethods.SCN_ZOOM:
                //    //    OnZoomChanged(EventArgs.Empty);
                //    //    break;

                //    default:
                //        // Not our notification
                //        base.WndProc(ref m);
                //        break;
                //}
            }
        }