mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
terminal2: add Pin.cells
This commit is contained in:
@ -2038,6 +2038,21 @@ pub const Pin = struct {
|
||||
return .{ .row = rac.row, .cell = rac.cell };
|
||||
}
|
||||
|
||||
pub const CellSubset = enum { all, left, right };
|
||||
|
||||
/// Returns the cells for the row that this pin is on. The subset determines
|
||||
/// what subset of the cells are returned. The "left/right" subsets are
|
||||
/// inclusive of the x coordinate of the pin.
|
||||
pub fn cells(self: Pin, subset: CellSubset) []pagepkg.Cell {
|
||||
const rac = self.rowAndCell();
|
||||
const all = self.page.data.getCells(rac.row);
|
||||
return switch (subset) {
|
||||
.all => all,
|
||||
.left => all[0 .. self.x + 1],
|
||||
.right => all[self.x..],
|
||||
};
|
||||
}
|
||||
|
||||
/// Iterators. These are the same as PageList iterator funcs but operate
|
||||
/// on pins rather than points. This is MUCH more efficient than calling
|
||||
/// pointFromPin and building up the iterator from points.
|
||||
|
@ -28,6 +28,7 @@ pub const MouseShape = @import("mouse_shape.zig").MouseShape;
|
||||
pub const Page = page.Page;
|
||||
pub const PageList = @import("PageList.zig");
|
||||
pub const Parser = @import("Parser.zig");
|
||||
pub const Pin = PageList.Pin;
|
||||
pub const Screen = @import("Screen.zig");
|
||||
pub const Selection = @import("Selection.zig");
|
||||
pub const Terminal = @import("Terminal.zig");
|
||||
|
Reference in New Issue
Block a user