Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandy Armstrong <sanfordarmstrong@gmail.com>2014-09-17 22:03:00 +0400
committerAaron Bockover <abock@xamarin.com>2014-10-04 02:36:08 +0400
commit2ddd2115b46bb9b1ce764db2d8f52bc98515d2e4 (patch)
tree392821e448edee61bad122b2ab1227e196a4004b
parent2a17a6a6ddea5a9f6bcea1173488d258df979123 (diff)
Allow subclasses to modify loaded/saved text
Hypothetically, a subclass of SourceEditorView might want to store metadata in a hidden header area of the file. Overriding ProcessLoadText gives the subclass an opportunity to extract said metadata, and ensure that the text loaded into the Document excludes it. Similarly, ProcessSaveText would allow this subclass to inject updated metadata into the file text just before the write occurs.
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs13
1 files changed, 12 insertions, 1 deletions
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
index d301d929f5..3990a458e3 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
@@ -614,6 +614,11 @@ namespace MonoDevelop.SourceEditor
messageBubbleCache = null;
}
}
+
+ protected virtual string ProcessSaveText (string text)
+ {
+ return text;
+ }
public override void Save (string fileName)
{
@@ -694,7 +699,7 @@ namespace MonoDevelop.SourceEditor
try {
var writeEncoding = encoding;
var writeBom = hadBom;
- var writeText = Document.Text;
+ var writeText = ProcessSaveText (Document.Text);
if (writeEncoding == null) {
if (this.encoding != null) {
writeEncoding = this.encoding;
@@ -821,6 +826,11 @@ namespace MonoDevelop.SourceEditor
Load (fileName, loadEncoding);
}
+ protected virtual string ProcessLoadText (string text)
+ {
+ return text;
+ }
+
public void Load (string fileName, Encoding loadEncoding, bool reload = false)
{
// Handle the "reload" case.
@@ -848,6 +858,7 @@ namespace MonoDevelop.SourceEditor
encoding = loadEncoding;
text = TextFileUtility.ReadAllText (fileName, loadEncoding, out hadBom);
}
+ text = ProcessLoadText (text);
if (reload) {
Document.Replace (0, Document.TextLength, text);
Document.DiffTracker.Reset ();