本文整理汇总了Golang中github.com/gizak/termui.StopLoop函数的典型用法代码示例。如果您正苦于以下问题:Golang StopLoop函数的具体用法?Golang StopLoop怎么用?Golang StopLoop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StopLoop函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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
示例2: 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
示例3: 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
示例4: 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
示例5: 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
示例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() {
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
示例8: 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
示例9: handleBackKey
func handleBackKey() {
if obj, ok := currentPage.(GoBacker); ok {
obj.GoBack()
} else {
ui.StopLoop()
exitNow = true
}
}
开发者ID:Feriority,项目名称:go-jira-ui,代码行数:8,代码来源:ui_controls.go
示例10: main
func main() {
if len(os.Args) < 2 {
log.Fatal("Usage: ", os.Args[0], " <sparkyfish server hostname/IP>[:port]")
}
dest := os.Args[1]
i := last(dest, ':')
if i < 0 {
dest = fmt.Sprint(dest, ":7121")
}
// Initialize our screen
err := termui.Init()
if err != nil {
panic(err)
}
if termui.TermWidth() < 60 || termui.TermHeight() < 28 {
fmt.Println("sparkyfish needs a terminal window at least 60x28 to run.")
os.Exit(1)
}
defer termui.Close()
// 'q' quits the program
termui.Handle("/sys/kbd/q", func(termui.Event) {
termui.StopLoop()
})
// 'Q' also works
termui.Handle("/sys/kbd/Q", func(termui.Event) {
termui.StopLoop()
})
sc := newsparkyClient()
sc.serverHostname = dest
sc.prepareChannels()
sc.wr = newwidgetRenderer()
// Begin our tests
go sc.runTestSequence()
termui.Loop()
}
开发者ID:mephux,项目名称:sparkyfish,代码行数:45,代码来源:sparkyfish-cli.go
示例11: 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
示例12: 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
示例13: 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
示例14: setupHandlers
func setupHandlers() {
termui.Handle("/sys/kbd/C-c", func(termui.Event) {
termui.StopLoop()
})
termui.Handle("/sys/kbd", func(ev termui.Event) {
if kbdEvent, ok := ev.Data.(termui.EvtKbd); ok {
keyStr := kbdEvent.KeyStr
switch {
case keyStr == "<enter>":
inp := parMap["input"].Text
count += 1
//addToOutput(fmt.Sprintf("parsing %d", count))
parseInput(inp)
parMap["input"].Text = ""
//addToOutput(fmt.Sprintf("cleared %d", count))
case keyStr == "<space>":
parMap["input"].Text += " "
case keyStr == "C-8", keyStr == "<backspace>":
// for some reason, backspace is C-8
if len(parMap["input"].Text) > 0 {
parMap["input"].Text = parMap["input"].Text[:len(parMap["input"].Text)-1]
}
case keyStr == "<up>":
for _, linesItem := range linesMap {
linesItem.Up()
}
case keyStr == "<down>":
for _, linesItem := range linesMap {
linesItem.Down()
}
case strings.Contains(keyStr, "<"):
default:
parMap["input"].Text += keyStr
}
update()
} else {
dataType := reflect.TypeOf(ev.Data)
addToOutput("event type of " + fmt.Sprint(dataType))
update()
}
})
termui.Handle("/sys/wnd/resize", func(e termui.Event) {
adjustDimensions()
update()
})
}
开发者ID:marktai,项目名称:T9-Terminal,代码行数:54,代码来源:ui.go
示例15: DispatchCommand
func DispatchCommand(command string) {
if command == "json" || command == "ejson" {
EnableEJSONParsing = !EnableEJSONParsing
if EnableEJSONParsing {
Display <- NewConsoleMsg(COMMAND, "EJSON parsing enabled")
} else {
Display <- NewConsoleMsg(COMMAND, "EJSON parsing disabled")
}
} else if command == "exit" || command == "quit" {
ui.StopLoop()
}
}
开发者ID:mhoc,项目名称:river,代码行数:12,代码来源:cmd_parse.go
示例16: sparkLinesEventLoop
func sparkLinesEventLoop() {
ui.Handle("/sys/kbd/q", func(ui.Event) {
ui.StopLoop()
})
ui.Handle("/sys/wnd/resize", func(e ui.Event) {
ui.Body.Width = ui.TermWidth()
ui.Body.Align()
ui.Render(ui.Body)
})
ui.Loop() // blocking call
}
开发者ID:catalyzeio,项目名称:cli,代码行数:12,代码来源:spark.go
示例17: main
func main() {
flag.Parse()
if err := ui.Init(); err != nil {
panic(err)
}
defer ui.Close()
draw()
ui.Handle("/sys/kbd", func(e ui.Event) {
ev := e.Data.(ui.EvtKbd)
switch ev.KeyStr {
case ":":
promptMsg = ":"
case "C-8":
if l := len(promptMsg); l != 0 {
promptMsg = promptMsg[:l-1]
}
case "<enter>":
handleInput()
promptMsg = ""
case "<left>":
case "<up>":
if reportPage > 0 {
reportPage--
}
case "<right>":
case "<down>":
reportPage++
case "<escape>":
promptMsg = ""
default:
// TODO: filter irrelevant keys such as up, down, etc.
promptMsg += ev.KeyStr
}
refresh()
})
ui.Handle("/sys/kbd/C-c", func(ui.Event) {
ui.StopLoop()
})
ui.Handle("/timer/1s", func(ui.Event) {
loadProfile(false)
loadStats()
refresh()
})
ui.Handle("/sys/wnd/resize", func(e ui.Event) {
ui.Body.Width = ui.TermWidth()
refresh()
})
ui.Body.Align()
ui.Render(ui.Body)
ui.Loop()
}
开发者ID:x0ry,项目名称:gom,代码行数:52,代码来源:gom.go
示例18: main
func main() {
// run as client
if len(os.Args) > 1 {
fmt.Print(debug.ConnectAndListen())
return
}
// run as server
go func() { panic(debug.ListenAndServe()) }()
if err := termui.Init(); err != nil {
panic(err)
}
defer termui.Close()
//termui.UseTheme("helloworld")
b := termui.NewBlock()
b.Width = 20
b.Height = 20
b.Float = termui.AlignCenter
b.BorderLabel = "[HELLO](fg-red,bg-white) [WORLD](fg-blue,bg-green)"
termui.Render(b)
termui.Handle("/sys", func(e termui.Event) {
k, ok := e.Data.(termui.EvtKbd)
debug.Logf("->%v\n", e)
if ok && k.KeyStr == "q" {
termui.StopLoop()
}
})
termui.Handle(("/usr"), func(e termui.Event) {
debug.Logf("->%v\n", e)
})
termui.Handle("/timer/1s", func(e termui.Event) {
t := e.Data.(termui.EvtTimer)
termui.SendCustomEvt("/usr/t", t.Count)
if t.Count%2 == 0 {
b.BorderLabel = "[HELLO](fg-red,bg-green) [WORLD](fg-blue,bg-white)"
} else {
b.BorderLabel = "[HELLO](fg-blue,bg-white) [WORLD](fg-red,bg-green)"
}
termui.Render(b)
})
termui.Loop()
}
开发者ID:Codzart,项目名称:go-ethereum,代码行数:52,代码来源:runtest.go
示例19: main
func main() {
err := termui.Init()
if err != nil {
panic(err)
}
defer termui.Close()
//termui.UseTheme("helloworld")
bc := termui.NewMBarChart()
math := []int{90, 85, 90, 80}
english := []int{70, 85, 75, 60}
science := []int{75, 60, 80, 85}
compsci := []int{100, 100, 100, 100}
bc.Data[0] = math
bc.Data[1] = english
bc.Data[2] = science
bc.Data[3] = compsci
studentsName := []string{"Ken", "Rob", "Dennis", "Linus"}
bc.BorderLabel = "Student's Marks X-Axis=Name Y-Axis=Marks[Math,English,Science,ComputerScience] in %"
bc.Width = 100
bc.Height = 30
bc.Y = 0
bc.BarWidth = 10
bc.DataLabels = studentsName
bc.ShowScale = true //Show y_axis scale value (min and max)
bc.SetMax(400)
bc.TextColor = termui.ColorGreen //this is color for label (x-axis)
bc.BarColor[3] = termui.ColorGreen //BarColor for computerscience
bc.BarColor[1] = termui.ColorYellow //Bar Color for english
bc.NumColor[3] = termui.ColorRed // Num color for computerscience
bc.NumColor[1] = termui.ColorRed // num color for english
//Other colors are automatically populated, btw All the students seems do well in computerscience. :p
termui.Render(bc)
termui.Handle("/sys/kbd/q", func(termui.Event) {
termui.StopLoop()
})
termui.Loop()
}
开发者ID:missingdays,项目名称:termui,代码行数:44,代码来源:mbarchart.go
示例20: main
func main() {
err := termui.Init()
if err != nil {
panic(err)
}
defer termui.Close()
//termui.UseTheme("helloworld")
par0 := termui.NewPar("Borderless Text")
par0.Height = 1
par0.Width = 20
par0.Y = 1
par0.Border = false
par1 := termui.NewPar("你好,世界。")
par1.Height = 3
par1.Width = 17
par1.X = 20
par1.BorderLabel = "标签"
par2 := termui.NewPar("Simple colored text\nwith label. It [can be](fg-red) multilined with \\n or [break automatically](fg-red,fg-bold)")
par2.Height = 5
par2.Width = 37
par2.Y = 4
par2.BorderLabel = "Multiline"
par2.BorderFg = termui.ColorYellow
par3 := termui.NewPar("Long text with label and it is auto trimmed.")
par3.Height = 3
par3.Width = 37
par3.Y = 9
par3.BorderLabel = "Auto Trim"
termui.Render(par0, par1, par2, par3)
termui.Handle("/sys/kbd/q", func(termui.Event) {
termui.StopLoop()
})
termui.Loop()
}
开发者ID:missingdays,项目名称:termui,代码行数:42,代码来源:par.go
注:本文中的github.com/gizak/termui.StopLoop函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论