Browse Source

add commands-in-new-pane and dynamic-timeline-name

pull/253/head
Rasmus Lindroth 3 years ago
parent
commit
545883032c
  1. 9
      config.example.toml
  2. 4
      config/config.go
  3. 9
      config/default_config.go
  4. 2
      config/toml.go
  5. 2
      config/toml_default.go
  6. 2
      docs/man/tut.1
  7. 2
      docs/man/tut.1.md
  8. 17
      docs/man/tut.5
  9. 10
      docs/man/tut.5.md
  10. 2
      docs/man/tut.7
  11. 2
      docs/man/tut.7.md
  12. 2
      ui/cmdbar.go
  13. 62
      ui/commands.go
  14. 25
      ui/input.go
  15. 4
      ui/linkview.go
  16. 83
      ui/timeline.go

9
config.example.toml

@ -94,6 +94,15 @@ stick-to-top=false
# default=false
show-boosted-user=false
# Open a new pane when you run a command like :timeline home.
# default=true
commands-in-new-pane=true
# Set a default name for the timeline if the name is empty. So if you run :tag
# linux the title of the pane will be set to #linux
# default=true
dynamic-timeline-name=true
# 0 = No terminal title
# 1 = Show title in terminal and top bar
# 2 = Only show terminal title, and no top bar in tut

4
config/config.go

@ -196,6 +196,8 @@ type General struct {
StickToTop bool
NotificationsToHide []NotificationToHide
ShowBoostedUser bool
DynamicTimelineName bool
CommandsInNewPane bool
}
type Style struct {
@ -834,6 +836,8 @@ func parseGeneral(cfg GeneralTOML) General {
general.RedrawUI = NilDefaultBool(cfg.RedrawUI, def.RedrawUI)
general.StickToTop = NilDefaultBool(cfg.StickToTop, def.StickToTop)
general.ShowBoostedUser = NilDefaultBool(cfg.ShowBoostedUser, def.ShowBoostedUser)
general.DynamicTimelineName = NilDefaultBool(cfg.DynamicTimelineName, def.DynamicTimelineName)
general.CommandsInNewPane = NilDefaultBool(cfg.CommandsInNewPane, def.CommandsInNewPane)
lp := NilDefaultString(cfg.ListPlacement, def.ListPlacement)
switch lp {

9
config/default_config.go

@ -96,6 +96,15 @@ stick-to-top=false
# default=false
show-boosted-user=false
# Open a new pane when you run a command like :timeline home.
# default=true
commands-in-new-pane=true
# Set a default name for the timeline if the name is empty. So if you run :tag
# linux the title of the pane will be set to #linux
# default=true
dynamic-timeline-name=true
# 0 = No terminal title
# 1 = Show title in terminal and top bar
# 2 = Only show terminal title, and no top bar in tut

2
config/toml.go

@ -36,6 +36,8 @@ type GeneralTOML struct {
StickToTop *bool `toml:"stick-to-top"`
NotificationsToHide *[]string `toml:"notifications-to-hide"`
ShowBoostedUser *bool `toml:"show-boosted-user"`
DynamicTimelineName *bool `toml:"dynamic-timeline-name"`
CommandsInNewPane *bool `toml:"commands-in-new-pane"`
}
type TimelineTOML struct {

2
config/toml_default.go

@ -34,6 +34,8 @@ var ConfigDefault = ConfigTOML{
RedrawUI: bt,
StickToTop: bf,
ShowBoostedUser: bf,
DynamicTimelineName: bt,
CommandsInNewPane: bt,
ListPlacement: sp("left"),
ListSplit: sp("row"),
ListProportion: ip(1),

2
docs/man/tut.1

@ -14,7 +14,7 @@
. ftr VB CB
. ftr VBI CBI
.\}
.TH "tut" "1" "2023-01-07" "tut 2.0.0" ""
.TH "tut" "1" "2023-01-23" "tut 2.0.0" ""
.hy
.SH NAME
.PP

2
docs/man/tut.1.md

@ -1,6 +1,6 @@
% tut(1) tut 2.0.0
% Rasmus Lindroth
% 2023-01-07
% 2023-01-23
# NAME
tut - a Mastodon TUI

17
docs/man/tut.5

@ -14,7 +14,7 @@
. ftr VB CB
. ftr VBI CBI
.\}
.TH "tut" "5" "2023-01-07" "tut 2.0.0" ""
.TH "tut" "5" "2023-01-23" "tut 2.0.0" ""
.hy
.SH NAME
.PP
@ -203,6 +203,21 @@ that boosted.
.P
.PD
\f[B]show-boosted-user\f[R]=\f[I]false\f[R]
.SS commands-in-new-pane
.PP
Open a new pane when you run a command like :timeline home.
.PD 0
.P
.PD
\f[B]commands-in-new-pane\f[R]=\f[I]true\f[R]
.SS dynamic-timeline-name
.PP
Set a default name for the timeline if the name is empty.
So if you run :tag linux the title of the pane will be set to #linux
.PD 0
.P
.PD
\f[B]dynamic-timeline-name\f[R]=\f[I]true\f[R]
.SS terminal-title
.PP
0 = No terminal title

10
docs/man/tut.5.md

@ -1,6 +1,6 @@
% tut(5) tut 2.0.0
% Rasmus Lindroth
% 2023-01-07
% 2023-01-23
# NAME
tut - configuration for tut(1)
@ -113,6 +113,14 @@ Always jump to the newest post. May ruin your reading experience.
Display the username of the person being boosted insted of the person that boosted.
**show-boosted-user**=*false*
## commands-in-new-pane
Open a new pane when you run a command like :timeline home.
**commands-in-new-pane**=*true*
## dynamic-timeline-name
Set a default name for the timeline if the name is empty. So if you run :tag linux the title of the pane will be set to \#linux
**dynamic-timeline-name**=*true*
## terminal-title
0 = No terminal title
1 = Show title in terminal and top bar

2
docs/man/tut.7

@ -14,7 +14,7 @@
. ftr VB CB
. ftr VBI CBI
.\}
.TH "tut" "7" "2023-01-07" "tut 2.0.0" ""
.TH "tut" "7" "2023-01-23" "tut 2.0.0" ""
.hy
.SH NAME
.PP

2
docs/man/tut.7.md

@ -1,6 +1,6 @@
% tut(7) tut 2.0.0
% Rasmus Lindroth
% 2023-01-07
% 2023-01-23
# NAME
tut - keys and commands inside of tut(1)

2
ui/cmdbar.go

@ -249,7 +249,7 @@ func (c *CmdBar) DoneFunc(key tcell.Key) {
NewUserSearchFeed(c.tutView, config.NewTimeline(config.Timeline{
FeedType: config.UserList,
Subaction: user,
})),
})), c.tutView.tut.Config.General.CommandsInNewPane,
)
c.Back()
case ":refetch":

62
ui/commands.go

@ -34,7 +34,7 @@ func (tv *TutView) BlockingCommand() {
tv.Timeline.AddFeed(
NewBlocking(tv, config.NewTimeline(config.Timeline{
FeedType: config.Blocking,
})),
})), tv.tut.Config.General.CommandsInNewPane,
)
}
@ -42,41 +42,47 @@ func (tv *TutView) BookmarksCommand() {
tv.Timeline.AddFeed(
NewBookmarksFeed(tv, config.NewTimeline(config.Timeline{
FeedType: config.Saved,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) FavoritedCommand() {
tv.Timeline.AddFeed(
NewFavoritedFeed(tv, config.NewTimeline(config.Timeline{
FeedType: config.Favorited,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) MutingCommand() {
tv.Timeline.AddFeed(
NewMuting(tv, config.NewTimeline(config.Timeline{
FeedType: config.Muting,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) FollowRequestsCommand() {
tv.Timeline.AddFeed(
NewFollowRequests(tv, config.NewTimeline(config.Timeline{
FeedType: config.FollowRequests,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) LocalCommand() {
tv.Timeline.AddFeed(
NewLocalFeed(tv, config.NewTimeline(config.Timeline{
FeedType: config.TimelineLocal,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) FederatedCommand() {
tv.Timeline.AddFeed(
NewFederatedFeed(tv, config.NewTimeline(config.Timeline{
FeedType: config.TimelineFederated,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) SpecialCommand(hideBoosts, hideReplies bool) {
@ -85,42 +91,48 @@ func (tv *TutView) SpecialCommand(hideBoosts, hideReplies bool) {
FeedType: config.TimelineHomeSpecial,
HideBoosts: hideBoosts,
HideReplies: hideReplies,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) DirectCommand() {
tv.Timeline.AddFeed(
NewConversationsFeed(tv, config.NewTimeline(config.Timeline{
FeedType: config.Conversations,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) HomeCommand() {
tv.Timeline.AddFeed(
NewHomeFeed(tv, config.NewTimeline(config.Timeline{
FeedType: config.TimelineHome,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) NotificationsCommand() {
tv.Timeline.AddFeed(
NewNotificationFeed(tv, config.NewTimeline(config.Timeline{
FeedType: config.Notifications,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) MentionsCommand() {
tv.Timeline.AddFeed(
NewNotificatioMentionsFeed(tv, config.NewTimeline(config.Timeline{
FeedType: config.Mentions,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) ListsCommand() {
tv.Timeline.AddFeed(
NewListsFeed(tv, config.NewTimeline(config.Timeline{
FeedType: config.Lists,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) TagCommand(tag string) {
@ -128,14 +140,16 @@ func (tv *TutView) TagCommand(tag string) {
NewTagFeed(tv, config.NewTimeline(config.Timeline{
FeedType: config.Tag,
Subaction: tag,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) TagsCommand() {
tv.Timeline.AddFeed(
NewTagsFeed(tv, config.NewTimeline(config.Timeline{
FeedType: config.Tags,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) TagFollowCommand(tag string) {
@ -200,7 +214,8 @@ func (tv *TutView) BoostsCommand() {
FeedType: config.Boosts,
HideBoosts: false,
HideReplies: true,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) FavoritesCommand() {
@ -216,7 +231,8 @@ func (tv *TutView) FavoritesCommand() {
tv.Timeline.AddFeed(
NewFavoritesStatus(tv, s.ID, config.NewTimeline(config.Timeline{
FeedType: config.Favorites,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) FollowingCommand() {
@ -231,7 +247,8 @@ func (tv *TutView) FollowingCommand() {
tv.Timeline.AddFeed(
NewFollowing(tv, s.Data.ID, config.NewTimeline(config.Timeline{
FeedType: config.Following,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) FollowersCommand() {
@ -246,7 +263,8 @@ func (tv *TutView) FollowersCommand() {
tv.Timeline.AddFeed(
NewFollowers(tv, s.Data.ID, config.NewTimeline(config.Timeline{
FeedType: config.Followers,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) HistoryCommand() {
@ -260,7 +278,8 @@ func (tv *TutView) HistoryCommand() {
tv.Timeline.AddFeed(
NewHistoryFeed(tv, item, config.NewTimeline(config.Timeline{
FeedType: config.History,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) ProfileCommand() {
@ -272,7 +291,8 @@ func (tv *TutView) ProfileCommand() {
tv.Timeline.AddFeed(
NewUserFeed(tv, item, config.NewTimeline(config.Timeline{
FeedType: config.User,
})))
})),
tv.tut.Config.General.CommandsInNewPane)
}
func (tv *TutView) PreferencesCommand() {

25
ui/input.go

@ -235,14 +235,9 @@ func (tv *TutView) matchedTimeline(tl *config.Timeline) {
nf := CreateFeed(tv, tl)
switch tl.OnCreationClosed {
case config.TimelineCreationClosedCurrentPane:
tv.Timeline.AddFeed(nf)
tv.Timeline.AddFeed(nf, false)
case config.TimelineCreationClosedNewPane:
tv.Timeline.Feeds = append(tv.Timeline.Feeds, &FeedHolder{
Feeds: []*Feed{nf},
})
tv.FocusFeed(len(tv.Timeline.Feeds)-1, nil)
tv.Shared.Top.SetText(tv.Timeline.GetTitle())
tv.Timeline.update <- true
tv.Timeline.AddFeed(nf, true)
}
}
@ -556,7 +551,7 @@ func (tv *TutView) InputStatus(event *tcell.EventKey, item api.Item, status *mas
if tv.tut.Config.Input.StatusThread.Match(event.Key(), event.Rune()) {
tv.Timeline.AddFeed(NewThreadFeed(tv, item, config.NewTimeline(config.Timeline{
FeedType: config.Thread,
})))
})), false)
return nil
}
if tv.tut.Config.Input.StatusUser.Match(event.Key(), event.Rune()) {
@ -570,7 +565,7 @@ func (tv *TutView) InputStatus(event *tcell.EventKey, item api.Item, status *mas
}
tv.Timeline.AddFeed(NewUserFeed(tv, user, config.NewTimeline(config.Timeline{
FeedType: config.User,
})))
})), false)
return nil
}
if tv.tut.Config.Input.StatusViewFocus.Match(event.Key(), event.Rune()) {
@ -800,7 +795,7 @@ func (tv *TutView) InputUser(event *tcell.EventKey, user *api.User, ut InputUser
if tv.tut.Config.Input.UserUser.Match(event.Key(), event.Rune()) {
tv.Timeline.AddFeed(NewUserFeed(tv, api.NewUserItem(user, true), config.NewTimeline(config.Timeline{
FeedType: config.User,
})))
})), false)
return nil
}
if tv.tut.Config.Input.UserViewFocus.Match(event.Key(), event.Rune()) {
@ -814,7 +809,7 @@ func (tv *TutView) InputUser(event *tcell.EventKey, user *api.User, ut InputUser
if tv.tut.Config.Input.GlobalEnter.Match(event.Key(), event.Rune()) {
tv.Timeline.AddFeed(NewUserFeed(tv, api.NewUserItem(user, true), config.NewTimeline(config.Timeline{
FeedType: config.User,
})))
})), false)
return nil
}
return event
@ -825,19 +820,19 @@ func (tv *TutView) InputList(event *tcell.EventKey, list *mastodon.List) *tcell.
tv.tut.Config.Input.GlobalEnter.Match(event.Key(), event.Rune()) {
tv.Timeline.AddFeed(NewListFeed(tv, list, config.NewTimeline(config.Timeline{
FeedType: config.List,
})))
})), false)
return nil
}
if tv.tut.Config.Input.ListUserList.Match(event.Key(), event.Rune()) {
tv.Timeline.AddFeed(NewUsersInListFeed(tv, list, config.NewTimeline(config.Timeline{
FeedType: config.ListUsersIn,
})))
})), false)
return nil
}
if tv.tut.Config.Input.ListUserAdd.Match(event.Key(), event.Rune()) {
tv.Timeline.AddFeed(NewUsersAddListFeed(tv, list, config.NewTimeline(config.Timeline{
FeedType: config.ListUsersAdd,
})))
})), false)
return nil
}
return event
@ -849,7 +844,7 @@ func (tv *TutView) InputTag(event *tcell.EventKey, tag *mastodon.Tag) *tcell.Eve
tv.Timeline.AddFeed(NewTagFeed(tv, config.NewTimeline(config.Timeline{
FeedType: config.Tag,
Subaction: tag.Name,
})))
})), false)
return nil
}
if tv.tut.Config.Input.TagFollow.Match(event.Key(), event.Rune()) {

4
ui/linkview.go

@ -114,7 +114,7 @@ func (lv *LinkView) Open() {
NewUserFeed(lv.tutView, u, config.NewTimeline(config.Timeline{
FeedType: config.User,
}),
))
), false)
lv.tutView.FocusMainNoHistory()
return
}
@ -124,7 +124,7 @@ func (lv *LinkView) Open() {
NewTagFeed(lv.tutView, config.NewTimeline(config.Timeline{
FeedType: config.Tag,
Subaction: tags[tIndex].Name,
})))
})), false)
lv.tutView.FocusMainNoHistory()
return
}

83
ui/timeline.go

@ -93,10 +93,75 @@ func NewTimeline(tv *TutView, update chan bool) *Timeline {
return tl
}
func (tl *Timeline) AddFeed(f *Feed) {
fh := tl.Feeds[tl.FeedFocusIndex]
fh.Feeds = append(fh.Feeds, f)
fh.FeedIndex = fh.FeedIndex + 1
func (tl *Timeline) AddFeed(f *Feed, newPane bool) {
if f.Timeline.Name == "" && tl.tutView.tut.Config.General.DynamicTimelineName {
name := f.Data.Name()
switch f.Timeline.FeedType {
case config.Favorited:
f.Timeline.Name = "Favorited"
case config.Notifications:
f.Timeline.Name = "Notifications"
case config.Mentions:
f.Timeline.Name = "Mentions"
case config.Tag:
parts := strings.Split(name, " ")
for i, p := range parts {
parts[i] = fmt.Sprintf("#%s", p)
}
f.Timeline.Name = strings.Join(parts, " ")
case config.Thread:
f.Timeline.Name = "Thread"
case config.History:
f.Timeline.Name = "History"
case config.TimelineFederated:
f.Timeline.Name = "Federated"
case config.TimelineHome:
f.Timeline.Name = "Home"
case config.TimelineHomeSpecial:
f.Timeline.Name = "Special"
case config.TimelineLocal:
f.Timeline.Name = "Local"
case config.Saved:
f.Timeline.Name = "Bookmarked"
case config.User:
f.Timeline.Name = fmt.Sprintf("@%s", name)
case config.UserList:
f.Timeline.Name = fmt.Sprintf("Search %s", name)
case config.Conversations:
f.Timeline.Name = "Direct"
case config.Lists:
f.Timeline.Name = "Lists"
case config.List:
f.Timeline.Name = fmt.Sprintf("List %s", name)
case config.Boosts:
f.Timeline.Name = "Boosts"
case config.Favorites:
f.Timeline.Name = "Favorites"
case config.Followers:
f.Timeline.Name = "Followers"
case config.Following:
f.Timeline.Name = "Following"
case config.FollowRequests:
f.Timeline.Name = "Follow requests"
case config.Blocking:
f.Timeline.Name = "Blocking"
case config.ListUsersAdd:
f.Timeline.Name = fmt.Sprintf("Add users to %s", name)
case config.ListUsersIn:
f.Timeline.Name = fmt.Sprintf("Delete users from %s", name)
}
}
if newPane {
tl.Feeds = append(tl.Feeds, &FeedHolder{
Feeds: []*Feed{f},
})
tl.tutView.FocusFeed(len(tl.Feeds)-1, nil)
} else {
fh := tl.Feeds[tl.FeedFocusIndex]
fh.Feeds = append(fh.Feeds, f)
fh.FeedIndex = fh.FeedIndex + 1
}
tl.tutView.Shared.Top.SetText(tl.GetTitle())
tl.update <- true
}
@ -261,11 +326,11 @@ func (tl *Timeline) GetTitle() string {
for i, p := range parts {
parts[i] = fmt.Sprintf("#%s", p)
}
ct = fmt.Sprintf("tag %s", strings.Join(parts, " "))
ct = strings.Join(parts, " ")
case config.Thread:
ct = "thread feed"
ct = "thread"
case config.History:
ct = "history feed"
ct = "history"
case config.TimelineFederated:
ct = "federated"
case config.TimelineHome:
@ -275,7 +340,7 @@ func (tl *Timeline) GetTitle() string {
case config.TimelineLocal:
ct = "local"
case config.Saved:
ct = "saved/bookmarked toots"
ct = "bookmarked"
case config.User:
ct = fmt.Sprintf("user %s", name)
case config.UserList:
@ -285,7 +350,7 @@ func (tl *Timeline) GetTitle() string {
case config.Lists:
ct = "lists"
case config.List:
ct = fmt.Sprintf("list named %s", name)
ct = fmt.Sprintf("list %s", name)
case config.Boosts:
ct = "boosts"
case config.Favorites:

Loading…
Cancel
Save