processbar

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 9 Imported by: 0

README

processbar package

This package is for processbar. This should not import internal package, and should not be aware of main 'model'

To-do

  • Finish code TODOs
  • Add end to end test with model
  • Add unit tests for Render(), and getSortedProcesses()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseMsg

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

TODO: Can we remove this duplication with model_msg ?

func (BaseMsg) GetReqID

func (msg BaseMsg) GetReqID() int

type Cmd

type Cmd func() UpdateMsg

type Model

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

Model for process bar internal

func New

func New() Model

func NewModelWithOptions

func NewModelWithOptions(width int, height int) Model

Note: We should considering our internal models, they should be returning pointer object, and implement tea.Model

func (*Model) AddOrUpdateProcess

func (m *Model) AddOrUpdateProcess(p Process)

func (*Model) AddProcess

func (m *Model) AddProcess(p Process) error

func (*Model) GetByID

func (m *Model) GetByID(id string) (Process, bool)

func (*Model) GetHeight added in v1.5.0

func (m *Model) GetHeight() int

func (*Model) GetListenCmd

func (m *Model) GetListenCmd() Cmd

An IO Operation, that will wait forever on msgChannel

func (*Model) GetProcessesSlice added in v1.5.0

func (m *Model) GetProcessesSlice() []Process

Copy of the current processes for read only purpose

func (*Model) GetWidth added in v1.5.0

func (m *Model) GetWidth() int

func (*Model) HasRunningProcesses

func (m *Model) HasRunningProcesses() bool

func (*Model) ListDown

func (m *Model) ListDown()

Control processbar panel list down

func (*Model) ListUp

func (m *Model) ListUp()

Control processbar panel list up There is a shadowing happening here, but it will be removed Once we make footerHeight part of model struct

func (*Model) ListenForChannelUpdates

func (m *Model) ListenForChannelUpdates()

Only used in tests, to have processbar used in a standalone way without model

func (*Model) Render

func (m *Model) Render(processBarFocused bool) string

func (*Model) SendAddProcessMsg

func (m *Model) SendAddProcessMsg(
	currentFile string, operation OperationType, total int, blockingSend bool,
) (Process, error)

func (*Model) SendStopListeningMsgBlocking

func (m *Model) SendStopListeningMsgBlocking()

func (*Model) SendUpdateProcessMsg

func (m *Model) SendUpdateProcessMsg(p Process, blockingSend bool) error

func (*Model) SetDimensions

func (m *Model) SetDimensions(width int, height int)

func (*Model) TrySendingUpdateProcessMsg

func (m *Model) TrySendingUpdateProcessMsg(p Process)

Non Blocking and can fail

func (*Model) UpdateExistingProcess

func (m *Model) UpdateExistingProcess(p Process) error

type NoProcessFoundError

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

func (*NoProcessFoundError) Error

func (p *NoProcessFoundError) Error() string

type OperationType added in v1.5.0

type OperationType int
const (
	OpCopy OperationType = iota
	OpCut
	OpDelete
	OpCompress
	OpExtract
)

func (OperationType) GetIcon added in v1.5.0

func (op OperationType) GetIcon() string

GetIcon returns the appropriate icon for the operation type

func (OperationType) GetPastVerb added in v1.5.0

func (op OperationType) GetPastVerb() string

GetPastVerb returns the past tense verb for the operation

func (OperationType) GetVerb added in v1.5.0

func (op OperationType) GetVerb() string

GetVerb returns the present tense verb for the operation

type Process

type Process struct {
	ID          string
	CurrentFile string
	// TODO : We always want ErrorMsg to be set when State is
	// moved to Cancelled or Failed. To ensure it, we need to only allow state
	// change via helper functions and ask for the  errorMsg
	ErrorMsg  string
	Operation OperationType
	Progress  progress.Model
	State     ProcessState
	Total     int
	Done      int
	DoneTime  time.Time
}

Model for an individual process Note : Its size is ~ 800 bytes

func NewProcess

func NewProcess(id string, currentFile string, operation OperationType, total int) Process

func (*Process) GetDisplayName added in v1.5.0

func (p *Process) GetDisplayName() string

GetDisplayName returns the appropriate display name for the process

type ProcessAlreadyExistsError

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

func (*ProcessAlreadyExistsError) Error

func (p *ProcessAlreadyExistsError) Error() string

type ProcessChannelFullError

type ProcessChannelFullError struct {
}

func (*ProcessChannelFullError) Error

func (p *ProcessChannelFullError) Error() string

type ProcessState

type ProcessState int
const (
	InOperation ProcessState = iota
	Successful
	Cancelled
	Failed
)

func (ProcessState) Icon

func (p ProcessState) Icon() string

TODO : Should we store in a global map for efficiency ? At least need to prerender Yes, this is a Render() call, which is expensive

type UpdateMsg

type UpdateMsg interface {
	Apply(m *Model) (Cmd, error)
	GetReqID() int
}

Jump to

Keyboard shortcuts

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