Documentation
¶
Index ¶
- func BuildEditorSupportFromMapping(mapping *mappings.ActionMappingConfig) []*keymapv1.EditorSupport
- func DecorateSetting(setting *keymapv1.Keymap, config *mappings.MappingConfig) *keymapv1.Keymap
- func Load(reader io.Reader, opt LoadOptions) (*keymapv1.Keymap, error)
- func MustFormatKeyBinding(kb *KeyBinding, p platform.Platform) string
- func NewActioinBinding(action string, keyChords ...string) *keymapv1.Action
- func NewActionBindingWithComment(action, keyChords, comment string) *keymapv1.Action
- func NewActionBindingWithDescription(action, keyChords, description string) *keymapv1.Action
- func Save(writer io.Writer, setting *keymapv1.Keymap, opt SaveOptions) error
- type KeyBinding
- type KeybindingStrings
- type LoadOptions
- type OneKeymapConfig
- type OneKeymapSetting
- type SaveOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildEditorSupportFromMapping ¶ added in v0.3.1
func BuildEditorSupportFromMapping(mapping *mappings.ActionMappingConfig) []*keymapv1.EditorSupport
BuildEditorSupportFromMapping constructs EditorSupport slice from an ActionMappingConfig.
func DecorateSetting ¶
DecorateSetting applies metadata (Description, Name, Category) to each KeyBinding in the provided KeymapSetting using the given MappingConfig. It also fills the KeyChordsReadable field when chords are present.
func MustFormatKeyBinding ¶
func MustFormatKeyBinding(kb *KeyBinding, p platform.Platform) string
func NewActioinBinding ¶
NewActioinBinding creates an ActionBinding with a single Binding. Note: Does not create ActionConfig to keep test expectations simple.
func NewActionBindingWithComment ¶
NewActionBindingWithComment creates an ActionBinding with one Binding and a comment.
func NewActionBindingWithDescription ¶
NewActionBindingWithDescription creates an ActionBinding with one Binding and a description.
Types ¶
type KeyBinding ¶
type KeyBinding struct {
*keymapv1.KeybindingReadable
}
KeyBinding represents a sequence of one or more key chords that must be pressed in order to trigger an action. This allows for multi-key sequences like "shift shift" or "ctrl+k ctrl+s".
func MustParseKeyBinding ¶
func MustParseKeyBinding(keybind string) *KeyBinding
MustParseKeyBinding parses a vscode-like keybind string (e.g., "ctrl+c") into a KeyBinding and panics on error.
func NewKeyBinding ¶
func NewKeyBinding(binding *keymapv1.KeybindingReadable) *KeyBinding
func ParseKeyBinding ¶
func ParseKeyBinding(keybind string, modifierSeparator string) (*KeyBinding, error)
ParseKeyBinding parse from vscode-like keybind into `KeyBinding` struct e.g. ctrl+c separator between key chords can be customized.
type KeybindingStrings ¶
type KeybindingStrings []string
KeybindingStrings is a custom type to handle single or multiple keybindings.
func (KeybindingStrings) MarshalJSON ¶
func (ks KeybindingStrings) MarshalJSON() ([]byte, error)
MarshalJSON allows KeybindingStrings to be marshalled to a single string if it contains only one element.
func (*KeybindingStrings) UnmarshalJSON ¶
func (ks *KeybindingStrings) UnmarshalJSON(data []byte) error
UnmarshalJSON allows KeybindingStrings to be unmarshalled from either a single string or an array of strings.
type LoadOptions ¶ added in v0.5.0
type LoadOptions struct {
MappingConfig *mappings.MappingConfig
}
LoadOptions provides advanced options for loading a OneKeymap config.
type OneKeymapConfig ¶
type OneKeymapConfig struct {
ID string `json:"id,omitempty"`
Keybinding KeybindingStrings `json:"keybinding,omitempty"`
Comment string `json:"comment,omitempty"`
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
}
OneKeymapConfig is a struct that matches the user config file format.
type OneKeymapSetting ¶
type OneKeymapSetting struct {
// Version default to 1.0. When having breaking changes, increment the version.
Version string `json:"version"`
Keymaps []OneKeymapConfig `json:"keymaps"`
}
OneKeymapSetting is the root struct for the user config file.