Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more symbols to the feed #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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