transfer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package transfer runs imports in the background and draws their progress: the mode indicator says WAIT, the context line offers Esc, the status line counts rows with a progress bar, and the terminal shows its own progress indicator. It remembers where the sheet came from, so Save can offer to export it back. What an import's result does to the workbook is the UI's; this package needs no host.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Rows

func Rows(n int) string

Rows is n rows in words: "1 row", "4,096 rows".

func Thousands

func Thousands(n int) string

Thousands writes n with commas between thousands.

Types

type ImportedMsg

type ImportedMsg struct {
	ID    int
	Name  string
	Opt   fileio.Options
	Place Place
	Res   *fileio.Result
	Err   error
}

ImportedMsg is an import's result.

type Place

type Place int

Place is where an import goes.

const (
	Book      Place = iota // replace the spreadsheet
	NewSheets              // insert new sheets
	Sheet                  // replace the sheet shown
)

type TickMsg

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

TickMsg refreshes the progress display.

type Transfer

type Transfer struct {
	Source  string      // the file the sheet was imported from, if any
	Kind    fileio.Kind // its format
	Startup string      // a file to import as the program starts
	// contains filtered or unexported fields
}

Transfer is the model's import state.

func (*Transfer) Begin

func (x *Transfer) Begin(name string, prog *fileio.Progress, cancel func(), place Place) int

Begin tracks an import of name reporting to prog, cancelled by cancel, replacing any import running, and returns its ID for its ImportedMsg.

func (*Transfer) Busy

func (x *Transfer) Busy() bool

Busy reports whether an import is running.

func (*Transfer) Cancel

func (x *Transfer) Cancel() string

Cancel stops the import at once and returns the name of its file; its result, if it still arrives, is ignored.

func (*Transfer) Line

func (x *Transfer) Line(th *theme.Theme) string

Line is the context line during an import.

func (*Transfer) ProgressBar

func (x *Transfer) ProgressBar() *tea.ProgressBar

ProgressBar is the terminal's own progress indicator (OSC 9;4), shown in the tab or title bar where supported.

func (*Transfer) Start

func (x *Transfer) Start(name, path string, opt fileio.Options, place Place, parent telemetry.Parent) tea.Cmd

Start reads name, at path on disk, in the background, replacing any import running. Its span nests under parent.

func (*Transfer) Status

func (x *Transfer) Status(th *theme.Theme, width int) (left, right string)

Status is the status line during an import, width wide: the file, the rows read, and a bar when the total is known.

func (*Transfer) Update

func (x *Transfer) Update(msg tea.Msg) (res ImportedMsg, done bool, cmd tea.Cmd)

Update handles the transfer's own messages: a tick of the running import asks for the next one, and the running import's result ends it and is returned for the model to use. Stale ticks and results, from an import replaced or cancelled, are dropped.

Jump to

Keyboard shortcuts

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