From 0e5d54cf18ba883ddc9ebcfc4c3b058311e4319c Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Tue, 29 Nov 2022 03:33:53 -0500 Subject: [PATCH] Various tweaks making use of new formatting --- bookmarks/bookmarks.go | 2 +- dom/document.go | 15 +++++++-------- fetch.go | 12 ++++++------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/bookmarks/bookmarks.go b/bookmarks/bookmarks.go index 46248d7..02b6183 100644 --- a/bookmarks/bookmarks.go +++ b/bookmarks/bookmarks.go @@ -19,7 +19,7 @@ type Bookmark struct { var bookmarks []Bookmark func Gemtext () (page string) { - page += "# Bookmarks\n" + page += "# Bookmarks\n\n" for _, bookmark := range bookmarks { page += "=> " + bookmark.Location.String() + diff --git a/dom/document.go b/dom/document.go index dbd212d..c7115ff 100644 --- a/dom/document.go +++ b/dom/document.go @@ -147,14 +147,14 @@ func (element *ElementHeading) Render ( if element.level == HeadingLevel1 { height ++ - y ++ for x = element.parent.metrics.margin; x < element.parent.metrics.maxWidth; x ++ { - target.SetRune(x, y, '-') - target.SetColor(x, y, stone.ColorBlue) + target.SetRune(x, y + 1, 0) + target.SetStyle(x, y + 1, stone.StyleUnderline) + target.SetColor(x, y + 1, stone.ColorDim) } } @@ -283,23 +283,22 @@ func (element *ElementQuote) Render ( offset int, ) { height := 1 - x := element.parent.metrics.margin + x := element.parent.metrics.margin + 2 y := offset - - text := " ''" + element.text + ",," target.SetColor(element.parent.metrics.margin, offset, stone.ColorGreen) - for _, character := range text { + for _, character := range element.text { if x >= element.parent.metrics.maxWidth || character == '\n' { height ++ - x = element.parent.metrics.margin + 3 + x = element.parent.metrics.margin + 2 y ++ } if unicode.IsPrint(character) { target.SetRune(x, y, character) target.SetColor(x, y, stone.ColorGreen) + target.SetStyle(x, y, stone.StyleItalic) x ++ } } diff --git a/fetch.go b/fetch.go index 27ad11e..c76f2ea 100644 --- a/fetch.go +++ b/fetch.go @@ -65,7 +65,7 @@ func fetchBack (location *url.URL, viewSource bool, addToHistory bool) { fetchString(bookmarks.Gemtext(), page.currentUrl) default: fetchString ( - "# Error\n" + + "# Error\n\n" + "That page does not exist.", page.currentUrl) } @@ -89,7 +89,7 @@ func fetchBack (location *url.URL, viewSource bool, addToHistory bool) { if err != nil { fetchString ( - "# Error\n" + + "# Error\n\n" + "There was an error connecting to " + location.String() + "\n\n" + "> " + err.Error() + "\n", @@ -134,7 +134,7 @@ func fetchBack (location *url.URL, viewSource bool, addToHistory bool) { case gemini.StatusRedirect: if page.redirectCounter > 8 { fetchString (fmt.Sprintf ( - "# Too many redirects\n" + + "# Too many redirects\n\n" + "Enough! The site has redirected us too many " + "times."), page.currentUrl) @@ -144,7 +144,7 @@ func fetchBack (location *url.URL, viewSource bool, addToHistory bool) { location, err := url.Parse(response.Meta) if err != nil { fetchString (fmt.Sprintf ( - "# Error\n" + + "# Error\n\n" + "The site responded with an invalid redirect:\n\n" + "%s", err.Error()), page.currentUrl) @@ -157,14 +157,14 @@ func fetchBack (location *url.URL, viewSource bool, addToHistory bool) { case gemini.StatusTemporaryFailure, gemini.StatusPermanentFailure: fetchString (fmt.Sprintf ( - "# Error %d\n" + + "# Error %d\n\n" + "The site responded with an error:\n\n" + "> %s", response.Status, response.Meta), page.currentUrl) default: fetchString (fmt.Sprintf ( - "# Unhandled response status %d\n" + + "# Unhandled response status %d\n\n" + "Skipper doesn't know how to handle this type of " + "response yet.", response.Status), page.currentUrl)