// ANSI Terminal Escape Codes and helpers package terminal import "fmt" const ClearLine = "\x1b[K" const ClearScreen = "\x1b[2J" const HideCursor = "\x1b[?25l" const ShowCursor = "\x1b[?25h" const ResetCursor = "\x1b[H" const KeyArrowUp = "\x1b[A" const KeyArrowDown = "\x1b[B" const KeyArrowRight = "\x1b[C" const KeyArrowLeft = "\x1b[D" func Code (s string) string { return fmt.Sprintf("\x1b[%s", s) } // Move the terminal cursor to the 0-based coordinate func MoveCursor(x int, y int) string { // Allow 0-based indexing, the terminal code is 1-based x += 1 y += 1 return Code(fmt.Sprintf("%d;%dH", y, x)) }