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


Golang gocui.Gui类代码示例

本文整理汇总了Golang中github.com/jroimartin/gocui.Gui的典型用法代码示例。如果您正苦于以下问题:Golang Gui类的具体用法?Golang Gui怎么用?Golang Gui使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Gui类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: layout

func (runner *appRunner) layout(g *gocui.Gui) error {
	maxX, maxY := g.Size()

	view, _ := g.SetView("mainControls", -1, -1, maxX/2, maxY)
	_, originY := view.Origin()
	_, cursorY := view.Cursor()

	view.Clear()
	runner.mainControlLines = 0
	runner.highlightedTexter = nil

	if g.CurrentView() == nil {
		g.SetCurrentView("mainControls")
	}
	view.Highlight = g.CurrentView() == view

	runner.rootTexter.TextMain(func(label, line string, texter ViewModelNodeTexter) {
		paddedLabel := fmt.Sprintf("%20s", label)
		fmt.Fprintf(view, "%s %v\n", paddedLabel[len(paddedLabel)-20:len(paddedLabel)], line)
		if (originY + cursorY) == runner.mainControlLines {
			runner.highlightedTexter = texter
		}
		runner.mainControlLines++
	})

	return nil
}
开发者ID:inkyblackness,项目名称:shocked-client,代码行数:27,代码来源:Run.go

示例2: layout

func layout(g *gocui.Gui) error {

	maxX, maxY := g.Size()
	v, err := g.SetView("mainmenu", 2, 1, maxX-2, maxY-2)

	v.FgColor = gocui.ColorGreen

	if err != nil {
		if err != gocui.ErrUnknownView {
			return err
		}
		//		b, err := ioutil.ReadFile("mainmenu")
		//if err != nil {
		//	log.Panicln(err)
		//	panic(err)
		//}
		v.Title = "Main Menu"
		v.Frame = true
		//fmt.Fprintf(v, "%s", b)

		v.Wrap = true
		v.SetCursor(10, 10)
		fmt.Println(v.Cursor())
	}
	return nil

}
开发者ID:shibukraj,项目名称:synapseconsole,代码行数:27,代码来源:console-dev.go

示例3: InputView

func InputView(g *gocui.Gui, x, y, maxX, maxY int) error {

	if v, err := g.SetView("input", x, y, maxX, maxY); err != nil {
		if err != gocui.ErrUnknownView {
			return err
		}

		_, err := g.SetCurrentView("input")

		if err != nil {
			return err
		}

		logger.Logger.Println(" CHANGE:", "input", x, y, maxX, maxY)

		v.Editor = Editor

		// v.FgColor = gocui.ColorGreen
		v.BgColor = gocui.ColorDefault

		v.Autoscroll = false
		v.Editable = true
		v.Wrap = false
		v.Frame = false

	}

	return nil
}
开发者ID:mephux,项目名称:komanda-cli,代码行数:29,代码来源:input.go

示例4: MoveTubeCursor

func MoveTubeCursor(g *gocui.Gui, mx, my int) error {
	if cmdMode {
		return nil
	}

	tv, err := g.View("tubes")
	if err != nil {
		return err
	}

	cx, cy := tv.Cursor()
	ny := cy + my

	//Check the cursor isn't trying to move above the first tube or past the last tube
	if ny < 1 || ny > len(cTubes.Conns) {
		return nil
	}

	if err = tv.SetCursor(cx, ny); err != nil {
		return err
	}

	//Set the selected tube to the currently highlighted row
	cTubes.SelectedIdx = ny - 1
	cTubes.Selected = cTubes.Names[cTubes.SelectedIdx]
	debugLog("Set tube to: ", cTubes.Selected)

	return nil
}
开发者ID:george-infinity,项目名称:bsw,代码行数:29,代码来源:views.go

示例5: MenuView

func MenuView(g *gocui.Gui, maxX, maxY int) error {

	if v, err := g.SetView("menu", -1, maxY-4, maxX, maxY+3); err != nil {
		if err != gocui.ErrUnknownView {
			return err
		}

		_, err := g.SetCurrentView("menu")

		if err != nil {
			return err
		}

		// v.FgColor = gocui.ColorGreen
		v.BgColor = gocui.ColorDefault

		v.Autoscroll = false
		v.Editable = false
		v.Wrap = false
		v.Frame = false

		go func() {
			for range time.Tick(time.Millisecond * 200) {
				UpdateMenuView(g)
			}
		}()

		UpdateMenuView(g)
	}

	return nil
}
开发者ID:mephux,项目名称:komanda-cli,代码行数:32,代码来源:menu.go

示例6: 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

示例7: 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

示例8: HeaderView

func HeaderView(g *gocui.Gui, x, y, maxX, maxY int) error {

	if v, err := g.SetView("header", x, y, maxX, maxY); err != nil {
		if err != gocui.ErrUnknownView {
			return err
		}

		// v.FgColor = gocui.ColorGreen
		v.BgColor = gocui.ColorDefault

		v.Autoscroll = false
		v.Editable = false
		v.Wrap = false
		v.Frame = false
		v.Overwrite = true

		fmt.Fprintf(v, "  --")

		go func() {
			for range time.Tick(time.Millisecond * 100) {
				UpdateHeaderView(g)
			}
		}()

	}

	return nil
}
开发者ID:mephux,项目名称:komanda-cli,代码行数:28,代码来源:header.go

示例9: getLine

func getLine(g *gocui.Gui, v *gocui.View) error {
	var l string
	var err error

	g.ShowCursor = false

	_, cy := v.Cursor()
	if l, err = v.Line(cy); err != nil {
		l = ""
	}

	maxX, maxY := g.Size()
	length := 10 + len(current_name)
	if l != "" {
		current_name = l
		if v, err := g.SetView("msg", maxX/2-length/2, maxY/2-3, maxX/2+length/2, maxY/2+3); err != nil {
			v.BgColor = gocui.ColorGreen
			v.FgColor = gocui.ColorBlack
			if err != gocui.ErrorUnkView {
				return err
			}
			current_proj = projects[current_name]
			current_proj.start()
			fmt.Fprintln(v, "")
			fmt.Fprintln(v, "")
			fmt.Fprintln(v, strings.Repeat(" ", (length-15)/2), "Active Project")
			fmt.Fprintln(v, "")
			fmt.Fprintln(v, strings.Repeat(" ", 5), current_name)
			fmt.Fprintln(v, "")
			setView(g, "msg")
		}
	}
	return nil
}
开发者ID:mkrapp,项目名称:go-watch,代码行数:34,代码来源:go-watch.go

示例10: layout

func layout(g *gocui.Gui) error {
	maxX, maxY := g.Size()
	if v, err := g.SetView("contacts", 1, 1, 60, maxY-1); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		v.Highlight = true
	}
	if v, err := g.SetView("main", 60, 1, maxX-1, maxY-3); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		v.Wrap = true
		v.WrapPrefix = "  "
	}
	if v, err := g.SetView("input", 60, maxY-3, maxX-1, maxY-1); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		v.Editable = true
		if err := g.SetCurrentView("input"); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:garry415,项目名称:goax,代码行数:26,代码来源:ui.go

示例11: delView

func delView(g *gocui.Gui, s string) error {
	if err := g.DeleteView(s); err != nil {
		return err
	}
	return nil

}
开发者ID:mkrapp,项目名称:go-watch,代码行数:7,代码来源:go-watch.go

示例12: removeProject

func removeProject(g *gocui.Gui, v *gocui.View) error {
	var l string
	var err error

	g.ShowCursor = false

	_, cy := v.Cursor()
	if l, err = v.Line(cy); err != nil {
		l = ""
	}
	current_name = l

	maxX, maxY := g.Size()
	length := 20
	if l != "" {
		if v, err := g.SetView("del_proj", maxX/2-length/2, maxY/2, maxX/2+length/2, maxY/2+2); err != nil {
			v.BgColor = gocui.ColorRed
			if err != gocui.ErrorUnkView {
				return err
			}
			fmt.Fprintln(v, "Press 'd' to delete")
			setView(g, "del_proj")
		}
	}
	return nil
}
开发者ID:mkrapp,项目名称:go-watch,代码行数:26,代码来源:go-watch.go

示例13: layout

func layout(g *ui.Gui) error {

	x, y := g.Size()
	size := len(cli.Nodes)

	if v, err := g.SetView("nodes-cursor", 0, 0, 6, size+1); err != nil {
		if err != ui.ErrUnknownView {
			return err
		}
		v.Highlight = true
		v.Frame = false
	}

	if v, err := g.SetView("nodes", 2, 0, 20, size+1); err != nil {
		if err != ui.ErrUnknownView {
			return err
		}
		v.Frame = false
		printNodes()
	}

	if v, err := g.SetView("node", 16, 0, x, y-1); err != nil {
		if err != ui.ErrUnknownView {
			return err
		}
		v.Frame = false
		v.Editable = true
		printNode(g)
	}
	return g.SetCurrentView(current)
}
开发者ID:cswank,项目名称:quimby,代码行数:31,代码来源:main.go

示例14: changeHost

func changeHost(g *gocui.Gui, v *gocui.View) error {

	if err := g.DeleteView("summary"); err != nil {
		return err
	}
	if err := g.DeleteView("detail"); err != nil {
		return err
	}

	_, cy := v.Cursor()
	l, err := v.Line(cy)
	if err != nil {
		return err
	}
	serverName := strings.TrimSpace(l)

	for _, r := range scanHistory.ScanResults {
		if serverName == strings.TrimSpace(r.ServerInfoTui()) {
			currentScanResult = r
			break
		}
	}

	if err := setSummaryLayout(g); err != nil {
		return err
	}
	if err := setDetailLayout(g); err != nil {
		return err
	}
	return nil
}
开发者ID:Rompei,项目名称:vuls,代码行数:31,代码来源:tui.go

示例15: CreateViews

func (c *column) CreateViews(g *gocui.Gui, colv *gocui.View) error {
	if c.isActive {
		colv.FgColor = gocui.ColorCyan | gocui.AttrBold
	} else {
		colv.FgColor = gocui.ColorDefault
	}
	x, y, maxX, maxY, err := g.ViewPosition(colv.Name())
	y = y + 2
	if err != nil {
		return err
	}
	maxIssues := maxY / LinesPerEntry
	c.maxIssues = maxIssues
	for i := 0; i < maxIssues; i++ {
		v, err := g.SetView(fmt.Sprintf("col-%s-%d", c.name, i),
			x, y+(i*LinesPerEntry), maxX, y+((i+1)*LinesPerEntry))
		if err != nil {
			if err != gocui.ErrorUnkView {
				return err
			}
		}
		v.SelBgColor = gocui.ColorRed
		v.Frame = false
		v.Wrap = true
	}
	return c.redraw(g)
}
开发者ID:pombredanne,项目名称:stroop,代码行数:27,代码来源:column.go


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