|
|
@ -13,6 +13,7 @@ import ( |
|
|
|
type Screen struct { |
|
|
|
type Screen struct { |
|
|
|
width int |
|
|
|
width int |
|
|
|
height int |
|
|
|
height int |
|
|
|
|
|
|
|
cleared bool |
|
|
|
tags map[string]termbox.Attribute |
|
|
|
tags map[string]termbox.Attribute |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -44,12 +45,14 @@ func (self *Screen) Initialize() *Screen { |
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
func (self *Screen) Resize() *Screen { |
|
|
|
func (self *Screen) Resize() *Screen { |
|
|
|
self.width, self.height = termbox.Size() |
|
|
|
self.width, self.height = termbox.Size() |
|
|
|
|
|
|
|
self.cleared = false |
|
|
|
return self |
|
|
|
return self |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
func (self *Screen) Clear() *Screen { |
|
|
|
func (self *Screen) Clear() *Screen { |
|
|
|
termbox.Clear(termbox.ColorDefault, termbox.ColorDefault) |
|
|
|
termbox.Clear(termbox.ColorDefault, termbox.ColorDefault) |
|
|
|
|
|
|
|
self.cleared = true |
|
|
|
return self |
|
|
|
return self |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -121,6 +124,9 @@ func (self *Screen) DrawLine(x int, y int, str string) { |
|
|
|
// private
|
|
|
|
// private
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
func (self *Screen) draw(str string) { |
|
|
|
func (self *Screen) draw(str string) { |
|
|
|
|
|
|
|
if !self.cleared { |
|
|
|
|
|
|
|
self.Clear() |
|
|
|
|
|
|
|
} |
|
|
|
for row, line := range strings.Split(str, "\n") { |
|
|
|
for row, line := range strings.Split(str, "\n") { |
|
|
|
self.DrawLine(0, row, line) |
|
|
|
self.DrawLine(0, row, line) |
|
|
|
} |
|
|
|
} |
|
|
|