slight refactor, gofmt

This commit is contained in:
2019-10-26 23:32:32 +03:00
parent 32c598f9e0
commit ec9d3d9a73
20 changed files with 303 additions and 239 deletions

View File

@ -1,14 +1,11 @@
package mainwindow
import blt "lab.zaar.be/thefish/bearlibterminal"
type LayerInterface interface {
Render()
Put(x, y int, symbol rune, color string)
}
import (
blt "lab.zaar.be/thefish/bearlibterminal"
)
type Layer struct {
idx int
idx int
defaultColor uint32
}
@ -35,31 +32,28 @@ func (layer *Layer) after() *Layer {
return layer
}
func (layer Layer) Put(x,y int, symbol string) {
rnes := []rune(symbol)
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) Print(x, y int, txt string) (w, h int) {
return blt.Print(x, y, txt)
}
func (layer Layer) DrawWindow (title string, x, y, w, h int) {
if len(title) > (w -2) {
title = title[:(w-2)]
}
layer.NewRect(x,y,w,h).DrawBorder()
centerX := x + (w / 2)
layer.Print(centerX - (len(title) / 2) - 1, y, "╡" + title + "╞")
};
func (layer *Layer) Decorate (f func (args ...interface{})) func (args ...interface{}) {
return func (args ...interface{}) {
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() {
}