Пример #1
0
// Handle an input event
// Only used for resizing panel
func (lp *LogPanel) HandleInput(ev termbox.Event) {
	if ev.Type == termbox.EventResize {
		w, h := termbox.Size()
		r := image.Rect(1, h-7, w-1, h-3)
		lp.Buffered = panel.NewBuffered(r, termbox.Cell{'s', termbox.ColorGreen, 0})
	}
}
Пример #2
0
func (c *PlayerPanel) HandleInput(ev termbox.Event) {
	if ev.Type == termbox.EventResize {
		w, h := termbox.Size()
		r := image.Rect(1, h-2, w/2, h-1)
		c.Buffered = panel.NewBuffered(r, termbox.Cell{'s', termbox.ColorGreen, 0})
	}
}
Пример #3
0
func (s *StatsPanel) HandleInput(ev termbox.Event) {
	if ev.Type == termbox.EventResize {
		w, _ := termbox.Size()
		r := image.Rect(1, 1, w-1, 2)
		s.Buffered = panel.NewBuffered(r, termbox.Cell{'s', termbox.ColorGreen, 0})
	}
}
Пример #4
0
func (vp *ViewPanel) HandleInput(ev termbox.Event) {
	if ev.Type == termbox.EventResize {
		w, h := termbox.Size()
		r := image.Rect(VIEW_START_X, VIEW_START_Y, w-VIEW_PAD_X, h-VIEW_PAD_Y)
		vp.Buffered = panel.NewBuffered(r, termbox.Cell{'s', termbox.ColorGreen, 0})

		vp.cam = NewCamera(r)

		//vp.cam.SetCenter(image.Pt(vp.g.Player.GetPos()))
	}
}
Пример #5
0
func (c *ChatPanel) HandleInput(ev termbox.Event) {
	c.m.Lock()
	defer c.m.Unlock()
	switch ev.Type {
	case termbox.EventKey:
		if ev.Ch != 0 {
			c.WriteRune(ev.Ch)
		} else {
			switch ev.Key {
			case termbox.KeySpace:
				// just add a space
				c.WriteRune(' ')

			case termbox.KeyBackspace:
				fallthrough

			case termbox.KeyBackspace2:
				// on backspace, remove the last rune in the buffer
				if c.Len() > 0 {
					_, size := utf8.DecodeLastRune(c.Bytes())
					c.Truncate(c.Len() - size)
				}

			case termbox.KeyCtrlU:
				// clear the buffer, like a UNIX terminal
				c.Reset()

			case termbox.KeyEnter:
				// input confirmed, send it
				if c.Len() > 0 {
					c.g.SendPacket(gnet.NewPacket("Tchat", c.String()))
					c.Reset()
					c.term.SetInputHandler(nil)

				}
			case termbox.KeyEsc:
				// input cancelled
				c.Reset()
				c.term.SetInputHandler(nil)
			}
		}
	case termbox.EventResize:
		w, h := termbox.Size()
		r := image.Rect(w-1, h-2, w/2, h-1)
		c.Buffered = panel.NewBuffered(r, termbox.Cell{'s', termbox.ColorGreen, 0})

	}

}
Пример #6
0
func newOcto() *panel.Buffered {
	p := panel.NewBuffered(image.Rect(10, 30, 50, 54), termbox.Cell{'d', 2, 0}).Clear()
	p.Write(octo)
	panels = append(panels, p)
	return p
}