mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-16 01:43:21 +00:00
chore(textinput): DefaultKeyMap is now a func that returns a KeyMap
This commit is contained in:
+20
-18
@@ -62,23 +62,25 @@ type KeyMap struct {
|
|||||||
|
|
||||||
// DefaultKeyMap is the default set of key bindings for navigating and acting
|
// DefaultKeyMap is the default set of key bindings for navigating and acting
|
||||||
// upon the textinput.
|
// upon the textinput.
|
||||||
var DefaultKeyMap = KeyMap{
|
func DefaultKeyMap() KeyMap {
|
||||||
CharacterForward: key.NewBinding(key.WithKeys("right", "ctrl+f")),
|
return KeyMap{
|
||||||
CharacterBackward: key.NewBinding(key.WithKeys("left", "ctrl+b")),
|
CharacterForward: key.NewBinding(key.WithKeys("right", "ctrl+f")),
|
||||||
WordForward: key.NewBinding(key.WithKeys("alt+right", "ctrl+right", "alt+f")),
|
CharacterBackward: key.NewBinding(key.WithKeys("left", "ctrl+b")),
|
||||||
WordBackward: key.NewBinding(key.WithKeys("alt+left", "ctrl+left", "alt+b")),
|
WordForward: key.NewBinding(key.WithKeys("alt+right", "ctrl+right", "alt+f")),
|
||||||
DeleteWordBackward: key.NewBinding(key.WithKeys("alt+backspace", "ctrl+w")),
|
WordBackward: key.NewBinding(key.WithKeys("alt+left", "ctrl+left", "alt+b")),
|
||||||
DeleteWordForward: key.NewBinding(key.WithKeys("alt+delete", "alt+d")),
|
DeleteWordBackward: key.NewBinding(key.WithKeys("alt+backspace", "ctrl+w")),
|
||||||
DeleteAfterCursor: key.NewBinding(key.WithKeys("ctrl+k")),
|
DeleteWordForward: key.NewBinding(key.WithKeys("alt+delete", "alt+d")),
|
||||||
DeleteBeforeCursor: key.NewBinding(key.WithKeys("ctrl+u")),
|
DeleteAfterCursor: key.NewBinding(key.WithKeys("ctrl+k")),
|
||||||
DeleteCharacterBackward: key.NewBinding(key.WithKeys("backspace", "ctrl+h")),
|
DeleteBeforeCursor: key.NewBinding(key.WithKeys("ctrl+u")),
|
||||||
DeleteCharacterForward: key.NewBinding(key.WithKeys("delete", "ctrl+d")),
|
DeleteCharacterBackward: key.NewBinding(key.WithKeys("backspace", "ctrl+h")),
|
||||||
LineStart: key.NewBinding(key.WithKeys("home", "ctrl+a")),
|
DeleteCharacterForward: key.NewBinding(key.WithKeys("delete", "ctrl+d")),
|
||||||
LineEnd: key.NewBinding(key.WithKeys("end", "ctrl+e")),
|
LineStart: key.NewBinding(key.WithKeys("home", "ctrl+a")),
|
||||||
Paste: key.NewBinding(key.WithKeys("ctrl+v")),
|
LineEnd: key.NewBinding(key.WithKeys("end", "ctrl+e")),
|
||||||
AcceptSuggestion: key.NewBinding(key.WithKeys("tab")),
|
Paste: key.NewBinding(key.WithKeys("ctrl+v")),
|
||||||
NextSuggestion: key.NewBinding(key.WithKeys("down", "ctrl+n")),
|
AcceptSuggestion: key.NewBinding(key.WithKeys("tab")),
|
||||||
PrevSuggestion: key.NewBinding(key.WithKeys("up", "ctrl+p")),
|
NextSuggestion: key.NewBinding(key.WithKeys("down", "ctrl+n")),
|
||||||
|
PrevSuggestion: key.NewBinding(key.WithKeys("up", "ctrl+p")),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Model is the Bubble Tea model for this text input element.
|
// Model is the Bubble Tea model for this text input element.
|
||||||
@@ -157,7 +159,7 @@ func New() Model {
|
|||||||
ShowSuggestions: false,
|
ShowSuggestions: false,
|
||||||
CompletionStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("240")),
|
CompletionStyle: lipgloss.NewStyle().Foreground(lipgloss.Color("240")),
|
||||||
Cursor: cursor.New(),
|
Cursor: cursor.New(),
|
||||||
KeyMap: DefaultKeyMap,
|
KeyMap: DefaultKeyMap(),
|
||||||
|
|
||||||
suggestions: [][]rune{},
|
suggestions: [][]rune{},
|
||||||
value: nil,
|
value: nil,
|
||||||
|
|||||||
Reference in New Issue
Block a user