本文整理汇总了Golang中github.com/jroimartin/gocui.Gui.View方法的典型用法代码示例。如果您正苦于以下问题:Golang Gui.View方法的具体用法?Golang Gui.View怎么用?Golang Gui.View使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jroimartin/gocui.Gui
的用法示例。
在下文中一共展示了Gui.View方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: 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
}
示例3: 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
}
示例4: 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
})
}
示例5: 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
}
示例6: 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
})
}
}
}
示例7: 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
})
}
示例8: nextView
func nextView(g *gocui.Gui, v *gocui.View) error {
if v == nil {
return g.SetCurrentView(vPlatforms)
}
getLine(g, v)
switch v.Name() {
case vPlatforms:
return g.SetCurrentView(vTranscripts)
case vTranscripts:
return g.SetCurrentView(vDestinations)
case vDestinations:
if x, err := g.View(vTop); err == nil {
x.Clear()
fmt.Fprintf(x, "Hit enter to submit selections")
}
return g.SetCurrentView(vSubmit)
case vSubmit:
return g.SetCurrentView(vText)
case vText:
return g.SetCurrentView(vPlatforms)
}
return g.SetCurrentView(vPlatforms)
}
示例9: setContacts
func setContacts(g *gocui.Gui, contacts map[string]*contact) error {
if jidBuffs == nil {
jidBuffs = make(map[string][]byte)
}
g.View("contacts").Clear()
viewJids = make([]string, 1)
viewJids[0] = "Home"
for _, c := range contacts {
if !c.HasAxo() {
continue
}
viewJids = append(viewJids, c.String())
}
sort.Strings(viewJids[1:])
for _, c := range viewJids {
fmt.Fprintln(g.View("contacts"), c)
}
// Cleanup buffers
for k, _ := range jidBuffs {
if _, ok := contacts[k]; !ok {
delete(jidBuffs, k)
}
}
g.Flush()
return nil
}
示例10: 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
}
示例11: 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
}
示例12: updateMainView
func updateMainView(g *gocui.Gui) {
main_view, _ := g.View("main")
for i := range main_output {
main_view.Clear()
fmt.Fprintln(main_view, i)
g.Flush()
}
}
示例13: updateSparksView
func updateSparksView(g *gocui.Gui) {
sparks_view, _ := g.View("sparks")
for i := range sparks_output {
sparks_view.Clear()
fmt.Fprintln(sparks_view, i)
g.Flush()
}
}
示例14: updateStatusView
// the UI could be a lot smoother if there was less Clear()
// and Flush() .. Flush() could run on an interval instead of
// inside these update*View functions
func updateStatusView(g *gocui.Gui) {
status_view, _ := g.View("status")
for i := range status_output {
status_view.Clear()
fmt.Fprintln(status_view, i)
g.Flush()
}
}
示例15: textUp
func textUp(g *gocui.Gui, v *gocui.View) error {
if v, err := g.View(vText); err == nil {
ox, oy := v.Origin()
oy = oy - 10
v.SetOrigin(ox, oy)
}
return nil
}