mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-06-03 07:50:49 +00:00
parent
401a5fd5ff
commit
37f43fbb35
|
@ -7,6 +7,8 @@ CHANGELOG
|
||||||
- Added `--algo=[v1|v2]` option so one can still choose the old algorithm
|
- Added `--algo=[v1|v2]` option so one can still choose the old algorithm
|
||||||
which values the search performance over the quality of the result
|
which values the search performance over the quality of the result
|
||||||
- Advanced scoring criteria
|
- Advanced scoring criteria
|
||||||
|
- `--read0` to read input delimited by ASCII NUL character
|
||||||
|
- `--print0` to print output delimited by ASCII NUL character
|
||||||
|
|
||||||
0.13.5
|
0.13.5
|
||||||
------
|
------
|
||||||
|
|
|
@ -285,6 +285,12 @@ with the default enter key.
|
||||||
e.g. \fBfzf --expect=ctrl-v,ctrl-t,alt-s,f1,f2,~,@\fR
|
e.g. \fBfzf --expect=ctrl-v,ctrl-t,alt-s,f1,f2,~,@\fR
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
|
.B "--read0"
|
||||||
|
Read input delimited by ASCII NUL character instead of newline character
|
||||||
|
.TP
|
||||||
|
.B "--print0"
|
||||||
|
Print output delimited by ASCII NUL character instead of newline character
|
||||||
|
.TP
|
||||||
.B "--sync"
|
.B "--sync"
|
||||||
Synchronous search for multi-staged filtering. If specified, fzf will launch
|
Synchronous search for multi-staged filtering. If specified, fzf will launch
|
||||||
ncurses finder only after the input stream is complete.
|
ncurses finder only after the input stream is complete.
|
||||||
|
|
12
src/core.go
12
src/core.go
|
@ -151,7 +151,7 @@ func Run(opts *Options) {
|
||||||
// Filtering mode
|
// Filtering mode
|
||||||
if opts.Filter != nil {
|
if opts.Filter != nil {
|
||||||
if opts.PrintQuery {
|
if opts.PrintQuery {
|
||||||
fmt.Println(*opts.Filter)
|
opts.Printer(*opts.Filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
pattern := patternBuilder([]rune(*opts.Filter))
|
pattern := patternBuilder([]rune(*opts.Filter))
|
||||||
|
@ -164,7 +164,7 @@ func Run(opts *Options) {
|
||||||
item := chunkList.trans(runes, 0)
|
item := chunkList.trans(runes, 0)
|
||||||
if item != nil {
|
if item != nil {
|
||||||
if result, _, _ := pattern.MatchItem(item, false, slab); result != nil {
|
if result, _, _ := pattern.MatchItem(item, false, slab); result != nil {
|
||||||
fmt.Println(item.text.ToString())
|
opts.Printer(item.text.ToString())
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ func Run(opts *Options) {
|
||||||
chunks: snapshot,
|
chunks: snapshot,
|
||||||
pattern: pattern})
|
pattern: pattern})
|
||||||
for i := 0; i < merger.Length(); i++ {
|
for i := 0; i < merger.Length(); i++ {
|
||||||
fmt.Println(merger.Get(i).item.AsString(opts.Ansi))
|
opts.Printer(merger.Get(i).item.AsString(opts.Ansi))
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,13 +254,13 @@ func Run(opts *Options) {
|
||||||
} else if val.final {
|
} else if val.final {
|
||||||
if opts.Exit0 && count == 0 || opts.Select1 && count == 1 {
|
if opts.Exit0 && count == 0 || opts.Select1 && count == 1 {
|
||||||
if opts.PrintQuery {
|
if opts.PrintQuery {
|
||||||
fmt.Println(opts.Query)
|
opts.Printer(opts.Query)
|
||||||
}
|
}
|
||||||
if len(opts.Expect) > 0 {
|
if len(opts.Expect) > 0 {
|
||||||
fmt.Println()
|
opts.Printer("")
|
||||||
}
|
}
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
fmt.Println(val.Get(i).item.AsString(opts.Ansi))
|
opts.Printer(val.Get(i).item.AsString(opts.Ansi))
|
||||||
}
|
}
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
os.Exit(exitOk)
|
os.Exit(exitOk)
|
||||||
|
|
|
@ -162,6 +162,7 @@ type Options struct {
|
||||||
Preview previewOpts
|
Preview previewOpts
|
||||||
PrintQuery bool
|
PrintQuery bool
|
||||||
ReadZero bool
|
ReadZero bool
|
||||||
|
Printer func(string)
|
||||||
Sync bool
|
Sync bool
|
||||||
History *History
|
History *History
|
||||||
Header []string
|
Header []string
|
||||||
|
@ -206,6 +207,7 @@ func defaultOptions() *Options {
|
||||||
Preview: previewOpts{"", posRight, sizeSpec{50, true}, false},
|
Preview: previewOpts{"", posRight, sizeSpec{50, true}, false},
|
||||||
PrintQuery: false,
|
PrintQuery: false,
|
||||||
ReadZero: false,
|
ReadZero: false,
|
||||||
|
Printer: func(str string) { fmt.Println(str) },
|
||||||
Sync: false,
|
Sync: false,
|
||||||
History: nil,
|
History: nil,
|
||||||
Header: make([]string, 0),
|
Header: make([]string, 0),
|
||||||
|
@ -935,6 +937,10 @@ func parseOptions(opts *Options, allArgs []string) {
|
||||||
opts.ReadZero = true
|
opts.ReadZero = true
|
||||||
case "--no-read0":
|
case "--no-read0":
|
||||||
opts.ReadZero = false
|
opts.ReadZero = false
|
||||||
|
case "--print0":
|
||||||
|
opts.Printer = func(str string) { fmt.Print(str, "\x00") }
|
||||||
|
case "--no-print0":
|
||||||
|
opts.Printer = func(str string) { fmt.Println(str) }
|
||||||
case "--print-query":
|
case "--print-query":
|
||||||
opts.PrintQuery = true
|
opts.PrintQuery = true
|
||||||
case "--no-print-query":
|
case "--no-print-query":
|
||||||
|
|
|
@ -63,6 +63,7 @@ type Terminal struct {
|
||||||
reading bool
|
reading bool
|
||||||
jumping jumpMode
|
jumping jumpMode
|
||||||
jumpLabels string
|
jumpLabels string
|
||||||
|
printer func(string)
|
||||||
merger *Merger
|
merger *Merger
|
||||||
selected map[int32]selectedItem
|
selected map[int32]selectedItem
|
||||||
reqBox *util.EventBox
|
reqBox *util.EventBox
|
||||||
|
@ -269,6 +270,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
||||||
reading: true,
|
reading: true,
|
||||||
jumping: jumpDisabled,
|
jumping: jumpDisabled,
|
||||||
jumpLabels: opts.JumpLabels,
|
jumpLabels: opts.JumpLabels,
|
||||||
|
printer: opts.Printer,
|
||||||
merger: EmptyMerger,
|
merger: EmptyMerger,
|
||||||
selected: make(map[int32]selectedItem),
|
selected: make(map[int32]selectedItem),
|
||||||
reqBox: util.NewEventBox(),
|
reqBox: util.NewEventBox(),
|
||||||
|
@ -347,21 +349,21 @@ func (t *Terminal) UpdateList(merger *Merger) {
|
||||||
|
|
||||||
func (t *Terminal) output() bool {
|
func (t *Terminal) output() bool {
|
||||||
if t.printQuery {
|
if t.printQuery {
|
||||||
fmt.Println(string(t.input))
|
t.printer(string(t.input))
|
||||||
}
|
}
|
||||||
if len(t.expect) > 0 {
|
if len(t.expect) > 0 {
|
||||||
fmt.Println(t.pressed)
|
t.printer(t.pressed)
|
||||||
}
|
}
|
||||||
found := len(t.selected) > 0
|
found := len(t.selected) > 0
|
||||||
if !found {
|
if !found {
|
||||||
cnt := t.merger.Length()
|
cnt := t.merger.Length()
|
||||||
if cnt > 0 && cnt > t.cy {
|
if cnt > 0 && cnt > t.cy {
|
||||||
fmt.Println(t.current())
|
t.printer(t.current())
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for _, sel := range t.sortSelected() {
|
for _, sel := range t.sortSelected() {
|
||||||
fmt.Println(sel.text)
|
t.printer(sel.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return found
|
return found
|
||||||
|
@ -1028,7 +1030,7 @@ func (t *Terminal) Loop() {
|
||||||
t.printPreview()
|
t.printPreview()
|
||||||
case reqPrintQuery:
|
case reqPrintQuery:
|
||||||
C.Close()
|
C.Close()
|
||||||
fmt.Println(string(t.input))
|
t.printer(string(t.input))
|
||||||
exit(exitOk)
|
exit(exitOk)
|
||||||
case reqQuit:
|
case reqQuit:
|
||||||
C.Close()
|
C.Close()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user