當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。