tiny command line application

tiny command line application

· json · rss
#golang 
View url →

About

From last post, I suspend my Go learning. But I never forgot it.

So if you got an app that output the log, that's OK. But if you want check frequently with same object's information, it should post it in the fixed position. How to stick it in the same place?

I tried termbox-go at first. Not go well as my expectation. But I got an clue in the Readme. So I used tview finally. It is very easy to use.

app := tview.NewApplication()
table := tview.NewTable().SetBorders(true)
....
if err := app.SetRoot(table, true).Run(); err != nil {
    panic(err)
}

Create an application with table, then run it. That's all you need done.

I recommend you follow the demo project to practise. So back the question, how to show the information at fixed position?

table.SetCell(rec.Index, 0, tview.NewTableCell(rec.Time).SetTextColor(tcell.ColorDarkGray).SetAlign(tview.AlignLeft))
app.Draw()

When you get data asynchronies, update it at the known place, and don't forget repaint the screen with last line code.