|
|
|
@ -73,7 +73,7 @@ func (c *client) Draw() {
|
|
|
|
|
screen.WriteString("\033[0m") |
|
|
|
|
screen.WriteString(c.TopBar.Render(c.Width, c.Options["theme"])) |
|
|
|
|
screen.WriteString("\n") |
|
|
|
|
pageContent := c.PageState.Render(c.Height, c.Width-1, (c.Options["theme"] == "color")) |
|
|
|
|
pageContent := c.PageState.Render(c.Height, c.Width-1, getMaxWidth(c.Options), (c.Options["theme"] == "color")) |
|
|
|
|
var re *regexp.Regexp |
|
|
|
|
if c.Options["theme"] == "inverse" { |
|
|
|
|
screen.WriteString("\033[7m") |
|
|
|
@ -264,7 +264,7 @@ func (c *client) TakeControlInput() {
|
|
|
|
|
} |
|
|
|
|
err = c.NextSearchItem(0) |
|
|
|
|
if err != nil { |
|
|
|
|
c.PageState.History[c.PageState.Position].WrapContent(c.Width-1,(c.Options["theme"] == "color")) |
|
|
|
|
c.PageState.History[c.PageState.Position].WrapContent(c.Width-1,getMaxWidth(c.Options),(c.Options["theme"] == "color")) |
|
|
|
|
c.Draw() |
|
|
|
|
} |
|
|
|
|
case ':', ' ': |
|
|
|
@ -994,7 +994,7 @@ func (c *client) handleGopher(u Url) {
|
|
|
|
|
} else { |
|
|
|
|
pg.FileType = "text" |
|
|
|
|
} |
|
|
|
|
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color")) |
|
|
|
|
pg.WrapContent(c.Width-1, getMaxWidth(c.Options), (c.Options["theme"] == "color")) |
|
|
|
|
c.PageState.Add(pg) |
|
|
|
|
c.SetPercentRead() |
|
|
|
|
c.ClearMessage() |
|
|
|
@ -1021,7 +1021,7 @@ func (c *client) handleGemini(u Url) {
|
|
|
|
|
u.Mime = capsule.MimeMin |
|
|
|
|
pg := MakePage(u, capsule.Content, capsule.Links) |
|
|
|
|
pg.FileType = capsule.MimeMaj |
|
|
|
|
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color")) |
|
|
|
|
pg.WrapContent(c.Width-1, getMaxWidth(c.Options), (c.Options["theme"] == "color")) |
|
|
|
|
c.PageState.Add(pg) |
|
|
|
|
c.SetPercentRead() |
|
|
|
|
c.ClearMessage() |
|
|
|
@ -1087,7 +1087,7 @@ func (c *client) handleLocal(u Url) {
|
|
|
|
|
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, getMaxWidth(c.Options), (c.Options["theme"] == "color")) |
|
|
|
|
c.PageState.Add(pg) |
|
|
|
|
c.SetPercentRead() |
|
|
|
|
c.ClearMessage() |
|
|
|
@ -1103,7 +1103,7 @@ func (c *client) handleFinger(u Url) {
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
pg := MakePage(u, content, []string{}) |
|
|
|
|
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color")) |
|
|
|
|
pg.WrapContent(c.Width-1, getMaxWidth(c.Options), (c.Options["theme"] == "color")) |
|
|
|
|
c.PageState.Add(pg) |
|
|
|
|
c.SetPercentRead() |
|
|
|
|
c.ClearMessage() |
|
|
|
@ -1123,7 +1123,7 @@ func (c *client) handleWeb(u Url) {
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
pg := MakePage(u, page.Content, page.Links) |
|
|
|
|
pg.WrapContent(c.Width-1, (c.Options["theme"] == "color")) |
|
|
|
|
pg.WrapContent(c.Width-1, getMaxWidth(c.Options), (c.Options["theme"] == "color")) |
|
|
|
|
c.PageState.Add(pg) |
|
|
|
|
c.SetPercentRead() |
|
|
|
|
c.ClearMessage() |
|
|
|
@ -1264,3 +1264,16 @@ func updateTimeouts(timeoutString string) error {
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// getMaxWidth looks through the given options map and will safely return a max width to render
|
|
|
|
|
// if the option is missing or malformed, it will default to 100. A sane minimum of 10 is enforced.
|
|
|
|
|
func getMaxWidth(options map[string]string) int { |
|
|
|
|
out, err := strconv.Atoi(options["maxwidth"]) |
|
|
|
|
if err != nil { |
|
|
|
|
out = 100 |
|
|
|
|
} |
|
|
|
|
if out < 10 { |
|
|
|
|
out = 10 |
|
|
|
|
} |
|
|
|
|
return out |
|
|
|
|
} |