Skip to content

Commit

Permalink
Fixed width calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
mrusme committed Apr 3, 2021
1 parent e2208b3 commit f3109b9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tui/toot.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package tui
import (
"fmt"
// "time"
// "context"

"github.com/mattn/go-runewidth"
"github.com/grokify/html-strip-tags-go"
"html"

// "image/color"
// "github.com/eliukblau/pixterm/pkg/ansimage"
// "context"

// "github.com/mattn/go-mastodon"
"github.com/mrusme/gomphotherium/mast"
Expand All @@ -35,7 +36,7 @@ func RenderToot(toot *mast.Toot, width int) (string, error) {
inReplyToLen = 2
}

output = fmt.Sprintf("%s[blue]%s[-] [grey]%s[-][magenta]%s[-][grey]%*d[-]\n", output, status.Account.DisplayName, account, inReplyTo, (width - len(string(toot.ID)) - len(status.Account.DisplayName) - len(account) - inReplyToLen), toot.ID)
output = fmt.Sprintf("%s[blue]%s[-] [grey]%s[-][magenta]%s[-][grey]%*d[-]\n", output, status.Account.DisplayName, account, inReplyTo, (width - len(string(toot.ID)) - runewidth.StringWidth(status.Account.DisplayName) - len(account) - inReplyToLen), toot.ID)
output = fmt.Sprintf("%s%s\n", output, html.UnescapeString(strip.StripTags(status.Content)))

// for _, attachment := range status.MediaAttachments {
Expand Down

0 comments on commit f3109b9

Please sign in to comment.