summaryrefslogtreecommitdiffstats
path: root/src/core.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2016-01-13 03:07:42 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2016-01-13 21:27:43 +0900
commit1d2d32c847e39818bedae5f86ca75e6b70b60444 (patch)
treec4920d669241446466448d5bb4d14162cc2085db /src/core.go
parentd635b3fd3ca34143b203eacc4308ed35628ac2f8 (diff)
Accept comma-separated list of sort criteria
Diffstat (limited to 'src/core.go')
-rw-r--r--src/core.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/core.go b/src/core.go
index dcba7ecf..1906c508 100644
--- a/src/core.go
+++ b/src/core.go
@@ -52,7 +52,7 @@ func Run(opts *Options) {
initProcs()
sort := opts.Sort > 0
- rankTiebreak = opts.Tiebreak
+ sortCriteria = opts.Criteria
if opts.Version {
fmt.Println(version)
@@ -103,9 +103,9 @@ func Run(opts *Options) {
runes, colors := ansiProcessor(data)
return &Item{
text: runes,
- index: uint32(index),
+ index: int32(index),
colors: colors,
- rank: Rank{0, 0, uint32(index)}}
+ rank: buildEmptyRank(int32(index))}
})
} else {
chunkList = NewChunkList(func(data []byte, index int) *Item {
@@ -120,9 +120,9 @@ func Run(opts *Options) {
item := Item{
text: joinTokens(trans),
origText: &runes,
- index: uint32(index),
+ index: int32(index),
colors: nil,
- rank: Rank{0, 0, uint32(index)}}
+ rank: buildEmptyRank(int32(index))}
trimmed, colors := ansiProcessorRunes(item.text)
item.text = trimmed
@@ -141,9 +141,19 @@ func Run(opts *Options) {
}
// Matcher
+ forward := true
+ for _, cri := range opts.Criteria[1:] {
+ if cri == byEnd {
+ forward = false
+ break
+ }
+ if cri == byBegin {
+ break
+ }
+ }
patternBuilder := func(runes []rune) *Pattern {
return BuildPattern(
- opts.Fuzzy, opts.Extended, opts.Case, opts.Tiebreak != byEnd,
+ opts.Fuzzy, opts.Extended, opts.Case, forward,
opts.Nth, opts.Delimiter, runes)
}
matcher := NewMatcher(patternBuilder, sort, opts.Tac, eventBox)