MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / Update

Method Update

internal/tui/logs_tab.go:79–169  ·  view source on GitHub ↗
(msg tea.Msg)

Source from the content-addressed store, hash-verified

77}
78
79func (m logsTabModel) Update(msg tea.Msg) (logsTabModel, tea.Cmd) {
80 switch msg := msg.(type) {
81 case localeChangedMsg:
82 m.viewport.SetContent(m.renderLogs())
83 return m, nil
84 case logsTickMsg:
85 if m.hook != nil {
86 return m, nil
87 }
88 return m, m.fetchLogs
89 case logsPollMsg:
90 if m.hook != nil {
91 return m, nil
92 }
93 if msg.err != nil {
94 m.lastErr = msg.err
95 } else {
96 m.lastErr = nil
97 m.after = msg.latest
98 if len(msg.lines) > 0 {
99 m.lines = append(m.lines, msg.lines...)
100 if len(m.lines) > m.maxLines {
101 m.lines = m.lines[len(m.lines)-m.maxLines:]
102 }
103 }
104 }
105 m.viewport.SetContent(m.renderLogs())
106 if m.autoScroll {
107 m.viewport.GotoBottom()
108 }
109 return m, m.waitForNextPoll()
110 case logLineMsg:
111 m.lines = append(m.lines, string(msg))
112 if len(m.lines) > m.maxLines {
113 m.lines = m.lines[len(m.lines)-m.maxLines:]
114 }
115 m.viewport.SetContent(m.renderLogs())
116 if m.autoScroll {
117 m.viewport.GotoBottom()
118 }
119 return m, m.waitForLog
120
121 case tea.KeyMsg:
122 switch msg.String() {
123 case "a":
124 m.autoScroll = !m.autoScroll
125 if m.autoScroll {
126 m.viewport.GotoBottom()
127 }
128 return m, nil
129 case "c":
130 m.lines = nil
131 m.lastErr = nil
132 m.viewport.SetContent(m.renderLogs())
133 return m, nil
134 case "1":
135 m.filter = ""
136 m.viewport.SetContent(m.renderLogs())

Callers

nothing calls this directly

Calls 3

renderLogsMethod · 0.95
waitForNextPollMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected