diff --git a/components/debug.go b/components/debug.go index aa0a26a..5fb1cc4 100644 --- a/components/debug.go +++ b/components/debug.go @@ -1,6 +1,10 @@ package components -import "github.com/erroneousboat/termui" +import ( + "fmt" + + "github.com/erroneousboat/termui" +) // Debug can be used to relay debugging information in the Debug component, // see event.go on how to use it @@ -57,3 +61,15 @@ func (d *Debug) Println(text string) { termui.Render(d) } + +func (d *Debug) Sprintf(format string, a ...interface{}) { + text := fmt.Sprintf(format, a...) + d.List.Items = append(d.List.Items, text) + + // When at the end remove first item + if len(d.List.Items) > d.List.InnerBounds().Max.Y-1 { + d.List.Items = d.List.Items[1:] + } + + termui.Render(d) +}