Documentation
¶
Overview ¶
Package state keeps what would be missed if lost: the drafts of edits not yet sent, and the locks that keep two gist from one gist's drafts.
Index ¶
- Variables
- type Draft
- type Lock
- type ReleaseSeen
- type Store
- func (s *Store) Draft(gist, file string) (Draft, bool, error)
- func (s *Store) DraftGists() ([]string, error)
- func (s *Store) Drafts(gist string) ([]Draft, error)
- func (s *Store) DraftsDir() string
- func (s *Store) HasDraft(gist, file string) bool
- func (s *Store) Lock(gist string) (*Lock, error)
- func (s *Store) PaneWidth() int
- func (s *Store) PreviewHeight() int
- func (s *Store) ReleaseSeen() ReleaseSeen
- func (s *Store) SavePaneWidth(w int) error
- func (s *Store) SavePreviewHeight(h int) error
- func (s *Store) SaveReleaseSeen(r ReleaseSeen) error
Constants ¶
This section is empty.
Variables ¶
var ErrLocked = errors.New("being edited in another gist process")
ErrLocked says another gist process is editing the gist.
Functions ¶
This section is empty.
Types ¶
type Draft ¶
type Draft struct {
Gist string `json:"gist"`
File string `json:"file"`
// Revision and Original are what the edit started from, and what it is
// compared with.
Revision string `json:"revision"`
Original []byte `json:"original"`
// Content is the file as edited.
Content []byte `json:"content"`
Created time.Time `json:"created"`
}
Draft is an edit not yet sent. Its text is kept as bytes, as a file need not be valid UTF-8 and JSON strings would change what is not.
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock is the hold of one process on a gist. Drafts are written and removed only through it, so another process cannot replace a draft or remove it.
func (*Lock) DeleteDraft ¶
DeleteDraft removes the draft of a file of the lock's gist, which need not exist.
func (*Lock) DeleteDrafts ¶
DeleteDrafts removes all the drafts of the lock's gist.
type ReleaseSeen ¶
type ReleaseSeen struct {
// Checked is when they were last read.
Checked time.Time `json:"checked,omitzero"`
// Latest is the newest found, and Told the newest told of.
Latest string `json:"latest,omitempty"`
Told string `json:"told,omitempty"`
}
ReleaseSeen is what was last found of gist's releases.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the state directory.
func (*Store) DraftGists ¶
DraftGists are the gists that have drafts.
func (*Store) Lock ¶
Lock takes the gist's lock, failing with ErrLocked when another process has it. The operating system lets it go if the process dies.
func (*Store) PaneWidth ¶ added in v2.2.0
PaneWidth is the width the pane beside the preview was dragged to, or 0.
func (*Store) PreviewHeight ¶
PreviewHeight is the height the preview was left at, or 0.
func (*Store) ReleaseSeen ¶
func (s *Store) ReleaseSeen() ReleaseSeen
ReleaseSeen is what was last found of the releases.
func (*Store) SavePaneWidth ¶ added in v2.2.0
SavePaneWidth remembers the width of the pane; 0 forgets it.
func (*Store) SavePreviewHeight ¶
SavePreviewHeight remembers the height of the preview.
func (*Store) SaveReleaseSeen ¶
func (s *Store) SaveReleaseSeen(r ReleaseSeen) error
SaveReleaseSeen remembers it.