From 8b0e3e29e6af32b8bd1be7f3f34c92e66d9d0e82 Mon Sep 17 00:00:00 2001 From: joop Date: Sat, 2 Apr 2022 06:02:33 +0100 Subject: Add clear screen and repetition of the prayer for better UX --- main.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 1976f7f..0de1cea 100644 --- a/main.go +++ b/main.go @@ -329,11 +329,13 @@ func main() { break } } - // Present the text, id and author of the prayer - fmt.Println(prayer.Text) - fmt.Println("ID:", prayer.Id) - fmt.Println("Author:", prayer.Author()) for code == "" { + // Clear the screen + fmt.Print("\033[H\033[2J") + // Present the text, id and author of the prayer + fmt.Println(prayer.Text) + fmt.Println("ID:", prayer.Id) + fmt.Println("Author:", prayer.Author()) // Ask for a keyword fmt.Print("Input a keyword for this prayer, skip to pick another one or code to enter the code manually: ") keyword := prompt.MustRead[string]() @@ -376,6 +378,12 @@ func main() { if answer == "skip" { break } + // If the answer is not y or skip, clear the screen + fmt.Print("\033[H\033[2J") + // Present the text, id and author of the prayer again + fmt.Println(prayer.Text) + fmt.Println("ID:", prayer.Id) + fmt.Println("Author:", prayer.Author()) } } if code != "" { -- cgit v1.2.3-70-g09d2