本文整理汇总了Golang中github.com/jroimartin/gocui.Gui.Size方法的典型用法代码示例。如果您正苦于以下问题:Golang Gui.Size方法的具体用法?Golang Gui.Size怎么用?Golang Gui.Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jroimartin/gocui.Gui
的用法示例。
在下文中一共展示了Gui.Size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: layout
func layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
if v, err := g.SetView("help", maxX-23, 0, maxX-1, 3); err != nil {
if err != gocui.ErrUnknownView {
return err
}
v.Title = "Keybindings"
fmt.Fprintln(v, "^a: Set mask")
fmt.Fprintln(v, "^c: Exit")
}
if v, err := g.SetView("input", 0, 0, maxX-24, maxY-1); err != nil {
if err != gocui.ErrUnknownView {
return err
}
if _, err := g.SetCurrentView("input"); err != nil {
return err
}
v.Editable = true
v.Wrap = true
}
return nil
}
示例2: 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
}
示例3: 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
}
示例4: 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
}
示例5: getLine
func getLine(g *gocui.Gui, v *gocui.View) error {
var l string
var err error
_, cy := v.Cursor()
if l, err = v.Line(cy); err != nil {
l = ""
}
maxX, maxY := g.Size()
if v, err := g.SetView("msg", maxX/2-30, maxY/2, maxX/2+30, maxY/2+2); err != nil {
if err != gocui.ErrorUnkView {
return err
}
fmt.Fprintln(v, l)
if err := g.SetCurrentView("msg"); err != nil {
return err
}
}
if v, err := g.View("main"); err != nil {
if err != gocui.ErrorUnkView {
return err
}
f := proj.GetFile(l)
if f != nil {
v.Clear()
fmt.Fprintf(v, "%s", f.GetBody())
}
v.Editable = true
v.Wrap = true
}
return nil
}
示例6: 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
}
示例7: setDetailLayout
func setDetailLayout(g *gocui.Gui) error {
maxX, maxY := g.Size()
summaryView, err := g.View("summary")
if err != nil {
return err
}
_, cy := summaryView.Cursor()
_, oy := summaryView.Origin()
currentCveInfo = cy + oy
if v, err := g.SetView("detail", 40, int(float64(maxY)*0.2), maxX, maxY); err != nil {
if err != gocui.ErrUnknownView {
return err
}
// text := report.ToPlainTextDetailsLangEn(
// currentScanResult.KnownCves[currentCveInfo],
// currentScanResult.Family)
text, err := detailLines()
if err != nil {
return err
}
fmt.Fprint(v, text)
v.Editable = false
v.Wrap = true
currentDetailLimitY = len(strings.Split(text, "\n")) - 1
}
return nil
}
示例8: layout
func layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
columnX := maxX / 3
g.BgColor = gocui.ColorWhite
g.FgColor = gocui.ColorBlack
g.RenderFrames = false
if v, err := g.SetView("status", -1, -1, maxX, 1); err != nil {
if err != gocui.ErrorUnkView {
return err
}
v.FgColor = gocui.ColorWhite
v.BgColor = gocui.ColorBlack
}
if v, err := g.SetView("counterHeader", -1, 0, columnX, maxY); err != nil {
if err != gocui.ErrorUnkView {
return err
}
v.FgColor = gocui.ColorWhite
v.BgColor = gocui.ColorBlue
fmt.Fprintf(v, "Counters")
}
if _, err := g.SetView("counters", -1, 1, columnX, maxY); err != nil {
if err != gocui.ErrorUnkView {
return err
}
}
if v, err := g.SetView("gaugeHeader", columnX, 0, columnX*2, maxY); err != nil {
if err != gocui.ErrorUnkView {
return err
}
v.FgColor = gocui.ColorWhite
v.BgColor = gocui.ColorCyan
fmt.Fprintf(v, "Gauges")
}
if _, err := g.SetView("gauges", columnX, 1, columnX*2, maxY); err != nil {
if err != gocui.ErrorUnkView {
return err
}
}
if v, err := g.SetView("timerHeader", columnX*2, 0, maxX-1, maxY); err != nil {
if err != gocui.ErrorUnkView {
return err
}
v.FgColor = gocui.ColorWhite
v.BgColor = gocui.ColorMagenta
fmt.Fprintf(v, "Timers")
}
if _, err := g.SetView("timers", (columnX * 2), 1, maxX-1, maxY); err != nil {
if err != gocui.ErrorUnkView {
return err
}
}
return nil
}
示例9: 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
}
示例10: 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
}
示例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.ErrorUnkView {
return err
}
v.Highlight = true
list := proj.GetFileList()
for _, f := range list {
fmt.Fprintln(v, filepath.Base(f.GetPath()))
}
}
if v, err := g.SetView("main", 30, -1, maxX, maxY); err != nil {
if err != gocui.ErrorUnkView {
return err
}
f := proj.GetFile("test.go")
if f != nil {
fmt.Fprintf(v, "%s", f.GetBody())
}
v.Editable = true
v.Wrap = false
if err := g.SetCurrentView("main"); err != nil {
return err
}
}
return nil
}
示例12: 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
}
示例13: layout
func layout(g *gocui.Gui) error {
var err error
maxX, maxY := g.Size()
if backgroundView, err = g.SetView("background", 0, 0, maxX, maxY); err != nil {
if err != gocui.ErrorUnkView {
return err
}
}
if profilePictureView, err = g.SetView("profilePicture", 1, 1, maxX-1, maxY-5); err != nil {
if err != gocui.ErrorUnkView {
return err
}
profilePictureView.Wrap = true
fmt.Fprintln(profilePictureView, "Loading...")
}
if swipeLeftView, err = g.SetView("swipeLeft", 6, maxY-4, maxX/2-5, maxY-1); err != nil {
if err != gocui.ErrorUnkView {
return err
}
fmt.Fprintln(swipeLeftView, "X")
}
if swipeRightView, err = g.SetView("swipeRight", maxX-(maxX/2-5), maxY-4, maxX-6, maxY-1); err != nil {
if err != gocui.ErrorUnkView {
return err
}
fmt.Fprintln(swipeRightView, "<3")
}
if infoView, err = g.SetView("info", maxX/2-4, maxY-4, maxX/2+4, maxY-1); err != nil {
if err != gocui.ErrorUnkView {
return err
}
fmt.Fprintln(infoView, "i")
}
return nil
}
示例14: layout
func layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
// main
if v, err := g.SetView("main", -1, -1, maxX, maxY); err != nil {
if err != gocui.ErrorUnkView {
return err
}
v.Wrap = true
v.Autoscroll = true
}
// key bindings
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quitKey); err != nil {
return err
}
// stats
once.Do(func() {
go func() {
ticker := time.NewTicker(time.Second)
for {
select {
case <-ticker.C:
showUpdate()
case <-stopChan:
return
}
}
}()
})
return nil
}
示例15: 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
}