package mainwindow import ( blt "lab.zaar.be/thefish/bearlibterminal" ) type Layer struct { idx int defaultColor uint32 } func AddLayer(idx int, colorName string) Layer { c := blt.ColorFromName(colorName) return Layer{idx: idx, defaultColor: c} } func (layer *Layer) before() *Layer { blt.Layer(layer.idx) return layer } func (layer *Layer) WithColor(colorName string) *Layer { layer.before() c := blt.ColorFromName(colorName) blt.Color(c) return layer } func (layer *Layer) after() *Layer { blt.Color(layer.defaultColor) blt.Layer(0) return layer } func (layer Layer) Put(x, y int, symbol interface{}) { if symbol == nil { return } rnes := []rune(symbol.(string)) if (len(rnes)) > 0 { blt.Put(x, y, int(rnes[0])) } } func (layer Layer) Print(x, y int, txt string) (w, h int) { return blt.Print(x, y, txt) } func (layer *Layer) Decorate(f func(args ...interface{})) func(args ...interface{}) { return func(args ...interface{}) { layer.before() f(args) layer.after() } } func (layer *Layer) Render() { }