sim

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sim provides a simulation backend for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	*backendtcell.Backend
	// contains filtered or unexported fields
}

Backend is a testable backend using a simulation screen.

func New

func New(width, height int) *Backend

New creates a new simulation backend with the given dimensions.

func (*Backend) Capture

func (s *Backend) Capture() string

Capture captures the current screen content as a string.

func (*Backend) CaptureCell

func (s *Backend) CaptureCell(x, y int) (mainc rune, comb []rune, style backend.Style)

CaptureCell returns the content and style of a single cell.

func (*Backend) CaptureRegion

func (s *Backend) CaptureRegion(x, y, w, h int) string

CaptureRegion captures a rectangular region of the screen.

func (*Backend) Clear

func (s *Backend) Clear()

Clear clears the screen to spaces with default style.

func (*Backend) ContainsText

func (s *Backend) ContainsText(text string) bool

ContainsText returns true if the text appears anywhere on screen.

func (*Backend) FindText

func (s *Backend) FindText(text string) (x, y int)

FindText searches for text on the screen and returns its position.

func (*Backend) InjectAltKey

func (s *Backend) InjectAltKey(r rune)

InjectAltKey injects an alt+key combination.

func (*Backend) InjectCtrlKey

func (s *Backend) InjectCtrlKey(r rune)

InjectCtrlKey injects a ctrl+key combination.

func (*Backend) InjectKey

func (s *Backend) InjectKey(key terminal.Key, r rune)

InjectKey injects a key event into the simulation.

func (*Backend) InjectKeyRune

func (s *Backend) InjectKeyRune(r rune)

InjectKeyRune injects a regular character keypress.

func (*Backend) InjectKeyString

func (s *Backend) InjectKeyString(str string)

InjectKeyString injects a string as a sequence of key events.

func (*Backend) InjectKeyWithMod

func (s *Backend) InjectKeyWithMod(key terminal.Key, r rune, ctrl, alt, shift bool)

InjectKeyWithMod injects a key event with modifiers.

func (*Backend) InjectMouse

func (s *Backend) InjectMouse(x, y int, button terminal.MouseButton)

InjectMouse injects a mouse press event into the simulation.

func (*Backend) InjectMouseAction

func (s *Backend) InjectMouseAction(x, y int, button terminal.MouseButton, action terminal.MouseAction)

InjectMouseAction injects a mouse event with a specific action.

func (*Backend) InjectResize

func (s *Backend) InjectResize(width, height int)

InjectResize injects a resize event.

func (*Backend) Resize

func (s *Backend) Resize(width, height int)

Resize changes the simulation screen size.

func (*Backend) ShowText

func (s *Backend) ShowText() string

ShowText is a convenience method to display the screen contents for debugging. Returns the captured screen content as a string.

Jump to

Keyboard shortcuts

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