这是indexloc提供的服务,不要输入任何密码
Skip to content

glitch when the writer RefreshInterval is too little #9

@renannprado

Description

@renannprado

When the RefreshInterval is too little like time.Nanosecond little or 0, you should use writer.Wait() to be able to use the library, but still the text glitches a little. And when you do not use the writer.Wait(), the library isn't able to replace the text and start to act almost like a regular fmt.Println.

package main

import (
        "fmt"

        "github.com/gosuri/uilive"
)

func main() {
        writer := uilive.New()

        // start listening for updates and render
        writer.RefreshInterval = 0

        writer.Start()

        for _, f := range []string{"Foo.zip", "Bar.iso"} {
                for i := 0; i <= 5000000; i++ {
                        fmt.Fprintf(writer, "Downloading %s.. (%d/%d) GB\n", f, i, 50)
                        writer.Wait()
                }
                fmt.Fprintf(writer.Bypass(), "Downloaded %s\n", f)
        }

        fmt.Fprintln(writer, "Finished: Downloaded 100GB")
        writer.Stop() // flush and stop rendering
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions