core

package
v0.0.0-...-b82ce1f Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FillerResource = Resource{
	Name:             "tableFiller",
	Description:      "tableFiller",
	Tier:             1,
	UrlGetter:        &UrlGetter{},
	FileName:         "example.txt",
	InitiateDownload: func(path string, logFunction func(string), downloadStruct *Resource) error { return nil },
	Info:             ResourceInformation{},
	Status:           StatusQueued,
	Error:            nil,
}

Functions

func GetWorkingDirectory

func GetWorkingDirectory() string

Types

type Application

type Application struct {
	TeaProgram *tea.Program

	GuidesFolderPath string

	ProtocolInitiated bool
	ProtocolPaused    bool

	ResourceList ResourceList

	LogFunction func(string)
	LogsContent Logs
}

Everything that the entire application should keep track of

var CurrentApplicationInstance *Application

func (*Application) GuideViewerCallback

func (a *Application) GuideViewerCallback(path string)

func (*Application) InitiateProtocol

func (a *Application) InitiateProtocol()

Initiate every resource download TODO: Limit to N at a time and queue the rest

func (*Application) Log

func (a *Application) Log(s string)

Log a message on the console

func (*Application) OrderToInitiateProtocol

func (a *Application) OrderToInitiateProtocol()

func (*Application) PauseProtocol

func (a *Application) PauseProtocol()

func (*Application) ResumeProtocol

func (a *Application) ResumeProtocol()

func (*Application) StartPeriodicTicks

func (a *Application) StartPeriodicTicks(deltaTime int)

type DownloadControl

type DownloadControl int
const (
	Start DownloadControl = iota // Synonymous with Continue
	Pause
	Cancel
)

type DownloadStatus

type DownloadStatus string
const (
	StatusQueued      DownloadStatus = "Queued"
	StatusDownloading DownloadStatus = "Downloading"
	StatusPaused      DownloadStatus = "Paused"
	StatusCompleted   DownloadStatus = "Completed"
	StatusFailed      DownloadStatus = "Failed"
	StatusIdle        DownloadStatus = "Idle"
)

type LoggedMsg

type LoggedMsg [][2]string

type Logs

type Logs = [][2]string

Logs Logic

type Resource

type Resource struct {
	Name                string
	Description         string
	Tier                int
	AssociatedGuidePath guides.Guide // Relative path to the guides directory from the 'packaged' directory

	UrlGetter        *UrlGetter
	FileName         string
	Location         string
	InitiateDownload func(path string, logFunction func(string), downloadStruct *Resource) error
	Info             ResourceInformation
	Status           DownloadStatus
	Error            error
	ControlChannel   chan DownloadControl // Channel for controlling the download

	CustomResource bool
}

N number of Downloads downloading at a time Rest are queued Appears on the Downloads list

func (*Resource) EnterPressed

func (r *Resource) EnterPressed()

func (*Resource) PauseResource

func (r *Resource) PauseResource()

func (*Resource) ResumeResource

func (r *Resource) ResumeResource()

func (*Resource) SpacePressed

func (r *Resource) SpacePressed()

type ResourceInformation

type ResourceInformation struct {
	Done      float64   // Bytes downloaded so far
	Size      float64   // Total size of the download in bytes
	Bandwidth float64   // Current download speed in bytes per second
	ETA       uint64    // Estimated time remaining (formatted as a string, e.g., "10.5 seconds")
	StartTime time.Time // Time when the download started
	EndTime   time.Time // Time when the download completed
}

Download info to construct the UI

func (ResourceInformation) ProgressPercent

func (d ResourceInformation) ProgressPercent() float64

type ResourceList

type ResourceList struct {
	DefaultResources []Resource
	CustomResources  []Resource
}

func (*ResourceList) GetCoreProgress

func (r *ResourceList) GetCoreProgress() float64

func (*ResourceList) GetOverallProgress

func (r *ResourceList) GetOverallProgress() float64

func (*ResourceList) PauseAllResources

func (r *ResourceList) PauseAllResources()

func (*ResourceList) ResumeAllResources

func (r *ResourceList) ResumeAllResources()

type TickMsg

type TickMsg time.Time

type UrlGetter

type UrlGetter struct {
	Key           string // used to identify resouce in the server
	RecentURLUsed string
	UpdatedURLURL []string
	DefaultURLs   []string
}

func (*UrlGetter) GetUrl

func (u *UrlGetter) GetUrl() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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