gizak / termui

Golang terminal dashboard
MIT License
13.14k stars 787 forks source link

Clear and render new grid? #91

Closed Kugelschieber closed 8 years ago

Kugelschieber commented 8 years ago

How can I clear the terminal and render a new grid? I'm trying to implement multiple views the user can switch between. The first one uses termui.Body. But when I add new rows and call render, they are appended (of course). I tried reinitializing the Body

termui.Body = termui.NewGrid(...)

and creating a separate grid:

grid := termui.newGrid(...)
grid.Align()
termui.Render(grid)

But both result in an empty terminal.

anujkhare commented 8 years ago

You could reinitialize the slice termui.Body.Rows by using:

termui.Body.Rows = []*termui.Body.Rows{}

I am new to Go, so not sure if this is the best way to do this.

miguelmota commented 7 years ago

To reset, before AddRows I did:

ui.Body.Rows = ui.Body.Rows[:0]