okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
8e3e173
main
1package tui 2 3import ( 4"regexp" 5"strings" 6 7 tea"charm.land/bubbletea/v2" 8) 9 10// Private APC marks describe rows for selection and clicks, not the terminal. 11// Ultraviolet preserves APC payloads, and Terminal.app prints unknown ones. 12var privateRowMarks = regexp .MustCompile (`\x1b_albedo:[^\x1b]*\x1b\\` ) 13 14// View captures the mouse only in chat, where it scrolls and selects; every 15// other screen leaves it to the terminal. 16func (m * AppModel )View () tea.View { 17v := tea .NewView (privateRowMarks .ReplaceAllString (m .content (),"" )) 18v .MouseMode = tea .MouseModeNone 19if m .State == AppStateChat { 20v .MouseMode = tea .MouseModeCellMotion 21 } 22return v 23} 24 25func (m * AppModel )content ()string { 26switch m .State { 27case AppStateChat : 28return m .Chat .View () 29case AppStateSessionPicker : 30var b strings.Builder 31for _ ,n := range m .Notices { 32style := DefaultStyles .Faint 33if n .Error { 34style = DefaultStyles .Error 35 } 36b .WriteString (style .Render (n .Message )) 37b .WriteByte ('\n' ) 38 } 39return b .String ()+ m .SessionPicker .View () 40case AppStateModelPicker : 41return m .ModelPicker .View () 42case AppStateExtensionPicker : 43return m .ExtensionPicker .View () 44case AppStateTreePicker : 45return m .TreePicker .View () 46case AppStateContextInspector : 47return m .ContextInspector .View () 48case AppStatePageView : 49return m .PageView .View () 50case AppStateCapabilityPage : 51return m .CapabilityPage .View () 52case AppStateWebhooksPage : 53return m .WebhooksPage .View () 54case AppStateAgents : 55return m .Agents .View () 56case AppStateFolderPicker : 57return m .FolderPicker .View () 58case AppStateLogin : 59return m .Login .View () 60case AppStateQuota : 61return m .Quota .View () 62default : 63return "" 64 } 65}