summaryrefslogtreecommitdiff
path: root/src/Text.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text.zig')
-rw-r--r--src/Text.zig5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Text.zig b/src/Text.zig
index 202cc339..7801d364 100644
--- a/src/Text.zig
+++ b/src/Text.zig
@@ -205,7 +205,10 @@ pub fn cellOffRange(text: []const u8, a: usize, c: usize) modal.Selection {
return .{ .anchor = modal.nextGrapheme(text, a), .head = c };
}
-pub fn rangeCells(text: []const u8, r: modal.Selection) struct { cur: usize, anc: usize } {
+/// A range's cursor and anchor cells, as offsets.
+pub const Cells = struct { cur: usize, anc: usize };
+
+pub fn rangeCells(text: []const u8, r: modal.Selection) Cells {
if (r.head > r.anchor) return .{ .cur = modal.prevGrapheme(text, r.head), .anc = r.anchor };
if (r.head < r.anchor) return .{ .cur = r.head, .anc = modal.prevGrapheme(text, r.anchor) };
return .{ .cur = r.head, .anc = r.head };