internal

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotRemembered = 0
	Hard          = 0.8
	Okay          = 1
	Easy          = 1.5
)

Difficulty constants

Variables

This section is empty.

Functions

func ClearConsole

func ClearConsole()

ClearConsole Moves the cursor to the home position (0,0) and erases everything from cursor to end of screen.

func CompareCategory

func CompareCategory(category, input string) bool

CompareCategory compares the category name to the user input and returns true if the input matches with the category according to the following rules: - If the input is empty, it will match with any category. - The category and input get transformed to lowercase. - The input matches the category either if it is equal or if it is a prefix of the category.

func FindClosestDate

func FindClosestDate(cards []Card) (time.Time, error)

FindClosestDate finds the closest due date in the future in the given slice of cards. If it contains a date that is before or equal to today, it will return an error.

func PrintJSON

func PrintJSON[T any](v T)

PrintJSON pretty prints any struct as JSON

func ReadEnterInput

func ReadEnterInput()

ReadEnterInput Blocks until the user enters a newline.

func ReadNumberInput

func ReadNumberInput(i, j int) int

ReadNumberInput reads a number from standard input. The number must be within i and j. If it is not, it will retry.

func ScrollDownScreen added in v1.1.0

func ScrollDownScreen()

ScrollDownScreen scrolls down by printing newlines. This can be helpful to prevent overwriting previous console output when clearing the console.

func WrapLines

func WrapLines(s string, lineLength uint) string

WrapLines wraps the given string into lines of the given length. It will not break words and thus only breaks at whitespace. It assumes that no word in the given string exceeds the requested line length. Lines that start with an indent will be indented by the given indent plus, if the line is a list item, the length of the list item prefix.

If the lineLength is 0, it will wrap the text depending on the terminal width.

Types

type Card

type Card struct {
	Front    string
	Back     string
	Category string
	// Box number starts at 0
	Box uint
	Due time.Time
}

type File

type File struct {
	Path         string
	BoxIntervals []uint
	Cards        []Card
}

func NewFile

func NewFile(path string) File

type Session

type Session struct {
	Sequential, TestMode, ShowCategory bool
	Category                           string
	ChooseCategories                   bool
	// Number of cards to study. If 0, study all cards.
	NumberCards uint
	// Usually a flashcard is due on a particular date. But if the study set would be less than Session.NumberCards,
	// the due date is ignored up to a certain number of days in the future. The cards where the due date was missed
	// are added to the study set anyway.
	FutureDaysDue uint
	WrapLines     uint
	File          File
	// contains filtered or unexported fields
}

func (*Session) CheckCategory

func (s *Session) CheckCategory() error

CheckCategory Checks if the session's category is valid, meaning it is present in the File. If the input is empty, it returns nil according to the CompareCategory function.

func (*Session) ChooseCategory

func (s *Session) ChooseCategory()

ChooseCategory Lets the user choose a category from the file's headings.

func (*Session) PrintNextDueDate

func (s *Session) PrintNextDueDate()

func (*Session) ReadFile

func (s *Session) ReadFile() error

ReadFile Reads a markdown file containing flashcards and returns a slice of Card structs.

func (*Session) Start

func (s *Session) Start()

Start Starts the study session.

func (*Session) WriteFile

func (s *Session) WriteFile() error

WriteFile Writes the file to disk with updated metadata.

type TestModeResults

type TestModeResults struct {
	NotRemembered, Hard, Okay, Easy uint
}

Jump to

Keyboard shortcuts

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