Exemplo n.º 1
0
        /// <summary>
        /// Handle text insert and delete events.
        /// </summary>
        /// <param name="s"></param>
        /// <param name="e"></param>
        private void HandleInsertAndDelete(object s, ModificationEventArgs e)
        {
            // internal function
            void HandleModificationEvent(ModificationEventArgs ev)
            {
                var first = LineFromPosition(ev.Position);
                var last  = first + ev.LinesAdded;

                UpdateCodeFolding(Math.Min(first, last), Math.Max(first, last));
            }

            FxLexer.Style(this, e.Position, TextLength);

            // update line number margins
            if (e.LinesAdded != 0)
            {
                UpdateLineNumbers();
                HandleModificationEvent(e);
            }
            // update code folding
            else if (e.Text.LastIndexOfAny(new[] { '{', '}' }) >= 0)
            {
                HandleModificationEvent(e);
            }
        }
Exemplo n.º 2
0
        private void ScnModified(ref NativeMethods.SCNotification scn)
        {
            // The InsertCheck, BeforeInsert, BeforeDelete, Insert, and Delete events can all potentially require
            // the same conversions: byte to char position, char* to string, etc.... To avoid doing the same work
            // multiple times we share that data between events.

            if ((scn.modificationType & NativeMethods.SC_MOD_INSERTCHECK) > 0)
            {
                var eventArgs = new InsertCheckEventArgs(this, scn.position, scn.length, scn.text);
                OnInsertCheck(eventArgs);

                cachedPosition = eventArgs.CachedPosition;
                cachedText = eventArgs.CachedText;
            }

            const int sourceMask = (NativeMethods.SC_PERFORMED_USER | NativeMethods.SC_PERFORMED_UNDO | NativeMethods.SC_PERFORMED_REDO);

            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);

                eventArgs.CachedPosition = cachedPosition;
                eventArgs.CachedText = cachedText;

                if ((scn.modificationType & NativeMethods.SC_MOD_BEFOREINSERT) > 0)
                {
                    OnBeforeInsert(eventArgs);
                }
                else
                {
                    OnBeforeDelete(eventArgs);
                }

                cachedPosition = eventArgs.CachedPosition;
                cachedText = eventArgs.CachedText;
            }

            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);

                eventArgs.CachedPosition = cachedPosition;
                eventArgs.CachedText = cachedText;

                if ((scn.modificationType & NativeMethods.SC_MOD_INSERTTEXT) > 0)
                {
                    OnInsert(eventArgs);
                }
                else
                {
                    OnDelete(eventArgs);
                }

                // Always clear the cache
                cachedPosition = null;
                cachedText = null;

                // For backward compatibility.... Of course this means that we'll raise two
                // TextChanged events for replace (insert/delete) operations, but that's life.
                OnTextChanged(EventArgs.Empty);
            }

            if ((scn.modificationType & NativeMethods.SC_MOD_CHANGEANNOTATION) > 0)
            {
                var eventArgs = new ChangeAnnotationEventArgs(scn.line);
                OnChangeAnnotation(eventArgs);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Raises the <see cref="Insert" /> event.
 /// </summary>
 /// <param name="e">A <see cref="ModificationEventArgs" /> that contains the event data.</param>
 protected virtual void OnInsert(ModificationEventArgs e)
 {
     var handler = Events[insertEventKey] as EventHandler<ModificationEventArgs>;
     if (handler != null)
         handler(this, e);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Raises the <see cref="Delete" /> event.
 /// </summary>
 /// <param name="e">A <see cref="ModificationEventArgs" /> that contains the event data.</param>
 protected virtual void OnDelete(ModificationEventArgs e)
 {
     var handler = Events[deleteEventKey] as EventHandler<ModificationEventArgs>;
     if (handler != null)
         handler(this, e);
 }
Exemplo n.º 5
0
 private void richTextBox1_Insert(object sender, ModificationEventArgs e)
 {
     if (e.LinesAdded != 0)
         UpdateLineNumbers(richTextBox1.LineFromPosition(e.Position));
 }
Exemplo n.º 6
0
 private void OnScintillaInsert(object sender, ModificationEventArgs eventArgs)
 {
     if (this.mShowLineNumbers) {
         if (eventArgs.LinesAdded != 0) {
             this.UpdateLineNumbers();
         }
     }
 }
Exemplo n.º 7
0
 void code_Insert(object sender, ModificationEventArgs e)
 {
     HLCode code = (HLCode)sender;
     if (e.LinesAdded != 0)
     {
         actualizarLineasMostradas(code, code.LineFromPosition(e.Position));
     }
 }
		/// <summary>
		/// Updates line numbering when lines have been inserted.
		/// </summary>
		private void  ConfigurationEditor_Insert ( object  sender, ModificationEventArgs  e )
		   {
			if  ( e. LinesAdded  !=  0 )
				UpdateLineNumbers ( ConfigurationEditor. LineFromPosition ( e. Position ) ) ;
		    }
Exemplo n.º 9
0
 private void LinesAmountChanged(object sender, ModificationEventArgs e)
 {
     int line = scintilla.LineFromPosition(e.Position);
     int n = _breakPoints.Count;
     for(int i = 0; i < n; i++)
     {
         if (_breakPoints[i] >= line)
             _breakPoints[i] += e.LinesAdded;
     }
     n = _execLines.Count;
     for(int i = 0; i < n; i++)
     {
         if (_execLines[i] >= line)
             _execLines[i] += e.LinesAdded;
     }
 }