processbar

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 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) GetListenCmd

func (m *Model) GetListenCmd() Cmd

An IO Operation, that will wait forever on msgChannel

func (*Model) HasRunningProcesses

func (m *Model) HasRunningProcesses() bool

func (*Model) ListDown

func (m *Model) ListDown(footerHeight int)

Control processbar panel list down

func (*Model) ListUp

func (m *Model) ListUp(footerHeight int)

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(processBarFocussed bool) string

func (*Model) SendAddProcessMsg

func (m *Model) SendAddProcessMsg(name string, 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 Process

type Process struct {
	ID       string
	Name     string
	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, name string, total int) 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