diff --git a/CSharp/Libraries/UniversalEditor.Core/Accessor.cs b/CSharp/Libraries/UniversalEditor.Core/Accessor.cs index f1d8c7b0..f606a3fe 100644 --- a/CSharp/Libraries/UniversalEditor.Core/Accessor.cs +++ b/CSharp/Libraries/UniversalEditor.Core/Accessor.cs @@ -189,5 +189,27 @@ namespace UniversalEditor { return String.Empty; } + + #region Position Saving and Loading + private Stack _positions = new Stack(); + [DebuggerNonUserCode()] + public void SavePosition() + { + _positions.Push(this.Position); + } + [DebuggerNonUserCode()] + public void LoadPosition() + { + if (_positions.Count > 0) this.Position = _positions.Pop(); + } + public void ClearLastPosition() + { + if (_positions.Count > 0) _positions.Pop(); + } + public void ClearAllPositions() + { + if (_positions.Count > 0) _positions.Clear(); + } + #endregion } } diff --git a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/BinHex/BinHexDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/BinHex/BinHexDataFormat.cs index 054ad4b8..59f31b75 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/BinHex/BinHexDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.FileSystem/DataFormats/FileSystem/BinHex/BinHexDataFormat.cs @@ -49,13 +49,13 @@ namespace UniversalEditor.DataFormats.FileSystem.BinHex if (fsom == null) throw new ObjectModelNotSupportedException(); Reader reader = base.Accessor.Reader; - reader.SavePosition(); + base.Accessor.SavePosition(); string line = reader.ReadLine(); if (!(line.StartsWith("(This file must be converted with BinHex ") && line.EndsWith(")"))) { if (mvarRequireWarningComment) throw new InvalidDataFormatException("File does not begin with BinHex warning comment"); - reader.LoadPosition(); + base.Accessor.LoadPosition(); } else { @@ -63,7 +63,7 @@ namespace UniversalEditor.DataFormats.FileSystem.BinHex line = line.Substring(0, line.Length - 1); mvarFormatVersion = new Version(line); } - reader.ClearLastPosition(); + base.Accessor.ClearLastPosition(); string inputStr = reader.ReadStringToEnd();