Advertisement
Guest User

Untitled

a guest
Aug 10th, 2023
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. package main
  2.  
  3. import "os"
  4. import "time"
  5. import "fmt"
  6.  
  7. import "github.com/nsf/termbox-go"
  8. import "github.com/mattn/go-runewidth"
  9.  
  10. func main() {
  11. err := termbox.Init()
  12.  
  13. if err != nil {
  14. fmt.Println(err)
  15. os.Exit(1)
  16. }
  17.  
  18. tbprint(2, 2, termbox.ColorRed, termbox.ColorDefault, "Hello terminal!")
  19. termbox.Flush()
  20.  
  21. time.Sleep(time.Second)
  22. termbox.Close()
  23. }
  24.  
  25. // This function is often useful:
  26. func tbprint(x, y int, fg, bg termbox.Attribute, msg string) {
  27. for _, c := range msg {
  28. termbox.SetCell(x, y, c, fg, bg)
  29. x += runewidth.RuneWidth(c)
  30. }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement