2024-03-18 09:13:29 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
2024-04-03 09:02:33 +02:00
|
|
|
"os"
|
2024-03-18 09:13:29 +01:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/gdamore/tcell/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
fmt.Println()
|
2024-04-03 09:02:33 +02:00
|
|
|
screen, err := tcell.NewScreen()
|
2024-03-18 09:13:29 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("%v", err)
|
|
|
|
}
|
2024-04-03 09:02:33 +02:00
|
|
|
if err := screen.Init(); err != nil {
|
2024-03-18 09:13:29 +01:00
|
|
|
log.Fatalf("%v", err)
|
|
|
|
}
|
2024-04-12 08:21:45 +02:00
|
|
|
x, y := 0, 0
|
2024-03-18 09:13:29 +01:00
|
|
|
|
|
|
|
//defStyle := tcell.StyleDefault.Background
|
|
|
|
defStyle := tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorReset)
|
2024-04-03 09:02:33 +02:00
|
|
|
screen.SetStyle(defStyle)
|
2024-04-12 08:21:45 +02:00
|
|
|
go Run(x, y, screen, defStyle)
|
2024-04-03 09:02:33 +02:00
|
|
|
|
2024-03-18 09:13:29 +01:00
|
|
|
for {
|
2024-04-03 09:02:33 +02:00
|
|
|
switch event := screen.PollEvent().(type) {
|
|
|
|
case *tcell.EventResize:
|
|
|
|
screen.Sync()
|
|
|
|
case *tcell.EventKey:
|
|
|
|
switch event.Key() == tcell.KeyEscape || event.Key() == tcell.KeyCtrlC {
|
|
|
|
case true:
|
|
|
|
screen.Fini()
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-03-18 09:13:29 +01:00
|
|
|
|
2024-04-03 09:02:33 +02:00
|
|
|
}
|
2024-03-18 09:13:29 +01:00
|
|
|
|
2024-04-12 08:21:45 +02:00
|
|
|
func Run(x int, y int, screen tcell.Screen, defStyle tcell.Style) {
|
2024-04-03 09:02:33 +02:00
|
|
|
for {
|
2024-04-12 08:21:45 +02:00
|
|
|
screen.SetContent(x, y, 'A', nil, defStyle)
|
2024-04-03 09:02:33 +02:00
|
|
|
screen.Show()
|
2024-04-12 08:21:45 +02:00
|
|
|
x++
|
|
|
|
y++
|
2024-03-18 09:13:29 +01:00
|
|
|
time.Sleep(time.Second)
|
|
|
|
}
|
|
|
|
}
|