mck

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
const DefaultSubControllerID = "sub-controller mock's ID"

DefaultSubControllerID is reported by the zero value of mck.SubController.

Variables

View Source
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

func GotoCmd(gt cll.Goto) cll.Command

GotoCmd conveniently provides the easiest way to create a command function returning given Goto for any rune or special key event.

func MkNBLines

func MkNBLines(n NLines) []byte

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

func OnRune(r rune, cmd cll.Command) kbCommand

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

func SetCmd added in v0.8.0

func SetCmd(s *SubController, ky vw.Key, vl cll.Command)

Types

type CEBuffer

type CEBuffer *bff.Buffer

type CmdBar

type CmdBar cll.CommandBar

type CommanderContext

type CommanderContext struct{ cll.Contexter }

CommanderContext can be passed to SplitEnv.Set inject a commander context into an SplitEnv instance.

type ContentContext

type ContentContext struct{ cll.Contexter }

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 Cursor

type Cursor image.Point // cursor row

type ID

type ID string

ID sets the ID which is provided in the Info value returned by SubController.Stat or SubController.Receiver.

type Lines

type Lines uint // number of lines

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 NLines

type NLines uint

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 Runes

type Runes cll.Runes

Runes sets the runes provided by SubController.Content.

func MkNRLines

func MkNRLines(n NLines) Runes

func (Runes) Lines

func (rr Runes) Lines() []string

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.

func (*SplitEnv) Set

func (env *SplitEnv) Set(ss ...any) *SplitEnv

Set aspects like CommanderContext or ContentContext of given SplitEnv mock. See about types for available settings.

func (*SplitEnv) SetOther

func (env *SplitEnv) SetOther(id string) cll.SubController

SetOther sets SplitEnv.RequestedSettingOther to given content.

type Stat

type Stat cll.Info

Stat defines the return value of SubController.Stat

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) Call added in v0.8.0

func (sc *SubController) Call(env cll.CmdEnv) (cll.Goto, error)

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.

type Width

type Width uint // number of runes per line

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL