Beispiel #1
0
        public void AttachBuffer(IBuffer buf)
        {
            var buffer = buf as DocumentBuffer;

            if (buffer == null)
            {
                throw new NotSupportedException();
            }

            if (Buffer != null && buffer != Buffer)
            {
                DetachBuffer();
            }
            else if (Buffer == buffer)
            {
                return;
            }

            var @lock = Buffer?.ObtainLock();

            try
            {
                buffer.LastAccess = DateTime.Now;

                if (buffer != Buffer)
                {
                    buffer.Editors.Add(this);
                    Buffer = buffer;
                }

                if (Buffer.GrammarKey == null)
                {
                    Buffer.GrammarKey = App.Component <IModeManager>()
                                        .SelectMode(buffer.File).Key;
                }

                Scroll.InvalidateLines(InvalidateFlags.Force);
                Scroll.ScrollPosition = buffer.ScrollPosition;
                Styles.RestyleDocument();
                Folding.RebuildFolding(full: true);
                Redraw();
                MatchBrackets.Match();
                Search.HideSearch();
                TopMargins.ResetMargins();
                BottomMargins.ResetMargins();
                LeftMargins.ResetMargins();
                RightMargins.ResetMargins();
            }
            finally
            {
                if (@lock != null)
                {
                    @lock.Release();
                }
            }
        }
Beispiel #2
0
 public StandardEditor(EditorSettings settings) : base(settings)
 {
     Dock = DockStyle.Fill;
     LeftMargins.Add(new LineNumberMargin(this)
     {
         MarkCurrentLine = true
     });
     LeftMargins.Add(new FoldingMargin(this));
     RightMargins.Add(new VerticalScrollBarMargin(this));
     BottomMargins.Add(new ScrollBarMargin(this, Orientation.Horizontal));
     TopMargins.Add(new TopMargin(this));
 }