mirror of
https://github.com/walles/moar.git
synced 2024-11-27 11:03:58 +03:00
Make line.go compile again
This commit is contained in:
parent
00ad3f4699
commit
71ee7db815
@ -24,11 +24,11 @@ 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.
|
||||
func (line *Line) HighlightedTokens(linePrefix string, search *regexp.Regexp, lineNumberOneBased *int) textstyles.CellsWithTrailer {
|
||||
plain := line.Plain(lineNumberOneBased)
|
||||
func (line *Line) HighlightedTokens(linePrefix string, search *regexp.Regexp, lineNumber *linenumbers.LineNumber) textstyles.CellsWithTrailer {
|
||||
plain := line.Plain(lineNumber)
|
||||
matchRanges := getMatchRanges(&plain, search)
|
||||
|
||||
fromString := textstyles.CellsFromString(linePrefix+line.raw, lineNumberOneBased)
|
||||
fromString := textstyles.CellsFromString(linePrefix+line.raw, lineNumber)
|
||||
returnCells := make([]twin.Cell, 0, len(fromString.Cells))
|
||||
for _, token := range fromString.Cells {
|
||||
style := token.Style
|
||||
|
@ -639,7 +639,7 @@ func (reader *Reader) getLinesUnlocked(firstLine linenumbers.LineNumber, wantedL
|
||||
lastLine := firstLine.NonWrappingAdd(wantedLineCount - 1)
|
||||
|
||||
if lastLine.AsZeroBased() >= len(reader.lines) {
|
||||
lastLine = linenumbers.LineNumberFromLength(len(reader.lines))
|
||||
lastLine = *linenumbers.LineNumberFromLength(len(reader.lines))
|
||||
}
|
||||
|
||||
// Prevent reading past the end of the available lines
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/walles/moar/m/linenumbers"
|
||||
"github.com/walles/moar/twin"
|
||||
)
|
||||
|
||||
@ -47,7 +48,7 @@ func isPlain(s string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func WithoutFormatting(s string, lineNumberOneBased *int) string {
|
||||
func WithoutFormatting(s string, lineNumber *linenumbers.LineNumber) string {
|
||||
if isPlain(s) {
|
||||
return s
|
||||
}
|
||||
@ -60,7 +61,7 @@ func WithoutFormatting(s string, lineNumberOneBased *int) string {
|
||||
// runes.
|
||||
stripped.Grow(len(s) * 2)
|
||||
|
||||
styledStringsFromString(s, lineNumberOneBased, func(str string, style twin.Style) {
|
||||
styledStringsFromString(s, lineNumber, func(str string, style twin.Style) {
|
||||
for _, runeValue := range runesFromStyledString(_StyledString{String: str, Style: style}) {
|
||||
switch runeValue {
|
||||
|
||||
@ -105,13 +106,13 @@ func WithoutFormatting(s string, lineNumberOneBased *int) string {
|
||||
}
|
||||
|
||||
// Turn a (formatted) string into a series of screen cells
|
||||
func CellsFromString(s string, lineNumberOneBased *int) CellsWithTrailer {
|
||||
func CellsFromString(s string, lineNumber *linenumbers.LineNumber) CellsWithTrailer {
|
||||
var cells []twin.Cell
|
||||
|
||||
// Specs: https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit
|
||||
styleUnprintable := twin.StyleDefault.WithBackground(twin.NewColor16(1)).WithForeground(twin.NewColor16(7))
|
||||
|
||||
trailer := styledStringsFromString(s, lineNumberOneBased, func(str string, style twin.Style) {
|
||||
trailer := styledStringsFromString(s, lineNumber, func(str string, style twin.Style) {
|
||||
for _, token := range tokensFromStyledString(_StyledString{String: str, Style: style}) {
|
||||
switch token.Rune {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user