You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fzf/src/item.go

49 lines
969 B
Go

10 years ago
package fzf
import (
"github.com/junegunn/fzf/src/util"
)
10 years ago
// Item represents each input line
10 years ago
type Item struct {
index int32
trimLength int32
text util.Chars
origText *[]byte
colors *[]ansiOffset
transformed []Token
}
8 years ago
// Index returns ordinal index of the Item
func (item *Item) Index() int32 {
return item.index
}
func (item *Item) TrimLength() int32 {
if item.trimLength >= 0 {
return item.trimLength
}
item.trimLength = int32(item.text.TrimLength())
return item.trimLength
}
// Colors returns ansiOffsets of the Item
func (item *Item) Colors() []ansiOffset {
if item.colors == nil {
return []ansiOffset{}
}
return *item.colors
10 years ago
}
10 years ago
// AsString returns the original string
func (item *Item) AsString(stripAnsi bool) string {
9 years ago
if item.origText != nil {
if stripAnsi {
trimmed, _, _ := extractColor(string(*item.origText), nil, nil)
return trimmed
}
return string(*item.origText)
}
return item.text.ToString()
10 years ago
}