diff --git a/client.go b/client.go index 1809d15..855f79d 100644 --- a/client.go +++ b/client.go @@ -1024,6 +1024,10 @@ func (c *client) handleLocal(u Url) { return } 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")) c.PageState.Add(pg) c.SetPercentRead() diff --git a/pages.go b/pages.go index 46d962b..241ea74 100644 --- a/pages.go +++ b/pages.go @@ -66,7 +66,17 @@ func (p *Pages) Render(termHeight, termWidth int, color bool) []string { } pos := p.History[p.Position].ScrollPosition 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) + now := len(p.History[p.Position].WrappedContent) if prev > now { diff := prev - now