Exemplo n.º 1
0
 public void InsertAt(int offset, char text, ITextDocumentFilterChain bypass)
 {
     if (rules.IsLineBreak('\0', text) == LineBreakType.None)
     {
         bypass.InsertAt(offset, text);
     }
 }
Exemplo n.º 2
0
 public void InsertAt(int offset, char text, ITextDocumentFilterChain bypass)
 {
     if (Filter(text))
     {
         bypass.InsertAt(offset, text);
     }
 }
Exemplo n.º 3
0
 protected AbstractDocument(IDocumentContent content)
 {
     Content = content;
     documentModifiedSupport    = new EventSupport <TextModificationEventArgs>();
     undoableEditCreatedSupport = new EventSupport <UndoableEditEventArgs>();
     filterChain = new RootFilterChain(this);
 }
Exemplo n.º 4
0
        public bool PopFilter(out ITextDocumentFilter filter)
        {
            if (filterChain.Parent == null)
            {
                filter = null;
                return(false);
            }

            filter      = filterChain.Filter;
            filterChain = filterChain.Parent;
            return(true);
        }
Exemplo n.º 5
0
        public void InsertAt(int offset, char text, ITextDocumentFilterChain bypass)
        {
            var ml = maxLengthFunction();

            if (ml > 0)
            {
                if (document.TextLength + 1 < ml)
                {
                    bypass.InsertAt(offset, text);
                }
            }
            else
            {
                bypass.InsertAt(offset, text);
            }
        }
Exemplo n.º 6
0
 public void InsertAt(int offset, string text, ITextDocumentFilterChain bypass)
 {
     buffer.Clear();
     buffer.EnsureCapacity(text.Length);
     for (var index = 0; index < text.Length; index++)
     {
         var c = text[index];
         if (Filter(c))
         {
             buffer.Append(c);
         }
     }
     if (buffer.Length > 0)
     {
         bypass.InsertAt(offset, buffer.ToString());
     }
 }
Exemplo n.º 7
0
        public void InsertAt(int offset, string text, ITextDocumentFilterChain bypass)
        {
            var ml = maxLengthFunction();

            if (ml > 0)
            {
                var remainingSpace = Math.Max(0, ml - document.TextLength);
                if (remainingSpace > 0)
                {
                    bypass.InsertAt(offset, text.Substring(0, Math.Min(text.Length, remainingSpace)));
                }
            }
            else
            {
                bypass.InsertAt(offset, text);
            }
        }
Exemplo n.º 8
0
        public void InsertAt(int offset, string text, ITextDocumentFilterChain bypass)
        {
            bufferContent.Clear();
            bufferContent.EnsureCapacity(text.Length);
            bufferContent.Insert(0, text);

            buffer.Clear();
            buffer.EnsureCapacity(text.Length);

            var breaker = new BreakIterator <LineBreakType>(bufferContent, rules.IsLineBreak, 0, bufferContent.Length);

            while (breaker.MoveNext())
            {
                if (breaker.Current == LineBreakType.None)
                {
                    buffer.Append(breaker.CurrentChar);
                }
            }

            if (buffer.Length > 0)
            {
                bypass.InsertAt(offset, buffer.ToString());
            }
        }
Exemplo n.º 9
0
 public TextDocumentFilterChain(ITextDocumentFilterChain parent, ITextDocumentFilter filter)
 {
     this.Parent = parent;
     this.Filter = filter;
 }
Exemplo n.º 10
0
 public void DeleteAt(int offset, int length, ITextDocumentFilterChain bypass)
 {
     bypass.DeleteAt(offset, length);
 }
Exemplo n.º 11
0
 public void PushFilter(ITextDocumentFilter filter)
 {
     filterChain = new TextDocumentFilterChain(filterChain, filter);
 }