-1

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.

3
  • 1
    Insufficient information. Your program is not a minimal reproducible example. You didn't tell us which gocui package you're using. You say "didn't work" but should tell us what actually happened. Finally, if you're using github.com/jroimartin/gocui why are you hand crafting the ANSI escape sequence to move the cursor? The whole point of using a package like gocui is to avoid having to do that. Commented Jul 13, 2023 at 23:32
  • @KurtisRader that's why i am asking how to do that in gocui library since the library is for that purpose. Now I don't know which other package is also known as gocui. Not answering questions is not the way to go. I did not find anything regarding my question in the documentation. If I would've found i would not have asked it here. Commented Jul 14, 2023 at 13:16
  • You may want to read How to Ask Commented Jul 14, 2023 at 22:38

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.