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

Combining with uitable causes leading whitespace #35

@jtyers

Description

@jtyers

Just come across your trio of console UI libraries, they look awesome!

One bug I've found is when combining this with uitable. Here's my code:

	writer := uilive.New()
	bufferedWriter := writer.Bypass()
	writer.Start()

	for i := 0; i <= 100; i++ {
		table := uitable.New()
		table.MaxColWidth = 50

		table.AddRow("Operation", "Progress", "%%")
		table.AddRow("Downloading", fmt.Sprintf("%d/%d", i, 100), fmt.Sprintf("%d", i/100))
		table.AddRow("And another", fmt.Sprintf("%d/%d", i*2, 1000), fmt.Sprintf("%d", (i*2)/1000))

		fmt.Fprintf(bufferedWriter, table.String())
		writer.Flush()
		time.Sleep(time.Millisecond * 500)
	}

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

And here's some output:

                                  Operation  	Progress	%
Downloading	35/100  	0 
And another	70/1000 	0

As you can see the top row of the table is indented by spaces. Is this easy to fix? As you can see above I am using .Newline(). I did also try writing direct to writer, but that still causes the bug. If I use .Bypass() then the indent goes away but then the table is echoed many times to the terminal as it updates. Removing .Flush() makes no difference.

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