aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-09-27 05:26:49 +0000
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-09-27 05:26:49 +0000
commitc0fc101f87d4b4b55dbe7958d68e2a416e191217 (patch)
treef151dcb43bbb38b3f7d32ca1ca3388220f20bb62
parent0c0359bcbbe32b0222a76d3dcdf036cb48928acc (diff)
LineSpan
-rw-r--r--Crow/src/Text/LineSpan.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/Crow/src/Text/LineSpan.cs b/Crow/src/Text/LineSpan.cs
new file mode 100644
index 00000000..1dc90de6
--- /dev/null
+++ b/Crow/src/Text/LineSpan.cs
@@ -0,0 +1,31 @@
+// Copyright (c) 2013-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using System;
+
+namespace Crow.Text
+{
+ public struct LineSpan : IEquatable<LineSpan>
+ {
+ public readonly CharLocation Start;
+ public readonly CharLocation End;
+ public LineSpan (CharLocation start, CharLocation end) {
+ Start = start;
+ End = end;
+ }
+ public bool IsEmpty => Start == End;
+
+ public bool Equals(LineSpan other)
+ => Start == other.Start && End == other.End;
+ public override bool Equals(object obj)
+ => obj is LineSpan ts ? Equals(ts) : false;
+
+ public override int GetHashCode()
+ => HashCode.Combine(Start, End);
+ public static bool operator ==(LineSpan left, LineSpan right)
+ => left.Equals (right);
+ public static bool operator !=(LineSpan left, LineSpan right)
+ => !left.Equals (right);
+ public override string ToString() => $"{Start},{End}";
+ }
+}