shithub: hell

Download patch

ref: 55ae655adf9d58d87afbe4b79a10a8f14810af23
parent: c842705d43f769cee4ae875f2a1ef24c8a5b771e
author: penny <penny@limitedideas.org>
date: Wed Sep 24 16:53:45 EDT 2025

Add bookmark paginator

--- a/commands.go
+++ b/commands.go
@@ -4,7 +4,7 @@
 	"strings"
 )
 
-var commands = []string{"examine", "reply", "like", "thread", "open", "prev", "download", "dm", "rt", "parent", "children", "rm", "mark", "unmark", "account", "vim", "import", "pause", "resume", "url", "fpost", "ufpost", "edit", "notice", "stats", "next", "preview"}
+var commands = []string{"examine", "reply", "like", "thread", "open", "prev", "download", "dm", "rt", "parent", "children", "rm", "mark", "unmark", "account", "vim", "import", "pause", "resume", "url", "fpost", "ufpost", "edit", "notice", "stats", "next", "preview", "bookmarks"}
 
 func processInput(input string) (command string, arguments string, found bool) {
 
--- a/main.go
+++ b/main.go
@@ -125,6 +125,11 @@
 				hc.page.Next()
 				fmt.Printf(hc.page.String())
 				return
+			case "bookmarks":
+				hc.page = &Page{}
+				hc.page.loader = &StatusPages{hc: hc}
+				fmt.Printf(hc.page.String())
+				return
 			case "notice":
 				defer hc.updatePrompt()
 				defer hc.pause(true)
--- a/mastodon.go
+++ b/mastodon.go
@@ -308,6 +308,11 @@
 	return post
 }
 
+func (hc *Hellclient) renderPostS(ref postref, post *mastodon.Status) string {
+	_, plaintext := hc.RenderPostPlaintext(post, ref.prefix+ref.ref, "")
+	return hyphenate(plaintext)
+}
+
 func (hc *Hellclient) RenderPostPlaintext(post *mastodon.Status, postref string, prefix string) (selectedPost *mastodon.Status, plaintext string) {
 	poststring := ""
 	postfix := ""
--- a/pages.go
+++ b/pages.go
@@ -37,7 +37,24 @@
 }
 
 func (statusData *StatusPages) Load(limit int) *[]PageItem {
-	return nil
+	if statusData.page == nil {
+		statusData.page = &mastodon.Pagination{}
+	}
+	statusData.page.Limit = int64(limit)
+	var statuses []*mastodon.Status
+	var err error
+	statuses, err = statusData.hc.client.GetBookmarks(context.Background(), statusData.page)
+	if err != nil {
+		fmt.Printf("Error loading status page: %s\n", err)
+	}
+	
+	var itemArray []PageItem
+	for i, _ := range statuses {
+		item := PageItem{itemtext: statusData.hc.renderAndIncrement(statusData.hc.ctxref, statuses[i]) + "\n"}
+		itemArray = append(itemArray, item)
+	}
+	statusData.page.MinID = ""
+	return &itemArray
 }
 
 func (noticeData *NotificationPages) Load(limit int) *[]PageItem {
--- a/references.go
+++ b/references.go
@@ -38,6 +38,13 @@
 	return
 }
 
+func (hc *Hellclient) renderAndIncrement(ref *postref, post *mastodon.Status) string {
+	plaintext := hc.renderPostS(*ref, post)
+	IncrementRef(ref, post)
+	ref.ref = IncrementString(ref.ref)
+	return plaintext
+}
+
 func printAndIncrementDetailed(ref *postref, post *mastodon.Status, format func(*mastodon.Status, string) string) {
 	fmt.Println(format(post, ref.ref))
 	IncrementRef(ref, post)
--