Draw the actual buffer text on screen

This commit is contained in:
Sasha Koshka 2022-11-11 18:14:43 -05:00
parent 85b6e5495e
commit 38f7185be2

View File

@ -142,6 +142,9 @@ func (backend *Backend) handleXEvent (event xgb.Event) {
// resize and rebind canvas // resize and rebind canvas
backend.reallocateCanvas() backend.reallocateCanvas()
// notify application of resize
backend.channel <- stone.EventResize { }
} }
} }
} }
@ -201,28 +204,50 @@ func (backend *Backend) reallocateCanvas () {
return backend.colors[stone.ColorApplication] return backend.colors[stone.ColorApplication]
}) })
backend.drawRune(0, 0, 'T') // backend.drawRune(0, 0, 'T')
backend.drawRune(1, 0, 'h') // backend.drawRune(1, 0, 'h')
backend.drawRune(2, 0, 'e') // backend.drawRune(2, 0, 'e')
backend.drawRune(4, 0, 'q') // backend.drawRune(4, 0, 'q')
backend.drawRune(5, 0, 'u') // backend.drawRune(5, 0, 'u')
backend.drawRune(6, 0, 'i') // backend.drawRune(6, 0, 'i')
backend.drawRune(7, 0, 'c') // backend.drawRune(7, 0, 'c')
backend.drawRune(8, 0, 'k') // backend.drawRune(8, 0, 'k')
backend.drawRune(0, 1, 'b') // backend.drawRune(0, 1, 'b')
backend.drawRune(1, 1, 'r') // backend.drawRune(1, 1, 'r')
backend.drawRune(2, 1, 'o') // backend.drawRune(2, 1, 'o')
backend.drawRune(3, 1, 'w') // backend.drawRune(3, 1, 'w')
backend.drawRune(4, 1, 'n') // backend.drawRune(4, 1, 'n')
backend.drawRune(6, 1, 'f') // backend.drawRune(6, 1, 'f')
backend.drawRune(7, 1, 'o') // backend.drawRune(7, 1, 'o')
backend.drawRune(8, 1, 'x') // backend.drawRune(8, 1, 'x')
backend.drawCells(true)
backend.canvas.XSurfaceSet(backend.window.Id) backend.canvas.XSurfaceSet(backend.window.Id)
backend.canvas.XDraw() backend.canvas.XDraw()
backend.canvas.XPaint(backend.window.Id) backend.canvas.XPaint(backend.window.Id)
} }
func (backend *Backend) drawCells (forceRedraw bool) (areas []image.Rectangle) {
width, height := backend.application.Size()
for y := 0; y < height; y ++ {
for x := 0; x < width; x ++ {
if !forceRedraw && backend.application.Clean(x, y) { continue }
backend.application.MarkClean(x, y)
cell := backend.application.Cell(x, y)
content := cell.Rune()
if content < 32 { continue }
backend.drawRune(x, y, content)
}}
return
}
func (backend *Backend) updateWindowAreas (areas ...image.Rectangle) {
backend.canvas.XPaintRects(backend.window.Id, areas...)
}
func (backend *Backend) drawRune (x, y int, character rune) { func (backend *Backend) drawRune (x, y int, character rune) {
// TODO: cache these draws as non-transparent buffers with the // TODO: cache these draws as non-transparent buffers with the
// application background color as the background. that way, we won't // application background color as the background. that way, we won't