common

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ConfigKey = &contextKey{"config"}
	RepoKey   = &contextKey{"repo"}
)

Keys to use for context.Context.

View Source
var CloneCmd = func(publicURL, name string) string {
	return fmt.Sprintf("git clone %s", RepoURL(publicURL, name))
}

CloneCmd returns the URL of the repository.

View Source
var ErrMissingRepo = errors.New("missing repo")

ErrMissingRepo indicates that the requested repository could not be found.

Functions

func ErrorCmd

func ErrorCmd(err error) tea.Cmd

ErrorCmd returns an ErrorMsg from error.

func FormatHighlight

func FormatHighlight(p, c string) (string, error)

FormatHighlight adds syntax highlighting to a string.

func FormatLineNumber

func FormatLineNumber(styles *styles.Styles, s string, color bool) (string, int)

FormatLineNumber adds line numbers to a string.

func RepoURL

func RepoURL(publicURL, name string) string

RepoURL returns the URL of the repository.

func StyleConfig

func StyleConfig() gansi.StyleConfig

StyleConfig returns the default Glamour style configuration.

func TruncateString

func TruncateString(s string, max int) string

TruncateString is a convenient wrapper around truncate.TruncateString.

Types

type Common

type Common struct {
	Width, Height int
	Styles        *styles.Styles
	KeyMap        *keymap.KeyMap
	Zone          *zone.Manager
	Output        *termenv.Output
	Logger        *log.Logger
	// contains filtered or unexported fields
}

Common is a struct all components should embed.

func NewCommon

func NewCommon(ctx context.Context, out *termenv.Output, width, height int) Common

NewCommon returns a new Common struct.

func (*Common) Backend

func (c *Common) Backend() *backend.Backend

Backend returns the Soft Serve backend.

func (*Common) Config

func (c *Common) Config() *config.Config

Config returns the server config.

func (*Common) Context

func (c *Common) Context() context.Context

Context returns the context.

func (*Common) PublicKey

func (c *Common) PublicKey() ssh.PublicKey

PublicKey returns the public key.

func (*Common) Repo

func (c *Common) Repo() *git.Repository

Repo returns the repository.

func (*Common) SetSize

func (c *Common) SetSize(width, height int)

SetSize sets the width and height of the common struct.

func (*Common) SetValue

func (c *Common) SetValue(key, value interface{})

SetValue sets a value in the context.

type Component

type Component interface {
	tea.Model
	help.KeyMap
	SetSize(width, height int)
}

Component represents a Bubble Tea model that implements a SetSize function.

type ErrorMsg

type ErrorMsg error

ErrorMsg is a Bubble Tea message that represents an error.

type TabComponent

type TabComponent interface {
	Component

	// StatusBarValue returns the status bar value component.
	StatusBarValue() string

	// StatusBarInfo returns the status bar info component.
	StatusBarInfo() string

	// SpinnerID returns the ID of the spinner.
	SpinnerID() int

	// TabName returns the name of the tab.
	TabName() string
}

TabComponenet represents a model that is mounted to a tab. TODO: find a better name

Jump to

Keyboard shortcuts

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