l.ui = ui
}
-func (l *Label) setActive(active bool) {
+func (l *Label) uiSetActive(active bool) {
}
-func (l *Label) setBounds(x0, y0, x1, y1 int) {
+func (l *Label) uiSetBounds(x0, y0, x1, y1 int) {
l.x0 = x0
l.y0 = y0
l.x1 = x1
l.y1 = y1
}
-func (l *Label) draw() {
+func (l *Label) uiDraw() {
reader := strings.NewReader(l.Text)
for y := l.y0; y < l.y1; y++ {
for x := l.x0; x < l.x1; x++ {
}
}
-func (l *Label) keyEvent(mod Modifier, key Key) {
+func (l *Label) uiKeyEvent(mod Modifier, key Key) {
}
-func (l *Label) characterEvent(chr rune) {
+func (l *Label) uiCharacterEvent(chr rune) {
}
t.ui = ui
}
-func (t *Textbox) setBounds(x0, y0, x1, y1 int) {
+func (t *Textbox) uiSetActive(active bool) {
+ t.active = active
+}
+
+func (t *Textbox) uiSetBounds(x0, y0, x1, y1 int) {
t.x0 = x0
t.y0 = y0
t.x1 = x1
t.y1 = y1
}
-func (t *Textbox) setActive(active bool) {
- t.active = active
-}
-
-func (t *Textbox) draw() {
+func (t *Textbox) uiDraw() {
var setCursor = false
reader := strings.NewReader(t.Text)
for y := t.y0; y < t.y1; y++ {
}
}
-func (t *Textbox) keyEvent(mod Modifier, key Key) {
+func (t *Textbox) uiKeyEvent(mod Modifier, key Key) {
redraw := false
switch key {
case KeyCtrlC:
}
}
if redraw {
- t.draw()
+ t.uiDraw()
termbox.Flush()
}
}
-func (t *Textbox) characterEvent(chr rune) {
+func (t *Textbox) uiCharacterEvent(chr rune) {
t.Text = t.Text + string(chr)
- t.draw()
+ t.uiDraw()
termbox.Flush()
}
t.ui = ui
}
-func (t *Textview) setActive(active bool) {
+func (t *Textview) uiSetActive(active bool) {
}
-func (t *Textview) setBounds(x0, y0, x1, y1 int) {
+func (t *Textview) uiSetBounds(x0, y0, x1, y1 int) {
t.x0 = x0
t.y0 = y0
t.x1 = x1
t.parsedLines = nil
}
-func (t *Textview) draw() {
+func (t *Textview) uiDraw() {
var reader *strings.Reader
line := len(t.parsedLines) - 1 - t.CurrentLine
if line < 0 {
}
}
-func (t *Textview) keyEvent(mod Modifier, key Key) {
+func (t *Textview) uiKeyEvent(mod Modifier, key Key) {
}
-func (t *Textview) characterEvent(chr rune) {
+func (t *Textview) uiCharacterEvent(chr rune) {
}
t.ui = ui
}
-func (t *Tree) setBounds(x0, y0, x1, y1 int) {
+func (t *Tree) uiSetActive(active bool) {
+ t.active = active
+}
+
+func (t *Tree) uiSetBounds(x0, y0, x1, y1 int) {
t.x0 = x0
t.y0 = y0
t.x1 = x1
return lines
}
-func (t *Tree) draw() {
+func (t *Tree) uiDraw() {
if t.lines == nil {
t.Rebuild()
}
}
}
-func (t *Tree) setActive(active bool) {
- t.active = active
-}
-
-func (t *Tree) keyEvent(mod Modifier, key Key) {
+func (t *Tree) uiKeyEvent(mod Modifier, key Key) {
switch key {
case KeyArrowUp:
t.activeLine = bounded(t.activeLine-1, 0, len(t.lines)-1)
t.ui.Refresh()
}
-func (t *Tree) characterEvent(ch rune) {
+func (t *Tree) uiCharacterEvent(ch rune) {
}
termbox.Clear(termbox.Attribute(ui.Fg), termbox.Attribute(ui.Bg))
termbox.HideCursor()
for _, element := range ui.elements {
- element.View.draw()
+ element.View.uiDraw()
}
termbox.Flush()
}
func (ui *Ui) SetActive(name string) {
element, _ := ui.elements[name]
if ui.activeElement != nil {
- ui.activeElement.View.setActive(false)
+ ui.activeElement.View.uiSetActive(false)
}
ui.activeElement = element
if element != nil {
- element.View.setActive(true)
+ element.View.uiSetActive(true)
}
ui.Refresh()
}
func (ui *Ui) onCharacterEvent(ch rune) {
if ui.activeElement != nil {
- ui.activeElement.View.characterEvent(ch)
+ ui.activeElement.View.uiCharacterEvent(ch)
}
}
}
}
if ui.activeElement != nil {
- ui.activeElement.View.keyEvent(mod, key)
+ ui.activeElement.View.uiKeyEvent(mod, key)
}
}
func (ui *Ui) SetBounds(name string, x0, y0, x1, y1 int) error {
element, ok := ui.elements[name]
if !ok {
- return errors.New("view cannot be found")
+ return errors.New("view does not exist")
}
- element.X0 = x0
- element.Y0 = y0
- element.X1 = x1
- element.Y1 = y1
- element.View.setBounds(x0, y0, x1, y1)
+ element.X0, element.Y0, element.X1, element.Y1 = x0, y0, x1, y1
+ element.View.uiSetBounds(x0, y0, x1, y1)
return nil
}
type View interface {
uiInitialize(ui *Ui)
- setActive(active bool)
- setBounds(x0, y0, x1, y1 int)
- draw()
- keyEvent(mod Modifier, key Key)
- characterEvent(ch rune)
+ uiSetActive(active bool)
+ uiSetBounds(x0, y0, x1, y1 int)
+ uiDraw()
+ uiKeyEvent(mod Modifier, key Key)
+ uiCharacterEvent(ch rune)
}