common

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 22 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 = colorprofile.ANSI256

DefaultColorProfile is the default color profile used by the SSH server.

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 IsFileMarkdown

func IsFileMarkdown(content, ext string) bool

IsFileMarkdown returns true if the file is markdown. It uses chroma lexers to analyze and determine the language.

func RepoURL

func RepoURL(publicURL, name string) string

RepoURL returns the URL of the repository.

func ScrollPercent

func ScrollPercent(position int) string

ScrollPercent returns a string representing the scroll percentage of the viewport.

func StyleConfig

func StyleConfig() gansi.StyleConfig

StyleConfig returns the default Glamour style configuration.

func StyleRenderer

func StyleRenderer() gansi.RenderContext

StyleRenderer returns a new Glamour renderer.

func StyleRendererWithStyles

func StyleRendererWithStyles(styles gansi.StyleConfig) gansi.RenderContext

StyleRendererWithStyles returns a new Glamour renderer.

func TruncateString

func TruncateString(s string, max int) string

TruncateString is a convenient wrapper around truncate.TruncateString.

func UnquoteFilename

func UnquoteFilename(s string) string

UnquoteFilename unquotes a filename. When Git is with "core.quotePath" set to "true" (default), it will quote the filename with double quotes if it contains control characters or unicode. this function will unquote the filename.

Types

type Common

type Common struct {
	Width, Height int
	Styles        *styles.Styles
	KeyMap        *keymap.KeyMap
	Zone          *zone.Manager
	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, 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

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 {
	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 Model

type Model interface {
	Init() tea.Cmd
	Update(tea.Msg) (Model, tea.Cmd)
	View() string
}

Model represents a simple UI model.

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