Skip to content

Commit

Permalink
Added more symbols to the feed
Browse files Browse the repository at this point in the history
This gives a better visual indication of what a message might be interesting to you and helps filter out noise from signal

To make this work I made the space for symbols a bit bigger (configurable), allowing multiple symbols
  • Loading branch information
proycon committed Dec 19, 2022
1 parent a3578f5 commit f681520
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
5 changes: 5 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ type General struct {
ContentProportion int
TerminalTitle int
ShowIcons bool
SymbolWidth int
SymbolFormat string
ShowHelp bool
RedrawUI bool
LeaderKey rune
Expand Down Expand Up @@ -844,6 +846,9 @@ func parseGeneral(cfg *ini.File) General {
general.ShortHints = cfg.Section("general").Key("short-hints").MustBool(false)
general.ShowFilterPhrase = cfg.Section("general").Key("show-filter-phrase").MustBool(true)
general.ShowIcons = cfg.Section("general").Key("show-icons").MustBool(true)
general.SymbolWidth = cfg.Section("general").Key("symbol-width").MustInt(6)
symbolFormat := "%" + fmt.Sprintf("%d", general.SymbolWidth) + "s"
general.SymbolFormat = cfg.Section("general").Key("symbol-format").MustString(symbolFormat)
general.ShowHelp = cfg.Section("general").Key("show-help").MustBool(true)
general.RedrawUI = cfg.Section("general").Key("redraw-ui").MustBool(true)
general.StickToTop = cfg.Section("general").Key("stick-to-top").MustBool(false)
Expand Down
47 changes: 36 additions & 11 deletions ui/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,31 @@ func DrawListItem(cfg *config.Config, item api.Item) (string, string) {
status := s
if s.Reblog != nil {
status = s.Reblog
}
if status.RepliesCount > 0 {
symbol = " ⤶ "
symbol += "♺ "
}
if item.Pinned() {
symbol = " ! "
symbol += "! "
}
if s.Bookmarked {
symbol += "☜ "
}
if s.Favourited {
symbol += "★ "
}
if s.Poll != nil {
symbol += "= "
}
if s.Sensitive || s.SpoilerText != "" {
symbol += "⚑ "
}
if len(s.MediaAttachments) > 0 {
symbol += "⚭ "
}
if s.Card != nil {
symbol += "⚯ "
}
if status.RepliesCount > 0 {
symbol += "⤷ "
}
acc := strings.TrimSpace(s.Account.Acct)
if cfg.General.ShowBoostedUser && s.Reblog != nil {
Expand All @@ -35,6 +54,9 @@ func DrawListItem(cfg *config.Config, item api.Item) (string, string) {
acc = fmt.Sprintf("♺ %s", acc)
}
d := OutputDate(cfg, s.CreatedAt.Local())
if symbol != "" {
symbol = fmt.Sprintf(cfg.General.SymbolFormat, symbol)
}
return fmt.Sprintf("%s %s", d, acc), symbol
case api.StatusHistoryType:
s := item.Raw().(*mastodon.StatusHistory)
Expand All @@ -51,19 +73,22 @@ func DrawListItem(cfg *config.Config, item api.Item) (string, string) {
symbol := ""
switch a.Item.Type {
case "follow", "follow_request":
symbol += " + "
symbol += "+ "
case "favourite":
symbol = " ★ "
symbol = "★ "
case "reblog":
symbol = " ♺ "
symbol = "♺ "
case "mention":
symbol = " ⤶ "
symbol = "⤶ "
case "update":
symbol = " ☢ "
symbol = "☢ "
case "poll":
symbol = " = "
symbol = "= "
case "status":
symbol = " ⤶ "
symbol = "⤶ "
}
if symbol != "" {
symbol = fmt.Sprintf(cfg.General.SymbolFormat, symbol)
}
d := OutputDate(cfg, a.Item.CreatedAt.Local())
return fmt.Sprintf("%s %s", d, strings.TrimSpace(a.Item.Account.Acct)), symbol
Expand Down
2 changes: 1 addition & 1 deletion ui/mainview.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (mv *MainView) ForceUpdate() {
}

func feedList(mv *TutView, fh *FeedHolder) *tview.Flex {
iw := 3
iw := mv.tut.Config.General.SymbolWidth
if !mv.tut.Config.General.ShowIcons {
iw = 0
}
Expand Down

0 comments on commit f681520

Please sign in to comment.