Compare commits
No commits in common. "db84a3a6080e6a490a1773c8cbfdbf13a5d2285a" and "b4cb362a7cd819ac292ccea586d811b7040b1a54" have entirely different histories.
db84a3a608
...
b4cb362a7c
5 changed files with 29 additions and 56 deletions
|
@ -125,11 +125,11 @@ func (p Printer) PrintAccountList(list model.AccountList) {
|
||||||
|
|
||||||
if list.Type == model.AccountListBlockedAccount {
|
if list.Type == model.AccountListBlockedAccount {
|
||||||
for ind := range list.Accounts {
|
for ind := range list.Accounts {
|
||||||
builder.WriteString("\n" + symbolBullet + " " + list.Accounts[ind].Acct + " (" + list.Accounts[ind].ID + ")")
|
builder.WriteString("\n" + p.bullet + " " + list.Accounts[ind].Acct + " (" + list.Accounts[ind].ID + ")")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for ind := range list.Accounts {
|
for ind := range list.Accounts {
|
||||||
builder.WriteString("\n" + symbolBullet + " " + p.fullDisplayNameFormat(list.Accounts[ind].DisplayName, list.Accounts[ind].Acct))
|
builder.WriteString("\n" + p.bullet + " " + p.fullDisplayNameFormat(list.Accounts[ind].DisplayName, list.Accounts[ind].Acct))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ func (p Printer) PrintList(list model.List) {
|
||||||
|
|
||||||
if len(list.Accounts) > 0 {
|
if len(list.Accounts) > 0 {
|
||||||
for acct, name := range list.Accounts {
|
for acct, name := range list.Accounts {
|
||||||
builder.WriteString("\n" + symbolBullet + " " + p.fullDisplayNameFormat(name, acct))
|
builder.WriteString("\n" + p.bullet + " " + p.fullDisplayNameFormat(name, acct))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
builder.WriteString("\n" + "None")
|
builder.WriteString("\n" + "None")
|
||||||
|
@ -40,7 +40,7 @@ func (p Printer) PrintLists(lists []model.List) {
|
||||||
builder.WriteString("\n" + p.headerFormat("LISTS"))
|
builder.WriteString("\n" + p.headerFormat("LISTS"))
|
||||||
|
|
||||||
for i := range lists {
|
for i := range lists {
|
||||||
builder.WriteString("\n" + symbolBullet + " " + lists[i].Title + " (" + lists[i].ID + ")")
|
builder.WriteString("\n" + p.bullet + " " + lists[i].Title + " (" + lists[i].ID + ")")
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.WriteString("\n")
|
builder.WriteString("\n")
|
||||||
|
|
|
@ -85,10 +85,10 @@ func (p Printer) pollMeter(votage float64) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
meter := "\n" + voteBlockColor + strings.Repeat(symbolPollMeter, numVoteBlocks) + p.theme.reset
|
meter := "\n" + voteBlockColor + strings.Repeat(p.pollMeterSymbol, numVoteBlocks) + p.theme.reset
|
||||||
|
|
||||||
if !p.noColor {
|
if !p.noColor {
|
||||||
meter += backgroundBlockColor + strings.Repeat(symbolPollMeter, numBackgroundBlocks) + p.theme.reset
|
meter += backgroundBlockColor + strings.Repeat(p.pollMeterSymbol, numBackgroundBlocks) + p.theme.reset
|
||||||
}
|
}
|
||||||
|
|
||||||
return meter
|
return meter
|
||||||
|
|
|
@ -13,20 +13,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
minTerminalWidth = 40
|
minTerminalWidth = 40
|
||||||
noMediaDescription = "This media attachment has no description."
|
noMediaDescription = "This media attachment has no description."
|
||||||
symbolBullet = "\u2022"
|
|
||||||
symbolPollMeter = "\u2501"
|
|
||||||
symbolSuccess = "\u2714"
|
|
||||||
symbolFailure = "\u2717"
|
|
||||||
symbolImage = "\uf03e"
|
|
||||||
symbolLiked = "\uf51f"
|
|
||||||
symbolNotLiked = "\uf41e"
|
|
||||||
symbolBookmarked = "\uf47a"
|
|
||||||
symbolNotBookmarked = "\uf461"
|
|
||||||
symbolBoosted = "\u2BAD"
|
|
||||||
dateFormat = "02 Jan 2006"
|
|
||||||
dateTimeFormat = "02 Jan 2006, 15:04 (MST)"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type theme struct {
|
type theme struct {
|
||||||
|
@ -38,8 +26,6 @@ type theme struct {
|
||||||
grey string
|
grey string
|
||||||
red string
|
red string
|
||||||
boldred string
|
boldred string
|
||||||
yellow string
|
|
||||||
boldyellow string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Printer struct {
|
type Printer struct {
|
||||||
|
@ -48,6 +34,13 @@ type Printer struct {
|
||||||
maxTerminalWidth int
|
maxTerminalWidth int
|
||||||
pager string
|
pager string
|
||||||
statusSeparator string
|
statusSeparator string
|
||||||
|
bullet string
|
||||||
|
pollMeterSymbol string
|
||||||
|
successSymbol string
|
||||||
|
failureSymbol string
|
||||||
|
dateFormat string
|
||||||
|
dateTimeFormat string
|
||||||
|
imageIcon string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPrinter(
|
func NewPrinter(
|
||||||
|
@ -64,8 +57,6 @@ func NewPrinter(
|
||||||
grey: "\033[90m",
|
grey: "\033[90m",
|
||||||
red: "\033[31m",
|
red: "\033[31m",
|
||||||
boldred: "\033[31;1m",
|
boldred: "\033[31;1m",
|
||||||
yellow: "\033[33m",
|
|
||||||
boldyellow: "\033[33;1m",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if maxTerminalWidth < minTerminalWidth {
|
if maxTerminalWidth < minTerminalWidth {
|
||||||
|
@ -78,22 +69,29 @@ func NewPrinter(
|
||||||
maxTerminalWidth: maxTerminalWidth,
|
maxTerminalWidth: maxTerminalWidth,
|
||||||
pager: pager,
|
pager: pager,
|
||||||
statusSeparator: strings.Repeat("\u2501", maxTerminalWidth),
|
statusSeparator: strings.Repeat("\u2501", maxTerminalWidth),
|
||||||
|
bullet: "\u2022",
|
||||||
|
pollMeterSymbol: "\u2501",
|
||||||
|
successSymbol: "\u2714",
|
||||||
|
failureSymbol: "\u2717",
|
||||||
|
dateFormat: "02 Jan 2006",
|
||||||
|
dateTimeFormat: "02 Jan 2006, 15:04 (MST)",
|
||||||
|
imageIcon: "\uf03e",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Printer) PrintSuccess(text string) {
|
func (p Printer) PrintSuccess(text string) {
|
||||||
success := p.theme.boldgreen + symbolSuccess + p.theme.reset
|
success := p.theme.boldgreen + p.successSymbol + p.theme.reset
|
||||||
if p.noColor {
|
if p.noColor {
|
||||||
success = symbolSuccess
|
success = p.successSymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
printToStdout(success + " " + text + "\n")
|
printToStdout(success + " " + text + "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Printer) PrintFailure(text string) {
|
func (p Printer) PrintFailure(text string) {
|
||||||
failure := p.theme.boldred + symbolFailure + p.theme.reset
|
failure := p.theme.boldred + p.failureSymbol + p.theme.reset
|
||||||
if p.noColor {
|
if p.noColor {
|
||||||
failure = symbolFailure
|
failure = p.failureSymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
printToStderr(failure + " " + text + "\n")
|
printToStderr(failure + " " + text + "\n")
|
||||||
|
@ -137,11 +135,11 @@ func (p Printer) fullDisplayNameFormat(displayName, acct string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Printer) formatDate(date time.Time) string {
|
func (p Printer) formatDate(date time.Time) string {
|
||||||
return date.Local().Format(dateFormat)
|
return date.Local().Format(p.dateFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Printer) formatDateTime(date time.Time) string {
|
func (p Printer) formatDateTime(date time.Time) string {
|
||||||
return date.Local().Format(dateTimeFormat)
|
return date.Local().Format(p.dateTimeFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Printer) print(text string) {
|
func (p Printer) print(text string) {
|
||||||
|
|
|
@ -59,12 +59,6 @@ func (p Printer) PrintStatus(status model.Status) {
|
||||||
builder.WriteString("\n" + p.fieldFormat("Likes: ") + strconv.Itoa(status.FavouritesCount))
|
builder.WriteString("\n" + p.fieldFormat("Likes: ") + strconv.Itoa(status.FavouritesCount))
|
||||||
builder.WriteString("\n" + p.fieldFormat("Replies: ") + strconv.Itoa(status.RepliesCount))
|
builder.WriteString("\n" + p.fieldFormat("Replies: ") + strconv.Itoa(status.RepliesCount))
|
||||||
|
|
||||||
// The user's actions on the status
|
|
||||||
builder.WriteString("\n\n" + p.headerFormat("YOUR ACTIONS:"))
|
|
||||||
builder.WriteString("\n" + p.fieldFormat("Boosted: ") + strconv.FormatBool(status.Reblogged))
|
|
||||||
builder.WriteString("\n" + p.fieldFormat("Liked: ") + strconv.FormatBool(status.Favourited))
|
|
||||||
builder.WriteString("\n" + p.fieldFormat("Bookmarked: ") + strconv.FormatBool(status.Bookmarked))
|
|
||||||
|
|
||||||
// Status visibility
|
// Status visibility
|
||||||
builder.WriteString("\n\n" + p.headerFormat("VISIBILITY:"))
|
builder.WriteString("\n\n" + p.headerFormat("VISIBILITY:"))
|
||||||
builder.WriteString("\n" + status.Visibility.String())
|
builder.WriteString("\n" + status.Visibility.String())
|
||||||
|
@ -110,7 +104,7 @@ func (p Printer) PrintStatusList(list model.StatusList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, media := range mediaAttachments {
|
for _, media := range mediaAttachments {
|
||||||
builder.WriteString("\n\n" + symbolImage + " Media attachment: " + media.ID)
|
builder.WriteString("\n\n" + p.imageIcon + " Media attachment: " + media.ID)
|
||||||
builder.WriteString("\n Media type: " + media.Type + "\n ")
|
builder.WriteString("\n Media type: " + media.Type + "\n ")
|
||||||
|
|
||||||
description := media.Description
|
description := media.Description
|
||||||
|
@ -121,25 +115,6 @@ func (p Printer) PrintStatusList(list model.StatusList) {
|
||||||
builder.WriteString(utilities.WrapLines(description, "\n ", p.maxTerminalWidth-3))
|
builder.WriteString(utilities.WrapLines(description, "\n ", p.maxTerminalWidth-3))
|
||||||
}
|
}
|
||||||
|
|
||||||
boosted := symbolBoosted
|
|
||||||
if status.Reblogged {
|
|
||||||
boosted = p.theme.boldyellow + symbolBoosted + p.theme.reset
|
|
||||||
}
|
|
||||||
|
|
||||||
liked := symbolNotLiked
|
|
||||||
if status.Favourited {
|
|
||||||
liked = p.theme.boldyellow + symbolLiked + p.theme.reset
|
|
||||||
}
|
|
||||||
|
|
||||||
bookmarked := symbolNotBookmarked
|
|
||||||
if status.Bookmarked {
|
|
||||||
bookmarked = p.theme.boldyellow + symbolBookmarked + p.theme.reset
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.WriteString("\n\n" + boosted + " " + p.fieldFormat("boosted:") + " " + strconv.FormatBool(status.Bookmarked))
|
|
||||||
builder.WriteString("\n" + liked + " " + p.fieldFormat("liked:") + " " + strconv.FormatBool(status.Favourited))
|
|
||||||
builder.WriteString("\n" + bookmarked + " " + p.fieldFormat("bookmarked:") + " " + strconv.FormatBool(status.Bookmarked))
|
|
||||||
|
|
||||||
builder.WriteString(
|
builder.WriteString(
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
p.fieldFormat("Status ID:") + " " + statusID + "\t" +
|
p.fieldFormat("Status ID:") + " " + statusID + "\t" +
|
||||||
|
|
Loading…
Reference in a new issue