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

Print logs on top and bar at bottom #42

@fenollp

Description

@fenollp

In trying to reproduce the apt progress bar I adapted https://github.com/gosuri/uiprogress/blob/ec0f254bbca2b17ed68f18af8773a0527b522f01/example/simple/simple.go so that some lines are printed:

package main

import (
        "time"
        "fmt"

        "github.com/gosuri/uiprogress"
)

func main() {
        uiprogress.Start()            // start rendering
        bar := uiprogress.AddBar(100) // Add a new bar

        // optionally, append and prepend completion and elapsed time
        bar.AppendCompleted()
        bar.PrependElapsed()

        i := 0
        for bar.Incr() {
                time.Sleep(time.Millisecond * 20)
                i++
                if i % 10 == 0 {
                        fmt.Println("Well hello there")
                }
        }
}

I'd like for the lines to print above the progress bar, which would stay at the bottom. However I'm only getting duplicated progress and only one line printed (also not at the right place but I'm sure that's another issue):

   0s [=====>--------------------------------------------------------------]  10%
   0s [============>-------------------------------------------------------]  20%
   0s [===================>------------------------------------------------]  30%
   0s [==========================>-----------------------------------------]  40%
   0s [=================================>----------------------------------]  50%
   1s [========================================>---------------------------]  60%
   1s [===============================================>--------------------]  70%
   1s [======================================================>-------------]  80%
   1s [=============================================================>------]  90%
   1s [====================================================================] 100%
Well hello there

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