diff --git a/environ.go b/environ.go index 9a3a62d7..fe444a12 100644 --- a/environ.go +++ b/environ.go @@ -41,7 +41,19 @@ func (p environ) LookupEnv(key string) (s string, v bool) { } // EnvMsg is a message that represents the environment variables of the -// program. This message is sent to the program when it starts. +// program. This is useful for getting the environment variables of programs +// running in a remote session like SSH. In that case, using [os.Getenv] would +// return the server's environment variables, not the client's. +// +// This message is sent to the program when it starts. +// +// Example: +// +// switch msg := msg.(type) { +// case EnvMsg: +// // What terminal type is being used? +// term := msg.Getenv("TERM") +// } type EnvMsg environ // Getenv returns the value of the environment variable named by the key. If diff --git a/raw.go b/raw.go index 0cb8b8c2..fb6ae44d 100644 --- a/raw.go +++ b/raw.go @@ -8,6 +8,28 @@ type RawMsg struct { // Raw is a command that prints the given string to the terminal without any // formatting. +// +// This is intended for advanced use cases where you need to query the terminal +// or send escape sequences directly. Don't use this unless you know what +// you're doing :) +// +// Example: +// +// func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { +// switch msg := msg.(type) { +// case input.PrimaryDeviceAttributesEvent: +// for _, attr := range msg { +// if attr == 4 { +// // We have Sixel graphics support! +// break +// } +// } +// } +// +// // Request the terminal primary device attributes to detect Sixel graphics +// // support. +// return m, tea.Raw(ansi.RequestPrimaryDeviceAttributes) +// } func Raw(r any) Cmd { return func() Msg { return RawMsg{r}