term

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LstFixture

func LstFixture(
	t *testing.T, listener func(api.Eventer), timeout time.Duration,
) (*UI, *Fixture)

LstFixture instantiates a new UI with an simulation screen and an testing instance reporting all events to provided listener. The ui is setup for transactional events, i.e. an event-post p returns not before all event-posts have been processed which were posted during p's processing. Processing of p times out after given timeout. LstFixture does not returns before initial resize event wasn't processed. Listener may be nil and a zero-timeout defaults to 100ms.

func NewFixture

func NewFixture(t *testing.T, timeout time.Duration) (*UI, *Fixture)

NewFixture instantiates a new UI with an simulation screen and an testing instance. In order to receive events [Testing.Listen] must be called additionally. The ui is setup for transactional events, i.e. an event-post p returns not before all event-posts have been processed which were posted during p's processing. Processing of p times out after given timeout. A zero-timeout defaults to 100ms.

Types

type Fixture

type Fixture struct {
	Width  int
	Height int
	// contains filtered or unexported fields
}

func (*Fixture) Cells

func (tt *Fixture) Cells() api.CellsScreen

func (*Fixture) CellsArea

func (tt *Fixture) CellsArea(x, y, width, height int) api.CellsScreen

func (*Fixture) Display

func (tt *Fixture) Display(s string, sty api.Style)

func (*Fixture) Listen

func (tt *Fixture) Listen(l func(api.Eventer))

Listen sets the listener and posts initial resize event. Listen is an no-op if already a listener is set.

func (*Fixture) PostBracketPaste

func (tt *Fixture) PostBracketPaste(paste string)

func (*Fixture) PostClick added in v0.9.0

func (tt *Fixture) PostClick(
	x, y int, b api.ButtonMask, m api.ModifierMask,
)

func (*Fixture) PostDrag added in v0.9.0

func (tt *Fixture) PostDrag(
	x, y int, b api.ButtonMask, m api.ModifierMask,
) (drop func(x, y int))

func (*Fixture) PostKey

func (tt *Fixture) PostKey(k api.Key, m api.ModifierMask)

func (*Fixture) PostMouse

func (tt *Fixture) PostMouse(
	x, y int, b api.ButtonMask, m api.ModifierMask,
)

func (*Fixture) PostMove added in v0.9.0

func (tt *Fixture) PostMove(x, y int, xy ...int)

func (*Fixture) PostResize

func (tt *Fixture) PostResize(width, height int)

func (*Fixture) PostRune

func (tt *Fixture) PostRune(r rune, m api.ModifierMask)

func (*Fixture) Screen

func (tt *Fixture) Screen() api.StringScreen

func (*Fixture) ScreenArea

func (tt *Fixture) ScreenArea(x, y, width, height int) api.StringScreen

func (*Fixture) Size

func (tt *Fixture) Size() (width, height int)

Size returns the number of available lines (height) and the number of runes per line (width) off the terminal screen/display.

func (*Fixture) TimeOut added in v0.10.0

func (fx *Fixture) TimeOut() time.Duration

TimeOut provides the duration given fixture waits for a polled event and all its subordinately triggered events to be processed.

type UI

type UI struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(listener func(api.Eventer)) *UI

func (*UI) Colors added in v0.10.0

func (u *UI) Colors() int

Colors provide the number of available (ANSI) colors. In case of a monochrome screen 0 is returned.

func (*UI) Display

func (u *UI) Display(x, y int, r rune, s api.Style)

Display sets at given screen coordinates (x,y) given rune r with given style s.

func (*UI) EnableTransactionalEventPosts

func (u *UI) EnableTransactionalEventPosts(timeout time.Duration)

EnableEventTransactions guarantees that an event-post p not returns before all other posted events during the processing of p have been processed.

func (*UI) Lib

func (u *UI) Lib() interface{}

func (*UI) NewStyle

func (u *UI) NewStyle() api.Style

NewStyle returns a new style corresponding to tcell's default style.

func (*UI) OnQuit

func (u *UI) OnQuit(listener func())

OnQuit registers given function to be called on quitting.

func (*UI) Post

func (u *UI) Post(evt api.Eventer) error

Post given event evt into the event queue. Post is a no-op if Quit has been already called.

func (*UI) Quit

func (u *UI) Quit()

Quit polling and reporting events, inform all listeners about about it and reset the terminal screen.

func (*UI) Redraw

func (u *UI) Redraw()

Redraw blank all cells and draw the screen content.

func (*UI) SetCursor added in v0.9.1

func (u *UI) SetCursor(x, y int, cs ...api.CursorStyle) (
	sx int, sy int, scs api.CursorStyle,
)

SetCursor sets the cursor to given coordinates (x,y) having optionally given style cs[0] provided (x,y) is on the screen and if so that cs[0] is not the ZeroCursor. Are later conditions not met the cursor is removed from the screen.

func (*UI) Size

func (u *UI) Size() (int, int)

Size returns the ui's screen size.

func (*UI) Update

func (u *UI) Update()

Update changed cells of the screen.

func (*UI) WaitForQuit

func (u *UI) WaitForQuit()

WaitForQuit returns a channel which is closed if the event-loop is quit.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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