Documentation
¶
Index ¶
- Constants
- Variables
- func Apply(ui *UI, ss ...Setting) error
- func ContinueExecution(bb []bool) func() bool
- func ContinueExecutionN(n int) func() bool
- func WantNextRepaintIn(dd []time.Duration) func() time.Duration
- func WantNextRepaintInD(d time.Duration) func() time.Duration
- type Call
- type Calls
- type Ops
- func (oo *Ops) AfterDisplay(rc backends.RepaintController)
- func (oo *Ops) BeforeDisplay(cb func())
- func (oo *Ops) Implements(backends.LytFlags, image.Point) backends.LytFlags
- func (or Ops) LenPaintedRects() int
- func (or Ops) LenPaintedRunes() int
- func (oo *Ops) PaintRect(dim image.Rectangle, c backends.Color)
- func (oo *Ops) PaintRune(r rune, column, row int, lyt backends.Layout)
- func (or Ops) PaintedRect(idx int) Rect
- func (or Ops) PaintedRune(idx int) Rune
- func (oo *Ops) SetImplements(ff backends.LytFlags) *Ops
- func (oo *Ops) Stat() OpsInfo
- type OpsInfo
- type Rect
- type Rects
- type Repainter
- func (r *Repainter) BufferCount() int
- func (r *Repainter) Execute(env backends.RepaintEnv) (done bool)
- func (r *Repainter) ExecuteCount() int
- func (r *Repainter) ID() string
- func (r *Repainter) IsStopped() bool
- func (r *Repainter) LastBuffer() *backends.DisplayBuffer
- func (r *Repainter) Origin() (x, y int)
- func (r *Repainter) Replacing() bool
- func (r *Repainter) SetID(id string)
- func (r *Repainter) SetOrigin(x, y uint)
- func (r *Repainter) SetReplacing(isReplacing bool)
- func (r *Repainter) Stop()
- func (r *Repainter) WantNextRepaintIn() (d time.Duration)
- func (r *Repainter) WantNextRepaintInCount() int
- type Rune
- type Runes
- type Setting
- type UI
- func (ui *UI) Apply(rc backends.ReConfig)
- func (ui *UI) Cleanup()
- func (ui *UI) Display() error
- func (ui *UI) Inject(evt backends.Event)
- func (ui *UI) InjectAsync(evt backends.Event)
- func (ui *UI) InjectAsyncFrame(columns, rows int)
- func (ui *UI) InjectAsyncKey(r rune, m backends.KeyModifier)
- func (ui *UI) LenPaintCalls() int
- func (ui *UI) LenPaintedRects() int
- func (ui *UI) LenPaintedRunes() int
- func (ui *UI) Paint(paint backends.Painter, lyt backends.Layout, column, row int, rr ...rune)
- func (ui *UI) PaintCall(n int) Call
- func (ui *UI) PaintedRect(n int) Rect
- func (ui *UI) PaintedRune(n int) Rune
- func (ui *UI) Poll() backends.Event
- func (ui *UI) Size() image.Point
- func (ui *UI) WaitForPolling()
Constants ¶
const ( // ColumnsDefault is reported by UI.Size if an ui's set columns // dimension is zero. ColumnsDefault = 80 // RowsDefault is reported by UI.Size if an ui's set rows dimension // is zero. RowsDefault = 24 )
Variables ¶
var DefaultExecuteDone = true
DefaultExecuteDone is reported by Repainter instance which is out of Repainter.ContinueExecution values.
var DefaultNextRepaintDuration = time.Duration(0)
DefaultNextRepaintDuration is reported by an Repainter instance which is out of Repainter.WantNextRepaintsIn values.
var (
MockedRepainterImplementation = uuid.NewString()
)
Functions ¶
func ContinueExecution ¶ added in v0.7.0
WantNextRepaintIn creates a closure around given Repainter.Execute return values which can be assigned to Repainter.ContinueExecution.
func ContinueExecutionN ¶ added in v0.7.0
WantNextRepaintIn creates a closure around given Repainter.Execute return values which can be assigned to Repainter.ContinueExecution.
func WantNextRepaintIn ¶ added in v0.7.0
WantNextRepaintIn creates a closure around given durations which can be assigned to Repainter.WantNextRepaintIn providing the mocked repaint duration of a mocked Repainter.
Types ¶
type Ops ¶ added in v0.7.0
type Ops struct {
// contains filtered or unexported fields
}
Ops implements backends.Ops.
func (*Ops) AfterDisplay ¶ added in v0.7.0
func (oo *Ops) AfterDisplay(rc backends.RepaintController)
AfterDisplay sets a callback which is supposed to be called after painting instructions are painted to the display.
func (*Ops) BeforeDisplay ¶ added in v0.7.0
func (oo *Ops) BeforeDisplay(cb func())
BeforeDisplay sets a callback which is supposed to be called before painting instructions are painted to the display.
func (*Ops) Implements ¶ added in v0.7.0
Implements is a dummy implementation of backends.Ops.Implements which pretends to implement given ops instance oo set layout flags.
func (Ops) LenPaintedRects ¶ added in v0.7.0
func (or Ops) LenPaintedRects() int
func (Ops) LenPaintedRunes ¶ added in v0.7.0
func (or Ops) LenPaintedRunes() int
func (*Ops) PaintRect ¶ added in v0.7.0
PaintRect is a dummy implementation of backends.Ops.PaintRect which only records the request.
func (*Ops) PaintRune ¶ added in v0.7.0
PaintRune is a dummy implementation of backends.Ops.PaintRune which only records the request.
func (Ops) PaintedRect ¶ added in v0.7.0
func (Ops) PaintedRune ¶ added in v0.7.0
type OpsInfo ¶ added in v0.7.0
type OpsInfo struct {
BeforeDisplay func()
AfterDisplay backends.RepaintController
}
type Repainter ¶ added in v0.7.0
type Repainter struct {
// WantNextRepaintsIn are the return values of a repainter mock's
// subsequent calls of Repainter.WantNextRepaintIn
WantNextRepaintsIn func() time.Duration
// ContinueExecution are the return values of a repainter mock's
// subsequent calls of Repainter.Execute
ContinueExecution func() bool
InjectedExecution func(backends.RepaintEnv) (done bool)
// contains filtered or unexported fields
}
Repainter implements backends.Repainter.
func (*Repainter) BufferCount ¶ added in v0.7.0
BufferCount reports with how many different buffer instances Repainter.Execute was called.
func (*Repainter) Execute ¶ added in v0.7.0
func (r *Repainter) Execute(env backends.RepaintEnv) (done bool)
Execute implements backends.Repainter.Execute and reports the values from given repainter r's ContinueExecution field unless r is out of values or stopped in which case DefaultExecuteDone is reported.
func (*Repainter) ExecuteCount ¶ added in v0.7.0
ExecuteCount reports how many time given repainter r's Execute method was called.
func (*Repainter) LastBuffer ¶ added in v0.7.0
func (r *Repainter) LastBuffer() *backends.DisplayBuffer
func (*Repainter) SetOrigin ¶ added in v0.7.0
SetOrigin implements backends.Repainter.SetOrigin; Note set value is reported by Repainter.Origin.
func (*Repainter) SetReplacing ¶ added in v0.7.0
func (*Repainter) Stop ¶ added in v0.7.0
func (r *Repainter) Stop()
Stop has given repainter r been done in the next repainting cycle.
func (*Repainter) WantNextRepaintIn ¶ added in v0.7.0
WantNextRepaintIn implements backends.Repainter.WantNextRepaintIn and reports the values from given repainter r's WantNextRepaintsIn field or DefaultExecuteDone if out of values.
func (*Repainter) WantNextRepaintInCount ¶ added in v0.7.0
WantNextRepaintInCount reports how many times given repainter r's WantNextRepaintsIn method was called.
type Setting ¶
type Setting = settingspkg.Setting
func BeforeRepaint ¶ added in v0.7.0
func MergedRepaint ¶ added in v0.7.0
func PanicEventPolling ¶
func SetImplements ¶
type UI ¶
type UI struct {
// contains filtered or unexported fields
}
UI is a backends implementation that reports only self-injected events for testing.
func Register ¶
func Register(ui *UI, scc *settingspkg.Contexts) *UI
Register given mocked ui on given settings context scc. While ui may be nil and is created Register panics if scc is nil.
func (*UI) Apply ¶ added in v0.7.0
Apply reconfigures given ui's behavior according to set ReConfig rc.Instructions.
func (*UI) Cleanup ¶
func (ui *UI) Cleanup()
Cleanup implements backend.UIer.Cleanup ensuring that the event polling go routine in vw.loop returns.
func (*UI) Display ¶
Display blocks the main go routine in production avoiding premature exiting of the main go routine. Hence production Display implementations will never return no matter what. Since this behavior is irrelevant for testing the effort dealing with a blocking vw.Display call can be spared.
func (*UI) Inject ¶
Inject injects given event to the event queue. NOTE Inject blocks until the event is polled! I.e. you can not inject and receive (quit/key) events in the same go routine.
func (*UI) InjectAsync ¶ added in v0.7.0
InjectAsync injects given event and returns instantly, i.e. before the event is reported.
func (*UI) InjectAsyncFrame ¶ added in v0.7.0
InjectAsyncFrame injects a backends.FrameEvent with given columns and rows counts without waiting for it being reported.
func (*UI) InjectAsyncKey ¶ added in v0.7.0
func (ui *UI) InjectAsyncKey(r rune, m backends.KeyModifier)
InjectAsyncFrame injects a backends.KeyEvent with given rune and modifier without waiting for it being reported.
func (*UI) LenPaintCalls ¶
func (*UI) LenPaintedRects ¶
LenPaintedRects return the number of rectangle painted by given ui's backends.Ops implementation.
func (*UI) LenPaintedRunes ¶
LenPaintedRunes returns the number of runes painted by given ui's backends.Ops implementation.
func (*UI) PaintedRect ¶
PaintedRect returns the n-th painted rectangle by the backends.Ops implementation of given ui.
func (*UI) PaintedRune ¶
PaintedRune returns the n-th painted rune by the backends.Ops implementation of given ui.
func (*UI) Size ¶
Size reports given ui's currently set size. Note set size is modified by injecting a backends.ResizeEvent. Note a zero columns dimension defaults to mock.ColumnsDefault and a zero rows dimension to mock.RowsDefault.
func (*UI) WaitForPolling ¶
func (ui *UI) WaitForPolling()
WaitForPolling implements backend.UIer.WaitForPolling mocking an WaitForPolling blocks until the event loop starts polling