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

Function SelectOption

viewer/ui.go:26–51  ·  view source on GitHub ↗
(m *TuiModel)

Source from the content-addressed store, hash-verified

24}
25
26func SelectOption(m *TuiModel) {
27 if m.UI.RenderSelection {
28 return
29 }
30
31 m.UI.RenderSelection = true
32 raw, _, col := m.GetSelectedOption()
33 if raw == nil {
34 return
35 }
36 l := len(col)
37 row := m.Viewport.YOffset + m.MouseData.Y - HeaderHeight
38
39 if row <= l && l > 0 &&
40 m.MouseData.Y >= HeaderHeight &&
41 m.MouseData.Y < m.Viewport.Height+HeaderHeight &&
42 m.MouseData.X < m.CellWidth()*(len(m.Data().TableHeadersSlice)) {
43 if conv, ok := (*raw).(string); ok {
44 m.Data().EditTextBuffer = conv
45 } else {
46 m.Data().EditTextBuffer = ""
47 }
48 } else {
49 m.UI.RenderSelection = false
50 }
51}
52
53// ScrollDown is a simple function to move the Viewport down
54func ScrollDown(m *TuiModel) {

Callers 2

initFunction · 0.85
HandleMouseEventsFunction · 0.85

Calls 3

GetSelectedOptionMethod · 0.80
CellWidthMethod · 0.80
DataMethod · 0.80

Tested by

no test coverage detected