Add Sprintf functaionlity to Debug window
This commit is contained in:
parent
3e7ef4859c
commit
14dae825e3
@ -1,6 +1,10 @@
|
|||||||
package components
|
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,
|
// Debug can be used to relay debugging information in the Debug component,
|
||||||
// see event.go on how to use it
|
// see event.go on how to use it
|
||||||
@ -57,3 +61,15 @@ func (d *Debug) Println(text string) {
|
|||||||
|
|
||||||
termui.Render(d)
|
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)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user