示例#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);
		}
示例#2
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;
     }
 }
示例#3
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);
 }
示例#4
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);
        }
示例#5
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);
        }
示例#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;
            }
        }
示例#7
0
文件: CGEeditor.cs 项目: nadar71/Krea
        private void Scintilla_TextDeleted(object sender,TextModifiedEventArgs e)
        {
            if (this.luaSyntaxCheckerBt.Checked == true)
                checkLuaSyntax();

            string changeWord = e.Text;
            AutoCompletionEngine.checkForAutoCompletion('!');
        }
		internal 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)
					);

				//	Adding in TextChanged because it's really common to 
				//	just want to know when the damned text changed
				bool textChanged = false;

				//	These messages all get fired seperately hence the if else ifs
				if ((modType & Constants.SC_MOD_BEFOREDELETE) > 0)
				{
					OnBeforeTextDelete(mea);
					textChanged = true;
				}
				else if ((modType & Constants.SC_MOD_BEFOREINSERT) > 0)
				{
					OnBeforeTextInsert(mea);
					textChanged = true;
				}
				else if ((modType & Constants.SC_MOD_DELETETEXT) > 0)
				{
					OnTextDeleted(mea);
					textChanged = true;
				}
				else if ((modType & Constants.SC_MOD_INSERTTEXT) > 0)
				{
					OnTextInserted(mea);
					textChanged = true;
				}

				if (textChanged)
				{
					_textChangedTimer.Start();
				}
			}
			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);
		}
示例#9
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;
		}
示例#10
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;
			}
		}
示例#11
0
 private void txt_Content_TextInserted(object sender, TextModifiedEventArgs e)
 {
     txt_Content_TextChanged(sender, e);
 }