formatting

package
v0.0.0-...-fa37776 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatNotification

func FormatNotification(notification *pb.Notification, notificationType string) string

FormatNotification formats a notification for display.

func MakeSessionIDHyperlink(sessionID string, enableHyperlinks bool) string

MakeSessionIDHyperlink creates a clickable session ID hyperlink. When clicked in iTerm2, opens the iterm2://session/activate/<id> URL.

func MakeTabIDHyperlink(tabID string, enableHyperlinks bool) string

MakeTabIDHyperlink creates a clickable tab ID hyperlink. When clicked in iTerm2, opens the iterm2://tab/activate/<id> URL.

func MakeWindowIDHyperlink(windowID string, enableHyperlinks bool) string

MakeWindowIDHyperlink creates a clickable window ID hyperlink. When clicked in iTerm2, opens the iterm2://window/activate/<id> URL.

func OSC8Hyperlink(url, text string) string

OSC8Hyperlink wraps text in an OSC 8 terminal hyperlink escape sequence. The format is: ESC ]8;;URI ESC \ text ESC ]8;; ESC \

Parameters:

  • url: The target URI (e.g., "iterm2://session/activate/ABC123")
  • text: The display text to show as a clickable link

Returns the text wrapped in OSC 8 sequences, or just the text if hyperlinks are disabled.

Reference: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda

func PrintJSON

func PrintJSON(v interface{}) error

PrintJSON is a convenience function for printing JSON output.

func PrintYAML

func PrintYAML(v interface{}) error

PrintYAML is a convenience function for printing YAML output.

func SessionActivateURL

func SessionActivateURL(sessionID string) string

SessionActivateURL generates an it2:// URL for activating a session. Format: it2://session/activate/<session-id>

func SupportsOSC8

func SupportsOSC8() bool

SupportsOSC8 detects if the current terminal supports OSC 8 hyperlinks. Returns true if the terminal is known to support OSC 8, false otherwise.

Supported terminals:

  • iTerm2 (TERM_PROGRAM=iTerm.app)
  • WezTerm (TERM_PROGRAM=WezTerm)
  • VSCode terminal (TERM_PROGRAM=vscode)
  • Kitty (TERM=xterm-kitty)
  • Terminals with VTE >= 0.50 (TERM contains "vte")

Hyperlinks are automatically disabled when:

  • NO_HYPERLINKS environment variable is set
  • Output is not a TTY (piped to watch, tee, files, etc.)

func TabActivateURL

func TabActivateURL(tabID string) string

TabActivateURL generates an it2:// URL for activating a tab. Format: it2://tab/activate/<tab-id>

func WindowActivateURL

func WindowActivateURL(windowID string) string

WindowActivateURL generates an it2:// URL for activating a window. Format: it2://window/activate/<window-id>

Types

type Annotation

type Annotation struct {
	ID        string    `json:"id"`
	Text      string    `json:"text"`
	Line      int       `json:"line,omitempty"`
	Column    int       `json:"column,omitempty"`
	Timestamp time.Time `json:"timestamp"`
	Type      string    `json:"type,omitempty"`
}

Annotation represents an annotation for formatting.

type Formatter

type Formatter struct {
	// contains filtered or unexported fields
}

Formatter handles formatting of iTerm2 data structures for display.

func New

func New(format string) *Formatter

New creates a new formatter with the specified format.

func NewWithHyperlinks(format string, columns []string, sortBy string, sortReverse bool, quiet bool, hyperlinks bool) *Formatter

NewWithHyperlinks creates a new formatter with full options including hyperlinks.

func NewWithOptions

func NewWithOptions(format string, columns []string, sortBy string, sortReverse bool, quiet bool) *Formatter

NewWithOptions creates a new formatter with column and sort options.

func (*Formatter) FormatAlertResponse

func (f *Formatter) FormatAlertResponse(response interface{}) error

FormatAlertResponse formats alert responses (placeholder).

func (*Formatter) FormatAnnotations

func (f *Formatter) FormatAnnotations(annotations []*Annotation) error

FormatAnnotations formats annotation information.

func (*Formatter) FormatBroadcastDomains

func (f *Formatter) FormatBroadcastDomains(domains []*client.BroadcastDomain) error

FormatBroadcastDomains formats broadcast domain information.

func (*Formatter) FormatBuffer

func (f *Formatter) FormatBuffer(resp *pb.GetBufferResponse) error

FormatBuffer formats buffer contents.

func (*Formatter) FormatBufferEscaped

func (f *Formatter) FormatBufferEscaped(resp *pb.GetBufferResponse, includeColors bool) error

FormatBufferEscaped formats buffer contents with escape sequences shown as visible characters (like cat -v).

func (*Formatter) FormatBufferWithColors

func (f *Formatter) FormatBufferWithColors(resp *pb.GetBufferResponse) error

FormatBufferWithColors formats buffer contents with ANSI color codes.

func (*Formatter) FormatClientWindows

func (f *Formatter) FormatClientWindows(windows []*client.WindowInfo) error

FormatClientWindows formats client.WindowInfo from the client package.

func (*Formatter) FormatCursor

func (f *Formatter) FormatCursor(cursor *pb.Coord) error

FormatCursor formats cursor position and state information.

func (*Formatter) FormatCustomControlResponse

func (f *Formatter) FormatCustomControlResponse(response interface{}) error

FormatCustomControlResponse formats custom control responses (placeholder).

func (*Formatter) FormatFilePanelResponse

func (f *Formatter) FormatFilePanelResponse(response interface{}) error

FormatFilePanelResponse formats file panel responses (placeholder).

func (*Formatter) FormatFindResults

func (f *Formatter) FormatFindResults(results []*client.FindResult, showLineNumbers bool) error

FormatFindResults formats text search results.

func (*Formatter) FormatGeneric

func (f *Formatter) FormatGeneric(v interface{}) error

FormatGeneric formats any interface{} as JSON.

func (*Formatter) FormatHighlightResults

func (f *Formatter) FormatHighlightResults(results []*client.HighlightResult) error

FormatHighlightResults formats text highlighting results.

func (*Formatter) FormatKeyBindings

func (f *Formatter) FormatKeyBindings(bindings []interface{}) error

FormatKeyBindings formats keyboard bindings output.

func (*Formatter) FormatLifecycleResponse

func (f *Formatter) FormatLifecycleResponse(response interface{}) error

FormatLifecycleResponse formats lifecycle responses (placeholder).

func (*Formatter) FormatReplaceResults

func (f *Formatter) FormatReplaceResults(results []*client.ReplaceResult) error

FormatReplaceResults formats text replacement results.

func (*Formatter) FormatSelection

func (f *Formatter) FormatSelection(selection *pb.Selection) error

FormatSelection formats a selection for display.

func (*Formatter) FormatSessions

func (f *Formatter) FormatSessions(sessions []*client.SessionInfo) error

FormatSessions formats a list of sessions for display.

func (*Formatter) FormatSessionsWithRawTree

func (f *Formatter) FormatSessionsWithRawTree(listResp *pb.ListSessionsResponse, sessions []*client.SessionInfo) error

FormatSessionsWithRawTree formats sessions using the raw split tree structure from iTerm2.

func (*Formatter) FormatStringList

func (f *Formatter) FormatStringList(title string, items []string) error

FormatStringList formats a list of strings with an optional title.

func (*Formatter) FormatTabInfo

func (f *Formatter) FormatTabInfo(tab *TabInfo) error

FormatTabInfo formats single tab information.

func (*Formatter) FormatTabResponse

func (f *Formatter) FormatTabResponse(resp *pb.CreateTabResponse) error

FormatTabResponse formats a tab creation response.

func (*Formatter) FormatTable

func (f *Formatter) FormatTable(data *TableData) error

FormatTable formats data as a table with aligned columns

func (*Formatter) FormatTabs

func (f *Formatter) FormatTabs(tabs []*TabInfo) error

FormatTabs formats tab information.

func (*Formatter) FormatTmuxConnections

func (f *Formatter) FormatTmuxConnections(connections []*client.TmuxConnection) error

FormatTmuxConnections formats tmux connection information.

func (*Formatter) FormatTriggers

func (f *Formatter) FormatTriggers(triggers []*Trigger) error

FormatTriggers formats trigger information.

func (*Formatter) GetFormat

func (f *Formatter) GetFormat() string

GetFormat returns the current format string.

func (*Formatter) SetIncludeEmptyLines

func (f *Formatter) SetIncludeEmptyLines(include bool)

SetIncludeEmptyLines sets whether to include trailing empty lines in buffer output.

type SplitTreeNode

type SplitTreeNode struct {
	IsSession      bool                   // True if this is a session, false if it's a split container
	IsVertical     bool                   // Direction of split (only relevant if IsSession=false)
	SessionID      string                 // Only set if IsSession=true
	ShortID        string                 // Only set if IsSession=true
	Name           string                 // Only set if IsSession=true
	CurrentCommand string                 // Only set if IsSession=true
	ShellPID       int32                  // Only set if IsSession=true
	JobPID         int32                  // Only set if IsSession=true
	PromptState    string                 // Only set if IsSession=true
	PluginData     map[string]interface{} // Only set if IsSession=true
	Children       []*SplitTreeNode       // Child nodes (either sessions or more splits)
}

SplitTreeNode represents a node in the panel hierarchy (can be a session or a split container).

type TabInfo

type TabInfo struct {
	TabID        string                 `json:"tab_id"`
	WindowID     string                 `json:"window_id"`
	WindowNumber int                    `json:"window_number"`
	Title        string                 `json:"title,omitempty"`
	Active       bool                   `json:"active"`
	Position     int                    `json:"position"`
	Sessions     []*client.SessionInfo  `json:"sessions,omitempty"`
	PluginData   map[string]interface{} `json:"plugin_data,omitempty"`
}

TabInfo represents tab information for formatting.

type TableData

type TableData struct {
	Headers []string
	Rows    [][]string
}

TableData represents data to be displayed in a table format

func NewTableData

func NewTableData(headers []string) *TableData

NewTableData creates a new TableData with headers

func (*TableData) AddRow

func (td *TableData) AddRow(row []string)

AddRow adds a row to the table data

func (*TableData) SelectColumns

func (td *TableData) SelectColumns(columns []string) *TableData

SelectColumns filters the table to only show specified columns

func (*TableData) SortBy

func (td *TableData) SortBy(column string, ascending bool)

SortBy sorts the table by the specified column

type TreeNode

type TreeNode struct {
	SessionID      string
	ShortID        string
	Name           string
	ParentID       string
	SplitVertical  *bool // Direction of split from parent (nil if no parent, true=vertical, false=horizontal)
	Children       []*TreeNode
	CurrentCommand string
	ShellPID       int32
	JobPID         int32
	PromptState    string
	PluginData     map[string]interface{}
}

TreeNode represents a session in the tree hierarchy.

type Trigger

type Trigger struct {
	ID      string    `json:"id"`
	Pattern string    `json:"pattern"`
	Action  string    `json:"action"`
	Enabled bool      `json:"enabled"`
	Created time.Time `json:"created"`
}

Trigger represents a trigger for formatting.

type WindowInfo

type WindowInfo struct {
	WindowID     string                 `json:"window_id"`
	Name         string                 `json:"name,omitempty"`
	Title        string                 `json:"title,omitempty"`
	Frame        string                 `json:"frame,omitempty"`
	Fullscreen   string                 `json:"fullscreen,omitempty"`
	Miniaturized string                 `json:"miniaturized,omitempty"`
	TabCount     int                    `json:"tab_count"`
	PluginData   map[string]interface{} `json:"plugin_data,omitempty"`
}

WindowInfo represents window information for formatting.

Jump to

Keyboard shortcuts

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