本文整理汇总了Golang中github.com/jroimartin/gocui.Gui.Execute方法的典型用法代码示例。如果您正苦于以下问题:Golang Gui.Execute方法的具体用法?Golang Gui.Execute怎么用?Golang Gui.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jroimartin/gocui.Gui
的用法示例。
在下文中一共展示了Gui.Execute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: guiLoadInfo
func guiLoadInfo(ipinfo IPInfoResult, gui *gocui.Gui) {
gui.Execute(func(g *gocui.Gui) error {
view, err := gui.View("info")
if err != nil {
log.Fatal(err)
}
loc, err := ipinfo.GetKey("loc")
if err != nil {
log.Fatal(err)
}
hostname, err := ipinfo.GetKey("hostname")
city, err := ipinfo.GetKey("city")
region, err := ipinfo.GetKey("region")
country, err := ipinfo.GetKey("country")
postal, err := ipinfo.GetKey("postal")
org, err := ipinfo.GetKey("org")
mu.Lock()
fmt.Fprintln(view, fmt.Sprintf("Hostname: %s", hostname))
fmt.Fprintln(view, fmt.Sprintf("Org: %s", org))
fmt.Fprintln(view, fmt.Sprintf("Longitude,Latitude: %s", loc))
fmt.Fprintln(view, fmt.Sprintf("City: %s", city))
fmt.Fprintln(view, fmt.Sprintf("Region: %s", region))
fmt.Fprintln(view, fmt.Sprintf("Country: %s", country))
fmt.Fprintln(view, fmt.Sprintf("Postal: %s", postal))
mu.Unlock()
return nil
})
}
示例2: counter
func counter(g *gocui.Gui) {
defer wg.Done()
for {
select {
case <-done:
return
case <-time.After(500 * time.Millisecond):
mu.Lock()
n := ctr
ctr++
mu.Unlock()
g.Execute(func(g *gocui.Gui) error {
v, err := g.View("ctr")
if err != nil {
return err
}
v.Clear()
fmt.Fprintln(v, n)
return nil
})
}
}
}
示例3: guiLoadMap
func guiLoadMap(ipinfo IPInfoResult, gui *gocui.Gui) {
gui.Execute(func(g *gocui.Gui) error {
view, err := gui.View("map")
if err != nil {
log.Fatal(err)
}
maxX, maxY := view.Size()
var mapCanvas MapCanvas
mapCanvas.Init(float64(maxX), float64(maxY))
mapCanvas.LoadCoordinates(CreateWorldMap())
lon, lat, err := ipinfo.GetLonLat()
if err != nil {
log.Fatal(err)
}
mapCanvas.PlotText(lon, lat, "X")
mu.Lock()
fmt.Fprintf(view, mapCanvas.String())
mu.Unlock()
return nil
})
}
示例4: startDeferrerRoutine
func startDeferrerRoutine(gui *gocui.Gui, deferrer <-chan func()) {
go func() {
for task := range deferrer {
deferredTask := task
gui.Execute(func(*gocui.Gui) error {
deferredTask()
return nil
})
}
}()
}
示例5: watchTubes
func watchTubes(g *gocui.Gui) {
for {
select {
case <-stop:
watch = false
return
case <-time.After(time.Duration(*refreshRate) * time.Second):
//Pause reloads while we're in cmd mode, this could cause weird issues
//with tubes disappearing when a command is run
if !cmdMode {
watch = true
//Refresh tube list
g.Execute(func(g *gocui.Gui) error {
return reloadTubes(g)
})
_ = reloadMenu(g)
}
}
}
}