From 7edf01eb99945cc1954d6edc22a2b360b2a1ce54 Mon Sep 17 00:00:00 2001 From: sloum Date: Sat, 15 Feb 2020 10:51:39 -0800 Subject: [PATCH] Adds a color property to the page struct to track the color mode --- page.go | 4 +++- pages.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/page.go b/page.go index 418975d..4ca0842 100644 --- a/page.go +++ b/page.go @@ -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 } diff --git a/pages.go b/pages.go index f3d761d..9fa6606 100644 --- a/pages.go +++ b/pages.go @@ -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) }