Adds support for image rendering in the terminal #137
|
@ -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()
|
||||
|
|
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
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue