Adds a color property to the page struct to track the color mode

This commit is contained in:
sloum 2020-02-15 10:51:39 -08:00
parent 4f9c8877b5
commit 7edf01eb99
2 changed files with 4 additions and 2 deletions

View File

@ -25,6 +25,7 @@ type Page struct {
SearchIndex int
FileType string
WrapWidth int
Color bool
}
//------------------------------------------------\\
@ -134,6 +135,7 @@ func (p *Page) WrapContent(width int, color bool) {
p.WrappedContent = strings.Split(content.String(), "\n")
p.WrapWidth = width
p.Color = color
p.HighlightFoundText()
}
@ -183,6 +185,6 @@ func (p *Page) FindText() {
// MakePage returns a Page struct with default values
func MakePage(url Url, content string, links []string) Page {
p := Page{make([]string, 0), content, links, url, 0, make([]int, 0), "", 0, "", 40}
p := Page{make([]string, 0), content, links, url, 0, make([]int, 0), "", 0, "", 40, false}
return p
}

View File

@ -67,7 +67,7 @@ func (p *Pages) Render(termHeight, termWidth int, color bool) []string {
pos := p.History[p.Position].ScrollPosition
prev := len(p.History[p.Position].WrappedContent)
if termWidth != p.History[p.Position].WrapWidth {
if termWidth != p.History[p.Position].WrapWidth || p.History[p.Position].Color != color {
p.History[p.Position].WrapContent(termWidth, color)
}