shared

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorReset     = "\033[0m"
	ColorRed       = "\033[31m"
	ColorGreen     = "\033[32m"
	ColorBlue      = "\033[34m"
	ColorCyan      = "\033[36m"
	ColorMagenta   = "\033[35m"
	ColorWhite     = "\033[37m"
	ColorGray      = "\033[90m"
	ColorBrightRed = "\033[91m"
)

ANSI Color Codes

View Source
const (
	LipglossBlue    = "34"
	LipglossGray    = "240"
	LipglossCyan    = "39"
	LipglossMagenta = "205"
)

Lipgloss Color Names

Variables

View Source
var (
	UserColor      = Color{ANSI: ColorCyan, Lipgloss: "36"}
	AssistantColor = Color{ANSI: ColorGreen, Lipgloss: "32"}
	ErrorColor     = Color{ANSI: ColorRed, Lipgloss: "31"}
	StatusColor    = Color{ANSI: ColorBlue, Lipgloss: LipglossBlue}
	AccentColor    = Color{ANSI: ColorMagenta, Lipgloss: "35"}
	DimColor       = Color{ANSI: ColorGray, Lipgloss: LipglossGray}
	BorderColor    = Color{ANSI: ColorWhite, Lipgloss: "37"}
	HeaderColor    = Color{ANSI: ColorCyan, Lipgloss: LipglossCyan}
	SpinnerColor   = Color{ANSI: ColorMagenta, Lipgloss: LipglossMagenta}
)

Predefined colors for consistent theming

Functions

func CreateColoredText

func CreateColoredText(text string, color Color) string

CreateColoredText creates colored text with automatic reset

func CreateSeparator

func CreateSeparator(width int, char string) string

CreateSeparator creates a separator line with the given width and character

func CreateStyledText

func CreateStyledText(text, colorCode string) string

CreateStyledText creates text with color and reset, commonly used pattern

func FormatResponsiveMessage

func FormatResponsiveMessage(content string, width int) string

FormatResponsiveMessage formats a message with responsive text wrapping

func FormatToolCall

func FormatToolCall(toolName string, args map[string]interface{}) string

FormatToolCall formats a tool call for consistent display across the application

func FormatToolResultExpanded

func FormatToolResultExpanded(result *domain.ToolExecutionResult) string

FormatToolResultExpanded formats a tool execution result with full details This is shown when user presses Ctrl+R to expand

func FormatToolResultExpandedResponsive

func FormatToolResultExpandedResponsive(result *domain.ToolExecutionResult, terminalWidth int) string

FormatToolResultExpandedResponsive formats a tool execution result with full details and responsive width

func FormatToolResultForUI

func FormatToolResultForUI(result *domain.ToolExecutionResult) string

FormatToolResultForUI formats tool execution results specifically for UI display This shows a compact "ToolName(args)" format with 2 lines of preview

func FormatToolResultForUIResponsive

func FormatToolResultForUIResponsive(result *domain.ToolExecutionResult, terminalWidth int) string

FormatToolResultForUIResponsive formats tool execution results for UI display with responsive width

func GetResponsiveWidth

func GetResponsiveWidth(terminalWidth int) int

GetResponsiveWidth calculates appropriate width based on terminal size

func Reset

func Reset() string

Reset returns the ANSI reset code

func WrapText

func WrapText(text string, width int) string

WrapText wraps text to fit within the specified width using wordwrap

Types

type ApprovalRequestMsg

type ApprovalRequestMsg struct {
	Action      string
	Description string
}

ApprovalRequestMsg requests user approval for an action

type ApprovalResponseMsg

type ApprovalResponseMsg struct {
	Approved   bool
	ApproveAll bool
}

ApprovalResponseMsg provides approval response

type AutocompleteInterface

type AutocompleteInterface interface {
	Update(inputText string, cursorPos int)
	HandleKey(key tea.KeyMsg) (bool, string)
	IsVisible() bool
	SetWidth(width int)
	Render() string
	GetSelectedCommand() string
	Hide()
}

AutocompleteInterface defines the interface for autocomplete functionality

type ClearErrorMsg

type ClearErrorMsg struct{}

ClearErrorMsg clears any displayed error

type ClearInputMsg

type ClearInputMsg struct{}

ClearInputMsg clears the input field

type Color

type Color struct {
	ANSI     string
	Lipgloss string
}

Color represents a color that can be used in both ANSI and Lipgloss contexts

func (Color) GetLipglossColor

func (c Color) GetLipglossColor() lipgloss.Color

GetLipglossColor returns a lipgloss color for the given Color

type CommonStyles

type CommonStyles struct {
	Header          lipgloss.Style
	Border          lipgloss.Style
	Separator       lipgloss.Style
	Input           lipgloss.Style
	Status          lipgloss.Style
	HelpBar         lipgloss.Style
	Conversation    lipgloss.Style
	BashIndicator   lipgloss.Style
	ModelIndicator  lipgloss.Style
	PlaceholderText lipgloss.Style
}

CommonStyles contains reusable lipgloss styles

func NewCommonStyles

func NewCommonStyles() *CommonStyles

NewCommonStyles creates a new set of common styles with consistent theming

type DebugKeyMsg

type DebugKeyMsg struct {
	Key     string
	Handler string
}

DebugKeyMsg provides debug information about key presses

type FileSelectedMsg

type FileSelectedMsg struct {
	FilePath string
}

FileSelectedMsg indicates file selection

type FileSelectionRequestMsg

type FileSelectionRequestMsg struct{}

FileSelectionRequestMsg requests file selection UI

type FocusRequestMsg

type FocusRequestMsg struct {
	ComponentID string
}

FocusRequestMsg requests focus change

type HideHelpBarMsg

type HideHelpBarMsg struct{}

HideHelpBarMsg hides the help bar when typing other characters

type KeyShortcut

type KeyShortcut struct {
	Key         string
	Description string
}

KeyShortcut represents a keyboard shortcut with description

type ModelSelectedMsg

type ModelSelectedMsg struct {
	Model string
}

ModelSelectedMsg indicates model selection

type ResizeMsg

type ResizeMsg struct {
	Width  int
	Height int
}

ResizeMsg handles terminal resize

type ScrollDirection

type ScrollDirection int

ScrollDirection represents different scroll directions

const (
	ScrollUp ScrollDirection = iota
	ScrollDown
	ScrollToTop
	ScrollToBottom
)

type ScrollRequestMsg

type ScrollRequestMsg struct {
	ComponentID string
	Direction   ScrollDirection
	Amount      int
}

ScrollRequestMsg requests scrolling in a component

type SetInputMsg

type SetInputMsg struct {
	Text string
}

SetInputMsg sets text in the input field

type SetStatusMsg

type SetStatusMsg struct {
	Message    string
	Spinner    bool
	TokenUsage string
}

SetStatusMsg sets a status message

type ShowErrorMsg

type ShowErrorMsg struct {
	Error  string
	Sticky bool // Whether error persists until dismissed
}

ShowErrorMsg displays an error message

type ToggleHelpBarMsg

type ToggleHelpBarMsg struct{}

ToggleHelpBarMsg toggles the help bar visibility

type UpdateHistoryMsg

type UpdateHistoryMsg struct {
	History []domain.ConversationEntry
}

UpdateHistoryMsg updates the conversation history display

type UserInputMsg

type UserInputMsg struct {
	Content string
}

UserInputMsg represents user input submission

Jump to

Keyboard shortcuts

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