common

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MIT Imports: 21 Imported by: 0

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 (
	// DefaultColorProfile is the default color profile used by the SSH server.
	DefaultColorProfile = termenv.ANSI256
)
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 StyleRenderer added in v0.7.4

func StyleRenderer() gansi.RenderContext

StyleRenderer returns a new Glamour renderer with the DefaultColorProfile.

func StyleRendererWithStyles added in v0.7.4

func StyleRendererWithStyles(styles gansi.StyleConfig) gansi.RenderContext

StyleRendererWithStyles returns a new Glamour renderer with the DefaultColorProfile and styles.

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
	HideCloneCmd  bool
	// 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) CloneCmd added in v0.7.4

func (c *Common) CloneCmd(publicURL, name string) string

CloneCmd returns the clone command string.

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

	// Path returns the hierarchical path of the tab.
	Path() 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