Exemplo n.º 1
0
 private void Scintilla_TextInserted(object sender, TextModifiedEventArgs e)
 {
     //	I'm going to have to look into making this a little less "sledge hammer to
     //	the entire documnet"ish
     //if (_snippetLinks.IsActive && (e.UndoRedoFlags.IsUndo || e.UndoRedoFlags.IsRedo))
     //Scintilla.NativeInterface.Colourise(0, -1);
 }
Exemplo n.º 2
0
 void editor_TextInserted(object sender, TextModifiedEventArgs e)
 {
     Debug.Print("editor_TextInserted");
     SuspendEditorUpdate = true;
     Text = Editor.Text;
     SuspendEditorUpdate = false;
 }
Exemplo n.º 3
0
 private void Scintilla_BeforeTextInsert(object sender, TextModifiedEventArgs e)
 {
     if (_snippetLinks.IsActive && !_pendingUndo && !(e.UndoRedoFlags.IsUndo || e.UndoRedoFlags.IsRedo))
     {
         _pendingUndo = true;
         Scintilla.UndoRedo.BeginUndoAction();
         _snippetLinkTimer.Enabled = true;
     }
 }
Exemplo n.º 4
0
 private void Scintilla_TextInserted(object sender, TextModifiedEventArgs e)
 {
     //	I'm going to have to look into making this a little less "sledge hammer to
     //	the entire documnet"ish
     if (_snippetLinks.IsActive && (e.UndoRedoFlags.IsUndo || e.UndoRedoFlags.IsRedo))
         Scintilla.NativeInterface.Colourise(0, -1);
 }
Exemplo n.º 5
0
 private void Scintilla_BeforeTextInsert(object sender, TextModifiedEventArgs e)
 {
     if (_snippetLinks.IsActive && !_pendingUndo && !(e.UndoRedoFlags.IsUndo || e.UndoRedoFlags.IsRedo))
     {
         _pendingUndo = true;
         Scintilla.UndoRedo.BeginUndoAction();
         _snippetLinkTimer.Enabled = true;
     }
 }
Exemplo n.º 6
0
        private void Scintilla_BeforeTextDelete(object sender, TextModifiedEventArgs e)
        {
            if (!_isEnabled)
                return;

            if (_snippetLinks.IsActive && !_pendingUndo && !(e.UndoRedoFlags.IsUndo || e.UndoRedoFlags.IsRedo))
            {
                _pendingUndo = true;
                Scintilla.UndoRedo.BeginUndoAction();
                _snippetLinkTimer.Enabled = true;
            }

            ManagedRange undoneSnippetLinkRange = null;
            if (e.UndoRedoFlags.IsUndo && _snippetLinks.IsActive)
            {
                foreach (ManagedRange mr in Scintilla.ManagedRanges)
                {
                    if (mr.Start == e.Position && mr.Length == e.Length && mr.Length > 1)
                    {
                        undoneSnippetLinkRange = mr;

                        //	Expanding the range So that it won't get marked for deletion
                        mr.End++;
                    }
                }
            }

            //	It's possible that the _end point may have been deleted. The endpoint
            //	is an ultra persistent marker that cannot be deleted until the Snippet
            //	Link mode is deactivated. Place a new EndPoint at the begining of the
            //	deleted range.
            if (_snippetLinks.IsActive && _snippetLinks.EndPoint != null && _snippetLinks.EndPoint.Scintilla == null)
            {
                SnippetLinkEnd eci = new SnippetLinkEnd(e.Position, Scintilla);
                Scintilla.ManagedRanges.Add(eci);
                _snippetLinks.EndPoint = eci;
            }

            //	Now collapse the Undone range in preparation for the
            //	newly inserted text that will be put in here
            if (undoneSnippetLinkRange != null)
                undoneSnippetLinkRange.End = undoneSnippetLinkRange.Start;

            //	Check to see if all SnippetLink ranges have been deleted.
            //	If this is the case we need to turn Deactivate SnippetLink
            //	mode.

            bool deactivate = true;
            foreach (SnippetLink sl in _snippetLinks.Values)
            {
                if (sl.Ranges.Count > 0)
                {
                    foreach (SnippetLinkRange slr in sl.Ranges)
                    {
                        if (slr.Scintilla != null)
                        {
                            deactivate = false;
                            break;
                        }
                    }
                }
                if (!deactivate)
                    break;
            }

            if (deactivate && IsActive)
                IsActive = false;
        }
Exemplo n.º 7
0
 void editor_TextDeleted(object sender, TextModifiedEventArgs e)
 {
     Debug.Print("editor_TextDeleted");
 }
Exemplo n.º 8
0
 /// <summary>
 ///     Raises the <see cref="TextInserted"/> event.
 /// </summary>
 /// <param name="e">An <see cref="TextModifiedEventArgs"/> that contains the event data.</param>
 protected virtual void OnTextInserted(TextModifiedEventArgs e)
 {
     EventHandler<TextModifiedEventArgs> handler = Events[_textInsertedEventKey] as EventHandler<TextModifiedEventArgs>;
     if (handler != null)
         handler(this, e);
 }
Exemplo n.º 9
0
        /// <summary>
        ///     Raises the <see cref="BeforeTextInsert"/> event.
        /// </summary>
        /// <param name="e">An <see cref="TextModifiedEventArgs"/> that contains the event data.</param>
        protected virtual void OnBeforeTextInsert(TextModifiedEventArgs e)
        {
            List<ManagedRange> offsetRanges = new List<ManagedRange>();
            foreach (ManagedRange mr in _managedRanges)
            {
                if (mr.Start == e.Position && mr.PendingDeletion)
                {
                    mr.PendingDeletion = false;
                    ManagedRange lmr = mr;
                    BeginInvoke(new MethodInvoker(delegate() { lmr.Change(e.Position, e.Position + e.Length); }));
                }

                //	If the Range is a single point we treat it slightly
                //	differently than a spanned range
                if (mr.IsPoint)
                {
                    //	Unlike a spanned range, if the insertion point of
                    //	the new text == the _start of the range (and thus
                    //	the _end as well) we offset the entire point.
                    if (mr.Start >= e.Position)
                        mr.Change(mr.Start + e.Length, mr.End + e.Length);
                    else if (mr.End >= e.Position)
                        mr.Change(mr.Start, mr.End + e.Length);
                }
                else
                {
                    //	We offset a spanned range entirely only if the
                    //	_start occurs after the insertion point of the new
                    //	text.
                    if (mr.Start > e.Position)
                        mr.Change(mr.Start + e.Length, mr.End + e.Length);
                    else if (mr.End >= e.Position)
                    {
                        //	However it the _start of the range == the insertion
                        //	point of the new text instead of offestting the
                        //	range we expand it.
                        mr.Change(mr.Start, mr.End + e.Length);
                    }
                }

            }

            EventHandler<TextModifiedEventArgs> handler = Events[_beforeTextInsertEventKey] as EventHandler<TextModifiedEventArgs>;
            if (handler != null)
                handler(this, e);
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Raises the <see cref="BeforeTextDelete"/> event.
        /// </summary>
        /// <param name="e">An <see cref="TextModifiedEventArgs"/> that contains the event data.</param>
        protected virtual void OnBeforeTextDelete(TextModifiedEventArgs e)
        {
            int firstPos = e.Position;
            int lastPos = firstPos + e.Length;

            List<ManagedRange> deletedRanges = new List<ManagedRange>();
            foreach (ManagedRange mr in _managedRanges)
            {

                //	These ranges lie within the deleted range so
                //	the ranges themselves need to be deleted
                if (mr.Start >= firstPos && mr.End <= lastPos)
                {

                    //	If the entire range is being delete and NOT a superset of the range,
                    //	don't delete it, only collapse it.
                    if (!mr.IsPoint && e.Position == mr.Start && (e.Position + e.Length == mr.End))
                    {
                        mr.Change(mr.Start, mr.Start);
                    }
                    else
                    {
                        //	Notify the virtual Range that it needs to cleanup
                        mr.Change(-1, -1);

                        //	Mark for deletion after this foreach:
                        deletedRanges.Add(mr);

                    }
                }
                else if (mr.Start >= lastPos)
                {
                    //	These ranges are merely offset by the deleted range
                    mr.Change(mr.Start - e.Length, mr.End - e.Length);
                }
                else if (mr.Start >= firstPos && mr.Start <= lastPos)
                {
                    //	The left side of the managed range is getting
                    //	cut off
                    mr.Change(firstPos, mr.End - e.Length);
                }
                else if (mr.Start < firstPos && mr.End >= firstPos && mr.End >= lastPos)
                {
                    mr.Change(mr.Start, mr.End - e.Length);
                }
                else if (mr.Start < firstPos && mr.End >= firstPos && mr.End < lastPos)
                {
                    mr.Change(mr.Start, firstPos);
                }

            }

            foreach (ManagedRange mr in deletedRanges)
                mr.Dispose();

            EventHandler<TextModifiedEventArgs> handler = Events[_beforeTextDeleteEventKey] as EventHandler<TextModifiedEventArgs>;
            if (handler != null)
                handler(this, e);
        }
Exemplo n.º 11
0
        private void Scintilla_BeforeTextDelete(object sender, TextModifiedEventArgs e)
        {
            if (!_isEnabled)
            {
                return;
            }

            if (_snippetLinks.IsActive && !_pendingUndo && !(e.UndoRedoFlags.IsUndo || e.UndoRedoFlags.IsRedo))
            {
                _pendingUndo = true;
                Scintilla.UndoRedo.BeginUndoAction();
                _snippetLinkTimer.Enabled = true;
            }

            ManagedRange undoneSnippetLinkRange = null;

            if (e.UndoRedoFlags.IsUndo && _snippetLinks.IsActive)
            {
                foreach (ManagedRange mr in Scintilla.ManagedRanges)
                {
                    if (mr.Start == e.Position && mr.Length == e.Length && mr.Length > 1)
                    {
                        undoneSnippetLinkRange = mr;

                        //	Expanding the range So that it won't get marked for deletion
                        mr.End++;
                    }
                }
            }

            //	It's possible that the _end point may have been deleted. The endpoint
            //	is an ultra persistent marker that cannot be deleted until the Snippet
            //	Link mode is deactivated. Place a new EndPoint at the begining of the
            //	deleted range.
            if (_snippetLinks.IsActive && _snippetLinks.EndPoint != null && _snippetLinks.EndPoint.Scintilla == null)
            {
                SnippetLinkEnd eci = new SnippetLinkEnd(e.Position, Scintilla);
                Scintilla.ManagedRanges.Add(eci);
                _snippetLinks.EndPoint = eci;
            }

            //	Now collapse the Undone range in preparation for the
            //	newly inserted text that will be put in here
            if (undoneSnippetLinkRange != null)
            {
                undoneSnippetLinkRange.End = undoneSnippetLinkRange.Start;
            }

            //	Check to see if all SnippetLink ranges have been deleted.
            //	If this is the case we need to turn Deactivate SnippetLink
            //	mode.

            bool deactivate = true;

            foreach (SnippetLink sl in _snippetLinks.Values)
            {
                if (sl.Ranges.Count > 0)
                {
                    foreach (SnippetLinkRange slr in sl.Ranges)
                    {
                        if (slr.Scintilla != null)
                        {
                            deactivate = false;
                            break;
                        }
                    }
                }
                if (!deactivate)
                {
                    break;
                }
            }

            if (deactivate && IsActive)
            {
                IsActive = false;
            }
        }
        private void FireModified(NativeScintillaEventArgs ea)
        {
            //	First we fire the INativeScintilla Modified event.
            if(Events[_modifiedEventKey] != null)
                ((EventHandler<NativeScintillaEventArgs>)Events[_modifiedEventKey])(this, ea);

            //	Now we use raw information from the Modified event to construct
            //	some more user friendly Events to fire.
            SCNotification scn	= ea.SCNotification;
            int modType			= scn.modificationType;

            if((modType & TEXT_MODIFIED_FLAGS) > 0)
            {
                TextModifiedEventArgs mea = new TextModifiedEventArgs
                    (
                    modType,
                    (modType & Constants.SC_PERFORMED_USER) != 0,
                    scn.line,
                    scn.position,
                    scn.length,
                    scn.linesAdded,
                    Utilities.IntPtrToString(_encoding, scn.text, scn.length)
                    );

                //	These messages all get fired seperately hence the if else ifs
                if ((modType & Constants.SC_MOD_BEFOREDELETE) > 0)
                {
                    OnBeforeTextDelete(mea);
                }
                else if ((modType & Constants.SC_MOD_BEFOREINSERT) > 0)
                {
                    OnBeforeTextInsert(mea);
                }
                else if ((modType & Constants.SC_MOD_DELETETEXT) > 0)
                {
                    OnTextDeleted(mea);
                }
                else if ((modType & Constants.SC_MOD_INSERTTEXT) > 0)
                {
                    OnTextInserted(mea);
                }
            }
            else if((modType & Constants.SC_MOD_CHANGEFOLD) > 0)
            {
                FoldChangedEventArgs fea = new FoldChangedEventArgs(scn.line, scn.foldLevelNow, scn.foldLevelPrev, scn.modificationType);
                OnFoldChanged(fea);
            }
            else if((modType & Constants.SC_MOD_CHANGESTYLE) > 0)
            {
                StyleChangedEventArgs sea = new StyleChangedEventArgs(scn.position, scn.length, scn.modificationType);
                OnStyleChanged(sea);
            }
            else if((modType & Constants.SC_MOD_CHANGEMARKER) > 0)
            {
                MarkerChangedEventArgs mea = new MarkerChangedEventArgs(scn.line, scn.modificationType);
                OnMarkerChanged(mea);
            }

            OnDocumentChange(ea);
        }
Exemplo n.º 13
0
 private void scintilla1_TextInserted(object sender, TextModifiedEventArgs e)
 {
     if (!EnableChangeDetection) return;
     CurrentFile.Changes = true;
     CurrentFile.TabButton.Changes = true;
     openFilesBar.Invalidate(true);
 }
Exemplo n.º 14
0
 void editor_TextInserted(object sender, TextModifiedEventArgs e)
 {
     if (!fDirty)
     {
         Console.WriteLine("Dirtying on text inserted");
         fDirty = true;
         UpdateFormTitle();
     }
 }