From 6d235bceee66bd6b7ca2de8311a3deae4793bfa8 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 18 May 2016 02:06:52 +0900 Subject: Add jump and jump-accept actions for --bind jump and jump-accept implement EasyMotion-like movement in fzf. Suggested by @mhrebenyuk. Close #569. --- src/options.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/options.go') diff --git a/src/options.go b/src/options.go index ea7d717c..089b4c2f 100644 --- a/src/options.go +++ b/src/options.go @@ -45,6 +45,7 @@ const usage = `usage: fzf [options] --hscroll-off=COL Number of screen columns to keep to the right of the highlighted substring (default: 10) --inline-info Display finder info inline with the query + --jump-labels=CHARS Label characters for jump and jump-accept --prompt=STR Input prompt (default: '> ') --bind=KEYBINDS Custom key bindings. Refer to the man page. --history=FILE History file @@ -112,6 +113,7 @@ type Options struct { Hscroll bool HscrollOff int InlineInfo bool + JumpLabels string Prompt string Query string Select1 bool @@ -153,6 +155,7 @@ func defaultOptions() *Options { Hscroll: true, HscrollOff: 10, InlineInfo: false, + JumpLabels: defaultJumpLabels, Prompt: "> ", Query: "", Select1: false, @@ -553,6 +556,10 @@ func parseKeymap(keymap map[int]actionType, execmap map[int]string, str string) keymap[key] = actForwardChar case "forward-word": keymap[key] = actForwardWord + case "jump": + keymap[key] = actJump + case "jump-accept": + keymap[key] = actJumpAccept case "kill-line": keymap[key] = actKillLine case "kill-word": @@ -804,6 +811,8 @@ func parseOptions(opts *Options, allArgs []string) { opts.InlineInfo = true case "--no-inline-info": opts.InlineInfo = false + case "--jump-labels": + opts.JumpLabels = nextString(allArgs, &i, "label characters required") case "-1", "--select-1": opts.Select1 = true case "+1", "--no-select-1": @@ -891,6 +900,8 @@ func parseOptions(opts *Options, allArgs []string) { opts.Tabstop = atoi(value) } else if match, value := optString(arg, "--hscroll-off="); match { opts.HscrollOff = atoi(value) + } else if match, value := optString(arg, "--jump-labels="); match { + opts.JumpLabels = value } else { errorExit("unknown option: " + arg) } @@ -908,6 +919,10 @@ func parseOptions(opts *Options, allArgs []string) { if opts.Tabstop < 1 { errorExit("tab stop must be a positive integer") } + + if len(opts.JumpLabels) == 0 { + errorExit("empty jump labels") + } } func postProcessOptions(opts *Options) { -- cgit v1.2.3