From a26f30f1a647d01da0d17c8ef10f7bddd415c7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20B=C3=B3di?= Date: Sat, 28 Jan 2023 20:39:03 +0100 Subject: [PATCH] Grid items can be cleared after the given index --- grid.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grid.go b/grid.go index a72d08e9..bddaf970 100644 --- a/grid.go +++ b/grid.go @@ -227,6 +227,15 @@ func (g *Grid) Clear() *Grid { return g } +// ClearAfter removes all items starting with the given index. +func (g *Grid) ClearAfter(index int) *Grid { + if len(g.items) <= index { + return g + } + g.items = g.items[:index] + return g +} + // SetOffset sets the number of rows and columns which are skipped before // drawing the first grid cell in the top-left corner. As the grid will never // completely move off the screen, these values may be adjusted the next time