util

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package util provides utility types and functions for the OpenCode TUI.

This package includes:

  • InfoMsg: Messages for displaying status information (info, warning, error)
  • ClearStatusMsg: Message for clearing status display
  • Helper functions for reporting errors, warnings, and info messages

These utilities are used across the TUI to display transient status messages to the user, such as error notifications or operation progress updates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clamp

func Clamp(v, low, high int) int

func CmdHandler

func CmdHandler(msg tea.Msg) tea.Cmd

CmdHandler wraps a message into a tea.Cmd for asynchronous handling. This is a convenience function for creating commands that return a specific message.

func ReportError

func ReportError(err error) tea.Cmd

ReportError creates a command that reports an error message to the user. The error will be displayed as an InfoMsg with InfoTypeError.

func ReportInfo

func ReportInfo(info string) tea.Cmd

ReportInfo creates a command that reports an informational message to the user. The message will be displayed as an InfoMsg with InfoTypeInfo.

func ReportWarn

func ReportWarn(warn string) tea.Cmd

ReportWarn creates a command that reports a warning message to the user. The message will be displayed as an InfoMsg with InfoTypeWarn.

Types

type ClearStatusMsg

type ClearStatusMsg struct{}

ClearStatusMsg is sent to clear any displayed status message.

type InfoMsg

type InfoMsg struct {
	// Type is the kind of message (Info, Warn, or Error).
	Type InfoType
	// Msg is the text content of the message.
	Msg string
	// TTL is the time duration after which the message should be cleared.
	// A value of 0 means the message persists until manually cleared.
	TTL time.Duration
}

InfoMsg is a message type for displaying status information to the user. It includes the message type (info, warning, error), the message text, and an optional time-to-live (TTL) for auto-dismissal.

type InfoType

type InfoType int

InfoType represents the type of information message.

const (
	// InfoTypeInfo indicates an informational message.
	InfoTypeInfo InfoType = iota
	// InfoTypeWarn indicates a warning message.
	InfoTypeWarn
	// InfoTypeError indicates an error message.
	InfoTypeError
)

Jump to

Keyboard shortcuts

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