shithub: hell

Download patch

ref: bc47f7bf1176b75ddd044c3ca296ee024b87d631
parent: b791b97ed43150a4be18b5153cf2829f74adc850
author: penny <penny@limitedideas.org>
date: Sun Oct 5 20:10:44 EDT 2025

normalize more rendering

--- a/format.go
+++ b/format.go
@@ -6,17 +6,17 @@
 	"golang.org/x/term"
 )
 
-func hyphenate(input string) string {
+func hyphenate(input string) (string, bool) {
 	width, _, _ := term.GetSize(int(0))
 	return hyphenateWithWidth(input, width)
 }
 
-func hyphenateWithWidth(input string, width int) string {
+func hyphenateWithWidth(input string, width int) (string, bool) {
 	var remainder = []rune(input)
 	var result []rune
 
 	if width < 2 {
-		return input
+		return input, false
 	}
 
 	longline := false
@@ -80,10 +80,7 @@
 		result = result[:len(result)-1]
 	}
 	//Put an extra newline at the end if status takes multiple lines
-	if longline {
-		result = append(result, '\n')
-	}
-	return string(result)
+	return string(result), longline
 }
 
 func countEmoji(runes []rune) int {
--- a/mastodon.go
+++ b/mastodon.go
@@ -175,33 +175,33 @@
 			sb.WriteString("Follow request pending\n")
 		}
 	}
-
-	return hyphenate(sb.String())
+	accountstring, _ := hyphenate(sb.String())
+	return accountstring
 }
 
 // Spaces before prefixes (no space if you're not passing a prefix)
 func (hc *Hellclient) formatReblog(post *mastodon.Status, index string) string {
 	reblogString := fmt.Sprintf(" <%s> Reblogged", post.Account.Username)
-	return hyphenate(hc.formatStatusDetailed(post.Reblog, index, reblogString))
+	return hc.formatStatusDetailed(post.Reblog, index, reblogString)
 }
 
 func (hc *Hellclient) formatWithPrefix(post *mastodon.Status, index string, prefix string) string {
 	postString := fmt.Sprintf("%s %s>", prefix, index)
-	return hyphenate(hc.formatStatusDetailed(post, "", postString))
+	return hc.formatStatusDetailed(post, "", postString)
 }
 func (hc *Hellclient) formatFavorite(post *mastodon.Status, index string) string {
 	favString := fmt.Sprintf("Favorited: %s", index)
-	return hyphenate(hc.formatStatusDetailed(post, "", favString))
+	return hc.formatStatusDetailed(post, "", favString)
 }
 
 func (hc *Hellclient) formatBookmark(post *mastodon.Status, index string) string {
 	favString := fmt.Sprintf("Bookmarked: %s", index)
-	return hyphenate(hc.formatStatusDetailed(post, "", favString))
+	return hc.formatStatusDetailed(post, "", favString)
 }
 
 func (hc *Hellclient) formatUnbookmark(post *mastodon.Status, index string) string {
 	favString := fmt.Sprintf("Unbookmarked: %s", index)
-	return hyphenate(hc.formatStatusDetailed(post, "", favString))
+	return hc.formatStatusDetailed(post, "", favString)
 }
 
 func (hc *Hellclient) formatStatus(post *mastodon.Status, index string) string {
@@ -220,7 +220,7 @@
 
 func (hc *Hellclient) formatEdit(post *mastodon.Status, index string) string {
 	editString := fmt.Sprintf(" <%s> EDITED:", post.Account.Username)
-	return hyphenate(hc.formatStatusDetailed(post, index, editString))
+	return hc.formatStatusDetailed(post, index, editString)
 }
 
 func printMastodonErr(err error) {
--- a/notifications.go
+++ b/notifications.go
@@ -72,12 +72,15 @@
 	var noticeTexts []string
 	status := func(Notification *mastodon.Notification, plaintext string) {
 		notification := fmt.Sprintf("[%s] from <%s>: %s", Notification.Type, Notification.Account.Acct, plaintext)
-		noticeTexts = append(noticeTexts, hyphenate(notification))
+		notification, _ = hyphenate(notification)
+		
+		noticeTexts = append(noticeTexts, notification)
 	}
 
 	other := func(Notification *mastodon.Notification) {
 		notification := fmt.Sprintf("[%s] from <%s>", Notification.Type, Notification.Account.Acct)
-		noticeTexts = append(noticeTexts, hyphenate(notification))
+		notification, _ = hyphenate(notification)
+		noticeTexts = append(noticeTexts, notification)
 	}
 
 	hc.PrintNotificationsCustom(notifications, status, other)
--- a/pages.go
+++ b/pages.go
@@ -157,7 +157,7 @@
 		fmt.Printf("Couldn't load status page: %s\n", err)
 	}
 	for i := range statuses {
-		item := makePageItem(statusData.hc.renderAndIncrement(statusData.hc.ctxref, statuses[i]))
+		item := makePageItem(statusData.hc.renderAndIncrement(statusData.hc.ctxref, statuses[i]) + "\n")
 		itemArray = append(itemArray, item)
 	}
 	return &itemArray
--- a/references.go
+++ b/references.go
@@ -43,7 +43,8 @@
 	post, plaintext := hc.RenderPostPlaintext(post, *ref)
 	IncrementRef(ref, post)
 	ref.ref = IncrementString(ref.ref)
-	return hyphenate(plaintext)
+	plaintext, _ = hyphenate(plaintext)
+	return plaintext
 }
 
 func printAndIncrementDetailed(ref *postref, post *mastodon.Status, format func(*mastodon.Status, string) string) {
--- a/renderer.go
+++ b/renderer.go
@@ -43,7 +43,7 @@
 	}
 	for _, item := range status.MediaAttachments {
 		if item.Description != "" {
-			sb.WriteString(fmt.Sprintf("\n🖼️[%s]", item.Description))
+			sb.WriteString(fmt.Sprintf("\n🖼️ [%s]", item.Description))
 			continue
 		}
 		sb.WriteString("🖼️")
--- a/templater.go
+++ b/templater.go
@@ -38,6 +38,9 @@
 		}
 		return fmt.Sprintf("[%%KEY_NOT_FOUND:%s]", key)
 	}
-
-	return hyphenate(os.Expand(template, expandMap)) + "\n", nil
+	template, long := hyphenate(os.Expand(template, expandMap))
+	if long {
+		return template + "\n\n", nil
+	}
+	return template + "\n", nil
 }
--