mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-10 15:50:56 +00:00
parent
d54a4fa223
commit
fe4e452d68
@ -37,6 +37,7 @@ const usage = `usage: fzf [options]
|
|||||||
--color=COLSPEC Base scheme (dark|light|16|bw) and/or custom colors
|
--color=COLSPEC Base scheme (dark|light|16|bw) and/or custom colors
|
||||||
--black Use black background
|
--black Use black background
|
||||||
--reverse Reverse orientation
|
--reverse Reverse orientation
|
||||||
|
--cycle Enable cyclic scroll
|
||||||
--no-hscroll Disable horizontal scroll
|
--no-hscroll Disable horizontal scroll
|
||||||
--inline-info Display finder info inline with the query
|
--inline-info Display finder info inline with the query
|
||||||
--prompt=STR Input prompt (default: '> ')
|
--prompt=STR Input prompt (default: '> ')
|
||||||
@ -107,6 +108,7 @@ type Options struct {
|
|||||||
Theme *curses.ColorTheme
|
Theme *curses.ColorTheme
|
||||||
Black bool
|
Black bool
|
||||||
Reverse bool
|
Reverse bool
|
||||||
|
Cycle bool
|
||||||
Hscroll bool
|
Hscroll bool
|
||||||
InlineInfo bool
|
InlineInfo bool
|
||||||
Prompt string
|
Prompt string
|
||||||
@ -148,6 +150,7 @@ func defaultOptions() *Options {
|
|||||||
Theme: defaultTheme(),
|
Theme: defaultTheme(),
|
||||||
Black: false,
|
Black: false,
|
||||||
Reverse: false,
|
Reverse: false,
|
||||||
|
Cycle: false,
|
||||||
Hscroll: true,
|
Hscroll: true,
|
||||||
InlineInfo: false,
|
InlineInfo: false,
|
||||||
Prompt: "> ",
|
Prompt: "> ",
|
||||||
@ -637,6 +640,10 @@ func parseOptions(opts *Options, allArgs []string) {
|
|||||||
opts.Reverse = true
|
opts.Reverse = true
|
||||||
case "--no-reverse":
|
case "--no-reverse":
|
||||||
opts.Reverse = false
|
opts.Reverse = false
|
||||||
|
case "--cycle":
|
||||||
|
opts.Cycle = true
|
||||||
|
case "--no-cycle":
|
||||||
|
opts.Cycle = false
|
||||||
case "--hscroll":
|
case "--hscroll":
|
||||||
opts.Hscroll = true
|
opts.Hscroll = true
|
||||||
case "--no-hscroll":
|
case "--no-hscroll":
|
||||||
|
@ -39,6 +39,7 @@ type Terminal struct {
|
|||||||
pressed int
|
pressed int
|
||||||
printQuery bool
|
printQuery bool
|
||||||
history *History
|
history *History
|
||||||
|
cycle bool
|
||||||
count int
|
count int
|
||||||
progress int
|
progress int
|
||||||
reading bool
|
reading bool
|
||||||
@ -195,6 +196,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|||||||
pressed: 0,
|
pressed: 0,
|
||||||
printQuery: opts.PrintQuery,
|
printQuery: opts.PrintQuery,
|
||||||
history: opts.History,
|
history: opts.History,
|
||||||
|
cycle: opts.Cycle,
|
||||||
merger: EmptyMerger,
|
merger: EmptyMerger,
|
||||||
selected: make(map[uint32]selectedItem),
|
selected: make(map[uint32]selectedItem),
|
||||||
reqBox: util.NewEventBox(),
|
reqBox: util.NewEventBox(),
|
||||||
@ -945,10 +947,22 @@ func (t *Terminal) constrain() {
|
|||||||
|
|
||||||
func (t *Terminal) vmove(o int) {
|
func (t *Terminal) vmove(o int) {
|
||||||
if t.reverse {
|
if t.reverse {
|
||||||
t.vset(t.cy - o)
|
o *= -1
|
||||||
} else {
|
|
||||||
t.vset(t.cy + o)
|
|
||||||
}
|
}
|
||||||
|
dest := t.cy + o
|
||||||
|
if t.cycle {
|
||||||
|
max := t.merger.Length() - 1
|
||||||
|
if dest > max {
|
||||||
|
if t.cy == max {
|
||||||
|
dest = 0
|
||||||
|
}
|
||||||
|
} else if dest < 0 {
|
||||||
|
if t.cy == 0 {
|
||||||
|
dest = max
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t.vset(dest)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Terminal) vset(o int) bool {
|
func (t *Terminal) vset(o int) bool {
|
||||||
|
@ -615,6 +615,25 @@ class TestGoFZF < TestBase
|
|||||||
File.unlink output rescue nil
|
File.unlink output rescue nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_cycle
|
||||||
|
tmux.send_keys "seq 8 | #{fzf :cycle}", :Enter
|
||||||
|
tmux.until { |lines| lines[-2].include? '8/8' }
|
||||||
|
tmux.send_keys :Down
|
||||||
|
tmux.until { |lines| lines[-10].start_with? '>' }
|
||||||
|
tmux.send_keys :Down
|
||||||
|
tmux.until { |lines| lines[-9].start_with? '>' }
|
||||||
|
tmux.send_keys :PgUp
|
||||||
|
tmux.until { |lines| lines[-10].start_with? '>' }
|
||||||
|
tmux.send_keys :PgUp
|
||||||
|
tmux.until { |lines| lines[-3].start_with? '>' }
|
||||||
|
tmux.send_keys :Up
|
||||||
|
tmux.until { |lines| lines[-4].start_with? '>' }
|
||||||
|
tmux.send_keys :PgDn
|
||||||
|
tmux.until { |lines| lines[-3].start_with? '>' }
|
||||||
|
tmux.send_keys :PgDn
|
||||||
|
tmux.until { |lines| lines[-10].start_with? '>' }
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def writelines path, lines
|
def writelines path, lines
|
||||||
File.unlink path while File.exists? path
|
File.unlink path while File.exists? path
|
||||||
|
Loading…
Reference in New Issue
Block a user