Pass keyboard events through application

This commit is contained in:
2022-11-06 15:12:44 -05:00
parent f6b8d9903b
commit ff7240d553
3 changed files with 43 additions and 7 deletions

View File

@@ -14,9 +14,18 @@ func main () {
func run (application *stone.Application) {
currentTime := time.Time { }
frameDelay := time.Second / 2
textBuffer := ""
for {
if application.Resized() || time.Since(currentTime) > frameDelay {
typed := application.Typed()
textBuffer += typed
shouldRender :=
application.Resized() ||
time.Since(currentTime) > frameDelay ||
len(typed) > 0
if shouldRender {
currentTime = time.Now()
application.ResetDot()
@@ -34,7 +43,10 @@ func run (application *stone.Application) {
application.SetRune(5, 1, ':')
application.SetRune(6, 1, rune(second / 10 + 48))
application.SetRune(7, 1, rune(second % 10 + 48))
application.Dot.X = 0
application.Dot.Y = 2
fmt.Fprintln(application, textBuffer)
}
if !application.Await(frameDelay) { break }