2
// <copyright see="prj:///doc/copyright.txt"/>
3
// <license see="prj:///doc/license.txt"/>
4
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
5
// <version value="$version"/>
10
using System.Collections;
12
using MonoDevelop.Core.Gui;
14
namespace MonoDevelop.TextEditor.Document
16
public class ProvidedDocumentInformation
19
ITextBufferStrategy textBuffer;
23
public ITextBufferStrategy TextBuffer {
32
public string FileName {
38
public int CurrentOffset {
40
// if (document != null) {
41
// return document.Caret.Offset;
46
// if (document != null) {
47
// document.Caret.Offset = value;
49
currentOffset = value;
54
public int EndOffset {
56
if (document != null) {
57
return SearchReplaceUtilities.CalcCurrentOffset(document);
63
public void Replace(int offset, int length, string pattern)
65
if (document != null) {
66
document.Replace(offset, length, pattern);
68
textBuffer.Replace(offset, length, pattern);
71
if (offset <= CurrentOffset) {
72
CurrentOffset = CurrentOffset - length + pattern.Length;
76
public void SaveBuffer()
78
if (document != null) {
81
StreamWriter streamWriter = File.CreateText(this.fileName);
82
streamWriter.Write(textBuffer.GetText(0, textBuffer.Length));
87
public IDocument CreateDocument()
89
if (document != null) {
92
return new DocumentFactory().CreateFromFile(fileName);
95
public ProvidedDocumentInformation(IDocument document, string fileName)
97
this.document = document;
98
this.textBuffer = document.TextBufferStrategy;
99
this.fileName = fileName;
100
// this.currentOffset = document.Caret.Offset;
103
public ProvidedDocumentInformation(ITextBufferStrategy textBuffer, string fileName, int currentOffset)
105
this.textBuffer = textBuffer;
106
this.fileName = fileName;
107
this.currentOffset = currentOffset;