terminal/page: add methods to get hyperlink and grapheme map capacities

This commit is contained in:
Qwerasd
2024-07-08 22:20:31 -04:00
parent 11c8bdc00e
commit 29e6dcdee5

View File

@ -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