Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The last line is being overwritten when width of the buffer exceeds screen width #3

Closed
gosuri opened this issue Dec 8, 2015 · 2 comments

Comments

@gosuri
Copy link
Owner

gosuri commented Dec 8, 2015

The last line seems to be overwritten when width of the buffer exceeds screen width:

screen shot 2015-12-08 at 11 11 19

Code:

package main

import (
    "fmt"
    "time"

    "github.com/gosuri/uilive"
)

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

    // start listening for updates and render
    writer.Start()

    str := ""
    for i := 0; i <= 100; i++ {
        str = str + "s"
    }
    str = str + "[end]"

    for i := 0; i <= 100; i++ {
        fmt.Fprintf(writer, "%d %s\n", i, str)
        time.Sleep(time.Second)
    }

    writer.Stop() // flush and stop rendering
}

(Ref #2)

@gosuri gosuri changed the title The last is being overwritten when width of the buffer exceeds screen width The last line is being overwritten when width of the buffer exceeds screen width Dec 9, 2015
apoorvam added a commit to apoorvam/uilive that referenced this issue Dec 10, 2015
…t work for windows. | gosuri#3

    This gets the terminal size and validates if buffer width exceeds screen width.
@apoorvam
Copy link

This commit on my fork works for windows too. It has a dependency on github.com/nsf/termbox-go.

Example code which works with this forked package:

package main

import (
    "fmt"
    "time"

    "github.com/apoorva/uilive"
)

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

    // start listening for updates and render
    writer.Start()
    uilive.InitializeTerminalWidth()

    str := ""
    for i:=0; i<200; i++ {
        str += "s"
    }

    str += "[end]"

    for i := 0; i <= 100; i++ {
        fmt.Fprintf(writer, "%d %s\n", i, str)
        time.Sleep(time.Second)
    }

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

@asahasrabuddhe
Copy link
Collaborator

This might be late for you but I think this could be helpful for you or someone else who might stumble over this issue:

I have made a fork of this library and have managed to fix most of the issues. I would gladly do a PR here if @gosuri is interested in reviving this package. Until then, we could collaborate and keep this wonderful package alive right here: https://github.com/asahasrabuddhe/uilive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants