From 29e6dcdee52b6b8cb9daa0f8ee4e4d46e21c5769 Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Mon, 8 Jul 2024 22:20:31 -0400 Subject: [PATCH] terminal/page: add methods to get hyperlink and grapheme map capacities --- src/terminal/page.zig | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/terminal/page.zig b/src/terminal/page.zig index 5b7c4a008..dee90a785 100644 --- a/src/terminal/page.zig +++ b/src/terminal/page.zig @@ -942,7 +942,7 @@ pub const Page = struct { map.removeByPtr(entry.key_ptr); cell.hyperlink = false; - // Mark that we no longer have graphemes, also search the row + // Mark that we no longer have hyperlinks, also search the row // to make sure its state is correct. const cells = row.cells.ptr(self.memory)[0..self.size.cols]; for (cells) |c| if (c.hyperlink) return; @@ -992,6 +992,18 @@ pub const Page = struct { map.putAssumeCapacity(dst_offset, value); } + /// Returns the number of hyperlinks in the page. This isn't the byte + /// size but the total number of unique cells that have hyperlink data. + pub fn hyperlinkCount(self: *const Page) usize { + return self.hyperlink_map.map(self.memory).count(); + } + + /// Returns the hyperlink capacity for the page. This isn't the byte + /// size but the number of unique cells that can have hyperlink data. + pub fn hyperlinkCapacity(self: *const Page) usize { + return self.hyperlink_map.map(self.memory).capacity(); + } + /// Append a codepoint to the given cell as a grapheme. pub fn appendGrapheme(self: *Page, row: *Row, cell: *Cell, cp: u21) Allocator.Error!void { defer self.assertIntegrity(); @@ -1114,6 +1126,12 @@ pub const Page = struct { return self.grapheme_map.map(self.memory).count(); } + /// Returns the grapheme capacity for the page. This isn't the byte + /// size but the number of unique cells that can have grapheme data. + pub fn graphemeCapacity(self: *const Page) usize { + return self.grapheme_map.map(self.memory).capacity(); + } + /// Returns the bitset for the dirty bits on this page. /// /// The returned value is a DynamicBitSetUnmanaged but it is NOT