本文整理汇总了Golang中github.com/gizak/termui.NewRow函数的典型用法代码示例。如果您正苦于以下问题:Golang NewRow函数的具体用法?Golang NewRow怎么用?Golang NewRow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewRow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: showMessages
func (ui *tatui) showMessages() {
ui.current = uiMessages
ui.selectedPane = uiMessages
ui.send.BorderLabel = " ✎ Action or New Message "
termui.Body.Rows = nil
ui.selectedPaneMessages = 0
if len(ui.currentListMessages) == 0 {
ui.currentListMessages[0] = nil
}
if _, ok := ui.uilists[uiTopics]; !ok || len(ui.uilists[uiTopics]) == 0 {
ui.msg.Text = "Please select a topic before doing this action"
ui.showHome()
return
}
if _, ok := ui.currentFilterMessages[ui.currentTopic.Topic]; !ok {
ui.clearFilterOnCurrentTopic()
}
ui.initMessages()
go func() {
for {
if ui.current != uiMessages {
break
}
mutex.Lock()
ui.updateMessages()
ui.firstCallMessages = true
mutex.Unlock()
time.Sleep(5 * time.Second)
}
}()
ui.uilists[uiTopics][0].list.BorderRight = true
ui.prepareTopMenu()
if len(ui.currentFilterMessages[ui.currentTopic.Topic]) > 1 {
// preserve order
for k := 0; k < len(ui.currentFilterMessages[ui.currentTopic.Topic]); k++ {
termui.Body.AddRows(termui.NewRow(termui.NewCol(12, 0, ui.uilists[uiMessages][k].list)))
}
} else {
termui.Body.AddRows(
termui.NewRow(
termui.NewCol(3, 0, ui.uilists[uiTopics][0].list),
termui.NewCol(9, 0, ui.uilists[uiMessages][0].list),
),
)
}
ui.prepareSendRow()
ui.colorizedPanes()
termui.Clear()
ui.render()
}
示例2: AdjustMemory
func (t *TerminalUI) AdjustMemory(stats Statistics) {
// memory gauges
mem := make([]*ui.Gauge, len(stats.Instances))
for i, idx := range stats.Instances {
// show max 8 instances
if i > 7 {
break
}
memory := uint64(stats.Data[idx].Stats.Usage.Memory)
quota := uint64(stats.Data[idx].Stats.MemoryQuota)
percent := int(math.Ceil((float64(memory) / float64(quota)) * 100.0))
mem[i] = ui.NewGauge()
mem[i].Percent = percent
mem[i].Height = 13 - min(len(stats.Instances), 8)
mem[i].Border.Label = fmt.Sprintf("Memory - Instance %d: %d%% (%s / %s)",
i, percent, bytefmt.ByteSize(memory), bytefmt.ByteSize(quota))
mem[i].Border.FgColor = ui.ColorWhite
mem[i].Border.LabelFgColor = ui.ColorWhite
mem[i].BarColor = colors[i%6]
mem[i].PercentColor = ui.ColorWhite
}
t.Memory = mem
// update layout
ui.Body.Rows = []*ui.Row{
ui.NewRow(
ui.NewCol(3, 0, t.Usage),
ui.NewCol(3, 0, t.Summary),
ui.NewCol(6, 0, t.Disk)),
ui.NewRow(
ui.NewCol(6, 0, t.CPU),
t.newMemCol(6, 0, t.Memory)),
}
}
示例3: main
func main() {
err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close()
w11 := ui.NewPar("Hello world")
w11.Height = 10
w11.Border.Label = "Hello"
w11.Border.LabelFgColor = ui.ColorGreen
w12 := ui.NewPar("first")
w12.Height = 20
w2 := ui.NewPar("second")
w2.Height = 20
ui.Body.AddRows(
ui.NewRow(
ui.NewCol(6, 0, w11),
ui.NewCol(6, 0, w12)),
ui.NewRow(
ui.NewCol(12, 0, w2)))
ui.Body.Align()
ui.Render(ui.Body)
<-ui.EventCh()
}
示例4: BuildUI
func BuildUI() {
ui.Init()
defer ui.Close()
receiveBox := CreateReceiveBox()
sendBox := CreateSendBox()
ui.Body.AddRows(
ui.NewRow(ui.NewCol(12, 0, receiveBox)),
ui.NewRow(ui.NewCol(12, 0, sendBox)),
)
ui.Body.Align()
ui.Render(ui.Body)
ui.Handle("/sys/kbd/C-x", func(e ui.Event) {
ui.StopLoop()
})
ui.Handle("/timer/1s", func(e ui.Event) {
ReceiveBoxHeight = ui.TermHeight() - SendBoxHeight
receiveBox.Height = ReceiveBoxHeight
ui.Body.Align()
ui.Render(ui.Body)
})
// Leaving this commented out for now
// I'd like to get this method of screen refreshing working instead of the 1s method,
// but this crashes on resize.
// ui.Handle("/sys/wnd/resize", func(e ui.Event) {
// ui.Body.Align()
// ui.Render(ui.Body)
// })
ui.Loop()
}
示例5: SwitchToView
func (v *ViewRPS) SwitchToView() View {
ResetView()
termui.Body.AddRows(
termui.NewRow(
termui.NewCol(3, 0, v.mongosWidget.Widget()),
termui.NewCol(3, 0, v.chunks[0].Widget(), v.chunks[1].Widget(), v.chunks[2].Widget()),
termui.NewCol(3, 0, widgets.Migration().Widget()),
),
termui.NewRow(
termui.NewCol(3, 0, v.replicas[0].Widget()),
termui.NewCol(3, 0, v.replicas[1].Widget()),
termui.NewCol(3, 0, v.replicas[2].Widget()),
),
termui.NewRow(
termui.NewCol(3, 0, v.replicas[3].Widget()),
termui.NewCol(3, 0, v.replicas[4].Widget()),
termui.NewCol(3, 0, v.replicas[5].Widget()),
),
termui.NewRow(
termui.NewCol(3, 0, v.replicas[6].Widget()),
termui.NewCol(3, 0, v.replicas[7].Widget()),
termui.NewCol(3, 0, v.replicas[8].Widget()),
),
)
// calculate layout
termui.Body.Align()
return v
}
示例6: Start
func (s *Stats) Start() {
s.cfUI.Say("Starting Stats...")
err := termui.Init()
if err != nil {
s.cfUI.Warn(err.Error())
return
}
defer termui.Close()
go func() {
sinkTypeChart := &charts.SinkTypeChart{}
sinkTypeChart.Init(s.cfUI)
uaaChart := &charts.UAAChart{}
uaaChart.Init(s.cfUI)
msgLossChart := &charts.MsgLossChart{}
msgLossChart.Init(s.cfUI)
notesChart := &charts.NotesChart{}
notesChart.Init()
s.client.Sift(
[]charts.Chart{
sinkTypeChart,
uaaChart,
msgLossChart,
},
)
termui.Body.AddRows(
termui.NewRow(
termui.NewCol(6, 0, sinkTypeChart),
termui.NewCol(6, 0, uaaChart),
),
termui.NewRow(
termui.NewCol(6, 0, msgLossChart),
termui.NewCol(6, 0, notesChart),
),
)
for {
termui.Body.Align()
termui.Render(termui.Body)
time.Sleep(1 * time.Second)
}
}()
termui.Handle("/sys/kbd/q", func(termui.Event) {
termui.StopLoop()
})
termui.Loop()
}
示例7: initWidgets
// TODO make new widget traffic light
// Waiting for canvas from termui
func initWidgets() (*ui.List, *ui.Par, *ui.Par, *ui.Par, *ui.Par) {
ui.UseTheme("Jenkins Term UI")
title := "q to quit - " + *jenkinsUrl
if *filter != "" {
title += " filter on " + *filter
}
p := ui.NewPar(title)
_, h := tm.Size()
p.Height = 3
p.TextFgColor = ui.ColorWhite
p.Border.Label = "Go Jenkins Dashboard"
p.Border.FgColor = ui.ColorCyan
info := ui.NewPar("")
info.Height = 3
info.Y = h - 3
info.TextFgColor = ui.ColorWhite
info.Border.FgColor = ui.ColorWhite
ls := ui.NewList()
ls.ItemFgColor = ui.ColorYellow
ls.Border.Label = "Jobs"
ls.Y = 3
ls.Height = h - 6
width, height := 4, 5
redbox, yellowbox, greenbox := ui.NewPar(""), ui.NewPar(""), ui.NewPar("")
redbox.HasBorder, yellowbox.HasBorder, greenbox.HasBorder = false, false, false
redbox.Height, yellowbox.Height, greenbox.Height = height, height, height
redbox.Width, yellowbox.Width, greenbox.Width = width, width, width
redbox.BgColor = ui.ColorRed
yellowbox.BgColor = ui.ColorYellow
greenbox.BgColor = ui.ColorGreen
ui.Body.AddRows(
ui.NewRow(
ui.NewCol(12, 0, p),
),
ui.NewRow(
ui.NewCol(10, 0, ls),
ui.NewCol(2, 0, redbox, yellowbox, greenbox),
),
ui.NewRow(
ui.NewCol(12, 0, info),
),
)
ui.Body.Align()
ui.Render(ui.Body)
return ls, info, redbox, yellowbox, greenbox
}
示例8: SwitchToView
func (v *ViewMain) SwitchToView() View {
ResetView()
statusRow := termui.NewRow(
termui.NewCol(12, 0, v.statusBar.Widget()),
)
termui.Body.AddRows(
termui.NewRow(
termui.NewCol(3, 0, v.serverW_mongos.Widget()),
termui.NewCol(3, 0, v.shards[0][0].Widget()),
termui.NewCol(3, 0, v.shards[1][0].Widget()),
termui.NewCol(3, 0, v.shards[2][0].Widget()),
),
termui.NewRow(
termui.NewCol(3, 0, nil),
termui.NewCol(3, 0, v.shards[0][1].Widget()),
termui.NewCol(3, 0, v.shards[1][1].Widget()),
termui.NewCol(3, 0, v.shards[2][1].Widget()),
),
termui.NewRow(
termui.NewCol(3, 0, nil),
termui.NewCol(3, 0, v.shards[0][2].Widget()),
termui.NewCol(3, 0, v.shards[1][2].Widget()),
termui.NewCol(3, 0, v.shards[2][2].Widget()),
),
/*
termui.NewRow(
termui.NewCol(1, 0, v.rpsWidgets[0].Widget()),
termui.NewCol(1, 1, v.rpsWidgets[1].Widget()),
termui.NewCol(1, 0, v.rpsWidgets[2].Widget()),
termui.NewCol(1, 0, v.rpsWidgets[3].Widget()),
termui.NewCol(1, 0, v.rpsWidgets[4].Widget()),
termui.NewCol(1, 0, v.rpsWidgets[5].Widget()),
termui.NewCol(1, 0, v.rpsWidgets[6].Widget()),
termui.NewCol(1, 0, v.rpsWidgets[7].Widget()),
termui.NewCol(1, 0, v.rpsWidgets[8].Widget()),
termui.NewCol(1, 0, v.rpsWidgets[9].Widget()),
),
*/
statusRow,
)
// calculate layout
termui.Body.Align()
return v
}
示例9: setupBody
func setupBody() {
height := termui.TermHeight() - 23
prompt := termui.NewPar("")
prompt.Height = 1
prompt.Border = false
parMap["prompt"] = prompt
input := termui.NewPar("")
input.Height = 3
input.BorderLabel = "Input"
input.BorderFg = termui.ColorYellow
parMap["input"] = input
moveHistory := termui.NewPar("")
moveHistory.Height = height - 4
moveHistory.BorderLabel = "Move History"
moveHistory.BorderFg = termui.ColorBlue
parMap["moveHistory"] = moveHistory
linesMap["moveHistory"] = NewLines()
output := termui.NewPar("")
output.Height = height
output.BorderLabel = "Output"
output.BorderFg = termui.ColorGreen
parMap["output"] = output
linesMap["output"] = NewLines()
board := termui.NewPar("")
board.Height = 23
board.Width = 37
board.BorderLabel = "Board"
board.BorderFg = termui.ColorRed
parMap["board"] = board
// build layout
termui.Body.AddRows(
termui.NewRow(
termui.NewCol(6, 0, parMap["prompt"], parMap["input"], parMap["moveHistory"]),
termui.NewCol(6, 0, parMap["output"]),
),
termui.NewRow(
termui.NewCol(12, 0, parMap["board"]),
),
)
changeState(0)
}
示例10: Start
func (m *Monitor) Start(conn *net.Conn) {
if err := ui.Init(); err != nil {
panic(err)
}
defer ui.Close()
help := ui.NewPar(":PRESS q TO QUIT")
help.Height = 3
help.Width = 50
help.TextFgColor = ui.ColorWhite
help.BorderLabel = "Help"
help.BorderFg = ui.ColorCyan
// build
ui.Body.AddRows(
ui.NewRow(
ui.NewCol(6, 0, help),
),
)
draw := func(t int) {
ui.Body.Align()
ui.Render(ui.Body)
}
draw(0)
ui.Handle("/sys/kbd/q", func(ui.Event) {
ui.StopLoop()
})
ui.Handle("/timer/1s", func(e ui.Event) {
t := e.Data.(ui.EvtTimer)
draw(int(t.Count))
})
ui.Loop()
}
示例11: addSparkLine
func addSparkLine(serviceName string, titles []string, color ui.Attribute) *ui.Sparklines {
var sparkLines []ui.Sparkline
for _, title := range titles {
sparkLine := ui.NewSparkline()
sparkLine.Height = 1
sparkLine.Data = []int{}
sparkLine.Title = title
sparkLine.TitleColor = titleColor
sparkLine.LineColor = color
sparkLines = append(sparkLines, sparkLine)
}
sp := ui.NewSparklines(sparkLines...)
sp.Height = 11
sp.BorderLabel = serviceName
ui.Body.AddRows(
ui.NewRow(ui.NewCol(12, 0, sp)),
)
ui.Body.Align()
ui.Render(sp)
ui.Render(ui.Body)
return sp
}
示例12: main
func main() {
err := ui.Init()
fmt.Println(daemon.UpSince())
if err != nil {
fmt.Println("Could not initialise UI")
}
defer ui.Close()
ut, _ := daemon.Uptime()
p := ui.NewPar(ut.String())
p.Height = 3
p.Width = 50
p.TextFgColor = ui.ColorWhite
p.Border.Label = "Uptime"
p.Border.FgColor = ui.ColorCyan
g0 := ui.NewGauge()
g0.Percent = 40
g0.Width = 50
g0.Height = 3
g0.Border.Label = "Memory"
g0.BarColor = ui.ColorRed
g0.Border.FgColor = ui.ColorWhite
g0.Border.LabelFgColor = ui.ColorCyan
g2 := ui.NewGauge()
g2.Percent = 60
g2.Width = 50
g2.Height = 3
g2.PercentColor = ui.ColorBlue
g2.Y = 3
g2.Border.Label = "CPU"
g2.BarColor = ui.ColorYellow
g2.Border.FgColor = ui.ColorWhite
ui.Body.AddRows(ui.NewRow(ui.NewCol(6, 0, g0), ui.NewCol(6, 0, p)),
ui.NewRow(ui.NewCol(6, 0, g2)))
ui.Body.Align()
ui.Render(ui.Body)
go updateMemCPU(g2, g0)
go updateUptime(p)
<-ui.EventCh()
}
示例13: render
// render Paints the different widgest that compose Lazarus
func render(ctx *cli.Context) {
err := termui.Init()
if err != nil {
panic(err)
}
ui.Title.Label = fmt.Sprintf("*********** %s (%s) ***********", ctx.App.Name, ctx.App.Version)
termui.Body.AddRows(
termui.NewRow(
termui.NewCol(12, 0, ui.Title),
),
termui.NewRow(
termui.NewCol(12, 0, ui.Songs),
),
termui.NewRow(
termui.NewCol(6, 0, ui.Quit),
),
)
}
示例14: prepareTopMenu
func (ui *tatui) prepareTopMenu() {
if !strings.Contains(ui.uiTopicCommands[ui.currentTopic.Topic], " /hide-top") {
termui.Body.AddRows(
termui.NewRow(
termui.NewCol(4, 0, ui.header),
termui.NewCol(6, 0, ui.msg),
termui.NewCol(2, 0, ui.lastRefresh),
),
)
}
}
示例15: prepareSendRow
func (ui *tatui) prepareSendRow() {
if strings.Contains(ui.uiTopicCommands[ui.currentTopic.Topic], " /hide-bottom") {
return
}
if !strings.Contains(ui.uiTopicCommands[ui.currentTopic.Topic], " /hide-top") {
termui.Body.AddRows(
termui.NewRow(
termui.NewCol(12, 0, ui.send),
),
)
} else {
termui.Body.AddRows(
termui.NewRow(
termui.NewCol(5, 0, ui.send),
termui.NewCol(5, 0, ui.msg),
termui.NewCol(2, 0, ui.lastRefresh),
),
)
}
}