terminal: sliding window search starts working

This commit is contained in:
Mitchell Hashimoto
2024-12-03 08:04:36 -05:00
parent 2a13c6b6a3
commit 6ed298c9c1
3 changed files with 702 additions and 0 deletions

View File

@@ -45,6 +45,17 @@ pub fn CircBuf(comptime T: type, comptime default: T) type {
self.idx += 1;
return &self.buf.storage[storage_idx];
}
/// Seek the iterator by a given amount. This will clamp
/// the values to the bounds of the buffer so overflows are
/// not possible.
pub fn seekBy(self: *Iterator, amount: isize) void {
if (amount > 0) {
self.idx +|= @intCast(amount);
} else {
self.idx -|= @intCast(@abs(amount));
}
}
};
/// Initialize a new circular buffer that can store size elements.