Documentation
¶
Index ¶
- Constants
- Variables
- func GotoCmd(gt cll.Goto) cll.Command
- func MkNBLines(n NLines) []byte
- func OnKey(k vw.SpecialKey, cmd cll.Command) kbCommand
- func OnRune(r rune, cmd cll.Command) kbCommand
- func Set(s *SubController, ss ...any) []any
- func SetCmd(s *SubController, ky vw.Key, vl cll.Command)
- type CEBuffer
- type CmdBar
- type CommanderContext
- type ContentContext
- type ContentEnv
- type Cursor
- type ID
- type Lines
- type LinesOffset
- type LytRanges
- type NLines
- type OtherFactory
- type PredecessorMock
- type Runes
- type SplitEnv
- type Stat
- type SubController
- func (sc *SubController) Call(env cll.CmdEnv) (cll.Goto, error)
- func (sc *SubController) Content(env cll.ContentEnv) (cll.Next, int)
- func (sc *SubController) LastContentEnv() cll.ContentEnv
- func (sc *SubController) ReplaceCommand(ky vw.Key, cmd cll.Command)
- func (sc *SubController) Set(ss ...any) *SubController
- func (sc *SubController) Stat() cll.Info
- type Width
Constants ¶
const ( // DefaultCommanderContextLabel is the SplitEnv.CommanderContext // label of an SplitEnv instance which has no commander context set. DefaultCommanderContextLabel = "mocked commander context" // DefaultContentContextLabel is the SplitEnv.ContentContext label // of an SplitEnv instance which has no content context set. DefaultContentContextLabel = "mocked content context" )
const DefaultSubControllerID = "sub-controller mock's ID"
DefaultSubControllerID is reported by the zero value of mck.SubController.
Variables ¶
var DefaultCommandBarMock = cll.CommandBar{ BarEnv: cll.BarEnv{ CommandSeparator: " ", LabelSeparator: ": ", Label: "default command bar mock", Left: cll.Idxs{0}, Right: cll.Idxs{3}, }, Cmds: *new(cll.BarCommands).Add( cll.BC{Label: "cmd-1"}, cll.BC{Label: "cmd-2"}, cll.BC{Label: "cmd-3"}, cll.BC{Label: "cmd-4"}, ), }
Functions ¶
func GotoCmd ¶ added in v0.8.0
GotoCmd conveniently provides the easiest way to create a command function returning given Goto for any rune or special key event.
func OnKey ¶
func OnKey(k vw.SpecialKey, cmd cll.Command) kbCommand
OnKey defines the controllers.Info that is returned when Set SubController instance receives given special key.
func OnRune ¶
OnRune registers a command that returns given controllers.Info and controllers.Goto request on given rune input.
func Set ¶ added in v0.8.0
func Set(s *SubController, ss ...any) []any
Types ¶
type CmdBar ¶
type CmdBar cll.CommandBar
type CommanderContext ¶
CommanderContext can be passed to SplitEnv.Set inject a commander context into an SplitEnv instance.
type ContentContext ¶
ContentContext can be passed to SplitEnv.Set inject a content context into an SplitEnv instance.
type ContentEnv ¶ added in v0.8.0
type ContentEnv struct {
// contains filtered or unexported fields
}
ContentEnv provides an environment for a sub-controllers content calculation. Its merit is that new(mck.ContentEnv).Mock() provides a reasonably set up controllers.ContentEnv instance.
func (ContentEnv) Mock ¶ added in v0.8.0
func (ce ContentEnv) Mock() cll.ContentEnv
Mock provide the wrapped controllers.ViewInfo with reasonable defaults injected in case they weren't set.
func (*ContentEnv) Set ¶ added in v0.8.0
func (ce *ContentEnv) Set(values ...any) *ContentEnv
Set fields of wrapped controllers.ViewInfo instance.
func (ContentEnv) Zero ¶ added in v0.8.0
func (ce ContentEnv) Zero() cll.ContentEnv
Zero returns a zero content env; This method is here to emphasize that the behavior for a zero content environment is tested.
type ID ¶
type ID string
ID sets the ID which is provided in the Info value returned by SubController.Stat or SubController.Receiver.
type LinesOffset ¶
type LinesOffset int
LinesOffset defines the display lines offset returned by SubController.Content
type LytRanges ¶
type LytRanges cll.LayoutRanges
LytRange sets the layout range provided by SubController.Content.
type OtherFactory ¶ added in v0.8.0
type OtherFactory func(string) cll.SubController
A OtherFactory when SplitEnv.Set is used by SplitEnv.Content to create the requested content. If unset a content Mock with given Id is created.
type PredecessorMock ¶
type PredecessorMock func()
func (PredecessorMock) Goto ¶
func (pm PredecessorMock) Goto()
type SplitEnv ¶
type SplitEnv struct {
// RequestedCancellation is set to true if SplitEnv.Cancel was
// called
RequestedCancellation bool
// RequestedContent is set by SplitEnv.Content to its given id
// string
RequestedContent string
// RequestedSettingOther is set by SplitEnv.SetOther to its given
// content
RequestedSettingOther cll.SubController
// contains filtered or unexported fields
}
SplitEnv implements controllers.SplitEnv end helps observing the behavior of a controllers.Splitter.
func (*SplitEnv) Cancel ¶
func (env *SplitEnv) Cancel()
Cancel sets SplitEnv.RequestedCancel to true.
func (*SplitEnv) CommanderContext ¶
func (env *SplitEnv) CommanderContext() cll.ContextInfo
CommanderContext provides an optionally set mock.CommanderContext or a default commander context with mck.DefaultCommanderContextLabel.
func (*SplitEnv) EditorContext ¶ added in v0.8.0
func (env *SplitEnv) EditorContext() cll.ContextInfo
ContentContext provides an optionally set mock.ContentContext or a default content context with mck.DefaultContentContextLabel.
type SubController ¶
type SubController struct {
// contains filtered or unexported fields
}
SubController implements cll.SubController allowing to inject runes content, control receiver behavior, and manage display lines offset.
func (*SubController) Content ¶
func (sc *SubController) Content(env cll.ContentEnv) (cll.Next, int)
Content implements controllers.SubController.Content and reports by default zero runes with lines offset equal to the provided lines count.
func (*SubController) LastContentEnv ¶
func (sc *SubController) LastContentEnv() cll.ContentEnv
func (*SubController) ReplaceCommand ¶ added in v0.8.0
func (sc *SubController) ReplaceCommand(ky vw.Key, cmd cll.Command)
func (*SubController) Set ¶
func (sc *SubController) Set(ss ...any) *SubController
Set allows to mock aspects of given controllers.SubController implementation. Set panics if an instance of an unknown type is set. Supported Types are
mck.ID, *.Stat, *.LinesOffset, *.Runes and *.LytRanges.
Supported function return values are:
mck.OnRune and *.OnKey.
func (*SubController) Stat ¶
func (sc *SubController) Stat() cll.Info
Stat implements controllers.SubController.Stat and reports by default an info which has only its ID set to mck.DefaultSubControllerID.