diff --git a/m/line.go b/m/line.go index 842b852f..d7ecb64d 100644 --- a/m/line.go +++ b/m/line.go @@ -23,8 +23,6 @@ func NewLine(raw string) Line { // Returns a representation of the string split into styled tokens. Any regexp // matches are highlighted. A nil regexp means no highlighting. -// -//revive:disable-next-line:unexported-return func (line *Line) HighlightedTokens(linePrefix string, search *regexp.Regexp, lineNumberOneBased *int) textstyles.CellsWithTrailer { plain := line.Plain(lineNumberOneBased) matchRanges := getMatchRanges(&plain, search) diff --git a/moar.go b/moar.go index e40ad8f6..61736bb8 100644 --- a/moar.go +++ b/moar.go @@ -225,10 +225,10 @@ func parseStatusBarStyle(styleOption string) (m.StatusBarOption, error) { func parseUnprintableStyle(styleOption string) (textstyles.UnprintableStyleT, error) { if styleOption == "highlight" { - return textstyles.UNPRINTABLE_STYLE_HIGHLIGHT, nil + return textstyles.UnprintableStyleHighlight, nil } if styleOption == "whitespace" { - return textstyles.UNPRINTABLE_STYLE_WHITESPACE, nil + return textstyles.UnprintableStyleWhitespace, nil } return 0, fmt.Errorf("Good ones are highlight or whitespace") @@ -417,7 +417,7 @@ func main() { noClearOnExit := flagSet.Bool("no-clear-on-exit", false, "Retain screen contents when exiting moar") statusBarStyle := flagSetFunc(flagSet, "statusbar", m.STATUSBAR_STYLE_INVERSE, "Status bar style: inverse, plain or bold", parseStatusBarStyle) - unprintableStyle := flagSetFunc(flagSet, "render-unprintable", textstyles.UNPRINTABLE_STYLE_HIGHLIGHT, + unprintableStyle := flagSetFunc(flagSet, "render-unprintable", textstyles.UnprintableStyleHighlight, "How unprintable characters are rendered: highlight or whitespace", parseUnprintableStyle) scrollLeftHint := flagSetFunc(flagSet, "scroll-left-hint", twin.NewCell('<', twin.StyleDefault.WithAttr(twin.AttrReverse)), diff --git a/textstyles/ansiTokenizer.go b/textstyles/ansiTokenizer.go index 1b6ca644..300b8afe 100644 --- a/textstyles/ansiTokenizer.go +++ b/textstyles/ansiTokenizer.go @@ -1,3 +1,6 @@ +// This package handles styled strings. It can strip styling from strings and it +// can turn a styled string into a series of screen cells. Some global variables +// can be used to configure how various things are rendered. package textstyles import ( @@ -12,10 +15,8 @@ import ( type UnprintableStyleT int const ( - //revive:disable-next-line:var-naming - UNPRINTABLE_STYLE_HIGHLIGHT UnprintableStyleT = iota - //revive:disable-next-line:var-naming - UNPRINTABLE_STYLE_WHITESPACE + UnprintableStyleHighlight UnprintableStyleT = iota + UnprintableStyleWhitespace ) var UnprintableStyle UnprintableStyleT @@ -75,9 +76,9 @@ func WithoutFormatting(s string, lineNumberOneBased *int) string { } case '�': // Go's broken-UTF8 marker - if UnprintableStyle == UNPRINTABLE_STYLE_HIGHLIGHT { + if UnprintableStyle == UnprintableStyleHighlight { stripped.WriteRune('?') - } else if UnprintableStyle == UNPRINTABLE_STYLE_WHITESPACE { + } else if UnprintableStyle == UnprintableStyleWhitespace { stripped.WriteRune(' ') } else { panic(fmt.Errorf("Unsupported unprintable-style: %#v", UnprintableStyle)) @@ -128,12 +129,12 @@ func CellsFromString(s string, lineNumberOneBased *int) CellsWithTrailer { } case '�': // Go's broken-UTF8 marker - if UnprintableStyle == UNPRINTABLE_STYLE_HIGHLIGHT { + if UnprintableStyle == UnprintableStyleHighlight { cells = append(cells, twin.Cell{ Rune: '?', Style: styleUnprintable, }) - } else if UnprintableStyle == UNPRINTABLE_STYLE_WHITESPACE { + } else if UnprintableStyle == UnprintableStyleWhitespace { cells = append(cells, twin.Cell{ Rune: '?', Style: twin.StyleDefault, @@ -150,12 +151,12 @@ func CellsFromString(s string, lineNumberOneBased *int) CellsWithTrailer { default: if !twin.Printable(token.Rune) { - if UnprintableStyle == UNPRINTABLE_STYLE_HIGHLIGHT { + if UnprintableStyle == UnprintableStyleHighlight { cells = append(cells, twin.Cell{ Rune: '?', Style: styleUnprintable, }) - } else if UnprintableStyle == UNPRINTABLE_STYLE_WHITESPACE { + } else if UnprintableStyle == UnprintableStyleWhitespace { cells = append(cells, twin.Cell{ Rune: ' ', Style: twin.StyleDefault,