cmd

package
v0.0.0-...-7f70b69 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = "dev"
	RootCmd = &cobra.Command{
		Use:  "typedeck",
		Long: "typedeck — typioca with a memory: it keeps every key and drills your weak spots",
		RunE: func(cmd *cobra.Command, args []string) error {
			if showVersion {
				fmt.Println("typedeck ", Version)
				return nil
			} else {
				termenv.SetWindowTitle("typedeck")
				defer println("bye!")

				termWidth, termHeight, _ := term.GetSize(int(os.Stdin.Fd()))
				p := tea.NewProgram(
					initialModel(
						termenv.ColorProfile(),
						nil,
						termWidth,
						termHeight,
					),
					tea.WithAltScreen(),
				)

				_, err := p.Run()
				return err
			}
		},
	}
)

Functions

func OsInit

func OsInit()

func WriteConfig

func WriteConfig(config Config)

Types

type AllPersistedResults

type AllPersistedResults = map[TestType]map[NumericSetting]map[WordListName][]PersistentResultsNode

type Book

type Book struct {
	Title   string
	Author  string
	Slug    string
	Source  string
	Chars   int // runes in the cleaned text
	Pos     int // the bookmark: next rune to type
	Laps    int // times finished
	Runs    int
	Typed   int   // characters typed in this book, all laps
	Started int64 // unix seconds of the import
	Last    int64 // unix seconds of the last run in it: the home screen offers that book first
}

func Books

func Books() []Book

func ImportBook

func ImportBook(src, title, start string) (Book, error)

ImportBook reads src (file, URL or Gutenberg number) and stores the cleaned book. Importing a book again refreshes its text and keeps the bookmark. start, when given, is a phrase of the text: everything before its first appearance (title page, contents, preface) is left out.

type Catalog

type Catalog struct {
	Cats    []string // Gutenberg's "Category:" shelves, sorted by name
	Entries []Entry  // ranked books first in rank order, then everything else by title
	Fetched time.Time
}

func FetchCatalog

func FetchCatalog() (*Catalog, error)

FetchCatalog downloads both files, parses them and saves the compact form.

func LoadCatalog

func LoadCatalog() (*Catalog, error)

LoadCatalog: the saved copy while it is fresh, otherwise a download. A stale copy still serves when the download fails (the deck's WiFi is not to be trusted).

type Category

type Category int

Category: two pseudo-categories in front of Gutenberg's own shelves.

type Config

type Config struct {
	TestSettingCursors TestSettingCursors
	EmbededWordLists   []EmbededWordList
	WordLists          []WordList
	LayoutFiles        []LayoutFile
	Layout             Layout
	Version            int
}

func ReadConfig

func ReadConfig() Config

type ConfigView

type ConfigView struct {
	// contains filtered or unexported fields
}

type ConfigViewSelection

type ConfigViewSelection struct{}

func (ConfigViewSelection) Enabled

func (s ConfigViewSelection) Enabled() bool

type EmbededWordList

type EmbededWordList struct {
	Name        string
	IsSentences bool
	Enabled     bool
}

type Entry

type Entry struct {
	ID     int
	Title  string
	Author string
	Rank   int     // 1 = most downloaded in the last 30 days, 0 = not in the top 1000
	Cats   []uint8 // indices into Catalog.Cats
	// contains filtered or unexported fields
}

type Finder

type Finder struct {
	// contains filtered or unexported fields
}

type Home

type Home struct {
	// contains filtered or unexported fields
}

type Layout

type Layout struct {
	Name     string        `json:"name"`
	Mappings map[rune]rune `json:"mappings"`
}

type LayoutFile

type LayoutFile struct {
	Name      string
	Path      string
	RemoteURI string
	// contains filtered or unexported fields
}

type LocalConfig

type LocalConfig struct {
	Words []WordList
}
type MainMenu struct {
	// contains filtered or unexported fields
}
type MainMenuSelection interface {
	Enabled() bool
	// contains filtered or unexported methods
}

type NumericSetting

type NumericSetting = int

type PersistentResults

type PersistentResults struct {
	Results AllPersistedResults
	Version int
}

func PersistResults

func PersistResults(results Results) PersistentResults

type PersistentResultsNode

type PersistentResultsNode struct {
	Wpm           int
	Accuracy      float64
	DeltaWpm      float64
	RawWpm        int
	Cpm           int
	WpmEachSecond []float64
}

type ProgressView

type ProgressView struct {
	// contains filtered or unexported fields
}

type ProgressViewSelection

type ProgressViewSelection struct{}

func (ProgressViewSelection) Enabled

func (s ProgressViewSelection) Enabled() bool

type Results

type Results struct {
	// contains filtered or unexported fields
}

type ResultsIdentifier

type ResultsIdentifier struct {
	// contains filtered or unexported fields
}

type SentenceCountBasedTest

type SentenceCountBasedTest struct {
	// contains filtered or unexported fields
}

type SentenceCountBasedTestSettings

type SentenceCountBasedTestSettings struct {
	// contains filtered or unexported fields
}

func (SentenceCountBasedTestSettings) Enabled

type SentenceCountTestResults

type SentenceCountTestResults struct {
	// contains filtered or unexported fields
}

type State

type State interface{}

type StringStyle

type StringStyle func(string) termenv.Style

type Styles

type Styles struct {
	// contains filtered or unexported fields
}

type TestBase

type TestBase struct {
	// contains filtered or unexported fields
}

type TestSettingCursors

type TestSettingCursors struct {
	TimerTimeCursor     int
	TimerWordlistCursor int

	WordCountCursor         int
	WordCountWordlistCursor int

	SentenceCountCursor         int
	SentenceCountWordlistCursor int
}

type TestType

type TestType = string

type TimerBasedTest

type TimerBasedTest struct {
	// contains filtered or unexported fields
}

type TimerBasedTestResults

type TimerBasedTestResults struct {
	// contains filtered or unexported fields
}

type TimerBasedTestSettings

type TimerBasedTestSettings struct {
	// contains filtered or unexported fields
}

func (TimerBasedTestSettings) Enabled

func (s TimerBasedTestSettings) Enabled() bool

type Toggleable

type Toggleable interface {
	// contains filtered or unexported methods
}

type WordCountBasedTest

type WordCountBasedTest struct {
	// contains filtered or unexported fields
}

type WordCountBasedTestSettings

type WordCountBasedTestSettings struct {
	// contains filtered or unexported fields
}

func (WordCountBasedTestSettings) Enabled

func (s WordCountBasedTestSettings) Enabled() bool

type WordCountTestResults

type WordCountTestResults struct {
	// contains filtered or unexported fields
}

type WordList

type WordList struct {
	Sentences bool
	Name      string
	Path      string
	RemoteURI string

	Enabled bool
	// contains filtered or unexported fields
}

type WordListName

type WordListName = string

type WordListSelection

type WordListSelection struct {
	// contains filtered or unexported fields
}

type WordsSelection

type WordsSelection struct {
	// contains filtered or unexported fields
}

todo: clean these up. Maybe we could reuse filtering by enabled and synce, because now it's redundant

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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