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


Golang Gui.SetCurrentView方法代码示例

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


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

示例1: prevView

func prevView(g *gocui.Gui, v *gocui.View) error {
	curView = getCurrentChannelIndex()

	next := curView - 1

	if next < 0 {
		next = len(Server.Channels) - 1
	}

	logger.Logger.Printf("PREV INDEX %d\n", next)

	if newView, err := g.View(Server.Channels[next].Name); err != nil {
		return err
	} else {
		newView.Autoscroll = true
		g.SetViewOnTop(newView.Name())
		g.SetViewOnTop("header")
	}

	if _, err := g.SetCurrentView(Server.Channels[next].Name); err != nil {
		return err
	}

	// logger.Logger.Printf("Set Current View %d\n", Server.Channels[next].Name)
	Server.CurrentChannel = Server.Channels[next].Name
	Server.Channels[next].Unread = false

	ui.UpdateMenuView(g)
	FocusInputView(g, v)

	curView = next
	return nil
}
开发者ID:mephux,项目名称:komanda-cli,代码行数:33,代码来源:util.go

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

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

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

示例5: setView

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

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

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

示例7: layout

func layout(g *gocui.Gui) error {
	theSizeX, theSizeY := 12, 6
	maxX, maxY := g.Size()
	centerX, centerY := maxX/2, maxY/2
	topLeftX, topLeftY := centerX-theSizeX, centerY-theSizeY
	bottomRightX, bottomRightY := centerX+theSizeX, centerY+theSizeY
	if v, err := g.SetView("yo", topLeftX, topLeftY, bottomRightX, bottomRightY); err != nil {
		if err != gocui.ErrUnknownView {
			return err
		}
		v.Editable = true
		v.Wrap = true
		fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9")
		fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9")
		fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9")
		fmt.Fprintln(v, " ---------------------")
		fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9")
		fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9")
		fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9")
		fmt.Fprintln(v, " ---------------------")
		fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9")
		fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9")
		fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9")
	}
	if err := g.SetCurrentView("yo"); err != nil {
		return err
	}
	return nil
}
开发者ID:thorncp,项目名称:hello-go,代码行数:29,代码来源:main.go

示例8: layout

func layout(g *gocui.Gui) error {
	maxX, maxY := g.Size()
	if v, err := g.SetView("side", -1, -1, 30, maxY); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		v.Highlight = true
		fmt.Fprintln(v, "Item 1")
		fmt.Fprintln(v, "Item 2")
		fmt.Fprintln(v, "Item 3")
		fmt.Fprintln(v, "Item 4")
	}
	if v, err := g.SetView("main", 30, -1, maxX, maxY); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		b, err := ioutil.ReadFile("Mark.Twain-Tom.Sawyer.txt")
		if err != nil {
			panic(err)
		}
		fmt.Fprintf(v, "%s", b)
		v.Editable = true
		if err := g.SetCurrentView("main"); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:balu-,项目名称:gocui,代码行数:28,代码来源:demo2.go

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

示例10: layout

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

	if v, err := g.SetView("legend", maxX-23, 0, maxX-1, 5); err != nil {
		if err != gocui.ErrUnknownView {
			return err
		}
		fmt.Fprintln(v, "KEYBINDINGS")
		fmt.Fprintln(v, "↑ ↓: Seek input")
		fmt.Fprintln(v, "A: Enable autoscroll")
		fmt.Fprintln(v, "^C: Exit")
	}

	if v, err := g.SetView("stdin", 0, 0, 80, 35); err != nil {
		if err != gocui.ErrUnknownView {
			return err
		}
		if _, err := g.SetCurrentView("stdin"); err != nil {
			return err
		}
		dumper := hex.Dumper(v)
		if _, err := io.Copy(dumper, os.Stdin); err != nil {
			return err
		}
		v.Wrap = true
	}

	return nil
}
开发者ID:jmptrader,项目名称:gocui,代码行数:29,代码来源:stdin.go

示例11: layout

func layout(g *gocui.Gui) error {
	maxX, maxY := g.Size()
	if v, err := g.SetView("side", -1, -1, 30, maxY); err != nil {
		if err != gocui.ErrUnknownView {
			return err
		}
		v.Highlight = true
		v.SelBgColor = gocui.ColorGreen
		v.SelFgColor = gocui.ColorBlack
		fmt.Fprintln(v, "Item 1")
		fmt.Fprintln(v, "Item 2")
		fmt.Fprintln(v, "Item 3")
		fmt.Fprint(v, "\rWill be")
		fmt.Fprint(v, "deleted\rItem 4\nItem 5")
	}
	if v, err := g.SetView("main", 30, -1, maxX, maxY); err != nil {
		if err != gocui.ErrUnknownView {
			return err
		}
		b, err := ioutil.ReadFile("Mark.Twain-Tom.Sawyer.txt")
		if err != nil {
			panic(err)
		}
		fmt.Fprintf(v, "%s", b)
		v.Editable = true
		v.Wrap = true
		if _, err := g.SetCurrentView("main"); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:jroimartin,项目名称:gocui,代码行数:32,代码来源:demo.go

示例12: nextView

func nextView(g *gocui.Gui, v *gocui.View) error {
	currentView := g.CurrentView()
	if currentView == nil || currentView.Name() == "contacts" {
		return g.SetCurrentView("input")
	}
	return g.SetCurrentView("contacts")
}
开发者ID:garry415,项目名称:goax,代码行数:7,代码来源:ui.go

示例13: nextView

func nextView(g *gocui.Gui, disableCurrent bool) error {
	next := curView + 1
	if next > len(views)-1 {
		next = 0
	}

	nv, err := g.View(views[next])
	if err != nil {
		return err
	}
	if err := g.SetCurrentView(views[next]); err != nil {
		return err
	}
	nv.BgColor = gocui.ColorRed

	if disableCurrent && len(views) > 1 {
		cv, err := g.View(views[curView])
		if err != nil {
			return err
		}
		cv.BgColor = g.BgColor
	}

	curView = next
	return nil
}
开发者ID:repos-go,项目名称:gocui,代码行数:26,代码来源:delete.go

示例14: newView

func newView(g *gocui.Gui) error {
	maxX, maxY := g.Size()
	name := fmt.Sprintf("v%v", idxView)
	v, err := g.SetView(name, maxX/2-5, maxY/2-5, maxX/2+5, maxY/2+5)
	if err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		v.Wrap = true
		fmt.Fprintln(v, strings.Repeat(name+" ", 30))
	}
	if err := g.SetCurrentView(name); err != nil {
		return err
	}
	v.BgColor = gocui.ColorRed

	if curView >= 0 {
		cv, err := g.View(views[curView])
		if err != nil {
			return err
		}
		cv.BgColor = g.BgColor
	}

	views = append(views, name)
	curView = len(views) - 1
	idxView += 1
	return nil
}
开发者ID:repos-go,项目名称:gocui,代码行数:29,代码来源:delete.go

示例15: codeComplete

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
}
开发者ID:YouROK,项目名称:GoProjectManager,代码行数:29,代码来源:edit.go


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