1package termbox
2
3// private API, common OS agnostic part
4
5type cellbuf struct {
6	width  int
7	height int
8	cells  []Cell
9}
10
11func (this *cellbuf) init(width, height int) {
12	this.width = width
13	this.height = height
14	this.cells = make([]Cell, width*height)
15}
16
17func (this *cellbuf) resize(width, height int) {
18	if this.width == width && this.height == height {
19		return
20	}
21
22	oldw := this.width
23	oldh := this.height
24	oldcells := this.cells
25
26	this.init(width, height)
27	this.clear()
28
29	minw, minh := oldw, oldh
30
31	if width < minw {
32		minw = width
33	}
34	if height < minh {
35		minh = height
36	}
37
38	for i := 0; i < minh; i++ {
39		srco, dsto := i*oldw, i*width
40		src := oldcells[srco : srco+minw]
41		dst := this.cells[dsto : dsto+minw]
42		copy(dst, src)
43	}
44}
45
46func (this *cellbuf) clear() {
47	for i := range this.cells {
48		c := &this.cells[i]
49		c.Ch = ' '
50		c.Fg = foreground
51		c.Bg = background
52	}
53}
54
55const cursor_hidden = -1
56
57func is_cursor_hidden(x, y int) bool {
58	return x == cursor_hidden || y == cursor_hidden
59}
60