Exemple #1
0
func (bf *ButtonsField) DrawInto(box box.Box, x, y int) {
	// do something to centre it.
	curX := x
	for b, butt := range bf.buttons {
		for _, ch := range butt.Text {
			curX++
			if b == bf.currentlySelected {
				box.SetCell(curX, y, ch, termbox.ColorWhite, termbox.ColorGreen)
			} else {
				box.SetCell(curX, y, ch, termbox.ColorWhite, termbox.ColorBlue)
			}
		}
		curX += 2
	}
}
Exemple #2
0
func DrawString(str string, box box.Box, offsetX, offsetY, width int) {
	curX := offsetX
	curY := offsetY
	str = FlowString(str, width)
	for _, ch := range str {
		switch ch {
		case '\r':
			curX = offsetX
		case '\n':
			curY++
		default:
			cell := box.GetCell(curX, curY)
			box.SetCell(curX, curY, ch, cell.Fg, cell.Bg)
			curX++
		}
	}

}