Skip to content

Commit

Permalink
use color pointer and remove quality conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
gwirn committed Jan 4, 2024
1 parent 280a636 commit d531c84
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ Compare the search results an print them in colors depending on what was found
* qualityCutOff: percentage of word needs to be found to count as a match
:return
*/
func showSearch(pattern, searchString string, inAlgn1, inAlgn2 []rune, color string, qualityCutOff float32) string {
func showSearch(pattern, searchString string, inAlgn1, inAlgn2 []rune, color *string, qualityCutOff float32) string {
cMap := getColorMap()
_, ok := cMap[color]
_, ok := cMap[*color]
if !ok {
log.Fatal("Invalif color choice:", color)
}
Expand Down Expand Up @@ -225,7 +225,7 @@ func showSearch(pattern, searchString string, inAlgn1, inAlgn2 []rune, color str
sb.WriteString(searchString[:i[0]])
}
sb.WriteString(cMap["bold"])
sb.WriteString(cMap[color])
sb.WriteString(cMap[*color])
sb.WriteString(searchString[i[0]:i[1]])
sb.WriteString(cMap["reset"])
// if there is a string between the current and the next match
Expand Down Expand Up @@ -290,7 +290,7 @@ func argparse() {
reverseRune(ag1)
reverseRune(ag2)

searchStringRes := showSearch(searchPattern, line, ag1, ag2, *colorPtr, float32(quality))
searchStringRes := showSearch(searchPattern, line, ag1, ag2, colorPtr, quality)
if len(searchStringRes) > 0 {
fmt.Printf("%d: %s\n", lineCount, searchStringRes)
}
Expand Down Expand Up @@ -320,7 +320,7 @@ func argparse() {
ag1, ag2 := backtrace(fm, []rune(searchPattern), []rune(line), []rune{}, []rune{}, mI, mJ, *gapPenaltyPtr, *mmPenaltyPtr, *matchBonusPtr)
reverseRune(ag1)
reverseRune(ag2)
searchStringRes := showSearch(searchPattern, line, ag1, ag2, *colorPtr, float32(quality))
searchStringRes := showSearch(searchPattern, line, ag1, ag2, colorPtr, quality)
if len(searchStringRes) > 0 {
fmt.Printf("%d: %s\n", lineCount, searchStringRes)
}
Expand Down

0 comments on commit d531c84

Please sign in to comment.