Example #1
0
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
}
Example #2
0
// 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
}
Example #3
0
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()
}