|
1 | 1 | package tea |
2 | 2 |
|
| 3 | +import "github.com/charmbracelet/x/ansi" |
| 4 | + |
3 | 5 | // WindowSizeMsg is used to report the terminal size. It's sent to Update once |
4 | 6 | // initially and then on every terminal resize. Note that Windows does not |
5 | 7 | // have support for reporting when resizes occur as it does not support the |
@@ -31,3 +33,45 @@ type LayerHitMsg struct { |
31 | 33 | ID string |
32 | 34 | Mouse MouseMsg |
33 | 35 | } |
| 36 | + |
| 37 | +// ModeReportMsg is a message that represents a mode report event (DECRPM). |
| 38 | +// |
| 39 | +// This is sent by the terminal in response to a request for a terminal mode |
| 40 | +// report (DECRQM). It indicates the current setting of a specific terminal |
| 41 | +// mode like cursor visibility, mouse tracking, etc. |
| 42 | +// |
| 43 | +// Example: |
| 44 | +// |
| 45 | +// ```go |
| 46 | +// func (m model) Init() tea.Cmd { |
| 47 | +// // Does my terminal support reporting focus events? |
| 48 | +// return tea.Raw(ansi.RequestModeFocusEvent) |
| 49 | +// } |
| 50 | +// |
| 51 | +// func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { |
| 52 | +// switch msg := msg.(type) { |
| 53 | +// case tea.ModeReportMsg: |
| 54 | +// if msg.Mode == ansi.ModeFocusEvent && !msg.Value.IsNotRecognized() { |
| 55 | +// // Terminal supports focus events |
| 56 | +// m.supportsFocus = true |
| 57 | +// } |
| 58 | +// } |
| 59 | +// return m, nil |
| 60 | +// } |
| 61 | +// |
| 62 | +// func (m model) View() tea.View { |
| 63 | +// var view tea.View |
| 64 | +// view.ReportFocus = m.supportsFocus |
| 65 | +// view.SetContent(fmt.Sprintf("Terminal supports focus events: %v", m.supportsFocus)) |
| 66 | +// return view |
| 67 | +// } |
| 68 | +// ``` |
| 69 | +// |
| 70 | +// See: https://vt100.net/docs/vt510-rm/DECRPM.html |
| 71 | +type ModeReportMsg struct { |
| 72 | + // Mode is the mode number. |
| 73 | + Mode ansi.Mode |
| 74 | + |
| 75 | + // Value is the mode value. |
| 76 | + Value ansi.ModeSetting |
| 77 | +} |
0 commit comments