forked from sloum/bombadillo
Adds a color property to the page struct to track the color mode
This commit is contained in:
parent
4f9c8877b5
commit
7edf01eb99
4
page.go
4
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
|
||||
}
|
||||
|
|
2
pages.go
2
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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue