mirror of
				https://github.com/cheat/cheat.git
				synced 2025-11-04 07:45:28 +01:00 
			
		
		
		
	chore: removes colorization from search
Deprecates `mgutz/ansi` and removes colorization from search as a first step toward improving the functionality.
This commit is contained in:
		@@ -3,13 +3,11 @@ package sheet
 | 
			
		||||
import (
 | 
			
		||||
	"regexp"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"github.com/mgutz/ansi"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Search searches for regexp matches in a cheatsheet's text, and optionally
 | 
			
		||||
// colorizes matching strings.
 | 
			
		||||
func (s *Sheet) Search(reg *regexp.Regexp, colorize bool) []Match {
 | 
			
		||||
func (s *Sheet) Search(reg *regexp.Regexp) []Match {
 | 
			
		||||
 | 
			
		||||
	// record matches
 | 
			
		||||
	matches := []Match{}
 | 
			
		||||
@@ -30,13 +28,6 @@ func (s *Sheet) Search(reg *regexp.Regexp, colorize bool) []Match {
 | 
			
		||||
			Text: strings.TrimSpace(line),
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// colorize the matching text if so configured
 | 
			
		||||
		if colorize {
 | 
			
		||||
			m.Text = reg.ReplaceAllStringFunc(m.Text, func(matched string) string {
 | 
			
		||||
				return ansi.Color(matched, "red+b")
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// record the match
 | 
			
		||||
		matches = append(matches, m)
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user