Various tweaks making use of new formatting
This commit is contained in:
parent
4395e5d563
commit
0e5d54cf18
|
@ -19,7 +19,7 @@ type Bookmark struct {
|
||||||
var bookmarks []Bookmark
|
var bookmarks []Bookmark
|
||||||
|
|
||||||
func Gemtext () (page string) {
|
func Gemtext () (page string) {
|
||||||
page += "# Bookmarks\n"
|
page += "# Bookmarks\n\n"
|
||||||
for _, bookmark := range bookmarks {
|
for _, bookmark := range bookmarks {
|
||||||
page +=
|
page +=
|
||||||
"=> " + bookmark.Location.String() +
|
"=> " + bookmark.Location.String() +
|
||||||
|
|
|
@ -147,14 +147,14 @@ func (element *ElementHeading) Render (
|
||||||
|
|
||||||
if element.level == HeadingLevel1 {
|
if element.level == HeadingLevel1 {
|
||||||
height ++
|
height ++
|
||||||
y ++
|
|
||||||
for
|
for
|
||||||
x = element.parent.metrics.margin;
|
x = element.parent.metrics.margin;
|
||||||
x < element.parent.metrics.maxWidth;
|
x < element.parent.metrics.maxWidth;
|
||||||
x ++ {
|
x ++ {
|
||||||
|
|
||||||
target.SetRune(x, y, '-')
|
target.SetRune(x, y + 1, 0)
|
||||||
target.SetColor(x, y, stone.ColorBlue)
|
target.SetStyle(x, y + 1, stone.StyleUnderline)
|
||||||
|
target.SetColor(x, y + 1, stone.ColorDim)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,23 +283,22 @@ func (element *ElementQuote) Render (
|
||||||
offset int,
|
offset int,
|
||||||
) {
|
) {
|
||||||
height := 1
|
height := 1
|
||||||
x := element.parent.metrics.margin
|
x := element.parent.metrics.margin + 2
|
||||||
y := offset
|
y := offset
|
||||||
|
|
||||||
text := " ''" + element.text + ",,"
|
|
||||||
|
|
||||||
target.SetColor(element.parent.metrics.margin, offset, stone.ColorGreen)
|
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' {
|
if x >= element.parent.metrics.maxWidth || character == '\n' {
|
||||||
height ++
|
height ++
|
||||||
x = element.parent.metrics.margin + 3
|
x = element.parent.metrics.margin + 2
|
||||||
y ++
|
y ++
|
||||||
}
|
}
|
||||||
|
|
||||||
if unicode.IsPrint(character) {
|
if unicode.IsPrint(character) {
|
||||||
target.SetRune(x, y, character)
|
target.SetRune(x, y, character)
|
||||||
target.SetColor(x, y, stone.ColorGreen)
|
target.SetColor(x, y, stone.ColorGreen)
|
||||||
|
target.SetStyle(x, y, stone.StyleItalic)
|
||||||
x ++
|
x ++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
fetch.go
12
fetch.go
|
@ -65,7 +65,7 @@ func fetchBack (location *url.URL, viewSource bool, addToHistory bool) {
|
||||||
fetchString(bookmarks.Gemtext(), page.currentUrl)
|
fetchString(bookmarks.Gemtext(), page.currentUrl)
|
||||||
default:
|
default:
|
||||||
fetchString (
|
fetchString (
|
||||||
"# Error\n" +
|
"# Error\n\n" +
|
||||||
"That page does not exist.",
|
"That page does not exist.",
|
||||||
page.currentUrl)
|
page.currentUrl)
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ func fetchBack (location *url.URL, viewSource bool, addToHistory bool) {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fetchString (
|
fetchString (
|
||||||
"# Error\n" +
|
"# Error\n\n" +
|
||||||
"There was an error connecting to " +
|
"There was an error connecting to " +
|
||||||
location.String() + "\n\n" +
|
location.String() + "\n\n" +
|
||||||
"> " + err.Error() + "\n",
|
"> " + err.Error() + "\n",
|
||||||
|
@ -134,7 +134,7 @@ func fetchBack (location *url.URL, viewSource bool, addToHistory bool) {
|
||||||
case gemini.StatusRedirect:
|
case gemini.StatusRedirect:
|
||||||
if page.redirectCounter > 8 {
|
if page.redirectCounter > 8 {
|
||||||
fetchString (fmt.Sprintf (
|
fetchString (fmt.Sprintf (
|
||||||
"# Too many redirects\n" +
|
"# Too many redirects\n\n" +
|
||||||
"Enough! The site has redirected us too many " +
|
"Enough! The site has redirected us too many " +
|
||||||
"times."),
|
"times."),
|
||||||
page.currentUrl)
|
page.currentUrl)
|
||||||
|
@ -144,7 +144,7 @@ func fetchBack (location *url.URL, viewSource bool, addToHistory bool) {
|
||||||
location, err := url.Parse(response.Meta)
|
location, err := url.Parse(response.Meta)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fetchString (fmt.Sprintf (
|
fetchString (fmt.Sprintf (
|
||||||
"# Error\n" +
|
"# Error\n\n" +
|
||||||
"The site responded with an invalid redirect:\n\n" +
|
"The site responded with an invalid redirect:\n\n" +
|
||||||
"%s",
|
"%s",
|
||||||
err.Error()), page.currentUrl)
|
err.Error()), page.currentUrl)
|
||||||
|
@ -157,14 +157,14 @@ func fetchBack (location *url.URL, viewSource bool, addToHistory bool) {
|
||||||
|
|
||||||
case gemini.StatusTemporaryFailure, gemini.StatusPermanentFailure:
|
case gemini.StatusTemporaryFailure, gemini.StatusPermanentFailure:
|
||||||
fetchString (fmt.Sprintf (
|
fetchString (fmt.Sprintf (
|
||||||
"# Error %d\n" +
|
"# Error %d\n\n" +
|
||||||
"The site responded with an error:\n\n" +
|
"The site responded with an error:\n\n" +
|
||||||
"> %s",
|
"> %s",
|
||||||
response.Status, response.Meta), page.currentUrl)
|
response.Status, response.Meta), page.currentUrl)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fetchString (fmt.Sprintf (
|
fetchString (fmt.Sprintf (
|
||||||
"# Unhandled response status %d\n" +
|
"# Unhandled response status %d\n\n" +
|
||||||
"Skipper doesn't know how to handle this type of " +
|
"Skipper doesn't know how to handle this type of " +
|
||||||
"response yet.",
|
"response yet.",
|
||||||
response.Status), page.currentUrl)
|
response.Status), page.currentUrl)
|
||||||
|
|
Loading…
Reference in New Issue