本文整理汇总了Golang中github.com/jroimartin/gocui.View.Size方法的典型用法代码示例。如果您正苦于以下问题:Golang View.Size方法的具体用法?Golang View.Size怎么用?Golang View.Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jroimartin/gocui.View
的用法示例。
在下文中一共展示了View.Size方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: cursorPageDown
func cursorPageDown(g *gocui.Gui, v *gocui.View) error {
jump := pageUpDownJumpCount(v)
if v != nil {
cx, cy := v.Cursor()
ox, oy := v.Origin()
ok, yLimit := movable(v, oy+cy+jump)
_, maxY := v.Size()
if !ok {
if yLimit < maxY {
v.SetCursor(cx, yLimit)
} else {
v.SetCursor(cx, maxY-1)
v.SetOrigin(ox, yLimit-maxY+1)
}
} else if yLimit < oy+jump+maxY {
if yLimit < maxY {
v.SetCursor(cx, yLimit)
} else {
v.SetOrigin(ox, yLimit-maxY+1)
v.SetCursor(cx, maxY-1)
}
} else {
v.SetCursor(cx, cy)
v.SetOrigin(ox, oy+jump)
}
onMovingCursorRedrawView(g, v)
}
return nil
}
示例2: draw
func (self *stack) draw(v *gocui.View, refresh bool) {
if refresh {
self.written = false
}
if self.written {
return
}
v.Clear()
self.sx, self.sy = v.Size()
blob := self.contents[self.bump:]
for off, b := range blob {
cur := self.lastaddr + uint16(off) + uint16(self.bump)
if off%2 == 0 {
if cur == self.lastsp {
fmt.Fprintf(v, "%0.4x:>> ", cur)
} else {
fmt.Fprintf(v, "%0.4x: ", cur)
}
fmt.Fprintf(v, "%0.2x", b)
} else {
fmt.Fprintf(v, "%0.2x\n", b)
}
}
self.written = true
}
示例3: PrintTubeList
func PrintTubeList(v *gocui.View) {
line := fmt.Sprintf("%-35s %-22s %-22s", "Tube", "ready/delayed/buried", "waiting/watching/using")
fmt.Fprintln(v, line)
//Reload the tube stats - will detect new tubes and drop removed tubes
cTubes.UseAll()
//Calculate the size for paging
_, vy := v.Size()
cTubes.Pages = int(math.Ceil(float64(len(cTubes.Conns)) / float64(vy-1)))
offset := vy * (cTubes.Page - 1)
limit := vy * cTubes.Page
if limit > len(cTubes.Conns) {
limit = len(cTubes.Conns)
}
displayed := cTubes.Conns[offset:limit]
for _, tube := range displayed {
stats, _ := tube.Stats()
jobStats := stats["current-jobs-ready"] + " / " + stats["current-jobs-delayed"] + " / " + stats["current-jobs-buried"]
workerStats := stats["current-waiting"] + " / " + stats["current-watching"] + " / " + stats["current-using"]
line := fmt.Sprintf("%-35s %-22s %-22s", tube.Name, jobStats, workerStats)
fmt.Fprintln(v, line)
}
}
示例4: cursorMoveMiddle
func cursorMoveMiddle(g *gocui.Gui, v *gocui.View) error {
if v != nil {
_, maxY := v.Size()
cx, _ := v.Cursor()
v.SetCursor(cx, maxY/2)
}
onMovingCursorRedrawView(g, v)
return nil
}
示例5: draw
// draw a simple hex dump, filling available space
func (self *dump) draw(v *gocui.View, refresh bool) {
if refresh {
self.written = false
}
if self.written {
return
}
v.Clear()
self.sx, self.sy = v.Size()
xpos := 0
ypos := 0
p, _ := fmt.Fprintf(v, "%0.4X: ", self.addr)
xpos += p
bytesThisLine := 1
for off, b := range self.contents {
need := 3
pad := " "
if bytesThisLine != 1 && bytesThisLine%4 == 0 {
need += 2
pad = " "
}
if xpos < (self.sx - need) {
bytesThisLine++
p, _ = fmt.Fprintf(v, "%.2x%s", b, pad)
xpos += p
} else {
xpos = 0
bytesThisLine = 2
ypos += 1
v.Write([]byte("\n"))
if ypos == self.sy {
break
}
p, _ = fmt.Fprintf(v, "%0.4X: %0.2x ", self.addr+uint16(off), b)
xpos += p
}
}
v.Write([]byte("\n"))
self.written = true
}
示例6: cursorPgup
func cursorPgup(g *gocui.Gui, v *gocui.View) error {
ox, oy := v.Origin()
cx, cy := v.Cursor()
_, pageSizeY := v.Size()
pageSizeY--
if newOriginY := oy - pageSizeY; newOriginY > 0 {
v.SetOrigin(ox, newOriginY)
v.SetCursor(cx, cy)
} else {
v.SetOrigin(ox, 0)
v.SetCursor(cx, cy)
}
updateTracksView(g, v)
return nil
}
示例7: cursorEnd
func cursorEnd(g *gocui.Gui, v *gocui.View) error {
if newIndex := getCurrentViewSize(v); newIndex > -1 {
ox, _ := v.Origin()
cx, _ := v.Cursor()
_, sizeY := v.Size()
sizeY--
if newIndex > sizeY {
v.SetOrigin(ox, newIndex-sizeY)
v.SetCursor(cx, sizeY)
} else {
v.SetCursor(cx, newIndex)
}
updateTracksView(g, v)
}
return nil
}
示例8: cursorPgdn
func cursorPgdn(g *gocui.Gui, v *gocui.View) error {
if maxSize := getCurrentViewSize(v); maxSize > -1 {
ox, oy := v.Origin()
cx, cy := v.Cursor()
_, pageSizeY := v.Size()
pageSizeY--
newOriginY := oy + pageSizeY
if hasMorePages(newOriginY, cy, maxSize) {
v.SetOrigin(ox, newOriginY)
v.SetCursor(cx, cy)
} else if isNotInLastPage(oy, pageSizeY, maxSize) {
v.SetOrigin(ox, maxSize-pageSizeY)
v.SetCursor(cx, pageSizeY)
}
updateTracksView(g, v)
}
return nil
}
示例9: showMsg
func showMsg(g *gocui.Gui, v *gocui.View) error {
jump := 8
_, cy := v.Cursor()
_, oy := v.Origin()
ok, yLimit := movable(v, oy+cy+jump)
// maxX, maxY := v.Size()
_, maxY := v.Size()
l := fmt.Sprintf("cy: %d, oy: %d, maxY: %d, yLimit: %d, curCve %d, ok: %v", cy, oy, maxY, yLimit, currentCveInfo, ok)
// if v, err := g.SetView("msg", maxX/2-30, maxY/2, maxX/2+30, maxY/2+2); err != nil {
if v, err := g.SetView("msg", 10, maxY/2, 10+50, maxY/2+2); err != nil {
if err != gocui.ErrUnknownView {
return err
}
fmt.Fprintln(v, l)
if err := g.SetCurrentView("msg"); err != nil {
return err
}
}
return nil
}