lib

package
v0.0.0-...-53ce5e3 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DB

func DB(path string) (*gorm.DB, error)

Types

type InputList

type InputList[T Listable] struct {
	App          *tview.Application
	Children     []T
	FocusIndex   int
	Grid         *tview.Grid
	MaxHeight    int
	MinRowHeight int
	NewFn        func() T
}

func NewInputList

func NewInputList[T Listable](app *tview.Application, newFn func() T, maxHeight, minRowHeight int) *InputList[T]

func (*InputList[T]) AddChild

func (list *InputList[T]) AddChild(child T)

func (*InputList[T]) Focus

func (list *InputList[T]) Focus()

func (*InputList[T]) GridInputCaptureFn

func (list *InputList[T]) GridInputCaptureFn(event *tcell.EventKey) *tcell.EventKey

func (*InputList[T]) RecalculateGrid

func (list *InputList[T]) RecalculateGrid()

func (*InputList[T]) RerenderGrid

func (list *InputList[T]) RerenderGrid()

func (*InputList[T]) SetFocus

func (list *InputList[T]) SetFocus(index int)

type Listable

type Listable interface {
	Empty() bool
	SetFocusFn(func()) Listable
	Height() int
	SetHeight(int) Listable
	Primitive() tview.Primitive
}

type ListableForm

type ListableForm struct {
	*tview.Form
	InputFields []*tview.InputField
	// contains filtered or unexported fields
}

func NewListableForm

func NewListableForm() *ListableForm

func NewListableSingleInputForm

func NewListableSingleInputForm() *ListableForm

func (*ListableForm) AddInputField

func (form *ListableForm) AddInputField(field *tview.InputField)

func (*ListableForm) Empty

func (form *ListableForm) Empty() bool

func (*ListableForm) Height

func (form *ListableForm) Height() int

func (*ListableForm) Primitive

func (form *ListableForm) Primitive() tview.Primitive

func (*ListableForm) SetFocusFn

func (form *ListableForm) SetFocusFn(fn func()) Listable

func (*ListableForm) SetHeight

func (form *ListableForm) SetHeight(height int) Listable

type ListableInputField

type ListableInputField struct {
	*tview.InputField
	// contains filtered or unexported fields
}

func NewListableInputField

func NewListableInputField() *ListableInputField

func (*ListableInputField) Empty

func (field *ListableInputField) Empty() bool

func (*ListableInputField) Height

func (field *ListableInputField) Height() int

func (*ListableInputField) Primitive

func (field *ListableInputField) Primitive() tview.Primitive

func (*ListableInputField) SetFocusFn

func (field *ListableInputField) SetFocusFn(fn func()) Listable

func (*ListableInputField) SetHeight

func (field *ListableInputField) SetHeight(height int) Listable

func (*ListableInputField) SetText

func (field *ListableInputField) SetText(text string) *ListableInputField

type NutrientInputsTUI

type NutrientInputsTUI struct {
	ListableForm
	IngredientInput *tview.InputField
	QuantityInput   *tview.InputField
	UnitInput       *tview.InputField
}

type NutrientSource

type NutrientSource struct {
	Ingredient string
	Quantity   float64
	Unit       string
}

type Recipe

type Recipe struct {
	ID              uint `yaml:"cache_id"`
	Title           string
	Author          string
	License         string
	Image           string
	ImageCredit     string `yaml:"image_credit"`
	ImageLicense    string `yaml:"image_license"`
	Servings        uint64
	Tags            []string
	Ingredients     []string
	Directions      []string
	NutrientSources []NutrientSource `yaml:"nutrient_sources"`
	// contains filtered or unexported fields
}

func RecipeFromFile

func RecipeFromFile(path string) (*Recipe, error)

func (*Recipe) Analyze

func (r *Recipe) Analyze(db *gorm.DB) (*nutrition.NutritionData, error)

func (*Recipe) ClearNutritionData

func (r *Recipe) ClearNutritionData()

func (*Recipe) NutritionData

func (r *Recipe) NutritionData(db *gorm.DB) *nutrition.NutritionData

func (*Recipe) SaveToDB

func (r *Recipe) SaveToDB(db *gorm.DB) error

func (*Recipe) ToFile

func (r *Recipe) ToFile(path string) error

type TUI

type TUI struct {
	Recipe            *Recipe
	FilePath          string
	App               *tview.Application
	Screen            tcell.Screen
	MainFlex          *tview.Flex
	LeftFlex          *tview.Flex
	RightFlex         *tview.Flex
	BasicsFlex        *tview.Flex
	TitleInput        *tview.InputField
	AuthorInput       *tview.InputField
	LicenseInput      *tview.InputField
	ServingsInput     *tview.InputField
	ImageFlex         *tview.Flex
	ImagePathInput    *tview.InputField
	ImageCreditInput  *tview.InputField
	ImageLicenseInput *tview.InputField
	TagsList          *InputList[*ListableForm]
	IngredientsList   *InputList[*ListableForm]
	DirectionsFlex    *tview.Flex
	DirectionsArea    *tview.TextArea
	NutrientsFormList *InputList[*NutrientInputsTUI]
	Main              *tview.Frame
	Pages             *tview.Pages
	// contains filtered or unexported fields
}

func NewTUI

func NewTUI(db *gorm.DB) *TUI

func (*TUI) LoadRecipe

func (tui *TUI) LoadRecipe(recipe *Recipe)

func (*TUI) NewNutrientInputsTUI

func (tui *TUI) NewNutrientInputsTUI() *NutrientInputsTUI

func (*TUI) NewTagForm

func (tui *TUI) NewTagForm() *ListableForm

func (*TUI) UpdateRecipe

func (tui *TUI) UpdateRecipe() error

Jump to

Keyboard shortcuts

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