model

package
v0.0.0-...-b88a432 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	// Percent is a value from 0 to 1 that represents the current completion of the typing test
	Percent  float64
	Progress *progress.Model
	// Text is the randomly generated text for the user to type
	Text []rune
	// Typed is the text that the user has typed so far
	Typed []rune
	// Start and end are the start and end time of the typing test
	Start time.Time
	// Mistakes is the number of characters that were mistyped by the user
	Mistakes int
	// Score is the user's score calculated by correct characters typed
	Score float64
	// Theme is the current color theme
	Theme *theme.Theme
}

func (Model) Init

func (m Model) Init() tea.Cmd

Init inits the bubbletea model for use

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update updates the bubbletea model by handling the progress bar update and adding typed characters to the state if they are valid typing characters

func (Model) View

func (m Model) View() string

View shows the current state of the typing test. It displays a progress bar for the progression of the typing test, the typed characters (with errors displayed in red) and remaining characters to be typed in a faint display

Jump to

Keyboard shortcuts

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