mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-05 04:36:07 +00:00
feat!(textinput): DefaultKeyMap is now a function; was formerly a global
This commit is contained in:
@@ -62,7 +62,8 @@ 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 {
|
||||||
|
return KeyMap{
|
||||||
CharacterForward: key.NewBinding(key.WithKeys("right", "ctrl+f")),
|
CharacterForward: key.NewBinding(key.WithKeys("right", "ctrl+f")),
|
||||||
CharacterBackward: key.NewBinding(key.WithKeys("left", "ctrl+b")),
|
CharacterBackward: key.NewBinding(key.WithKeys("left", "ctrl+b")),
|
||||||
WordForward: key.NewBinding(key.WithKeys("alt+right", "ctrl+right", "alt+f")),
|
WordForward: key.NewBinding(key.WithKeys("alt+right", "ctrl+right", "alt+f")),
|
||||||
@@ -79,6 +80,7 @@ var DefaultKeyMap = KeyMap{
|
|||||||
AcceptSuggestion: key.NewBinding(key.WithKeys("tab")),
|
AcceptSuggestion: key.NewBinding(key.WithKeys("tab")),
|
||||||
NextSuggestion: key.NewBinding(key.WithKeys("down", "ctrl+n")),
|
NextSuggestion: key.NewBinding(key.WithKeys("down", "ctrl+n")),
|
||||||
PrevSuggestion: key.NewBinding(key.WithKeys("up", "ctrl+p")),
|
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