model

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2021 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 代表当前打字练习的进度, 值的范围为 [0, 1]
	Percent  float64
	Progress *progress.Model
	// Text 随机生成的用于用户练习的中文文本
	Text []rune
	// Display Text 的拼音
	Display []string
	// TextShuangpin Text 的双拼
	TextShuangpin string
	// Typed 用户到目前为止的输入
	Typed string
	// Notice 用户当前按键代表的声母或韵母
	Notice []string
	// Start 和 end 是打字练习开始和结束的时间
	Start time.Time
	// Mistakes 用户错误输入的字符数量
	Mistakes int
	// Score 用户正确输入的字符数量
	Score float64
}

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