| 333 | } |
| 334 | |
| 335 | func (l *Log) applyFilter(index int, q string) ([][]byte, error) { |
| 336 | if q == "" { |
| 337 | return nil, nil |
| 338 | } |
| 339 | matches, indices, err := l.lines.Filter(index, q, l.logOptions.ShowTimestamp) |
| 340 | if err != nil { |
| 341 | return nil, err |
| 342 | } |
| 343 | |
| 344 | // No filter! |
| 345 | if matches == nil { |
| 346 | ll := make([][]byte, l.lines.Len()) |
| 347 | l.lines.Render(index, l.logOptions.ShowTimestamp, ll) |
| 348 | return ll, nil |
| 349 | } |
| 350 | // Blank filter |
| 351 | if len(matches) == 0 { |
| 352 | return nil, nil |
| 353 | } |
| 354 | filtered := make([][]byte, 0, len(matches)) |
| 355 | ll := make([][]byte, l.lines.Len()) |
| 356 | l.lines.Lines(index, l.logOptions.ShowTimestamp, ll) |
| 357 | for i, idx := range matches { |
| 358 | filtered = append(filtered, color.Highlight(ll[idx], indices[i], 209)) |
| 359 | } |
| 360 | |
| 361 | return filtered, nil |
| 362 | } |
| 363 | |
| 364 | func (l *Log) fireLogBuffChanged(index int) { |
| 365 | ll := make([][]byte, l.lines.Len()-index) |