forked from sloum/bombadillo
Leaves a note re: improving render speeds
This commit is contained in:
parent
c9765bf0fa
commit
996e209c50
|
@ -1024,6 +1024,10 @@ func (c *client) handleLocal(u Url) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pg := MakePage(u, content, links)
|
pg := MakePage(u, content, links)
|
||||||
|
ext := strings.ToLower(filepath.Ext(u.Full))
|
||||||
|
if ext == ".jpg" || ext == ".jpeg" || ext == ".gif" || ext == ".png" {
|
||||||
|
pg.FileType = "image"
|
||||||
|
}
|
||||||
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color"))
|
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color"))
|
||||||
c.PageState.Add(pg)
|
c.PageState.Add(pg)
|
||||||
c.SetPercentRead()
|
c.SetPercentRead()
|
||||||
|
|
10
pages.go
10
pages.go
|
@ -66,7 +66,17 @@ func (p *Pages) Render(termHeight, termWidth int, color bool) []string {
|
||||||
}
|
}
|
||||||
pos := p.History[p.Position].ScrollPosition
|
pos := p.History[p.Position].ScrollPosition
|
||||||
prev := len(p.History[p.Position].WrappedContent)
|
prev := len(p.History[p.Position].WrappedContent)
|
||||||
|
|
||||||
|
// TODO figure out a way to only do this when needed
|
||||||
|
// it is horribly slow to do this every render.
|
||||||
|
//
|
||||||
|
// Current thought is add a "WrapWidth" to each page
|
||||||
|
// and compare the WrapWidth against the width being
|
||||||
|
// 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)
|
p.History[p.Position].WrapContent(termWidth, color)
|
||||||
|
|
||||||
now := len(p.History[p.Position].WrappedContent)
|
now := len(p.History[p.Position].WrappedContent)
|
||||||
if prev > now {
|
if prev > now {
|
||||||
diff := prev - now
|
diff := prev - now
|
||||||
|
|
Loading…
Reference in New Issue