event

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const EventTsLayout = "2006-01-02 15:04:05.000"

Variables

This section is empty.

Functions

func RuneToEventExpected

func RuneToEventExpected(r rune) string

func TeaKeyMsgToEventTyped

func TeaKeyMsgToEventTyped(msg tea.KeyMsg) string

Converts a bubbletea key message to a string. Used to properly record key events.

Types

type Event

type Event struct {
	// The moment the event took place.
	Ts time.Time

	// The key that was Typed.
	Typed string

	// The rune that was Expected. Optional, since the user
	// may have pressed backspace.
	Expected string

	// The index of the exercise when the rune was typed.
	I int
}

A recording of a keypress during the exercise.

These are used to perform analysis on the user's performance, display stats, and keys that were causing the most trouble.

func NewEvent

func NewEvent(typed string, expected string, i int) Event

Creates a new event. Should be used when recording a keystroke to the model.

func ParseEvent

func ParseEvent(line string) (e Event)

Converts an event string to an event struct.

func (Event) Matches

func (a Event) Matches(b Event) bool

Checks if an event has the same timestamp, index, typed and expected characters. Used primarily for testing.

func (Event) String

func (e Event) String() string

Converts an event to a string.

type Events

type Events []Event

func ParseEvents

func ParseEvents(list string) (events Events)

Same as above, but for a multi-line list of events.

func (Events) String

func (events Events) String() (s string)

Returns a string of an array of events.

Jump to

Keyboard shortcuts

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