本文整理汇总了Golang中github.com/gizak/termui.NewPar函数的典型用法代码示例。如果您正苦于以下问题:Golang NewPar函数的具体用法?Golang NewPar怎么用?Golang NewPar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewPar函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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
示例2: NewView
func NewView() *View {
var view = View{}
view.Header = ui.NewPar("Containers")
view.Header.Border = false
view.Header.Text = " Dockdash - Interactive realtime container inspector"
view.Header.Height = 2
view.InfoBar = ui.NewPar("InfoBar")
view.InfoBar.Border = false
view.InfoBar.Text = ""
view.InfoBar.Height = 2
view.NameList = createContainerList()
view.NameList.BorderLabel = "Name"
view.InfoList = createContainerList()
view.InfoList.BorderLabel = "Image"
view.CpuChart = ui.NewBarChart()
view.CpuChart.Border = true
view.CpuChart.BorderLabel = "%CPU"
view.CpuChart.BorderFg = ui.ColorBlack
view.CpuChart.Height = 8
view.MemChart = ui.NewBarChart()
view.MemChart.Border = true
view.MemChart.BorderLabel = "%MEM"
view.MemChart.BorderFg = ui.ColorBlack
view.MemChart.Height = 8
return &view
}
开发者ID:byrnedo,项目名称:dockdash,代码行数:33,代码来源:view.go
示例3: 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
示例4: 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
示例5: Init
// Init creates widgets, sets sizes and labels.
func (t *TermUISingle) Init(data UIData) error {
err := termui.Init()
if err != nil {
return err
}
t.Sparklines = make(map[VarName]*termui.Sparkline)
termui.UseTheme("helloworld")
t.Title = func() *termui.Par {
p := termui.NewPar("")
p.Height = 3
p.TextFgColor = termui.ColorWhite
p.Border.Label = "Services Monitor"
p.Border.FgColor = termui.ColorCyan
return p
}()
t.Status = func() *termui.Par {
p := termui.NewPar("")
p.Height = 3
p.TextFgColor = termui.ColorWhite
p.Border.Label = "Status"
p.Border.FgColor = termui.ColorCyan
return p
}()
t.Pars = make([]*termui.Par, len(data.Vars))
for i, name := range data.Vars {
par := termui.NewPar("")
par.TextFgColor = colorByKind(name.Kind())
par.Border.Label = name.Short()
par.Border.LabelFgColor = termui.ColorGreen
par.Height = 3
t.Pars[i] = par
}
var sparklines []termui.Sparkline
for _, name := range data.Vars {
spl := termui.NewSparkline()
spl.Height = 1
spl.TitleColor = colorByKind(name.Kind())
spl.LineColor = colorByKind(name.Kind())
spl.Title = name.Long()
sparklines = append(sparklines, spl)
}
t.Sparkline = func() *termui.Sparklines {
s := termui.NewSparklines(sparklines...)
s.Height = 2*len(sparklines) + 2
s.HasBorder = true
s.Border.Label = fmt.Sprintf("Monitoring")
return s
}()
t.Relayout()
return nil
}
开发者ID:nordicdyno,项目名称:twemon,代码行数:60,代码来源:ui_single.go
示例6: newTerminalUI
func newTerminalUI(appName string) error {
if err := ui.Init(); err != nil {
return err
}
ui.UseTheme("helloworld")
// usage text
usageText := fmt.Sprintf(`Show live statistics for [%s]
:Press 'q' or 'ctrl-c' to exit
:Press 'PageUp' to increase app instances
:Press 'PageDown' to decrease app instances`, appName)
usage := ui.NewPar(usageText)
usage.Height = 12
usage.TextFgColor = ui.ColorWhite
usage.Border.Label = "Usage"
usage.Border.FgColor = ui.ColorCyan
// summary text
summary := ui.NewPar("")
summary.Height = 12
summary.TextFgColor = ui.ColorRed
summary.Border.Label = "Summary"
summary.Border.FgColor = ui.ColorCyan
// cpu sparklines
data := [400]int{}
line := ui.NewSparkline()
line.Data = data[:]
line.Height = 4
line.LineColor = colors[0]
cpu := ui.NewSparklines(line)
cpu.Height = 7
cpu.Border.Label = "CPU Usage"
// memory gauges
mem := make([]*ui.Gauge, 1)
for i := range mem {
mem[i] = ui.NewGauge()
mem[i].Percent = 0
mem[i].Height = 5
}
// disk bars
disk := ui.NewBarChart()
disk.Border.Label = "Disk Usage (in MB)"
disk.Data = []int{0, 0, 0, 0, 0, 0, 0, 0}
disk.Height = 12
disk.BarWidth = 10
disk.DataLabels = []string{"I: 0", "I: 1", "I: 2", "I: 3", "I: 4", "I: 5", "I: 6", "I: 7"}
disk.TextColor = ui.ColorWhite
disk.BarColor = ui.ColorYellow
disk.NumColor = ui.ColorWhite
term = &TerminalUI{ui.Body, usage, summary, cpu, mem, disk}
return nil
}
开发者ID:swisscom,项目名称:cf-statistics-plugin,代码行数:57,代码来源:terminal.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: main
func main() {
err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close()
p := ui.NewPar(":PRESS q TO QUIT DEMO")
p.Height = 3
p.Width = 50
p.TextFgColor = ui.ColorWhite
p.BorderLabel = "Text Box"
p.BorderFg = ui.ColorCyan
g := ui.NewGauge()
g.Percent = 50
g.Width = 50
g.Height = 3
g.Y = 11
g.BorderLabel = "Gauge"
g.BarColor = ui.ColorRed
g.BorderFg = ui.ColorWhite
g.BorderLabelFg = ui.ColorCyan
ui.Render(p, g) // feel free to call Render, it's async and non-block
}
开发者ID:ringtail,项目名称:pug,代码行数:26,代码来源:main.go
示例10: Init
func (w *MigrationWidget) Init() {
w.G = gen.ChunkMigration()
par3 := termui.NewPar("")
par3.Height = LINE + 2
par3.Width = 137
par3.Y = 9
par3.Border.Label = "> Migrations <"
par3.Text = ""
w.bc = par3
go func() {
for {
time.Sleep(1 * time.Second)
// request data
w.G.C <- [3]int64{1, 1, 1}
a := <-w.G.C
m := fmt.Sprintf(" %d: %d --> %d", a[0], a[1], a[2])
if len(w.msg) == LINE {
w.msg = append(w.msg[1:LINE], m)
} else {
w.msg = append(w.msg, m)
}
text := strings.Join(w.msg, "\n ")
w.bc.Text = " " + text
}
}()
}
开发者ID:rzh,项目名称:montu,代码行数:33,代码来源:migration.go
示例11: initLastRefresh
func (ui *tatui) initLastRefresh() {
p := termui.NewPar("")
p.Height = uiHeightTop
p.TextFgColor = termui.ColorWhite
p.BorderTop, p.BorderLeft, p.BorderRight, p.BorderBottom = false, false, false, false
ui.lastRefresh = p
}
开发者ID:ovh,项目名称:tatcli,代码行数:7,代码来源:ui.go
示例12: initHeader
func (ui *tatui) initHeader() {
p := termui.NewPar("TAT ➠ topics: (f)avorites - un(r)ead - (a)ll | (h)ome | (q)uit")
p.Height = uiHeightTop
p.TextFgColor = termui.ColorWhite
p.Border = false
ui.header = p
}
开发者ID:ovh,项目名称:tatcli,代码行数:7,代码来源:ui.go
示例13: 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
示例14: main
func main() {
err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close()
p := ui.NewPar("Press q to QUIT THE DEMO. [There](fg-blue) are other things [that](fg-red) are going to fit in here I think. What do you think? Now is the time for all good [men to](bg-blue) come to the aid of their country. [This is going to be one really really really long line](fg-green) that is going to go together and stuffs and things. Let's see how this thing renders out.\n Here is a new paragraph and stuffs and things. There should be a tab indent at the beginning of the paragraph. Let's see if that worked as well.")
p.WrapLength = 48 // this should be at least p.Width - 2
p.Height = 20
p.Width = 50
p.Y = 2
p.X = 20
p.TextFgColor = ui.ColorWhite
p.BorderLabel = "Text Box with Wrapping"
p.BorderFg = ui.ColorCyan
//p.Border = false
ui.Render(p)
ui.Handle("/sys/kbd/q", func(ui.Event) {
ui.StopLoop()
})
ui.Loop()
}
开发者ID:jmptrader,项目名称:termui,代码行数:27,代码来源:wrappar.go
示例15: quitWidget
// quitWidget Displays the key required to quit
func quitWidget() *termui.Par {
q := termui.NewPar("Press q to quit Lazarus; s to skip a song.")
q.TextFgColor = termui.ColorRed
q.Height = 1
q.Border = false
return q
}
开发者ID:avadhutp,项目名称:lazarus,代码行数:9,代码来源:widgets.go
示例16: CreateSendBox
func CreateSendBox() *ui.Par {
p := ui.NewPar("")
p.Height = SendBoxHeight
p.TextFgColor = ui.ColorWhite
p.BorderLabel = "Send"
p.BorderFg = ui.ColorCyan
SendBoxEvents(p)
return p
}
开发者ID:mhoc,项目名称:river,代码行数:9,代码来源:send_box.go
示例17: CreateReceiveBox
func CreateReceiveBox() *ui.Par {
p := ui.NewPar("")
// p.Height = ui.TermHeight() - SendBoxHeight
p.Height = ReceiveBoxHeight
p.TextFgColor = ui.ColorWhite
p.BorderFg = ui.ColorCyan
go ReadReceives(p)
return p
}
开发者ID:mhoc,项目名称:river,代码行数:9,代码来源:receive_box.go
示例18: initHomeLeft
func (ui *tatui) initHomeLeft() {
textURL := viper.GetString("url")
if textURL == "" {
textURL = "[Invalid URL, please check your config file](fg-red)"
}
p := termui.NewPar(` TEXT AND TAGS
----------------------------------------------
----------------------------------------------
||| |||
||| |||
||| ||| |||
||| ||| |||
||| |||
||| ||| |||
||| ||| |||
||| |||
||| |||
Tatcli Version: ` + internal.VERSION + `
https://github.com/ovh/tatcli
TAT Engine: https://github.com/ovh/tat
Current Tat Engine: ` + textURL + `
Current config file: ` + internal.ConfigFile + `
Shortcuts:
- Ctrl + a to view all topics. Cmd /topics in send box
- Ctrl + b to go back to messsages list, after selected a message
- Ctrl + c clears filters and UI on current messages list
- Ctrl + f to view favorites topics. Cmd /favorites
- Ctrl + h to go back home. Cmd /home or /help
- Ctrl + t hide or show top menu. Cmd /toggle-top
- Ctrl + y hide or show actionbox menu. Cmd /toggle-bottom
- Ctrl + o open current message on tatwebui with a browser. Cmd /open
Use option tatwebui-url in config file. See /set-tatwebui-url
- Ctrl + p open links in current message with a browser. Cmd /open-links
- Ctrl + j / Ctrl + k (for reverse action):
if mode run is enabled, set a msg from open to doing,
from doing to done from done to open.
if mode monitoring is enabled, set a msg from UP to AL,
from AL to UP.
- Ctrl + q to quit. Cmd /quit
- Ctrl + r to view unread topics. Cmd /unread
- Ctrl + u display/hide usernames in messages list. Cmd /toggle-usernames
- UP / Down to move into topics & messages list
- UP / Down to navigate through history of action box
- <tab> to go to next section on screen`)
p.Height = termui.TermHeight() - uiHeightTop - uiHeightSend
p.TextFgColor = termui.ColorWhite
p.BorderTop = true
p.BorderLeft = false
p.BorderBottom = false
ui.homeLeft = p
}
开发者ID:ovh,项目名称:tatcli,代码行数:55,代码来源:home.go
示例19: readMessage
func readMessage(message *imap.MessageInfo) {
set := new(imap.SeqSet)
set.AddNum(message.Seq)
cmd, err := imap.Wait(c.Fetch(set, BODY_PART_NAME))
panicMaybe(err)
reader, err := messageReader(cmd.Data[0].MessageInfo())
panicMaybe(err)
scanner := bufio.NewScanner(reader)
var lines []string
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
messageBodyStr := strings.Join(lines[:min(len(lines), ui.TermHeight()-2)], "\n")
if len(messageBodyStr) <= 0 {
LOG.Printf("Message body was empty or could not be retrieved: +%v\n", err)
return
}
msgBox := ui.NewPar(messageBodyStr)
msgBox.Border.Label = "Reading Message"
msgBox.Height = ui.TermHeight()
msgBox.Width = ui.TermWidth()
msgBox.Y = 0
ui.Render(msgBox)
topLineIndex := 0
redraw := make(chan bool)
for {
select {
case e := <-ui.EventCh():
switch e.Key {
case ui.KeyArrowDown:
topLineIndex = max(0, min(
len(lines)-msgBox.Height/2,
topLineIndex+1))
go func() { redraw <- true }()
case ui.KeyArrowUp:
topLineIndex = max(0, topLineIndex-1)
go func() { redraw <- true }()
case ui.KeyEsc:
// back to "list messages"
return
}
case <-redraw:
messageBodyStr = strings.Join(lines[topLineIndex+1:], "\n")
msgBox.Text = messageBodyStr
ui.Render(msgBox)
}
}
}
开发者ID:llvtt,项目名称:gomail,代码行数:55,代码来源:readmail.go
示例20: main
func main() {
err := termui.Init()
if err != nil {
panic(err)
}
defer termui.Close()
sinps := (func() []float64 {
n := 220
ps := make([]float64, n)
for i := range ps {
ps[i] = 1 + math.Sin(float64(i)/5)
}
return ps
})()
p := termui.NewPar(":PRESS q or Esc TO QUIT DEMO Hello World")
p.Height = 3
p.Width = 50
p.TextFgColor = termui.ColorWhite
p.BorderLabel = "Hello-World"
p.BorderFg = termui.ColorCyan
lc1 := termui.NewLineChart()
lc1.BorderLabel = "dot-mode Line Chart"
lc1.Mode = "dot"
lc1.Data = sinps
lc1.Width = 26
lc1.Height = 12
lc1.X = 51
lc1.DotStyle = '+'
lc1.AxesColor = termui.ColorWhite
lc1.LineColor = termui.ColorYellow | termui.AttrBold
g0 := termui.NewGauge()
g0.Percent = 40
g0.Width = 50
g0.Height = 3
g0.Y = 3
g0.BorderLabel = "Slim Gauge"
g0.BarColor = termui.ColorRed
g0.BorderFg = termui.ColorWhite
g0.BorderLabelFg = termui.ColorCyan
termui.Render(p, g0, lc1)
termui.Handle("/sys", func(e termui.Event) {
k, ok := e.Data.(termui.EvtKbd)
if ok && (k.KeyStr == "q" || k.KeyStr == "<escape>") {
termui.StopLoop()
}
})
termui.Loop()
}
开发者ID:VonC,项目名称:hello-world-go,代码行数:55,代码来源:main.go
注:本文中的github.com/gizak/termui.NewPar函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论