From 5009ab6645d75accfc4635ce6f6086b4d6e87c80 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 29 Feb 2024 11:29:39 -0800 Subject: [PATCH] terminal/new: page resizebuf boilerplate --- src/terminal/new/page.zig | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/terminal/new/page.zig b/src/terminal/new/page.zig index df443b4c3..02c8dbd11 100644 --- a/src/terminal/new/page.zig +++ b/src/terminal/new/page.zig @@ -206,6 +206,35 @@ pub const Page = struct { return result; } + /// Clone and resize this page to the new layout with a provided + /// memory buffer. The new layout can change any parameters. If they + /// do not fit within the new layout, OutOfMemory is returned. + /// If OutOfMemory is returned, the memory buffer is not zeroed; + /// the caller should zero if it is reused. + /// + /// If reflow is true, soft-wrapped text will be reflowed. If reflow + /// is false then soft-wrapped text will be truncated. + /// + /// For deleted cells, this will reclaim the grapheme/style memory + /// as appropriate. A page has no concept of the current active style + /// so if you want the current active style to not be GCd then you + /// should increase the ref count before calling this function, and + /// decrease it after. + pub fn resizeBuf( + self: *Page, + buf: OffsetBuf, + l: Layout, + reflow: bool, + ) !Page { + // TODO + if (reflow) @panic("TODO"); + + // Non-reflow resize is relatively simple. + _ = self; + _ = buf; + _ = l; + } + /// Get a single row. y must be valid. pub fn getRow(self: *const Page, y: usize) *Row { assert(y < self.size.rows);