Example #1
0
func codeComplete(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()

		x, y := ox+cx, oy+cy

		f := proj.GetFile("test.go")
		off := f.GetOffset(x, y)
		cands := codecomplete.Complete(proj, f, off)

		maxX, maxY := g.Size()
		maxY = maxY/2 - (len(cands) / 2)
		if v, err := g.SetView("msg", maxX/2-30, maxY, maxX/2+30, maxY+len(cands)+2); err != nil {
			if err != gocui.ErrorUnkView {
				return err
			}
			fmt.Fprintln(v, x, y, off)
			for _, c := range cands {
				fmt.Fprintln(v, c.Name, c.Perc)
			}

			if err := g.SetCurrentView("msg"); err != nil {
				return err
			}
		}
	}
	return nil
}
Example #2
0
func main1() {
	p, err := project.OpenProject("testprj/test.gop")
	if err != nil {
		log.Println(err)
		return
	}
	codecomplete.Init(p)

	file := p.GetFile("test.go")
	if file != nil {
		x := 4
		y := 33
		off := file.GetOffset(x, y)
		log.Println(x, y, off)
		log.Println(codecomplete.Complete(p, file, off))
	}

	/*err = build.GetDepends(p, false)
	if err != nil {
		log.Println(err)
	}
	err = build.Build(p)
	if err != nil {
		log.Println(err)
	}*/
}