Documentation ¶
Index ¶
- Constants
- func ClearConsole()
- func CompareCategory(category, input string) bool
- func FindClosestDate(cards []Card) (time.Time, error)
- func PrintJSON[T any](v T)
- func ReadEnterInput()
- func ReadNumberInput(i, j int) int
- func ScrollDownScreen()
- func WrapLines(s string, lineLength uint) string
- type Card
- type File
- type Session
- type TestModeResults
Constants ¶
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 ¶
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 ¶
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 ReadNumberInput ¶
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 ¶
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 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 ¶
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()
type TestModeResults ¶
type TestModeResults struct {
NotRemembered, Hard, Okay, Easy uint
}