config

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = &Config{
	Settings: Settings{
		Debug:          false,
		Reverse:        false,
		Mouse:          true,
		SearchMode:     false,
		SortKeys:       false,
		Title:          "",
		Prompt:         "keys > ",
		PromptLocation: "top",
		Placeholder:    "...",
		PrefixSep:      ";",
		SepWidth:       4,
		Margin:         0,
		Padding:        1,
		BorderStyle:    "hidden",
	},
	Color: Color{
		FilterFg: "#FFA066",
	},
	Keys: Keys{
		Quit:                     "q, ctrl+c",
		Up:                       "k, up",
		Down:                     "j, down",
		UpFocus:                  "ctrl+k",
		DownFocus:                "ctrl+j",
		HalfUp:                   "ctrl+u",
		HalfDown:                 "ctrl+d",
		FullUp:                   "ctrl+b",
		FullDown:                 "ctrl+f",
		GoToFirstLine:            "g",
		GoToLastLine:             "G",
		GoToTop:                  "H",
		GoToMiddle:               "M",
		GoToBottom:               "L",
		Search:                   "/",
		ClearSearch:              "alt+d",
		Normal:                   "esc",
		CursorWordForward:        "alt+right, alt+f",
		CursorWordBackward:       "alt+left, alt+b",
		CursorDeleteWordBackward: "alt+backspace",
		CursorDeleteWordForward:  "alt+delete",
		CursorDeleteAfterCursor:  "alt+k",
		CursorDeleteBeforeCursor: "alt+u",
		CursorLineStart:          "home, ctrl+a",
		CursorLineEnd:            "end, ctrl+e",
		CursorPaste:              "ctrl+v",
	},
}

Functions

func AddEntry added in v0.3.0

func AddEntry(path, binding string, kbIgnorePrefix bool) error

func Parse

func Parse(flagCPath, flagKPath string) (Apps, *Config, error)

Read configuration and keyb file from flags, default path. If config directory and/or files do not exist, create them.

Types

type App

type App struct {
	Name     string    `yaml:"name"`
	Prefix   string    `yaml:"prefix,omitempty"`
	Keybinds []KeyBind `yaml:"keybinds"`
}

func (App) String added in v0.3.0

func (a App) String() string

type Apps

type Apps []*App

func UnmarshalKeyb added in v0.6.0

func UnmarshalKeyb(keybFile, basePath string) (Apps, error)

Read keyb file or create default keyb file not exist

type Color

type Color struct {
	PromptColor   string `yaml:"prompt"`
	CursorFg      string `yaml:"cursor_fg"`
	CursorBg      string `yaml:"cursor_bg"`
	FilterFg      string `yaml:"filter_fg"`
	FilterBg      string `yaml:"filter_bg"`
	CounterFg     string `yaml:"counter_fg"`
	CounterBg     string `yaml:"counter_bg"`
	PlaceholderFg string `yaml:"placeholder_fg"`
	PlaceholderBg string `yaml:"placeholder_bg"`
	BorderColor   string `yaml:"border_color"`
}

type Config

type Config struct {
	Settings `yaml:"settings"`
	Color    `yaml:"color"`
	Keys     `yaml:"keys"`
}

func UnmarshalConfig added in v0.6.0

func UnmarshalConfig(configFile, basePath string) (*Config, error)

Read config file and merge with default config

type KeyBind

type KeyBind struct {
	Name string `yaml:"name"`
	Key  string `yaml:"key"`

	// ignore prefix defaults to false
	// so user can choose to ignore prefix for a specific kb
	IgnorePrefix bool `yaml:"ignore_prefix,omitempty"`
}

type Keys added in v0.2.0

type Keys struct {
	Quit                     string
	Up                       string
	Down                     string
	UpFocus                  string `yaml:"up_focus"`
	DownFocus                string `yaml:"down_focus"`
	HalfUp                   string `yaml:"half_up"`
	HalfDown                 string `yaml:"half_down"`
	FullUp                   string `yaml:"full_up"`
	FullDown                 string `yaml:"full_bottom"`
	GoToFirstLine            string `yaml:"first_line"`
	GoToLastLine             string `yaml:"last_line"`
	GoToTop                  string `yaml:"top"`
	GoToMiddle               string `yaml:"middle"`
	GoToBottom               string `yaml:"bottom"`
	Search                   string
	ClearSearch              string `yaml:"clear_search"`
	Normal                   string
	CursorWordForward        string `yaml:"cursor_word_forward"`
	CursorWordBackward       string `yaml:"cursor_word_backward"`
	CursorDeleteWordBackward string `yaml:"cursor_delete_word_backward"`
	CursorDeleteWordForward  string `yaml:"cursor_delete_word_forward"`
	CursorDeleteAfterCursor  string `yaml:"cursor_delete_after_cursor"`
	CursorDeleteBeforeCursor string `yaml:"cursor_delete_before_cursor"`
	CursorLineStart          string `yaml:"cursor_line_start"`
	CursorLineEnd            string `yaml:"cursor_line_end"`
	CursorPaste              string `yaml:"cursor_paste"`
}

type Settings

type Settings struct {
	KeybPath       string `yaml:"keyb_path"`
	Debug          bool
	Reverse        bool
	Mouse          bool
	SearchMode     bool `yaml:"search_mode"`
	SortKeys       bool `yaml:"sort_keys"`
	Title          string
	Prompt         string
	PromptLocation string `yaml:"prompt_location"`
	Placeholder    string
	PrefixSep      string `yaml:"prefix_sep"`
	SepWidth       int    `yaml:"sep_width"`
	Margin         int
	Padding        int
	BorderStyle    string `yaml:"border"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL