• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang termui.NewCol函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/gizak/termui.NewCol函数的典型用法代码示例。如果您正苦于以下问题:Golang NewCol函数的具体用法?Golang NewCol怎么用?Golang NewCol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewCol函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
}
开发者ID:ovh,项目名称:tatcli,代码行数:60,代码来源:messages.go


示例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)),
	}
}
开发者ID:swisscom,项目名称:cf-statistics-plugin,代码行数:35,代码来源:terminal.go


示例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()

}
开发者ID:plumbum,项目名称:go-samples,代码行数:33,代码来源:main.go


示例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()
}
开发者ID:mhoc,项目名称:river,代码行数:35,代码来源:ui.go


示例5: 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()

}
开发者ID:wfernandes,项目名称:firehose-stats,代码行数:55,代码来源:stats.go


示例6: 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),
			),
		)
	}
}
开发者ID:ovh,项目名称:tatcli,代码行数:11,代码来源:ui.go


示例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
}
开发者ID:mikepea,项目名称:goJenkinsDashboard,代码行数:53,代码来源:goJenkinsDashboard.go


示例8: 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)
}
开发者ID:marktai,项目名称:T9-Terminal,代码行数:48,代码来源:ui.go


示例9: 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()
}
开发者ID:fasmide,项目名称:lagpipe,代码行数:35,代码来源:Monitor.go


示例10: 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
}
开发者ID:catalyzeio,项目名称:cli,代码行数:25,代码来源:spark.go


示例11: showHome

func (ui *tatui) showHome() {
	ui.current = uiHome
	ui.selectedPane = uiActionBox
	termui.Body.Rows = nil

	ui.prepareTopMenu()

	termui.Body.AddRows(
		termui.NewRow(
			termui.NewCol(5, 0, ui.homeLeft),
			termui.NewCol(7, 0, ui.homeRight),
		),
	)
	ui.prepareSendRow()
	termui.Clear()
	ui.colorizedPanes()
	ui.render()
}
开发者ID:ovh,项目名称:tatcli,代码行数:18,代码来源:home.go


示例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()
}
开发者ID:nindalf,项目名称:gotop,代码行数:43,代码来源:main.go


示例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),
		),
	)
}
开发者ID:avadhutp,项目名称:lazarus,代码行数:21,代码来源:main.go


示例14: 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),
			),
		)
	}
}
开发者ID:ovh,项目名称:tatcli,代码行数:20,代码来源:ui.go


示例15: draw

func draw() {
	display = ui.NewPar("")
	display.Height = 1
	display.Border = false

	prompt = ui.NewPar(promptMsg)
	prompt.Height = 1
	prompt.Border = false

	help := ui.NewPar(`:c, :h for profiles; :f to filter; ↓ and ↑ to paginate`)
	help.Height = 1
	help.Border = false
	help.TextBgColor = ui.ColorBlue
	help.Bg = ui.ColorBlue
	help.TextFgColor = ui.ColorWhite

	gs := ui.Sparkline{}
	gs.Title = "goroutines"
	gs.Height = 4
	gs.LineColor = ui.ColorCyan

	ts := ui.Sparkline{}
	ts.Title = "threads"
	ts.Height = 4
	ts.LineColor = ui.ColorCyan

	sp = ui.NewSparklines(gs, ts)
	sp.Height = 10
	sp.Border = false

	ls = ui.NewList()
	ls.Border = false
	ui.Body.AddRows(
		ui.NewRow(ui.NewCol(4, 0, prompt), ui.NewCol(8, 0, help)),
		ui.NewRow(ui.NewCol(12, 0, sp)),
		ui.NewRow(ui.NewCol(12, 0, display)),
		ui.NewRow(ui.NewCol(12, 0, ls)),
	)
}
开发者ID:ZhiqinYang,项目名称:gom,代码行数:39,代码来源:gom.go


示例16: showMessage

func (ui *tatui) showMessage() {
	ui.current = uiMessage
	ui.selectedPane = uiMessage
	ui.send.BorderLabel = " ✎ Action or New Reply "
	termui.Body.Rows = nil

	if ui.uilists[uiMessages][ui.selectedPaneMessages].list == nil || ui.uilists[uiMessages][ui.selectedPaneMessages].position < 0 {
		return
	}

	ui.uilists[uiMessage] = make(map[int]*uilist)

	ui.initMessage()

	go func() {
		for {
			if ui.current != uiMessage {
				break
			}
			mutex.Lock()
			ui.updateMessage()
			mutex.Unlock()
			time.Sleep(5 * time.Second)
		}
	}()
	ui.addMarker(ui.uilists[uiMessage][0], 0)

	ui.prepareTopMenu()
	termui.Body.AddRows(
		termui.NewRow(
			termui.NewCol(3, 0, ui.uilists[uiTopics][0].list),
			termui.NewCol(9, 0, ui.uilists[uiMessage][0].list),
		),
	)
	ui.prepareSendRow()
	ui.colorizedPanes()
	termui.Clear()
	ui.render()
}
开发者ID:ovh,项目名称:tatcli,代码行数:39,代码来源:message.go


示例17: DisplayDiscovering

func DisplayDiscovering() {
	p := ui.NewPar("Discovering Pip-Boys")
	p.Width = 22
	p.Height = 3
	discoverUi := ui.NewGrid(
		ui.NewRow(
			ui.NewCol(4, 4, p),
		),
	)
	discoverUi.Width = ui.Body.Width
	discoverUi.Align()
	ui.Render(discoverUi)
}
开发者ID:andyleap,项目名称:GoBoy,代码行数:13,代码来源:main.go


示例18: refresh

func (u Ui) refresh() {
	grid := termui.NewGrid(
		termui.NewRow(
			termui.NewCol(9, 0, u.headerWidget),
			termui.NewCol(3, 0, u.infoWidget),
		),
		termui.NewRow(
			termui.NewCol(12, 0, u.feedsWidget),
		),
	)

	for _, widget := range u.activeDownloadWidgets {
		grid.AddRows(
			termui.NewRow(
				termui.NewCol(12, 0, widget),
			),
		)
	}

	grid.Width = u.gridWidth
	grid.Align()
	termui.Render(grid)
}
开发者ID:bigwhoop,项目名称:podcastd,代码行数:23,代码来源:ui.go


示例19: SwitchToView

func (v *ViewEvent) SwitchToView() View {
	ResetView()

	statusRow := termui.NewRow(
		termui.NewCol(12, 0, v.dash.Widget()),
	)

	termui.Body.AddRows(
		termui.NewRow(
			termui.NewCol(1, 0, v.mongosWidget.Widget()),
			termui.NewCol(1, 0, v.replica1Widget.Widget()),
		),
		termui.NewRow(
			termui.NewCol(1, 0, v.mongosWidget_2.Widget()),
			termui.NewCol(1, 0, v.replica1Widget_2.Widget()),
		),
		statusRow,
	)

	// calculate layout
	termui.Body.Align()

	return v
}
开发者ID:rzh,项目名称:montu,代码行数:24,代码来源:dashboard_view.go


示例20: ScaleApp

func (t *TerminalUI) ScaleApp(appName string, instances int) {
	// scaling text
	scaling := ui.NewPar(fmt.Sprintf("\nSCALING [%s] TO [%d] INSTANCES...\n", appName, instances))
	scaling.Height = 5
	scaling.TextFgColor = ui.ColorYellow
	scaling.Border.Label = "Scale"
	scaling.Border.FgColor = ui.ColorRed
	scaling.Border.LabelFgColor = ui.ColorWhite
	scaling.Border.LabelBgColor = ui.ColorRed

	ui.Body.Rows = []*ui.Row{ui.NewRow(
		ui.NewCol(8, 2, scaling),
	)}

	term.Render()
}
开发者ID:swisscom,项目名称:cf-statistics-plugin,代码行数:16,代码来源:terminal.go



注:本文中的github.com/gizak/termui.NewCol函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang termui.NewGauge函数代码示例发布时间:2022-05-23
下一篇:
Golang termui.Loop函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap