|
|
@ -85,29 +85,30 @@ func Run(opts *Options, revision string) {
|
|
|
|
var chunkList *ChunkList
|
|
|
|
var chunkList *ChunkList
|
|
|
|
header := make([]string, 0, opts.HeaderLines)
|
|
|
|
header := make([]string, 0, opts.HeaderLines)
|
|
|
|
if len(opts.WithNth) == 0 {
|
|
|
|
if len(opts.WithNth) == 0 {
|
|
|
|
chunkList = NewChunkList(func(data []byte, index int) Item {
|
|
|
|
chunkList = NewChunkList(func(item *Item, data []byte, index int) bool {
|
|
|
|
if len(header) < opts.HeaderLines {
|
|
|
|
if len(header) < opts.HeaderLines {
|
|
|
|
header = append(header, string(data))
|
|
|
|
header = append(header, string(data))
|
|
|
|
eventBox.Set(EvtHeader, header)
|
|
|
|
eventBox.Set(EvtHeader, header)
|
|
|
|
return nilItem
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
chars, colors := ansiProcessor(data)
|
|
|
|
item.text, item.colors = ansiProcessor(data)
|
|
|
|
chars.Index = int32(index)
|
|
|
|
item.text.Index = int32(index)
|
|
|
|
return Item{text: chars, colors: colors}
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
chunkList = NewChunkList(func(data []byte, index int) Item {
|
|
|
|
chunkList = NewChunkList(func(item *Item, data []byte, index int) bool {
|
|
|
|
tokens := Tokenize(string(data), opts.Delimiter)
|
|
|
|
tokens := Tokenize(string(data), opts.Delimiter)
|
|
|
|
trans := Transform(tokens, opts.WithNth)
|
|
|
|
trans := Transform(tokens, opts.WithNth)
|
|
|
|
transformed := joinTokens(trans)
|
|
|
|
transformed := joinTokens(trans)
|
|
|
|
if len(header) < opts.HeaderLines {
|
|
|
|
if len(header) < opts.HeaderLines {
|
|
|
|
header = append(header, transformed)
|
|
|
|
header = append(header, transformed)
|
|
|
|
eventBox.Set(EvtHeader, header)
|
|
|
|
eventBox.Set(EvtHeader, header)
|
|
|
|
return nilItem
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
trimmed, colors := ansiProcessor([]byte(transformed))
|
|
|
|
item.text, item.colors = ansiProcessor([]byte(transformed))
|
|
|
|
trimmed.Index = int32(index)
|
|
|
|
item.text.Index = int32(index)
|
|
|
|
return Item{text: trimmed, colors: colors, origText: &data}
|
|
|
|
item.origText = &data
|
|
|
|
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -151,8 +152,8 @@ func Run(opts *Options, revision string) {
|
|
|
|
slab := util.MakeSlab(slab16Size, slab32Size)
|
|
|
|
slab := util.MakeSlab(slab16Size, slab32Size)
|
|
|
|
reader := Reader{
|
|
|
|
reader := Reader{
|
|
|
|
func(runes []byte) bool {
|
|
|
|
func(runes []byte) bool {
|
|
|
|
item := chunkList.trans(runes, 0)
|
|
|
|
item := Item{}
|
|
|
|
if !item.Nil() {
|
|
|
|
if chunkList.trans(&item, runes, 0) {
|
|
|
|
if result, _, _ := pattern.MatchItem(&item, false, slab); result != nil {
|
|
|
|
if result, _, _ := pattern.MatchItem(&item, false, slab); result != nil {
|
|
|
|
opts.Printer(item.text.ToString())
|
|
|
|
opts.Printer(item.text.ToString())
|
|
|
|
found = true
|
|
|
|
found = true
|
|
|
|