terminal

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Fuchsia     = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Dark: "#EE6FF8", Light: "#EE6FF8"})
	DarkFuchsia = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Dark: "#AD58B4", Light: "#F793FF"})
	Red         = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Dark: "#ED567A", Light: "#FF4672"})
	DarkRed     = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Dark: "#C74665", Light: "#FF6F91"})
	White       = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Dark: "#DDDDDD", Light: "#1A1A1A"})
)

Functions

func CLI

func CLI(args []string, stdout io.Writer, stderr io.Writer) int

func RenderMarkdown

func RenderMarkdown(text string, width int) (string, error)

Types

type Model

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

func NewModel

func NewModel(path string, opts ...ModelOption) Model

NewModel creates a new model instance given a decks location.

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() string

type ModelOption

type ModelOption func(*Model)

ModelOption configure the Model options.

func WithClock

func WithClock(clock clock.Clock) ModelOption

WithClock initializes the model with the given clock.

func WithRepository

func WithRepository(factory func(clock.Clock) (Repository, error)) ModelOption

WithRepository configure the terminal with an alternative repository.

func WithWindowSize

func WithWindowSize(width, height int) ModelOption

WithWindowSize initializes the model with the given width and height.

type Repository

type Repository interface {
	List() []flashcard.Deck
	Create(name string, cards []flashcard.Card) (flashcard.Deck, error)
	Save(flashcard.Deck) error
	Delete(flashcard.Deck) error
}

Repository wraps the file system operation to be easier and quicker run the tests.

Jump to

Keyboard shortcuts

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