/// <summary>
        /// Creates a new document and loads the given file
        /// </summary>
        public IDocument CreateFromTextBuffer(ITextBufferStrategy textBuffer)
        {
            DefaultDocument doc = (DefaultDocument)CreateDocument();

            doc.TextContent        = textBuffer.GetText(0, textBuffer.Length);
            doc.TextBufferStrategy = textBuffer;
            return(doc);
        }
 /// <summary>
 /// Creates a new instance of <see cref="DefaultSelection"/>
 /// </summary>
 public DefaultSelection(IDocument document, TextLocation startPosition, TextLocation endPosition)
 {
     DefaultDocument.ValidatePosition(document, startPosition);
     DefaultDocument.ValidatePosition(document, endPosition);
     Debug.Assert(startPosition <= endPosition);
     this.document      = document;
     this.startPosition = startPosition;
     this.endPosition   = endPosition;
 }
        /// <remarks>
        /// Creates a new <see cref="IDocument"/> object. Only create
        /// <see cref="IDocument"/> with this method.
        /// </remarks>
        public IDocument CreateDocument()
        {
            DefaultDocument doc = new DefaultDocument();

            doc.TextBufferStrategy             = new GapTextBufferStrategy();
            doc.FormattingStrategy             = new DefaultFormattingStrategy();
            doc.LineManager                    = new LineManager(doc, null);
            doc.FoldingManager                 = new FoldingManager(doc, doc.LineManager);
            doc.FoldingManager.FoldingStrategy = null;                   //new ParserFoldingStrategy();
            doc.MarkerStrategy                 = new MarkerStrategy(doc);
            doc.BookmarkManager                = new BookmarkManager(doc, doc.LineManager);
            doc.BreakpointManager              = new BreakpointManager(doc);
            return(doc);
        }