aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/nsf/termbox-go/termbox_common.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-30 18:11:53 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-30 18:11:53 +0200
commitbb9168f98a9dd50a7215652ab77a1c46615064cd (patch)
tree8ee16c1b5c6078cd48427c799375b78c95749bcd /vendor/github.com/nsf/termbox-go/termbox_common.go
parent29bb7364c8e873c72a386f4f6fa26248e5355cb2 (diff)
downloadgit-bug-bb9168f98a9dd50a7215652ab77a1c46615064cd.tar.gz
vendor gocui
Diffstat (limited to 'vendor/github.com/nsf/termbox-go/termbox_common.go')
-rw-r--r--vendor/github.com/nsf/termbox-go/termbox_common.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/vendor/github.com/nsf/termbox-go/termbox_common.go b/vendor/github.com/nsf/termbox-go/termbox_common.go
new file mode 100644
index 00000000..c3355cc2
--- /dev/null
+++ b/vendor/github.com/nsf/termbox-go/termbox_common.go
@@ -0,0 +1,59 @@
+package termbox
+
+// private API, common OS agnostic part
+
+type cellbuf struct {
+ width int
+ height int
+ cells []Cell
+}
+
+func (this *cellbuf) init(width, height int) {
+ this.width = width
+ this.height = height
+ this.cells = make([]Cell, width*height)
+}
+
+func (this *cellbuf) resize(width, height int) {
+ if this.width == width && this.height == height {
+ return
+ }
+
+ oldw := this.width
+ oldh := this.height
+ oldcells := this.cells
+
+ this.init(width, height)
+ this.clear()
+
+ minw, minh := oldw, oldh
+
+ if width < minw {
+ minw = width
+ }
+ if height < minh {
+ minh = height
+ }
+
+ for i := 0; i < minh; i++ {
+ srco, dsto := i*oldw, i*width
+ src := oldcells[srco : srco+minw]
+ dst := this.cells[dsto : dsto+minw]
+ copy(dst, src)
+ }
+}
+
+func (this *cellbuf) clear() {
+ for i := range this.cells {
+ c := &this.cells[i]
+ c.Ch = ' '
+ c.Fg = foreground
+ c.Bg = background
+ }
+}
+
+const cursor_hidden = -1
+
+func is_cursor_hidden(x, y int) bool {
+ return x == cursor_hidden || y == cursor_hidden
+}