From a47445f494805defb0c6ae9b6cb4f84c0c908e04 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Tue, 22 Nov 2022 00:47:33 -0500 Subject: [PATCH] Press tab to view the end result in the readout instead! --- draw.go | 28 ++++++++++++++++++++++++++-- main.go | 8 +++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/draw.go b/draw.go index 4844295..8027f1a 100644 --- a/draw.go +++ b/draw.go @@ -11,6 +11,13 @@ func clear (x, y, width, height int) { }} } +func fillColor (x, y, width, height int, color stone.Color) { + for yy := 0; yy < height; yy ++ { + for xx := 0; xx < width; xx ++ { + application.SetColor(xx + x, yy + y, color) + }} +} + func redraw () { width, _ := application.Size() showLeftColumn = width > 44 @@ -60,13 +67,30 @@ func drawInput () { func drawNumberReadouts () { _, height := application.Size() + + indicatorY := height - 12 + application.SetDot(0, indicatorY) + fmt.Fprint(application, "sel fin") + fillColor(0, indicatorY, 10, 1, stone.ColorDim) + + if showEndResult { + fillColor(4, indicatorY, 3, 1, stone.ColorBlue) + } else { + fillColor(0, indicatorY, 3, 1, stone.ColorBlue) + } clear(0, height - 10, 25, 10) var number int64 var err error - if selectedExpression != nil { - number, err = selectedExpression.Solution() + if showEndResult { + if expressionRoot != nil { + number, err = expressionRoot.Solution() + } + } else { + if selectedExpression != nil { + number, err = selectedExpression.Solution() + } } if err != nil { diff --git a/main.go b/main.go index eff3f4d..5d032d6 100644 --- a/main.go +++ b/main.go @@ -15,10 +15,11 @@ var application = &stone.Application { } var expressionRoot Expression var inputBuffer stone.DamageBuffer var showLeftColumn bool +var showEndResult bool func main () { application.SetTitle("MathPan") - application.SetSize(64, 10) + application.SetSize(64, 12) icon, _, err := image.Decode(bytes.NewReader(iconBytes)) if err != nil { panic(err) } @@ -80,6 +81,11 @@ func onPress (button stone.Button, modifiers stone.Modifiers) { redraw() application.Draw() + case stone.KeyTab: + showEndResult = !showEndResult + redraw() + application.Draw() + case stone.KeyDelete: if selectedExpression == nil { break } parent := selectedExpression.Parent()