本文整理汇总了Golang中github.com/gizak/termui.Close函数的典型用法代码示例。如果您正苦于以下问题:Golang Close函数的具体用法?Golang Close怎么用?Golang Close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Close函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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
示例2: main
func main() {
if err := termui.Init(); err != nil {
panic(err)
}
defer termui.Close()
bc := termui.NewBarChart()
data := []int{3, 2, 5, 3, 9, 5, 3, 2, 5, 8, 3, 2, 4, 5, 3, 2, 5, 7, 5, 3, 2, 6, 7, 4, 6, 3, 6, 7, 8, 3, 6, 4, 5, 3, 2, 4, 6, 4, 8, 5, 9, 4, 3, 6, 5, 3, 6}
bclabels := []string{"S0", "S1", "S2", "S3", "S4", "S5"}
bc.BorderLabel = "Bar Chart"
bc.Data = data
bc.Width = 26
bc.Height = 10
bc.DataLabels = bclabels
bc.TextColor = termui.ColorGreen
bc.BarColor = termui.ColorRed
bc.NumColor = termui.ColorYellow
termui.Render(bc)
termui.Handle("/sys/kbd/q", func(termui.Event) {
termui.StopLoop()
})
termui.Loop()
}
开发者ID:himanshugpt,项目名称:termui,代码行数:26,代码来源:barchart.go
示例3: main
func main() {
err := termui.Init()
if err != nil {
panic(err)
}
defer termui.Close()
termui.UseTheme("helloworld")
bc := termui.NewBarChart()
data := []int{3, 2, 5, 3, 9, 5, 3, 2, 5, 8, 3, 2, 4, 5, 3, 2, 5, 7, 5, 3, 2, 6, 7, 4, 6, 3, 6, 7, 8, 3, 6, 4, 5, 3, 2, 4, 6, 4, 8, 5, 9, 4, 3, 6, 5, 3, 6}
bclabels := []string{"S0", "S1", "S2", "S3", "S4", "S5"}
bc.Border.Label = "Bar Chart"
bc.Data = data
bc.Width = 26
bc.Height = 10
bc.DataLabels = bclabels
bc.TextColor = termui.ColorGreen
bc.BarColor = termui.ColorRed
bc.NumColor = termui.ColorYellow
termui.Render(bc)
<-termui.EventCh()
}
开发者ID:j4ustin,项目名称:go-ethereum,代码行数:25,代码来源:barchart.go
示例4: 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
示例5: 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
示例6: 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
示例7: main
func main() {
flag.Parse()
if err := termui.Init(); err != nil {
panic(err)
}
defer termui.Close()
ticker := time.NewTicker(15 * time.Second)
go func() {
for {
mstats, err := fetch.FetchMemStats(*target)
if err != nil {
termui.StopLoop()
log.Fatal(err)
}
render(*mstats)
<-ticker.C
}
}()
termui.Handle("/sys/kbd/q", func(termui.Event) {
// press q to quit
termui.StopLoop()
})
termui.Loop()
}
开发者ID:vibhavp,项目名称:memstats,代码行数:26,代码来源:memstats.go
示例8: 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
示例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: 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
示例11: ResetView
func ResetView() {
termui.Close()
err := termui.Init()
if err != nil {
panic(err)
}
}
开发者ID:rzh,项目名称:montu,代码行数:7,代码来源:main_view.go
示例12: main
func main() {
err := termui.Init()
if err != nil {
panic(err)
}
defer termui.Close()
//termui.UseTheme("helloworld")
data := []int{4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6}
spl0 := termui.NewSparkline()
spl0.Data = data[3:]
spl0.Title = "Sparkline 0"
spl0.LineColor = termui.ColorGreen
// single
spls0 := termui.NewSparklines(spl0)
spls0.Height = 2
spls0.Width = 20
spls0.Border = false
spl1 := termui.NewSparkline()
spl1.Data = data
spl1.Title = "Sparkline 1"
spl1.LineColor = termui.ColorRed
spl2 := termui.NewSparkline()
spl2.Data = data[5:]
spl2.Title = "Sparkline 2"
spl2.LineColor = termui.ColorMagenta
// group
spls1 := termui.NewSparklines(spl0, spl1, spl2)
spls1.Height = 8
spls1.Width = 20
spls1.Y = 3
spls1.BorderLabel = "Group Sparklines"
spl3 := termui.NewSparkline()
spl3.Data = data
spl3.Title = "Enlarged Sparkline"
spl3.Height = 8
spl3.LineColor = termui.ColorYellow
spls2 := termui.NewSparklines(spl3)
spls2.Height = 11
spls2.Width = 30
spls2.BorderFg = termui.ColorCyan
spls2.X = 21
spls2.BorderLabel = "Tweeked Sparkline"
termui.Render(spls0, spls1, spls2)
termui.Handle("/sys/kbd/q", func(termui.Event) {
termui.StopLoop()
})
termui.Loop()
}
开发者ID:himanshugpt,项目名称:termui,代码行数:59,代码来源:sparklines.go
示例13: runJiraCmdEdit
func runJiraCmdEdit(ticketId string) {
opts := getJiraOpts()
c := jira.New(opts)
ui.Close()
c.CmdEdit(ticketId)
log.Notice("Regrettably, need to exit after edit. See https://github.com/mikepea/go-jira-ui/issues/8")
os.Exit(0)
}
开发者ID:Feriority,项目名称:go-jira-ui,代码行数:8,代码来源:utils.go
示例14: runUI
func runUI(args []string) {
ui := &tatui{}
ui.init(args)
ui.draw(0)
defer termui.Close()
termui.Loop()
}
开发者ID:ovh,项目名称:tatcli,代码行数:8,代码来源:cmd.go
示例15: cleanExit
func cleanExit() {
clearScreen()
ui.Close()
// Show cursor once again
fmt.Print("\033[?25h")
os.Exit(0)
}
开发者ID:lparis,项目名称:nats-top,代码行数:8,代码来源:nats-top.go
示例16: main
func main() {
err := termui.Init()
if err != nil {
panic(err)
}
defer termui.Close()
showSubreddit("golang")
}
开发者ID:bnadland,项目名称:r,代码行数:9,代码来源:main.go
示例17: main
func main() {
err := termui.Init()
if err != nil {
panic(err)
}
defer termui.Close()
//termui.UseTheme("helloworld")
sinps := (func() []float64 {
n := 220
ps := make([]float64, n)
for i := range ps {
ps[i] = 1 + math.Sin(float64(i)/5)
}
return ps
})()
lc0 := termui.NewLineChart()
lc0.BorderLabel = "braille-mode Line Chart"
lc0.Data = sinps
lc0.Width = 50
lc0.Height = 12
lc0.X = 0
lc0.Y = 0
lc0.AxesColor = termui.ColorWhite
lc0.LineColor = termui.ColorGreen | termui.AttrBold
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
lc2 := termui.NewLineChart()
lc2.BorderLabel = "dot-mode Line Chart"
lc2.Mode = "dot"
lc2.Data = sinps[4:]
lc2.Width = 77
lc2.Height = 16
lc2.X = 0
lc2.Y = 12
lc2.AxesColor = termui.ColorWhite
lc2.LineColor = termui.ColorCyan | termui.AttrBold
termui.Render(lc0, lc1, lc2)
termui.Handle("/sys/kbd/q", func(termui.Event) {
termui.StopLoop()
})
termui.Loop()
}
开发者ID:missingdays,项目名称:termui,代码行数:57,代码来源:linechart.go
示例18: 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
示例19: doLiveGraph
//doLiveGraph builds a graph in the terminal window that
//updates every graphUpdate seconds
//It will build up to maxGraphs graphs with one time-series
//per graph
func doLiveGraph(res *wavefront.QueryResponse, query *wavefront.Querying, period int64) {
err := ui.Init()
if err != nil {
log.Fatal(err)
}
defer ui.Close()
if maxGraphs > len(res.TimeSeries) {
maxGraphs = len(res.TimeSeries)
}
var wDivisor, hDivisor int
switch maxGraphs {
case 1:
wDivisor = 1
hDivisor = 1
case 2:
wDivisor = 2
hDivisor = 1
case 3, 4:
wDivisor = 2
hDivisor = 2
}
height := ui.TermHeight() / hDivisor
width := ui.TermWidth() / wDivisor
xVals, yVals := calculateCoords(maxGraphs, ui.TermWidth()/wDivisor, ui.TermHeight()/hDivisor)
graphs := buildGraphs(res, height, width, xVals, yVals)
ui.Render(graphs...)
ui.Handle("/sys/kbd/q", func(ui.Event) {
// press q to quit
ui.StopLoop()
})
ui.Handle("/sys/kbd/C-c", func(ui.Event) {
// handle Ctrl + c combination
ui.StopLoop()
})
ui.Handle("/timer/1s", func(e ui.Event) {
query.SetEndTime(time.Now())
query.SetStartTime(period)
res, err := query.Execute()
if err != nil {
log.Fatal(err)
}
graphs := buildGraphs(res, height, width, xVals, yVals)
ui.Render(graphs...)
})
ui.Loop()
}
开发者ID:spaceapegames,项目名称:go-wavefront,代码行数:59,代码来源:query.go
示例20: 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
注:本文中的github.com/gizak/termui.Close函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论