aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Document/DocumentChangeOperation.cs
blob: f24b7ed4da2e60af6c1fadc2565645f6bf836051 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)

using System;
using System.Diagnostics;

namespace Tango.Scripting.Editors.Document
{
	/// <summary>
	/// Describes a change to a TextDocument.
	/// </summary>
	sealed class DocumentChangeOperation : IUndoableOperationWithContext
	{
		TextDocument document;
		DocumentChangeEventArgs change;
		
		public DocumentChangeOperation(TextDocument document, DocumentChangeEventArgs change)
		{
			this.document = document;
			this.change = change;
		}
		
		public void Undo(UndoStack stack)
		{
			Debug.Assert(stack.state == UndoStack.StatePlayback);
			stack.RegisterAffectedDocument(document);
			stack.state = UndoStack.StatePlaybackModifyDocument;
			this.Undo();
			stack.state = UndoStack.StatePlayback;
		}
		
		public void Redo(UndoStack stack)
		{
			Debug.Assert(stack.state == UndoStack.StatePlayback);
			stack.RegisterAffectedDocument(document);
			stack.state = UndoStack.StatePlaybackModifyDocument;
			this.Redo();
			stack.state = UndoStack.StatePlayback;
		}
		
		public void Undo()
		{
			OffsetChangeMap map = change.OffsetChangeMapOrNull;
			document.Replace(change.Offset, change.InsertionLength, change.RemovedText, map != null ? map.Invert() : null);
		}
		
		public void Redo()
		{
			document.Replace(change.Offset, change.RemovalLength, change.InsertedText, change.OffsetChangeMapOrNull);
		}
	}
}
k">using scg = global::System.Collections.Generic; namespace Tango.PMR.ColorLab { /// <summary>Holder for reflection information generated from ConversionOutput.proto</summary> public static partial class ConversionOutputReflection { #region Descriptor /// <summary>File descriptor for ConversionOutput.proto</summary> public static pbr::FileDescriptor Descriptor { get { return descriptor; } } private static pbr::FileDescriptor descriptor; static ConversionOutputReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "ChZDb252ZXJzaW9uT3V0cHV0LnByb3RvEhJUYW5nby5QTVIuQ29sb3JMYWIa", "F091dHB1dENvb3JkaW5hdGVzLnByb3RvIpICChBDb252ZXJzaW9uT3V0cHV0", "Ej4KD0hpdmVDb29yZGluYXRlcxgBIAMoCzIlLlRhbmdvLlBNUi5Db2xvckxh", "Yi5PdXRwdXRDb29yZGluYXRlcxJAChFUcmlwbGVDb29yZGluYXRlcxgCIAMo", "CzIlLlRhbmdvLlBNUi5Db2xvckxhYi5PdXRwdXRDb29yZGluYXRlcxJAChFT", "aW5nbGVDb29yZGluYXRlcxgDIAEoCzIlLlRhbmdvLlBNUi5Db2xvckxhYi5P", "dXRwdXRDb29yZGluYXRlcxISCgpPdXRPZkdhbXV0GAUgASgIEhAKCEhhc0Vy", "cm9yGAYgASgIEhQKDEVycm9yTWVzc2FnZRgHIAEoCUIeChxjb20udHdpbmUu", "dGFuZ28ucG1yLmNvbG9ybGFiYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.ColorLab.OutputCoordinatesReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.ColorLab.ConversionOutput), global::Tango.PMR.ColorLab.ConversionOutput.Parser, new[]{ "HiveCoordinates", "TripleCoordinates", "SingleCoordinates", "OutOfGamut", "HasError", "ErrorMessage" }, null, null, null) })); } #endregion } #region Messages public sealed partial class ConversionOutput : pb::IMessage<ConversionOutput> { private static readonly pb::MessageParser<ConversionOutput> _parser = new pb::MessageParser<ConversionOutput>(() => new ConversionOutput()); [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser<ConversionOutput> Parser { get { return _parser; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Tango.PMR.ColorLab.ConversionOutputReflection.Descriptor.MessageTypes[0]; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ConversionOutput() { OnConstruction(); } partial void OnConstruction(); [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ConversionOutput(ConversionOutput other) : this() { hiveCoordinates_ = other.hiveCoordinates_.Clone(); tripleCoordinates_ = other.tripleCoordinates_.Clone(); SingleCoordinates = other.singleCoordinates_ != null ? other.SingleCoordinates.Clone() : null; outOfGamut_ = other.outOfGamut_; hasError_ = other.hasError_; errorMessage_ = other.errorMessage_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ConversionOutput Clone() { return new ConversionOutput(this); } /// <summary>Field number for the "HiveCoordinates" field.</summary> public const int HiveCoordinatesFieldNumber = 1; private static readonly pb::FieldCodec<global::Tango.PMR.ColorLab.OutputCoordinates> _repeated_hiveCoordinates_codec = pb::FieldCodec.ForMessage(10, global::Tango.PMR.ColorLab.OutputCoordinates.Parser); private readonly pbc::RepeatedField<global::Tango.PMR.ColorLab.OutputCoordinates> hiveCoordinates_ = new pbc::RepeatedField<global::Tango.PMR.ColorLab.OutputCoordinates>(); [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField<global::Tango.PMR.ColorLab.OutputCoordinates> HiveCoordinates { get { return hiveCoordinates_; } } /// <summary>Field number for the "TripleCoordinates" field.</summary> public const int TripleCoordinatesFieldNumber = 2; private static readonly pb::FieldCodec<global::Tango.PMR.ColorLab.OutputCoordinates> _repeated_tripleCoordinates_codec = pb::FieldCodec.ForMessage(18, global::Tango.PMR.ColorLab.OutputCoordinates.Parser); private readonly pbc::RepeatedField<global::Tango.PMR.ColorLab.OutputCoordinates> tripleCoordinates_ = new pbc::RepeatedField<global::Tango.PMR.ColorLab.OutputCoordinates>(); [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public pbc::RepeatedField<global::Tango.PMR.ColorLab.OutputCoordinates> TripleCoordinates { get { return tripleCoordinates_; } } /// <summary>Field number for the "SingleCoordinates" field.</summary> public const int SingleCoordinatesFieldNumber = 3; private global::Tango.PMR.ColorLab.OutputCoordinates singleCoordinates_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Tango.PMR.ColorLab.OutputCoordinates SingleCoordinates { get { return singleCoordinates_; } set { singleCoordinates_ = value; } } /// <summary>Field number for the "OutOfGamut" field.</summary> public const int OutOfGamutFieldNumber = 5; private bool outOfGamut_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool OutOfGamut { get { return outOfGamut_; } set { outOfGamut_ = value; } } /// <summary>Field number for the "HasError" field.</summary> public const int HasErrorFieldNumber = 6; private bool hasError_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool HasError { get { return hasError_; } set { hasError_ = value; } } /// <summary>Field number for the "ErrorMessage" field.</summary> public const int ErrorMessageFieldNumber = 7; private string errorMessage_ = ""; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string ErrorMessage { get { return errorMessage_; } set { errorMessage_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ConversionOutput); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(ConversionOutput other) { if (ReferenceEquals(other, null)) { return false; } if (ReferenceEquals(other, this)) { return true; } if(!hiveCoordinates_.Equals(other.hiveCoordinates_)) return false; if(!tripleCoordinates_.Equals(other.tripleCoordinates_)) return false; if (!object.Equals(SingleCoordinates, other.SingleCoordinates)) return false; if (OutOfGamut != other.OutOfGamut) return false; if (HasError != other.HasError) return false; if (ErrorMessage != other.ErrorMessage) return false; return true; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; hash ^= hiveCoordinates_.GetHashCode(); hash ^= tripleCoordinates_.GetHashCode(); if (singleCoordinates_ != null) hash ^= SingleCoordinates.GetHashCode(); if (OutOfGamut != false) hash ^= OutOfGamut.GetHashCode(); if (HasError != false) hash ^= HasError.GetHashCode(); if (ErrorMessage.Length != 0) hash ^= ErrorMessage.GetHashCode(); return hash; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { hiveCoordinates_.WriteTo(output, _repeated_hiveCoordinates_codec); tripleCoordinates_.WriteTo(output, _repeated_tripleCoordinates_codec); if (singleCoordinates_ != null) { output.WriteRawTag(26); output.WriteMessage(SingleCoordinates); } if (OutOfGamut != false) { output.WriteRawTag(40); output.WriteBool(OutOfGamut); } if (HasError != false) { output.WriteRawTag(48); output.WriteBool(HasError); } if (ErrorMessage.Length != 0) { output.WriteRawTag(58); output.WriteString(ErrorMessage); } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; size += hiveCoordinates_.CalculateSize(_repeated_hiveCoordinates_codec); size += tripleCoordinates_.CalculateSize(_repeated_tripleCoordinates_codec); if (singleCoordinates_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(SingleCoordinates); } if (OutOfGamut != false) { size += 1 + 1; } if (HasError != false) { size += 1 + 1; } if (ErrorMessage.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(ErrorMessage); } return size; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(ConversionOutput other) { if (other == null) { return; } hiveCoordinates_.Add(other.hiveCoordinates_); tripleCoordinates_.Add(other.tripleCoordinates_); if (other.singleCoordinates_ != null) { if (singleCoordinates_ == null) { singleCoordinates_ = new global::Tango.PMR.ColorLab.OutputCoordinates(); } SingleCoordinates.MergeFrom(other.SingleCoordinates); } if (other.OutOfGamut != false) { OutOfGamut = other.OutOfGamut; } if (other.HasError != false) { HasError = other.HasError; } if (other.ErrorMessage.Length != 0) { ErrorMessage = other.ErrorMessage; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { switch(tag) { default: input.SkipLastField(); break; case 10: { hiveCoordinates_.AddEntriesFrom(input, _repeated_hiveCoordinates_codec); break; } case 18: { tripleCoordinates_.AddEntriesFrom(input, _repeated_tripleCoordinates_codec); break; } case 26: { if (singleCoordinates_ == null) { singleCoordinates_ = new global::Tango.PMR.ColorLab.OutputCoordinates(); } input.ReadMessage(singleCoordinates_); break; } case 40: { OutOfGamut = input.ReadBool(); break; } case 48: { HasError = input.ReadBool(); break; } case 58: { ErrorMessage = input.ReadString(); break; } } } } } #endregion } #endregion Designer generated code