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

Golang termui.NewList函数代码示例

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

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



在下文中一共展示了NewList函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: New

// New creates a new edit info console GUI.
//
func New(log cdtype.Logger, packs packages.AppletPackages) *Editor {
	ed := &Editor{
		applets: termui.NewList(),
		fields:  termui.NewList(),
		appinfo: termui.NewList(),
		locked:  termui.NewPar(""),
		desc:    termui.NewPar(""),
		title:   termui.NewPar(infoText),
		packs:   packs,
		log:     log,
	}

	ed.applets.ItemFgColor = termui.ColorYellow
	ed.applets.BorderLabel = "[ Applets ]"
	ed.applets.Width = 20 // TODO autodetect.
	ed.applets.BorderBottom = false
	ed.applets.BorderFg = termui.ColorCyan

	ed.fields.BorderLabel = "[ Fields ]"
	ed.fields.X = ed.applets.Width
	ed.fields.Height = 6 + 2 + 2 // last 2 for blank lines around text
	ed.fields.Width = len(fields[1]) + 2
	ed.fields.BorderLeft = false
	ed.fields.BorderBottom = false
	ed.fields.BorderFg = termui.ColorCyan

	ed.appinfo.BorderLabel = "[ Value ]"
	ed.appinfo.X = ed.fields.X + ed.fields.Width
	ed.appinfo.Height = 6 + 2 + 2 // last 2 for blank lines around text
	ed.appinfo.BorderLeft = false
	ed.appinfo.BorderRight = false
	ed.appinfo.BorderBottom = false
	ed.appinfo.BorderFg = termui.ColorCyan

	ed.locked.BorderLabel = "[ Details ]"
	ed.locked.X = ed.applets.Width
	ed.locked.Y = ed.fields.Height - 1 // offset 1 for border
	ed.locked.Height = 6
	ed.locked.BorderBottom = false
	ed.locked.BorderLeft = false
	ed.locked.BorderRight = false
	ed.locked.BorderFg = termui.ColorCyan

	ed.desc.BorderLabel = "[ Description ]"
	ed.desc.X = ed.applets.Width
	ed.desc.BorderBottom = false
	ed.desc.BorderLeft = false
	ed.desc.BorderRight = false
	ed.desc.BorderFg = termui.ColorCyan

	ed.title.BorderLabel = "[ Edit applet info ]"
	ed.title.Height = 2
	ed.title.TextFgColor = termui.ColorWhite
	ed.title.BorderBottom = false
	ed.title.BorderLeft = false
	ed.title.BorderRight = false
	ed.title.BorderFg = termui.ColorCyan

	return ed
}
开发者ID:sqp,项目名称:godock,代码行数:62,代码来源:editui.go


示例2: main

func main() {
	err := termui.Init()
	if err != nil {
		panic(err)
	}
	defer termui.Close()

	//termui.UseTheme("helloworld")

	strs := []string{
		"[0] github.com/gizak/termui",
		"[1] [你好,世界](fg-blue)",
		"[2] [こんにちは世界](fg-red)",
		"[3] [color output](fg-white,bg-green)",
		"[4] output.go",
		"[5] random_out.go",
		"[6] dashboard.go",
		"[7] nsf/termbox-go"}

	ls := termui.NewList()
	ls.Items = strs
	ls.ItemFgColor = termui.ColorYellow
	ls.BorderLabel = "List"
	ls.Height = 7
	ls.Width = 25
	ls.Y = 0

	termui.Render(ls)
	termui.Handle("/sys/kbd/q", func(termui.Event) {
		termui.StopLoop()
	})
	termui.Loop()

}
开发者ID:missingdays,项目名称:termui,代码行数:34,代码来源:list.go


示例3: NewScrollingList

// NewScrollingList returns a new *ScrollingList with current theme.
func NewScrollingList() *ScrollingList {
	l := &ScrollingList{}
	l.List = *ui.NewList()
	l.Scroller = Scroller{}
	l.Scroller.block = &l.List.Block
	return l
}
开发者ID:ryandonahue,项目名称:termui_addons,代码行数:8,代码来源:tui_addons.go


示例4: main

func main() {
	err := termui.Init()
	if err != nil {
		panic(err)
	}
	defer termui.Close()

	termui.UseTheme("helloworld")

	strs := []string{
		"[0] github.com/gizak/termui",
		"[1] 你好,世界",
		"[2] こんにちは世界",
		"[3] keyboard.go",
		"[4] output.go",
		"[5] random_out.go",
		"[6] dashboard.go",
		"[7] nsf/termbox-go"}

	ls := termui.NewList()
	ls.Items = strs
	ls.ItemFgColor = termui.ColorYellow
	ls.Border.Label = "List"
	ls.Height = 7
	ls.Width = 25
	ls.Y = 0

	termui.Render(ls)

	<-termui.EventCh()
}
开发者ID:j4ustin,项目名称:go-ethereum,代码行数:31,代码来源:list.go


示例5: createContainerList

func createContainerList() *ui.List {
	list := ui.NewList()
	list.ItemFgColor = ui.ColorCyan
	list.BorderFg = ui.ColorBlack
	list.Border = true
	return list
}
开发者ID:byrnedo,项目名称:dockdash,代码行数:7,代码来源:view.go


示例6: Create

func (p *TicketListPage) Create() {
	log.Debugf("TicketListPage.Create(): self:        %s (%p)", p.Id(), p)
	log.Debugf("TicketListPage.Create(): currentPage: %s (%p)", currentPage.Id(), currentPage)
	ui.Clear()
	ls := ui.NewList()
	p.uiList = ls
	if p.statusBar == nil {
		p.statusBar = new(StatusBar)
	}
	if p.commandBar == nil {
		p.commandBar = commandBar
	}
	query := p.ActiveQuery.JQL
	if sort := p.ActiveSort.JQL; sort != "" {
		re := regexp.MustCompile(`(?i)\s+ORDER\s+BY.+$`)
		query = re.ReplaceAllString(query, ``) + " " + sort
	}
	if len(p.cachedResults) == 0 {
		p.cachedResults = JiraQueryAsStrings(query, p.ActiveQuery.Template)
	}
	if p.selectedLine >= len(p.cachedResults) {
		p.selectedLine = len(p.cachedResults) - 1
	}
	p.displayLines = make([]string, len(p.cachedResults))
	ls.ItemFgColor = ui.ColorYellow
	ls.BorderLabel = fmt.Sprintf("%s: %s", p.ActiveQuery.Name, p.ActiveQuery.JQL)
	ls.Height = ui.TermHeight() - 2
	ls.Width = ui.TermWidth()
	ls.Y = 0
	p.statusBar.Create()
	p.commandBar.Create()
	p.Update()
}
开发者ID:Feriority,项目名称:go-jira-ui,代码行数:33,代码来源:ticket_list_page.go


示例7: Create

func (p *LabelListPage) Create() {
	ui.Clear()
	ls := ui.NewList()
	p.uiList = ls
	if p.statusBar == nil {
		p.statusBar = new(StatusBar)
	}
	if p.commandBar == nil {
		p.commandBar = commandBar
	}
	queryName := p.ActiveQuery.Name
	queryJQL := p.ActiveQuery.JQL
	p.labelCounts = countLabelsFromQuery(queryJQL)
	p.cachedResults = p.labelsAsSortedList()
	p.isPopulated = true
	p.displayLines = make([]string, len(p.cachedResults))
	ls.ItemFgColor = ui.ColorYellow
	ls.BorderLabel = fmt.Sprintf("Label view -- %s: %s", queryName, queryJQL)
	ls.Height = ui.TermHeight() - 2
	ls.Width = ui.TermWidth()
	ls.Y = 0
	p.statusBar.Create()
	p.commandBar.Create()
	p.Update()
}
开发者ID:Feriority,项目名称:go-jira-ui,代码行数:25,代码来源:label_list_page.go


示例8: NewUi

func NewUi() Ui {
	headerWidget := termui.NewPar(fmt.Sprintf("podcastd v%s\nCopyright 2015 Philippe Gerber\nhttps://github.com/bigwhoop/podcastd", VERSION))
	headerWidget.Height = 5
	headerWidget.HasBorder = false
	headerWidget.PaddingTop = 1
	headerWidget.PaddingBottom = 1
	headerWidget.PaddingLeft = 1

	infoWidget := termui.NewPar("")
	infoWidget.HasBorder = false
	infoWidget.Text = fmt.Sprintf("Press 'q' to quit")

	feedsWidget := termui.NewList()
	feedsWidget.Border.Label = "Feeds"

	return Ui{
		termui.TermWidth(),
		headerWidget,
		infoWidget,
		feedsWidget,
		make(map[string]bool, 0),
		make([]*termui.Gauge, 0),
		make(map[string]curl.ProgressStatus, 0),
	}
}
开发者ID:bigwhoop,项目名称:podcastd,代码行数:25,代码来源:ui.go


示例9: songsWidget

// songsWidget Provides the song list widget
func songsWidget() *termui.List {
	w := termui.NewList()
	w.Items = []string{"Downloading..."}
	w.BorderLabel = "Song list"
	w.Height = 5

	return w
}
开发者ID:avadhutp,项目名称:lazarus,代码行数:9,代码来源:widgets.go


示例10: NewSelectList

func NewSelectList() *SelectList {
	s := &SelectList{Block: *ui.NewBlock()}
	s.upperList = *ui.NewList()
	s.lowerList = *ui.NewList()
	s.upperList.HasBorder = false
	s.lowerList.HasBorder = false

	s.HasBorder = true

	s.middle = *ui.NewPar("")
	s.middle.Height = 1
	s.middle.HasBorder = false
	s.middle.TextBgColor = ui.ColorBlue

	s.upperList.Overflow = "wrap"
	s.lowerList.Overflow = "wrap"

	return s
}
开发者ID:cfstras,项目名称:pcm,代码行数:19,代码来源:term.go


示例11: Create

func (p *CommandBar) Create() {
	ls := ui.NewList()
	p.uiList = ls
	ls.ItemFgColor = ui.ColorGreen
	ls.Border = false
	ls.Height = 1
	ls.Width = ui.TermWidth()
	ls.X = 0
	ls.Y = ui.TermHeight() - 1
	p.Update()
}
开发者ID:Feriority,项目名称:go-jira-ui,代码行数:11,代码来源:command_bar.go


示例12: Create

func (p *TicketShowPage) Create() {
	log.Debugf("TicketShowPage.Create(): self:        %s (%p)", p.Id(), p)
	log.Debugf("TicketShowPage.Create(): currentPage: %s (%p)", currentPage.Id(), currentPage)
	p.opts = getJiraOpts()
	if p.TicketId == "" {
		p.TicketId = ticketListPage.GetSelectedTicketId()
	}
	if p.MaxWrapWidth == 0 {
		if m := p.opts["max_wrap"]; m != nil {
			p.MaxWrapWidth = uint(m.(int64))
		} else {
			p.MaxWrapWidth = defaultMaxWrapWidth
		}
	}
	ui.Clear()
	ls := ui.NewList()
	if p.statusBar == nil {
		p.statusBar = new(StatusBar)
	}
	if p.commandBar == nil {
		p.commandBar = commandBar
	}
	p.uiList = ls
	if p.Template == "" {
		if templateOpt := p.opts["template"]; templateOpt == nil {
			p.Template = "jira_ui_view"
		} else {
			p.Template = templateOpt.(string)
		}
	}
	innerWidth := uint(ui.TermWidth()) - 3
	if innerWidth < p.MaxWrapWidth {
		p.WrapWidth = innerWidth
	} else {
		p.WrapWidth = p.MaxWrapWidth
	}
	if p.apiBody == nil {
		p.apiBody, _ = FetchJiraTicket(p.TicketId)
	}
	p.cachedResults = WrapText(JiraTicketAsStrings(p.apiBody, p.Template), p.WrapWidth)
	p.displayLines = make([]string, len(p.cachedResults))
	if p.selectedLine >= len(p.cachedResults) {
		p.selectedLine = len(p.cachedResults) - 1
	}
	ls.ItemFgColor = ui.ColorYellow
	ls.Height = ui.TermHeight() - 2
	ls.Width = ui.TermWidth()
	ls.Border = true
	ls.BorderLabel = fmt.Sprintf("%s %s", p.TicketId, p.ticketTrailAsString())
	ls.Y = 0
	p.statusBar.Create()
	p.commandBar.Create()
	p.Update()
}
开发者ID:Feriority,项目名称:go-jira-ui,代码行数:54,代码来源:ticket_show_page.go


示例13: drawView

func (d *Dash) drawView() {
	st := d.sum()
	d.view = termui.NewList()
	d.view.ItemFgColor = termui.ColorYellow
	d.view.BorderLabel = "overview"
	d.view.Height = d.height
	d.view.Width = d.width
	d.view.X = 40
	d.view.Y = 0
	d.view.Items = st.List()
}
开发者ID:ChinaLongGanHu,项目名称:wqs,代码行数:11,代码来源:dash.go


示例14: Create

func (p *StatusBar) Create() {
	ls := ui.NewList()
	p.uiList = ls
	ls.ItemFgColor = ui.ColorWhite
	ls.ItemBgColor = ui.ColorRed
	ls.Bg = ui.ColorRed
	ls.Border = false
	ls.Height = 1
	ls.Width = ui.TermWidth()
	ls.X = 0
	ls.Y = ui.TermHeight() - 2
	p.Update()
}
开发者ID:Feriority,项目名称:go-jira-ui,代码行数:13,代码来源:status_bar.go


示例15: Create

func (p *BaseListPage) Create() {
	ui.Clear()
	ls := ui.NewList()
	p.uiList = ls
	p.cachedResults = make([]string, 0)
	p.displayLines = make([]string, len(p.cachedResults))
	ls.ItemFgColor = ui.ColorYellow
	ls.BorderLabel = "Updating, please wait"
	ls.Height = ui.TermHeight()
	ls.Width = ui.TermWidth()
	ls.Y = 0
	p.Update()
}
开发者ID:Feriority,项目名称:go-jira-ui,代码行数:13,代码来源:base_list_page.go


示例16: 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


示例17: Create

func (p *BaseInputBox) Create() {
	ls := ui.NewList()
	var strs []string
	p.uiList = ls
	ls.Items = strs
	ls.ItemFgColor = ui.ColorGreen
	ls.BorderFg = ui.ColorRed
	ls.Height = 1
	ls.Width = 30
	ls.Overflow = "wrap"
	ls.X = ui.TermWidth()/2 - ls.Width/2
	ls.Y = ui.TermHeight()/2 - ls.Height/2
	p.Update()
}
开发者ID:Feriority,项目名称:go-jira-ui,代码行数:14,代码来源:base_input_box.go


示例18: Create

func (p *PasswordInputBox) Create() {
	ls := ui.NewList()
	p.uiList = ls
	var strs []string
	ls.Items = strs
	ls.ItemFgColor = ui.ColorGreen
	ls.BorderLabel = "Enter Password:"
	ls.BorderFg = ui.ColorRed
	ls.Height = 3
	ls.Width = 30
	ls.X = ui.TermWidth()/2 - ls.Width/2
	ls.Y = ui.TermHeight()/2 - ls.Height/2
	p.Update()
}
开发者ID:Feriority,项目名称:go-jira-ui,代码行数:14,代码来源:password_input_box.go


示例19: showSubreddit

func showSubreddit(subredditName string) error {
	r := geddit.NewSession("r by /u/bnadland")

	submissions, err := r.SubredditSubmissions(subredditName, geddit.HotSubmissions, geddit.ListingOptions{})
	if err != nil {
		return err
	}

	isActive := true

	cursor := 3
	for isActive {

		entries := []string{}
		for i, submission := range submissions {
			entries = append(entries, fmt.Sprintf("%s %s", isActiveCursor(cursor, i), submission.Title))
		}

		ls := termui.NewList()
		ls.Items = entries
		ls.ItemFgColor = termui.ColorDefault
		ls.Border.Label = fmt.Sprintf("Subreddit: %s", subredditName)
		ls.Height = termui.TermHeight()
		ls.Width = termui.TermWidth()
		ls.Y = 0
		termui.Render(ls)
		event := <-termui.EventCh()
		if event.Type == termui.EventKey {
			switch event.Key {
			case termui.KeyArrowLeft:
				isActive = false
			case termui.KeyArrowDown:
				cursor = cursor + 1
				if cursor > len(submissions) {
					cursor = len(submissions)
				}
			case termui.KeyArrowUp:
				cursor = cursor - 1
				if cursor < 0 {
					cursor = 0
				}
			}
		}
	}
	return nil
}
开发者ID:bnadland,项目名称:r,代码行数:46,代码来源:main.go


示例20: initMessage

func (ui *tatui) initMessage() {
	strs := []string{"[Loading...](fg-black,bg-white)"}

	ls := termui.NewList()
	ls.BorderTop, ls.BorderLeft, ls.BorderRight, ls.BorderBottom = true, false, false, false
	ls.Items = strs
	ls.ItemFgColor = termui.ColorWhite
	ls.BorderLabel = "Message"
	ls.Overflow = "wrap"
	ls.Width = 25
	ls.Y = 0
	ls.Height = termui.TermHeight() - uiHeightTop - uiHeightSend
	_, ok := ui.uilists[uiMessages][ui.selectedPaneMessages]
	if ok && ui.uilists[uiMessages][ui.selectedPaneMessages].position >= 0 && ui.uilists[uiMessages][ui.selectedPaneMessages].position < len(ui.currentListMessages[ui.selectedPaneMessages]) {
		ui.currentMessage = ui.currentListMessages[ui.selectedPaneMessages][ui.uilists[uiMessages][ui.selectedPaneMessages].position]
		ui.uilists[uiMessage][0] = &uilist{uiType: uiMessage, list: ls, position: 0, page: 0, update: ui.updateMessage}
	}
}
开发者ID:ovh,项目名称:tatcli,代码行数:18,代码来源:message.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang termui.NewPar函数代码示例发布时间:2022-05-23
下一篇:
Golang termui.NewLineChart函数代码示例发布时间: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