本文整理汇总了Golang中github.com/gizak/termui.Close函数的典型用法代码示例。如果您正苦于以下问题:Golang Close函数的具体用法?Golang Close怎么用?Golang Close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Close函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}
示例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
}
示例11: ResetView
func ResetView() {
termui.Close()
err := termui.Init()
if err != nil {
panic(err)
}
}
示例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()
}
示例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)
}
示例14: runUI
func runUI(args []string) {
ui := &tatui{}
ui.init(args)
ui.draw(0)
defer termui.Close()
termui.Loop()
}
示例15: cleanExit
func cleanExit() {
clearScreen()
ui.Close()
// Show cursor once again
fmt.Print("\033[?25h")
os.Exit(0)
}