func (a *CellView) SetView(view View) {
	port := a.port
	port.SetView(view)
	a.view = view
	if view == nil {
		return
	}
	width, height := view.Size()
	a.port.Resize(0, 0, width, height)
	if a.model != nil {
		w, h := a.model.GetBounds()
		a.port.SetContentSize(w, h, true)
	}
	a.Resize()
}
SetView sets the View context.
package views
import (
	"sync"
	"github.com/gdamore/tcell"
)
type CellModel interface {
	GetCell(x, y int) (rune, tcell.Style, []rune, int)
	GetBounds() (int, int)
	SetCursor(int, int)
	GetCursor() (int, int, bool, bool)
	MoveCursor(offx, offy int)
}
type CellView struct {
	port     *ViewPort
	view     View
	content  Widget
	contentV *ViewPort
	cursorX  int
	cursorY  int
	style    tcell.Style
	lines    []string
	model    CellModel
	once     sync.Once
	WidgetWatchers
}
func (a *CellView) Draw() {
	port := a.port
	model := a.model
	port.Fill(' ', a.style)
	if a.view == nil {
		return
	}
	if model == nil {
		return
	}
	vw, vh := a.view.Size()
	for y := 0; y < vh; y++ {
		for x := 0; x < vw; x++ {
			a.view.SetContent(x, y, ' ', nil, a.style)
		}
	}
	ex, ey := model.GetBounds()
	vx, vy := port.Size()
	if ex < vx {
		ex = vx
	}
	if ey < vy {
		ey = vy
	}
	for y := 0; y < ey; y++ {
		for x := 0; x < ex; x++ {
			ch, style, comb, wid := model.GetCell(x, y)
			if ch == 0 {
				ch = ' '
				style = a.style
			}
			cx, cy, en, sh := a.model.GetCursor()
			if en && x == cx && y == cy && sh {
				style = style.Reverse(true)
			}
			port.SetContent(x, y, ch, comb, style)
			x += wid - 1
		}
	}
}
func (a *CellView) keyUp() {
	if _, _, en, _ := a.model.GetCursor(); !en {
		a.port.ScrollUp(1)
		return
	}
	a.model.MoveCursor(0, -1)
	a.MakeCursorVisible()
}
func (a *CellView) keyDown() {
	if _, _, en, _ := a.model.GetCursor(); !en {
		a.port.ScrollDown(1)
		return
	}
	a.model.MoveCursor(0, 1)
	a.MakeCursorVisible()
}
func (a *CellView) keyLeft() {
	if _, _, en, _ := a.model.GetCursor(); !en {
		a.port.ScrollLeft(1)
		return
	}
	a.model.MoveCursor(-1, 0)
	a.MakeCursorVisible()
}
func (a *CellView) keyRight() {
	if _, _, en, _ := a.model.GetCursor(); !en {
		a.port.ScrollRight(1)
		return
	}
	a.model.MoveCursor(+1, 0)
	a.MakeCursorVisible()
}
func (a *CellView) keyPgUp() {
	_, vy := a.port.Size()
	if _, _, en, _ := a.model.GetCursor(); !en {
		a.port.ScrollUp(vy)
		return
	}
	a.model.MoveCursor(0, -vy)
	a.MakeCursorVisible()
}
func (a *CellView) keyPgDn() {
	_, vy := a.port.Size()
	if _, _, en, _ := a.model.GetCursor(); !en {
		a.port.ScrollDown(vy)
		return
	}
	a.model.MoveCursor(0, +vy)
	a.MakeCursorVisible()
}
func (a *CellView) keyHome() {
	vx, vy := a.model.GetBounds()
	if _, _, en, _ := a.model.GetCursor(); !en {
		a.port.ScrollUp(vy)
		a.port.ScrollLeft(vx)
		return
	}
	a.model.SetCursor(0, 0)
	a.MakeCursorVisible()
}
func (a *CellView) keyEnd() {
	vx, vy := a.model.GetBounds()
	if _, _, en, _ := a.model.GetCursor(); !en {
		a.port.ScrollDown(vy)
		a.port.ScrollRight(vx)
		return
	}
	a.model.SetCursor(vx, vy)
	a.MakeCursorVisible()
}
func (a *CellView) MakeCursorVisible() {
	if a.model == nil {
		return
	}
	x, y, enabled, _ := a.model.GetCursor()
	if enabled {
		a.MakeVisible(x, y)
	}
}
func (a *CellView) HandleEvent(e tcell.Event) bool {
	if a.model == nil {
		return false
	}
	switch e := e.(type) {
	case *tcell.EventKey:
		switch e.Key() {
		case tcell.KeyUp, tcell.KeyCtrlP:
			a.keyUp()
			return true
		case tcell.KeyDown, tcell.KeyCtrlN:
			a.keyDown()
			return true
		case tcell.KeyRight, tcell.KeyCtrlF:
			a.keyRight()
			return true
		case tcell.KeyLeft, tcell.KeyCtrlB:
			a.keyLeft()
			return true
		case tcell.KeyPgDn:
			a.keyPgDn()
			return true
		case tcell.KeyPgUp:
			a.keyPgUp()
			return true
		case tcell.KeyEnd:
			a.keyEnd()
			return true
		case tcell.KeyHome:
			a.keyHome()
			return true
		}
	}
	return false
}
func (a *CellView) Size() (int, int) {
	w, h := a.model.GetBounds()
	if w > 2 {
		w = 2
	}
	if h > 2 {
		h = 2
	}
	return w, h
}
func (a *CellView) SetModel(model CellModel) {
	w, h := model.GetBounds()
	model.SetCursor(0, 0)
	a.model = model
	a.port.SetContentSize(w, h, true)
	a.port.ValidateView()
	a.PostEventWidgetContent(a)
}