Various tweaks making use of new formatting

This commit is contained in:
Sasha Koshka 2022-11-29 03:33:53 -05:00
parent 4395e5d563
commit 0e5d54cf18
3 changed files with 14 additions and 15 deletions

View File

@ -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() +

View File

@ -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 ++
}
}

View File

@ -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)