29 行
1.3 KiB
C#
29 行
1.3 KiB
C#
using System.Text.Json.Serialization;
|
|
|
|
namespace UndoTree;
|
|
|
|
internal sealed record UndoTreeRecordCommand(string Kind, string Target, string Member, string Detail, string Path = "", string Before = "", string After = "", int AddedCount = 0, int RemovedCount = 0);
|
|
|
|
internal sealed record UndoTreeRecordNode(int Id, int Parent, string Label, DateTime Time, IReadOnlyList<UndoTreeRecordCommand> Commands, string Tag = "", bool Saved = false, IReadOnlyList<UndoTreeStep>? Steps = null, string ProjectHash = "");
|
|
|
|
internal sealed record UndoTreeRecordBranch(string Name, int Base, int Head);
|
|
|
|
internal sealed record UndoTreeRecord(DateTime SavedAt, IReadOnlyList<UndoTreeRecordNode> Nodes, int CursorId = -1, IReadOnlyList<UndoTreeRecordBranch>? Branches = null, int ActiveBranch = -1)
|
|
{
|
|
[JsonIgnore]
|
|
public bool HasEdits => Nodes.Count > 1;
|
|
|
|
[JsonIgnore]
|
|
public IReadOnlyList<UndoTreeRecordBranch> NamedBranches => Branches ?? [];
|
|
}
|
|
|
|
internal sealed record UndoTreeRecordFile(int Version, string ProjectPath, UndoTreeRecord? Previous, UndoTreeRecord? Current)
|
|
{
|
|
public const int CurrentVersion = 1;
|
|
|
|
[JsonIgnore]
|
|
public UndoTreeRecord? Latest => Current is { HasEdits: true } ? Current : Previous;
|
|
}
|
|
|
|
internal sealed record UndoTreeRecordUsage(int Count, long Bytes);
|