Skip to content
Myr

screen.go

This file

Path

screen.go

66 lines · 1.9 KiB · Go

Last changed by

chore: remove deprecated windows note (#1695)Jasonbefore adoptionaf9a33e

History of this file

Take it

1package tea23import "github.com/charmbracelet/x/ansi"45// WindowSizeMsg is used to report the terminal size. It's sent to Update once6// initially and then on every terminal resize.7type WindowSizeMsg struct {8	Width  int9	Height int10}1112// ClearScreen is a special command that tells the program to clear the screen13// before the next update. This can be used to move the cursor to the top left14// of the screen and clear visual clutter when the alt screen is not in use.15//16// Note that it should never be necessary to call ClearScreen() for regular17// redraws.18func ClearScreen() Msg {19	return clearScreenMsg{}20}2122// clearScreenMsg is an internal message that signals to clear the screen.23// You can send a clearScreenMsg with ClearScreen.24type clearScreenMsg struct{}2526// ModeReportMsg is a message that represents a mode report event (DECRPM).27//28// This is sent by the terminal in response to a request for a terminal mode29// report (DECRQM). It indicates the current setting of a specific terminal30// mode like cursor visibility, mouse tracking, etc.31//32// Example:33//34//	```go35//	func (m model) Init() tea.Cmd {36//	  // Does my terminal support reporting focus events?37//	  return tea.Raw(ansi.RequestModeFocusEvent)38//	}39//40//	func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {41//	  switch msg := msg.(type) {42//	  case tea.ModeReportMsg:43//	    if msg.Mode == ansi.ModeFocusEvent && !msg.Value.IsNotRecognized() {44//	      // Terminal supports focus events45//	      m.supportsFocus = true46//	    }47//	  }48//	  return m, nil49//	}50//51//	func (m model) View() tea.View {52//	  var view tea.View53//	  view.ReportFocus = m.supportsFocus54//	  view.SetContent(fmt.Sprintf("Terminal supports focus events: %v", m.supportsFocus))55//	  return view56//	}57//	```58//59// See: https://vt100.net/docs/vt510-rm/DECRPM.html60type ModeReportMsg struct {61	// Mode is the mode number.62	Mode ansi.Mode6364	// Value is the mode value.65	Value ansi.ModeSetting66}