diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/helper/incremental_print.go | 19 | ||||
-rw-r--r-- | utils/ncfmt/effects.go (renamed from utils/helper/effects.go) | 2 | ||||
-rw-r--r-- | utils/ncfmt/incremental_print.go | 30 |
3 files changed, 31 insertions, 20 deletions
diff --git a/utils/helper/incremental_print.go b/utils/helper/incremental_print.go deleted file mode 100644 index c94f904..0000000 --- a/utils/helper/incremental_print.go +++ /dev/null @@ -1,19 +0,0 @@ -package helper - -import ( - "time" - - . "github.com/gbin/goncurses" -) - -func IncrementalPrint(scr *Window, text string, from_y int, from_x int, interval_millis int) { - for i:=0; i < len(text); i++ { - ch := string([]rune(text)[i]) - _, mx := scr.MaxYX() - cy := i / mx + from_y - cx := i % mx + 1 - scr.MovePrint(cy, cx, ch) - time.Sleep( time.Duration(1000 / len(text)) * time.Millisecond) - scr.Refresh() - } -} diff --git a/utils/helper/effects.go b/utils/ncfmt/effects.go index ff9a93a..170ed11 100644 --- a/utils/helper/effects.go +++ b/utils/ncfmt/effects.go @@ -1,4 +1,4 @@ -package helper +package ncfmt import ( "fmt" diff --git a/utils/ncfmt/incremental_print.go b/utils/ncfmt/incremental_print.go new file mode 100644 index 0000000..8ab0f05 --- /dev/null +++ b/utils/ncfmt/incremental_print.go @@ -0,0 +1,30 @@ +package ncfmt + +import ( + "time" + + . "github.com/gbin/goncurses" +) + +func IncrementalPrintMany( + w *Window, + y int, + x int, + texts []string, + duration time.Duration, +) { + for i := 0; i < len(texts); i++ { + IncrementalPrint(w, texts[i], y+i, x, int(1*time.Second)) + } +} +func IncrementalPrint(scr *Window, text string, from_y int, from_x int, interval_millis int) { + for i := 0; i < len(text); i++ { + ch := string([]rune(text)[i]) + _, mx := scr.MaxYX() + cy := i/mx + from_y + cx := i%mx + 1 + scr.MovePrint(cy, cx, ch) + time.Sleep(time.Duration(1000/len(text)) * time.Millisecond) + scr.Refresh() + } +} |