diff --git a/buffer.go b/buffer.go index e02b016..1311e5c 100644 --- a/buffer.go +++ b/buffer.go @@ -44,7 +44,7 @@ func (cell Cell) Color () (color Color) { } // Style returns the styling information associated with the cell -func (cell Cell) Style (style Style) { +func (cell Cell) Style () (style Style) { style = cell.style return } diff --git a/examples/style/main.go b/examples/style/main.go index 6f19035..784d9ba 100644 --- a/examples/style/main.go +++ b/examples/style/main.go @@ -3,6 +3,7 @@ package main import "os" import "fmt" import "image" +import "math/rand" import _ "image/png" import "git.tebibyte.media/sashakoshka/stone" import _ "git.tebibyte.media/sashakoshka/stone/backends/x" @@ -11,7 +12,7 @@ var application = &stone.Application { } func main () { application.SetTitle("style demo") - application.SetSize(9, 7) + application.SetSize(11, 8) iconFile16, err := os.Open("assets/scaffold16.png") if err != nil { panic(err) } @@ -28,11 +29,17 @@ func main () { application.OnStart(redraw) application.OnResize(redraw) + application.OnPress(onPress) err = application.Run() if err != nil { panic(err) } } +func onPress (button stone.Button, modifiers stone.Modifiers) { + redraw() + application.Draw() +} + func redraw () { width, _ := application.Size() application.SetDot(0, 0) @@ -44,7 +51,8 @@ func redraw () { "underline\n", "all 3\n", "highlighted\n", - "all 4\n") + "all 4\n", + "highlight?") fillStyle(0, width, stone.StyleNormal) fillStyle(1, width, stone.StyleBold) fillStyle(2, width, stone.StyleItalic) @@ -53,10 +61,17 @@ func redraw () { fillStyle(5, width, stone.StyleHighlight) fillStyle(6, width, stone.StyleBoldItalic | stone.StyleUnderline | stone.StyleHighlight) + + if rand.Int() % 2 == 0 { + fillStyle(7, width, stone.StyleNormal) + } else { + fillStyle(7, width, stone.StyleHighlight) + } } func fillStyle (yOffset, width int, style stone.Style) { for x := 0; x < width; x ++ { application.SetStyle(x, yOffset, style) + application.SetColor(x, yOffset, stone.Color(x % 7 + 1)) } }