common

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GlamourMaxWidth  = 120
	RepoNameMaxWidth = 32
	MaxDiffLines     = 1000
	MaxDiffFiles     = 100
	MaxPatchWait     = time.Second * 3
)

Variables

View Source
var (
	PrevPage = key.NewBinding(
		key.WithKeys("pgup", "b", "u"),
		key.WithHelp("pgup", "prev page"),
	)
	NextPage = key.NewBinding(
		key.WithKeys("pgdown", "f", "d"),
		key.WithHelp("pgdn", "next page"),
	)
)
View Source
var (
	ErrDiffTooLong      = errors.New("diff is too long")
	ErrDiffFilesTooLong = errors.New("diff files are too long")
	ErrBinaryFile       = errors.New("binary file")
	ErrFileTooLarge     = errors.New("file is too large")
	ErrInvalidFile      = errors.New("invalid file")
)
View Source
var (
	RenderCtx = DefaultRenderCtx()
	Styles    = DefaultStyles()
)

Functions

func DefaultRenderCtx

func DefaultRenderCtx() gansi.RenderContext

func DefaultStyles

func DefaultStyles() gansi.StyleConfig

func Glamourize

func Glamourize(w int, md string) (string, error)

func Max

func Max(a, b int) int

func NewRenderCtx

func NewRenderCtx(worldwrap int) gansi.RenderContext

func RenderFile

func RenderFile(path, content string, width int) (string, error)

func TruncateString

func TruncateString(s string, max int, tail string) string

Types

type BubbleHelper

type BubbleHelper interface {
	Help() []HelpEntry
}

type BubbleReset

type BubbleReset interface {
	Reset() tea.Msg
}

type ErrMsg

type ErrMsg struct {
	Err error
}

func (ErrMsg) Error

func (e ErrMsg) Error() string

func (ErrMsg) View

func (e ErrMsg) View(s *style.Styles) string

func (ErrMsg) ViewWithPrefix

func (e ErrMsg) ViewWithPrefix(s *style.Styles, prefix string) string

type GitRepo

type GitRepo interface {
	Name() string
	Readme() (string, string)
	HEAD() (*git.Reference, error)
	CommitsByPage(*git.Reference, int, int) (git.Commits, error)
	CountCommits(*git.Reference) (int64, error)
	Diff(*git.Commit) (*git.Diff, error)
	References() ([]*git.Reference, error)
	Tree(*git.Reference, string) (*git.Tree, error)
}

type HelpEntry

type HelpEntry struct {
	Key   string
	Value string
}

Jump to

Keyboard shortcuts

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