Skip to content

Commit

Permalink
1.0.25 (#214)
Browse files Browse the repository at this point in the history
* bump version

* stick to the top

* add support for filtering boosts and replies

* Add CommandText for cmdbar personalization (#210)

* Config typos (#213)

* update modules

Co-authored-by: ryspace <[email protected]>
Co-authored-by: Kir Axanov <[email protected]>
  • Loading branch information
3 people authored Dec 13, 2022
1 parent 06f16fe commit d81279d
Show file tree
Hide file tree
Showing 16 changed files with 340 additions and 232 deletions.
25 changes: 19 additions & 6 deletions config.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,22 @@ mouse-support=false
# Tag is special as you need to add the tag after, see the example below.
#
# The syntax is:
# timelines=feed,[name],[keys...]
# timelines=feed,[name],[keys...],[showBoosts],[showReplies]
#
# Tha values in brackets are optional. You can see the syntax for keys under the
# [input] section.
#
# showBoosts and showReplies must be formated as bools. So either true or false.
# They always defaults to true.
#
# Some examples:
#
# home timeline with the name Home
# timelines=home,Home
#
# local timeline with the name Local and it gets focus when you press 2
# timelines=local,Local,'2'
# local timeline with the name Local and it gets focus when you press 2. It will
# also hide boosts in the timeline, but show toots that are replies.
# timelines=local,Local,'2',false,true
#
# notification timeline with the name [N]otifications and it gets focus when you
# press n or N
Expand Down Expand Up @@ -119,6 +123,11 @@ show-filter-phrase=true
# default=true
show-help=true

# If you always want tut to jump to the newest post. May ruin your reading
# experience.
# default=false
stick-to-top=false

# 0 = No terminal title
# 1 = Show title in terminal and top bar
# 2 = Only show terminal title, and no top bar in tut.
Expand Down Expand Up @@ -251,7 +260,7 @@ link-viewer=xdg-open
link-terminal=false

[open-custom]
# This sections allows you to set up to five custom programs to upen URLs with.
# This sections allows you to set up to five custom programs to open URLs with.
# If the url points to an image, you can set c1-name to img and c1-use to imv.
# If the program runs in a terminal and you want to run it in the same terminal
# as tut. Set cX-terminal to true. The name will show up in the UI, so keep it
Expand Down Expand Up @@ -364,7 +373,7 @@ background=
# default=
text=

# The color to display sublte elements or subtle text. Like lines and help text.
# The color to display subtle elements or subtle text. Like lines and help text.
# default=
subtle=

Expand Down Expand Up @@ -404,6 +413,10 @@ status-bar-view-background=
# default=
status-bar-view-text=

# The color of the text in the command bar at the bottom.
# default=
command-text=

# Background of selected list items.
# default=
list-selected-background=
Expand Down Expand Up @@ -488,7 +501,7 @@ timeline-name-text=
# with single quotation marks or double ones.
#
# The single ones are for single chars like 'a', 'b', 'c' and double marks are
# for special keys like "Enter". Remember that they are case sensetive.
# for special keys like "Enter". Remember that they are case sensitive.
#
# To find the names of special keys you have to go to the following site and
# look for "var KeyNames = map[Key]string{"
Expand Down
127 changes: 99 additions & 28 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"strings"
"text/template"

"github.com/RasmusLindroth/tut/feed"
"github.com/gdamore/tcell/v2"
"github.com/gobwas/glob"
"golang.org/x/exp/slices"
"gopkg.in/ini.v1"
)

Expand Down Expand Up @@ -82,11 +82,43 @@ const (
LeaderLoadNewer
)

type FeedType uint

const (
Favorites FeedType = iota
Favorited
Boosts
Followers
Following
FollowRequests
Blocking
Muting
History
InvalidFeed
Notifications
Saved
Tag
Tags
Thread
TimelineFederated
TimelineHome
TimelineLocal
Conversations
User
UserList
Lists
List
ListUsersIn
ListUsersAdd
)

type Timeline struct {
FeedType feed.FeedType
Subaction string
Name string
Key Key
FeedType FeedType
Subaction string
Name string
Key Key
ShowBoosts bool
ShowReplies bool
}

type General struct {
Expand All @@ -96,7 +128,7 @@ type General struct {
DateFormat string
DateRelative int
MaxWidth int
StartTimeline feed.FeedType
StartTimeline FeedType
NotificationFeed bool
QuoteReply bool
CharLimit int
Expand All @@ -115,6 +147,7 @@ type General struct {
LeaderActions []LeaderAction
TimelineName bool
Timelines []Timeline
StickToTop bool
}

type Style struct {
Expand Down Expand Up @@ -160,6 +193,8 @@ type Style struct {
TimelineNameText tcell.Color

IconColor tcell.Color

CommandText tcell.Color
}

type Media struct {
Expand Down Expand Up @@ -621,6 +656,12 @@ func parseStyle(cfg *ini.File, cnfPath string, cnfDir string) Style {
} else {
style.TimelineNameText = style.Subtle
}
s = tcfg.Section("").Key("command-text").String()
if len(s) > 0 {
style.CommandText = tcell.GetColor(s)
} else {
style.CommandText = style.StatusBarText
}
} else {
s := cfg.Section("style").Key("background").String()
style.Background = parseColor(s, "#27822", xrdbColors)
Expand Down Expand Up @@ -740,6 +781,13 @@ func parseStyle(cfg *ini.File, cnfPath string, cnfDir string) Style {
} else {
style.TimelineNameText = style.Subtle
}

s = cfg.Section("style").Key("command-text").String()
if len(s) > 0 {
style.CommandText = parseColor(s, "white", xrdbColors)
} else {
style.CommandText = style.StatusBarText
}
}

return style
Expand Down Expand Up @@ -771,13 +819,13 @@ func parseGeneral(cfg *ini.File) General {
tl := cfg.Section("general").Key("timeline").In("home", []string{"home", "direct", "local", "federated"})
switch tl {
case "direct":
general.StartTimeline = feed.Conversations
general.StartTimeline = Conversations
case "local":
general.StartTimeline = feed.TimelineLocal
general.StartTimeline = TimelineLocal
case "federated":
general.StartTimeline = feed.TimelineFederated
general.StartTimeline = TimelineFederated
default:
general.StartTimeline = feed.TimelineHome
general.StartTimeline = TimelineHome
}

general.NotificationFeed = cfg.Section("general").Key("notification-feed").MustBool(true)
Expand All @@ -789,6 +837,7 @@ func parseGeneral(cfg *ini.File) General {
general.ShowIcons = cfg.Section("general").Key("show-icons").MustBool(true)
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)

lp := cfg.Section("general").Key("list-placement").In("left", []string{"left", "right", "top", "bottom"})
switch lp {
Expand Down Expand Up @@ -950,50 +999,72 @@ func parseGeneral(cfg *ini.File) General {
tl := Timeline{}
switch cmd {
case "home":
tl.FeedType = feed.TimelineHome
tl.FeedType = TimelineHome
case "direct":
tl.FeedType = feed.Conversations
tl.FeedType = Conversations
case "local":
tl.FeedType = feed.TimelineLocal
tl.FeedType = TimelineLocal
case "federated":
tl.FeedType = feed.TimelineFederated
tl.FeedType = TimelineFederated
case "bookmarks":
tl.FeedType = feed.Saved
tl.FeedType = Saved
case "saved":
tl.FeedType = feed.Saved
tl.FeedType = Saved
case "favorited":
tl.FeedType = feed.Favorited
tl.FeedType = Favorited
case "notifications":
tl.FeedType = feed.Notification
tl.FeedType = Notifications
case "lists":
tl.FeedType = feed.Lists
tl.FeedType = Lists
case "tag":
tl.FeedType = feed.Tag
tl.FeedType = Tag
tl.Subaction = subaction
default:
fmt.Printf("timeline %s is invalid\n", parts[0])
os.Exit(1)
}
tl.Name = parts[1]
tfs := []bool{true, true}
tfStr := []string{"true", "false"}
stop := len(parts)
if len(parts) > 2 {
vals := []string{""}
vals = append(vals, parts[2:]...)
tl.Key = inputStrOrErr(vals, false)
if slices.Contains(tfStr, parts[len(parts)-2]) &&
slices.Contains(tfStr, parts[len(parts)-1]) &&
len(parts)-2 > 1 {
tfs[0] = parts[len(parts)-2] == "true"
tfs[1] = parts[len(parts)-1] == "true"
stop = len(parts) - 2
} else if slices.Contains(tfStr, parts[len(parts)-1]) &&
len(parts)-1 > 1 {
tfs[0] = parts[len(parts)-1] == "true"
stop = len(parts) - 1
}
if stop > 2 {
vals := []string{""}
vals = append(vals, parts[2:stop]...)
tl.Key = inputStrOrErr(vals, false)
}
}
tl.ShowBoosts = tfs[0]
tl.ShowReplies = tfs[1]
tls = append(tls, tl)
}
if len(tls) == 0 {
tls = append(tls,
Timeline{
FeedType: feed.TimelineHome,
Name: "",
FeedType: TimelineHome,
Name: "",
ShowBoosts: true,
ShowReplies: true,
},
)
tls = append(tls,
Timeline{
FeedType: feed.Notification,
Name: "[N]otifications",
Key: inputStrOrErr([]string{"", "'n'", "'N'"}, false),
FeedType: Notifications,
Name: "[N]otifications",
Key: inputStrOrErr([]string{"", "'n'", "'N'"}, false),
ShowBoosts: true,
ShowReplies: true,
},
)
}
Expand Down
25 changes: 19 additions & 6 deletions config/default_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@ mouse-support=false
# Tag is special as you need to add the tag after, see the example below.
#
# The syntax is:
# timelines=feed,[name],[keys...]
# timelines=feed,[name],[keys...],[showBoosts],[showReplies]
#
# Tha values in brackets are optional. You can see the syntax for keys under the
# [input] section.
#
# showBoosts and showReplies must be formated as bools. So either true or false.
# They always defaults to true.
#
# Some examples:
#
# home timeline with the name Home
# timelines=home,Home
#
# local timeline with the name Local and it gets focus when you press 2
# timelines=local,Local,'2'
# local timeline with the name Local and it gets focus when you press 2. It will
# also hide boosts in the timeline, but show toots that are replies.
# timelines=local,Local,'2',false,true
#
# notification timeline with the name [N]otifications and it gets focus when you
# press n or N
Expand Down Expand Up @@ -121,6 +125,11 @@ show-filter-phrase=true
# default=true
show-help=true
# If you always want tut to jump to the newest post. May ruin your reading
# experience.
# default=false
stick-to-top=false
# 0 = No terminal title
# 1 = Show title in terminal and top bar
# 2 = Only show terminal title, and no top bar in tut.
Expand Down Expand Up @@ -253,7 +262,7 @@ link-viewer=xdg-open
link-terminal=false
[open-custom]
# This sections allows you to set up to five custom programs to upen URLs with.
# This sections allows you to set up to five custom programs to open URLs with.
# If the url points to an image, you can set c1-name to img and c1-use to imv.
# If the program runs in a terminal and you want to run it in the same terminal
# as tut. Set cX-terminal to true. The name will show up in the UI, so keep it
Expand Down Expand Up @@ -366,7 +375,7 @@ background=
# default=
text=
# The color to display sublte elements or subtle text. Like lines and help text.
# The color to display subtle elements or subtle text. Like lines and help text.
# default=
subtle=
Expand Down Expand Up @@ -406,6 +415,10 @@ status-bar-view-background=
# default=
status-bar-view-text=
# The color of the text in the command bar at the bottom.
# default=
command-text=
# Background of selected list items.
# default=
list-selected-background=
Expand Down Expand Up @@ -490,7 +503,7 @@ timeline-name-text=
# with single quotation marks or double ones.
#
# The single ones are for single chars like 'a', 'b', 'c' and double marks are
# for special keys like "Enter". Remember that they are case sensetive.
# for special keys like "Enter". Remember that they are case sensitive.
#
# To find the names of special keys you have to go to the following site and
# look for "var KeyNames = map[Key]string{"
Expand Down
1 change: 1 addition & 0 deletions config/themes/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ status-bar-background=#f92672
status-bar-text=#f8f8f2
status-bar-view-background=#ae81ff
status-bar-view-text=#f8f8f2
command-text=#f8f8f2
list-selected-background=#f92672
list-selected-text=#f8f8f2
list-selected-inactive-background=#ae81ff
Expand Down
1 change: 1 addition & 0 deletions config/themes/papercolor-light.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ status-bar-background=#4271AE
status-bar-text=#EEEEEE
status-bar-view-background=#718C00
status-bar-view-text=#f5f5f5
command-text=#4D4D4C
list-selected-background=#D7005F
list-selected-text=#f5f5f5
Loading

0 comments on commit d81279d

Please sign in to comment.