当前位置: 首页>>代码示例>>Golang>>正文


Golang Gui.Execute方法代码示例

本文整理汇总了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
	})
}
开发者ID:cruatta,项目名称:ip411,代码行数:33,代码来源:ip411.go

示例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
			})
		}
	}
}
开发者ID:mephux,项目名称:komanda-cli,代码行数:25,代码来源:goroutine.go

示例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
	})
}
开发者ID:cruatta,项目名称:ip411,代码行数:27,代码来源:ip411.go

示例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
			})
		}
	}()
}
开发者ID:inkyblackness,项目名称:shocked-client,代码行数:12,代码来源:Run.go

示例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)
			}
		}
	}
}
开发者ID:george-infinity,项目名称:bsw,代码行数:21,代码来源:main.go


注:本文中的github.com/jroimartin/gocui.Gui.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。