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

Function HandleEditInput

viewer/mode.go:49–75  ·  view source on GitHub ↗
(m *TuiModel, str, val string)

Source from the content-addressed store, hash-verified

47}
48
49func HandleEditInput(m *TuiModel, str, val string) (ret bool) {
50 selectedInput := &m.TextInput.Model
51 input := selectedInput.Value()
52 inputLen := len(input)
53
54 if str == "backspace" {
55 cursor := selectedInput.Cursor()
56 runes := []rune(input)
57 if cursor == inputLen && inputLen > 0 {
58 selectedInput.SetValue(input[0 : inputLen-1])
59 } else if cursor > 0 {
60 min := Max(selectedInput.Cursor(), 0)
61 min = Min(min, inputLen-1)
62 first := runes[:min-1]
63 last := runes[min:]
64 selectedInput.SetValue(string(first) + string(last))
65 selectedInput.SetCursor(selectedInput.Cursor() - 1)
66 }
67
68 ret = true
69 } else if str == "enter" { // writes your selection
70 EditEnter(m)
71 ret = true
72 }
73
74 return ret
75}
76
77func HandleEditMovement(m *TuiModel, str, val string) (ret bool) {
78 selectedInput := &m.TextInput.Model

Callers 1

HandleEditModeFunction · 0.85

Calls 7

MaxFunction · 0.85
MinFunction · 0.85
EditEnterFunction · 0.85
ValueMethod · 0.80
SetValueMethod · 0.80
SetCursorMethod · 0.80
CursorMethod · 0.45

Tested by

no test coverage detected