MCPcopy
hub / github.com/mathaou/termdbms / HandleKeyboardEvents

Function HandleKeyboardEvents

viewer/events.go:113–150  ·  view source on GitHub ↗

HandleKeyboardEvents does that

(m *TuiModel, msg *tea.KeyMsg)

Source from the content-addressed store, hash-verified

111
112// HandleKeyboardEvents does that
113func HandleKeyboardEvents(m *TuiModel, msg *tea.KeyMsg) tea.Cmd {
114 var (
115 cmd tea.Cmd
116 )
117 str := msg.String()
118
119 if m.UI.EditModeEnabled { // handle edit mode
120 HandleEditMode(m, str)
121 return nil
122 } else if m.UI.FormatModeEnabled {
123 if str == "esc" { // cycle focus
124 if m.TextInput.Model.Focused() {
125 cmd = m.FormatInput.Model.FocusCommand()
126 m.TextInput.Model.Blur()
127 } else {
128 cmd = m.TextInput.Model.FocusCommand()
129 m.FormatInput.Model.Blur()
130 }
131 return cmd
132 }
133
134 if m.TextInput.Model.Focused() {
135 HandleEditMode(m, str)
136 } else {
137 HandleFormatMode(m, str)
138 }
139
140 return nil
141 }
142
143 for k := range GlobalCommands {
144 if str == k {
145 return GlobalCommands[str](m)
146 }
147 }
148
149 return nil
150}

Callers 1

UpdateMethod · 0.85

Calls 6

HandleEditModeFunction · 0.85
HandleFormatModeFunction · 0.85
FocusedMethod · 0.80
FocusCommandMethod · 0.80
BlurMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected