mirror of
https://github.com/antonmedv/fx.git
synced 2024-09-11 18:27:10 +03:00
Better dig key handling
This commit is contained in:
parent
0b6ab660a3
commit
1f977869fc
@ -53,11 +53,11 @@ func init() {
|
|||||||
key.WithHelp("", "half page down"),
|
key.WithHelp("", "half page down"),
|
||||||
),
|
),
|
||||||
GotoTop: key.NewBinding(
|
GotoTop: key.NewBinding(
|
||||||
key.WithKeys("g"),
|
key.WithKeys("g", "home"),
|
||||||
key.WithHelp("", "goto top"),
|
key.WithHelp("", "goto top"),
|
||||||
),
|
),
|
||||||
GotoBottom: key.NewBinding(
|
GotoBottom: key.NewBinding(
|
||||||
key.WithKeys("G"),
|
key.WithKeys("G", "end"),
|
||||||
key.WithHelp("", "goto bottom"),
|
key.WithHelp("", "goto bottom"),
|
||||||
),
|
),
|
||||||
Down: key.NewBinding(
|
Down: key.NewBinding(
|
||||||
|
17
main.go
17
main.go
@ -247,7 +247,24 @@ func (m *model) handleDigKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case key.Matches(msg, key.NewBinding(key.WithKeys("ctrl+w"))):
|
||||||
|
digPath, ok := jsonpath.Split(m.digInput.Value())
|
||||||
|
if ok {
|
||||||
|
digPath = digPath[:len(digPath)-1]
|
||||||
|
n := m.selectByPath(digPath)
|
||||||
|
if n != nil {
|
||||||
|
m.selectNode(n)
|
||||||
|
m.digInput.SetValue(m.cursorPath())
|
||||||
|
m.digInput.CursorEnd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
if key.Matches(msg, key.NewBinding(key.WithKeys("."))) {
|
||||||
|
m.digInput.SetValue(m.cursorPath())
|
||||||
|
m.digInput.CursorEnd()
|
||||||
|
}
|
||||||
|
|
||||||
m.digInput, cmd = m.digInput.Update(msg)
|
m.digInput, cmd = m.digInput.Update(msg)
|
||||||
n := m.dig(m.digInput.Value())
|
n := m.dig(m.digInput.Value())
|
||||||
if n != nil {
|
if n != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user