summaryrefslogtreecommitdiffstats
path: root/src/item.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-01-12 03:01:24 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-01-12 03:18:40 +0900
commit7a2bc2cada971c7a390d09b0afda34780ff56fb6 (patch)
treecaa19fa8bf404a854c9e2cdf6eb08194e1733a6f /src/item.go
parent9dbf6b02d24b52ae43e36905bbb1e83087e1dfe9 (diff)
Lint
Diffstat (limited to 'src/item.go')
-rw-r--r--src/item.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/item.go b/src/item.go
index 41aa34bd..4cbd3f98 100644
--- a/src/item.go
+++ b/src/item.go
@@ -1,9 +1,9 @@
package fzf
-import "fmt"
-
+// Offset holds two 32-bit integers denoting the offsets of a matched substring
type Offset [2]int32
+// Item represents each input line
type Item struct {
text *string
origText *string
@@ -13,12 +13,14 @@ type Item struct {
rank Rank
}
+// Rank is used to sort the search result
type Rank struct {
matchlen uint16
strlen uint16
index uint32
}
+// Rank calculates rank of the Item
func (i *Item) Rank(cache bool) Rank {
if cache && (i.rank.matchlen > 0 || i.rank.strlen > 0) {
return i.rank
@@ -45,14 +47,15 @@ func (i *Item) Rank(cache bool) Rank {
return rank
}
-func (i *Item) Print() {
+// AsString returns the original string
+func (i *Item) AsString() string {
if i.origText != nil {
- fmt.Println(*i.origText)
- } else {
- fmt.Println(*i.text)
+ return *i.origText
}
+ return *i.text
}
+// ByOrder is for sorting substring offsets
type ByOrder []Offset
func (a ByOrder) Len() int {
@@ -69,6 +72,7 @@ func (a ByOrder) Less(i, j int) bool {
return (ioff[0] < joff[0]) || (ioff[0] == joff[0]) && (ioff[1] <= joff[1])
}
+// ByRelevance is for sorting Items
type ByRelevance []*Item
func (a ByRelevance) Len() int {