diff --git a/page.go b/page.go index ba9258b..418975d 100644 --- a/page.go +++ b/page.go @@ -24,6 +24,7 @@ type Page struct { SearchTerm string SearchIndex int FileType string + WrapWidth int } //------------------------------------------------\\ @@ -56,6 +57,7 @@ func (p *Page) RenderImage(width int) { w = 300 } p.WrappedContent = tdiv.Render([]byte(p.RawContent), w) + p.WrapWidth = width } // WrapContent performs a hard wrap to the requested @@ -131,6 +133,7 @@ func (p *Page) WrapContent(width int, color bool) { } p.WrappedContent = strings.Split(content.String(), "\n") + p.WrapWidth = width p.HighlightFoundText() } @@ -180,6 +183,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, ""} + p := Page{make([]string, 0), content, links, url, 0, make([]int, 0), "", 0, "", 40} return p } diff --git a/pages.go b/pages.go index 241ea74..01cd1e0 100644 --- a/pages.go +++ b/pages.go @@ -75,7 +75,9 @@ func (p *Pages) Render(termHeight, termWidth int, color bool) []string { // passed in here. If it is different then go through // all of that. Otherwise, just send the already wrapped // data. - p.History[p.Position].WrapContent(termWidth, color) + if termWidth != p.History[p.Position].WrapWidth { + p.History[p.Position].WrapContent(termWidth, color) + } now := len(p.History[p.Position].WrappedContent) if prev > now {