Documentation ¶
Index ¶
- type ControlsData
- type LiveStats
- func (ls *LiveStats) Accuracy() (float64, error)
- func (ls *LiveStats) ElapsedTime() (*utils.TimeFormatted, error)
- func (ls *LiveStats) FinishRace() error
- func (ls *LiveStats) SetChannels(preceiver chan StatMsg, updateCh chan bool, finishCh chan OneStat)
- func (ls *LiveStats) StartRace() error
- func (ls *LiveStats) TryStartTicker(g *gocui.Gui)
- func (ls *LiveStats) Wpm() (int, error)
- type OneStat
- type ParagraphData
- func (pd *ParagraphData) DebugAdvance()
- func (pd *ParagraphData) DoneCh() chan struct{}
- func (pd *ParagraphData) FinishRace() error
- func (pd *ParagraphData) GetCurrentIdx() int
- func (pd *ParagraphData) GetLineCount() int
- func (pd *ParagraphData) OnEditorChange(w string)
- func (pd *ParagraphData) SetChannels(statsCh chan StatMsg, updateCh chan bool)
- func (pd *ParagraphData) StartRace(g *gocui.Gui)
- type StatMsg
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ControlsData ¶
type ControlsData struct {
Content string
}
ControlsData wraps content for controls view
func NewControlsData ¶
func NewControlsData() *ControlsData
NewControlsData creates new instance of ControlsData
func (*ControlsData) DefaultControls ¶
func (c *ControlsData) DefaultControls()
DefaultControls sets content for default controls view
func (*ControlsData) StartRace ¶
func (c *ControlsData) StartRace()
StartRace sets content for controls for race in progresse
type LiveStats ¶
type LiveStats struct { IsActive bool // whether this data is active to show in stats view - for current race // contains filtered or unexported fields }
LiveStats represents contents show during a race in stats view
func (*LiveStats) ElapsedTime ¶
func (ls *LiveStats) ElapsedTime() (*utils.TimeFormatted, error)
ElapsedTime during a race
func (*LiveStats) FinishRace ¶
FinishRace finishes a ongoing race
func (*LiveStats) SetChannels ¶
SetChannels sets channels for communication
func (*LiveStats) TryStartTicker ¶
TryStartTicker starts the ticker, so timer in stats view gets updated FIXME: anyway we can keep away from passing gocui instance?
type OneStat ¶
type OneStat struct { // words per minute Wpm int // accuracy. e.g., 95.6% Accuracy float64 // time of race When time.Time }
OneStat represents information about completed race
type ParagraphData ¶
type ParagraphData struct { // words in paragraph Words []string // whether target word is mistyped Mistyped bool // true if a race is in progress RaceInProgress bool // if set the wordeditor will be cleared for next target word ShouldClearEditor bool // Dimensions of the view // FIXME: this shouldn't be available in viewdata H int W int // For highlighted word; Line, Word number both start at 0 Line int Word int // Y position of View origin Oy int // contains filtered or unexported fields }
ParagraphData keeps track of state, data required for view's content
func NewParagraphData ¶
func NewParagraphData() *ParagraphData
NewParagraphData creates instance of ParagraphData
func (*ParagraphData) DebugAdvance ¶
func (pd *ParagraphData) DebugAdvance()
DebugAdvance advances by a word to debug stuff
func (*ParagraphData) DoneCh ¶
func (pd *ParagraphData) DoneCh() chan struct{}
DoneCh returns reference to done channel
func (*ParagraphData) FinishRace ¶
func (pd *ParagraphData) FinishRace() error
FinishRace is called to finish a race
func (*ParagraphData) GetCurrentIdx ¶
func (pd *ParagraphData) GetCurrentIdx() int
GetCurrentIdx tells index of target word
func (*ParagraphData) GetLineCount ¶
func (pd *ParagraphData) GetLineCount() int
GetLineCount returns number of lines displayed in paragraph view
func (*ParagraphData) OnEditorChange ¶
func (pd *ParagraphData) OnEditorChange(w string)
OnEditorChange is called on every change event to woreditor
func (*ParagraphData) SetChannels ¶
func (pd *ParagraphData) SetChannels(statsCh chan StatMsg, updateCh chan bool)
SetChannels sets channels for UI, stats updates
func (*ParagraphData) StartRace ¶
func (pd *ParagraphData) StartRace(g *gocui.Gui)
StartRace is called when a race starts
type Stats ¶
type Stats struct { List []*OneStat Selected int // To keep track of highlighted stat in history IsActive bool // whether this data is active to show in stats view - for race history }
Stats is a datastructure to store stats for past races
func NewStatsHistory ¶
NewStatsHistory creates new Stats instance to keep track of race history
func (*Stats) LoadHistory ¶
LoadHistory loads history data from local FS
func (*Stats) SaveNewStat ¶
SaveNewStat saves current race's stat to history of stats
func (*Stats) ScrollDown ¶
ScrollDown is a keybinding to scroll in race history list increments selected race index