ファイル
YMM4-UndoTree/UndoTree/UndoTreeText.cs
T

28 行
1001 B
C#

namespace UndoTree;
internal static class UndoTreeText
{
public const int MaxLength = 60;
const string LineBreakMark = "↵";
public static string SingleLine(string text) => text.ReplaceLineEndings(LineBreakMark);
public static string Shorten(string text)
{
if (text.Length <= MaxLength)
return text;
var length = char.IsHighSurrogate(text[MaxLength - 1]) ? MaxLength - 1 : MaxLength;
return text[..length] + "…";
}
public static string Join(string target, string member)
=> target.Length == 0 ? member : member.Length == 0 ? target : $"{target} / {member}";
public static string WithDetail(string text, string detail) => detail.Length > 0 ? $"{text}: {detail}" : text;
public static string Marks(bool isCompareBase, bool isSaved, string tag)
=> (isCompareBase ? $"[{Texts.BaseMark}]" : string.Empty) + (isSaved ? $"[{Texts.SavedMark}]" : string.Empty) + (tag.Length > 0 ? $"[{tag}]" : string.Empty);
}