本文整理汇总了Golang中github.com/jroimartin/gocui.View.Write方法的典型用法代码示例。如果您正苦于以下问题:Golang View.Write方法的具体用法?Golang View.Write怎么用?Golang View.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jroimartin/gocui.View
的用法示例。
在下文中一共展示了View.Write方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: draw
func (self *source) draw(v *gocui.View, refresh bool) {
if refresh {
self.written = false
}
if self.written {
return
}
v.Write(self.contents)
self.written = true
}
示例2: 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
}
示例3: draw
func (self *output) draw(v *gocui.View, refresh bool) {
if refresh {
self.written = 0
}
if self.written == self.contents.Len() {
return
}
buf := self.contents.Bytes()
v.Write(buf[self.written:])
self.written = self.contents.Len()
}