package main import "os" import "image" import "image/color" import _ "image/png" import "git.tebibyte.media/sashakoshka/stone" import "git.tebibyte.media/sashakoshka/stone/config" import _ "git.tebibyte.media/sashakoshka/stone/backends/x" var application = &stone.Application { } var inputState struct { x int y int } var globalConfig config.Config func main () { application.SetTitle("configuration viewer") application.SetSize(32, 16) iconFile16, err := os.Open("assets/scaffold16.png") if err != nil { panic(err) } icon16, _, err := image.Decode(iconFile16) if err != nil { panic(err) } iconFile16.Close() iconFile32, err := os.Open("assets/scaffold32.png") if err != nil { panic(err) } icon32, _, err := image.Decode(iconFile32) if err != nil { panic(err) } iconFile16.Close() application.SetIcon([]image.Image { icon16, icon32 }) application.OnPress(onPress) application.OnRelease(onRelease) application.OnMouseMove(onMouseMove) application.OnStart(onStart) application.OnResize(redraw) err = application.Run() if err != nil { panic(err) } } func onStart () { // this is just copy pasted from config.go globalConfig = config.Config { LegalParameters: map[string] config.Type { "fontNormal": config.TypeString, "fontSize": config.TypeInteger, "padding": config.TypeInteger, "center": config.TypeBoolean, "colorBackground": config.TypeColor, "colorForeground": config.TypeColor, "colorDim": config.TypeColor, "colorRed": config.TypeColor, "colorYellow": config.TypeColor, "colorGreen": config.TypeColor, "colorBlue": config.TypeColor, "colorPurple": config.TypeColor, }, Parameters: map[string] any { "fontNormal": "", "fontSize": 11, "padding": 2, "center": false, "colorBackground": color.RGBA { R: 0, G: 0, B: 0, A: 0 }, "colorForeground": color.RGBA { R: 0xFF, G: 0xFF, B: 0xFF, A: 0xFF }, "colorDim": color.RGBA { R: 0x80, G: 0x80, B: 0x80, A: 0xFF }, "colorRed": color.RGBA { R: 0xFF, G: 0x00, B: 0x00, A: 0xFF }, "colorYellow": color.RGBA { R: 0xFF, G: 0xFF, B: 0x00, A: 0xFF }, "colorGreen": color.RGBA { R: 0x00, G: 0xFF, B: 0x00, A: 0xFF }, "colorBlue": color.RGBA { R: 0x00, G: 0x80, B: 0xFF, A: 0xFF }, "colorPurple": color.RGBA { R: 0x80, G: 0x40, B: 0xFF, A: 0xFF }, }, } globalConfig.Load("stone") redraw() } func redraw () { // i fucking love go interfaces application.Clear() application.SetDot(0, 0) globalConfig.SaveTo(application) } func onPress (button stone.Button, modifiers stone.Modifiers) { } func onRelease (button stone.Button) { } func onMouseMove (x, y int) { inputState.x = x inputState.y = y }