Skip to content
Myr

item.go

This file

Path

src/item.go

44 lines · 957 bytes · Go

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than 577024f point at it.

Use rounded cornersJunegunn Choibefore adoption577024f

lines 1–44why, one step back
1package fzf
23import (4 "github.com/junegunn/fzf/src/util"5)67// Item represents each input line. 56 bytes.8type Item struct {9 text util.Chars // 32 = 24 + 1 + 1 + 2 + 410 transformed *[]Token // 811 origText *[]byte // 812 colors *[]ansiOffset // 813}1415// Index returns ordinal index of the Item16func (item *Item) Index() int32 {17 return item.text.Index18}1920var minItem = Item{text: util.Chars{Index: -1}}2122func (item *Item) TrimLength() uint16 {23 return item.text.TrimLength()24}2526// Colors returns ansiOffsets of the Item27func (item *Item) Colors() []ansiOffset {28 if item.colors == nil {29 return []ansiOffset{}30 }31 return *item.colors32}3334// AsString returns the original string35func (item *Item) AsString(stripAnsi bool) string {36 if item.origText != nil {37 if stripAnsi {38 trimmed, _, _ := extractColor(string(*item.origText), nil, nil)39 return trimmed40 }41 return string(*item.origText)42 }43 return item.text.ToString()44}