How to display data in a tabular format using gocui in Golang?

200 views Asked by At

I'm working on a Go project using the gocui library for creating a terminal-based user interface. I have a list of results that I want to display in a tabular format with multiple columns. However, I'm having trouble achieving the desired layout.

I have earlier used termbox-go library and achieved the output using this code:

func renderText(row, column int, text string) {
    for i, char := range text {
        termbox.SetCell(column+i, row, char, termbox.ColorDefault, termbox.ColorDefault)
    }
}

I have tried doing this with gocui but it didn't work:

func renderText(v *gocui.View, row, column int, text string) {
    v.Write([]byte(fmt.Sprintf("\033[%d;%dH%s", row+1, column, text)))
}

I am new to golang so any help would be appreciated.

1

There are 1 answers

0
Kurtis Rader On

The documentation has a MoveCursor method that seems to be what you're looking for.