Browse Source

1.0.10 (#151)

* clean files on exit

* update version

* update README

* exit user select

* update help

* add list-placement and list-split from tut

* add proportions

* update example config

* upgrade packages
pull/156/head 1.0.10
Rasmus Lindroth 4 years ago committed by GitHub
parent
commit
784e13dd4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      README.md
  2. 18
      config.example.ini
  3. 12
      config/config.go
  4. 18
      config/default_config.go
  5. 14
      config/help.tmpl
  6. 10
      go.mod
  7. 20
      go.sum
  8. 7
      main.go
  9. 50
      ui/cmdbar.go
  10. 27
      ui/commands.go
  11. 29
      ui/input.go
  12. 12
      ui/mainview.go
  13. 1
      ui/media.go
  14. 5
      ui/timeline.go
  15. 12
      ui/tutview.go

3
README.md

@ -37,9 +37,12 @@ You can find Linux binaries under [releases](https://github.com/RasmusLindroth/t
* `:favorites` lists users that favorited the toot
* `:h` `:help` view help
* `:lists` show a list of your lists
* `:list-placement` top, right, bottom, left
* `:list-split` row, column
* `:muting` lists users that you have muted
* `:preferences` update your profile and some other settings
* `:profile` go to your profile
* `:proportions` [int] [int], where the first integer is the list and the other content, e.g. `:proportions 1 3`
* `:requests` see following requests
* `:saved` alias for bookmarks
* `:tag` followed by the hashtag e.g. `:tag linux`

18
config.example.ini

@ -137,16 +137,23 @@ leader-timeout=1000
#
# Available commands: home, direct, local, federated, compose, blocking,
# bookmarks, saved, favorited, boosts, favorites, following, followers, muting,
# preferences, profile, notifications, lists, tag, window
# preferences, profile, notifications, lists, tag, window, list-placement,
# list-split, proportions
#
# The shortcuts are up to you, but keep them quite short and make sure they
# don't collide. If you have one shortcut that is "f" and an other one that is
# "fav", the one with "f" will always run and "fav" will never run. Tag is
# special as you need to add the tag after, see the example below.
# "fav", the one with "f" will always run and "fav" will never run.
#
# Window is also special as it's a shortcut for switching between the timelines
# Some special leaders:
# tag is special as you need to add the tag after, e.g. tag linux
# window is special as it's a shortcut for switching between the timelines
# you've set under general and they are zero indexed. window 0 = your first
# timeline, window 1 = your second and so on.
# list-placement as it takes the argument top, right, bottom or left
# list-split as it takes the argument column or row
# proportions takes the arguments [int] [int], where the first integer is the
# list and the other content, e.g. proportions 1 3. See list-proportion above
# for more information.
#
# Some examples:
# leader-action=local,lo
@ -155,6 +162,9 @@ leader-timeout=1000
# leader-action=direct,d
# leader-action=tag linux,tl
# leader-action=window 0,h
# leader-action=list-placement bottom,b
# leader-action=list-split column,c
# leader-action=proportions 1 3,3
#

12
config/config.go

@ -64,9 +64,12 @@ const (
LeaderFavorites
LeaderFollowing
LeaderFollowers
LeaderListPlacement
LeaderListSplit
LeaderMuting
LeaderPreferences
LeaderProfile
LeaderProportions
LeaderNotifications
LeaderLists
LeaderTag
@ -681,6 +684,15 @@ func parseGeneral(cfg *ini.File) General {
case "tag":
la.Command = LeaderTag
la.Subaction = subaction
case "list-placement":
la.Command = LeaderListPlacement
la.Subaction = subaction
case "list-split":
la.Command = LeaderListSplit
la.Subaction = subaction
case "proportions":
la.Command = LeaderProportions
la.Subaction = subaction
case "window":
la.Command = LeaderWindow
la.Subaction = subaction

18
config/default_config.go

@ -139,16 +139,23 @@ leader-timeout=1000
#
# Available commands: home, direct, local, federated, compose, blocking,
# bookmarks, saved, favorited, boosts, favorites, following, followers, muting,
# preferences, profile, notifications, lists, tag, window
# preferences, profile, notifications, lists, tag, window, list-placement,
# list-split, proportions
#
# The shortcuts are up to you, but keep them quite short and make sure they
# don't collide. If you have one shortcut that is "f" and an other one that is
# "fav", the one with "f" will always run and "fav" will never run. Tag is
# special as you need to add the tag after, see the example below.
# "fav", the one with "f" will always run and "fav" will never run.
#
# Window is also special as it's a shortcut for switching between the timelines
# Some special leaders:
# tag is special as you need to add the tag after, e.g. tag linux
# window is special as it's a shortcut for switching between the timelines
# you've set under general and they are zero indexed. window 0 = your first
# timeline, window 1 = your second and so on.
# list-placement as it takes the argument top, right, bottom or left
# list-split as it takes the argument column or row
# proportions takes the arguments [int] [int], where the first integer is the
# list and the other content, e.g. proportions 1 3. See list-proportion above
# for more information.
#
# Some examples:
# leader-action=local,lo
@ -157,6 +164,9 @@ leader-timeout=1000
# leader-action=direct,d
# leader-action=tag linux,tl
# leader-action=window 0,h
# leader-action=list-placement bottom,b
# leader-action=list-split column,c
# leader-action=proportions 1 3,3
#

14
config/help.tmpl

@ -61,12 +61,24 @@ Here's a list of supported commands.
{{ Color .Style.TextSpecial2 }}{{ Flags "b" }}:lists{{ Flags "-" }}{{ Color .Style.Text }}
Show a list of your lists
{{ Color .Style.TextSpecial2 }}{{ Flags "b" }}:list-placement{{ Flags "-" }}{{ Color .Style.Text }} top|right|bottom|left
Place the lists where you want them
{{ Color .Style.TextSpecial2 }}{{ Flags "b" }}:list-split{{ Flags "-" }}{{ Color .Style.Text }} row|column
Split lists as rows or columns
{{ Color .Style.TextSpecial2 }}{{ Flags "b" }}:muting{{ Flags "-" }}{{ Color .Style.Text }}
lists users that you have muted
Lists users that you have muted
{{ Color .Style.TextSpecial2 }}{{ Flags "b" }}:preferences{{ Flags "-" }}{{ Color .Style.Text }}
Update your profile and some other settings
{{ Color .Style.TextSpecial2 }}{{ Flags "b" }}:profile{{ Flags "-" }}{{ Color .Style.Text }}
Go to your own profile
{{ Color .Style.TextSpecial2 }}{{ Flags "b" }}:proportions{{ Flags "-" }}{{ Color .Style.Text }} [int] [int]
Set proportions for list and content with an int. First list proportion then content proportion
{{ Color .Style.TextSpecial2 }}{{ Flags "b" }}:requests{{ Flags "-" }}{{ Color .Style.Text }}
See following requests

10
go.mod

@ -6,14 +6,14 @@ require (
github.com/RasmusLindroth/go-mastodon v0.0.7
github.com/atotto/clipboard v0.1.4
github.com/gdamore/tcell/v2 v2.5.1
github.com/gen2brain/beeep v0.0.0-20220402123239-6a3042f4b71a
github.com/gen2brain/beeep v0.0.0-20220518085355-d7852edf42fc
github.com/gobwas/glob v0.2.3
github.com/icza/gox v0.0.0-20220321141217-e2d488ab2fbc
github.com/microcosm-cc/bluemonday v1.0.18
github.com/pelletier/go-toml/v2 v2.0.0-beta.8
github.com/pelletier/go-toml/v2 v2.0.1
github.com/rivo/tview v0.0.0-20220307222120-9994674d60a8
github.com/rivo/uniseg v0.2.0
golang.org/x/net v0.0.0-20210614182718-04defd469f4e
golang.org/x/net v0.0.0-20220526153639-5463443f8c37
gopkg.in/ini.v1 v1.66.4
)
@ -29,7 +29,7 @@ require (
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
golang.org/x/text v0.3.7 // indirect
)

20
go.sum

@ -11,8 +11,8 @@ github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo
github.com/gdamore/tcell/v2 v2.4.1-0.20210905002822-f057f0a857a1/go.mod h1:Az6Jt+M5idSED2YPGtwnfJV0kXohgdCBPmHGSYc1r04=
github.com/gdamore/tcell/v2 v2.5.1 h1:zc3LPdpK184lBW7syF2a5C6MV827KmErk9jGVnmsl/I=
github.com/gdamore/tcell/v2 v2.5.1/go.mod h1:wSkrPaXoiIWZqW/g7Px4xc79di6FTcpB8tvaKJ6uGBo=
github.com/gen2brain/beeep v0.0.0-20220402123239-6a3042f4b71a h1:fwNLHrP5Rbg/mGSXCjtPdpbqv2GucVTA/KMi8wEm6mE=
github.com/gen2brain/beeep v0.0.0-20220402123239-6a3042f4b71a/go.mod h1:/WeFVhhxMOGypVKS0w8DUJxUBbHypnWkUVnW7p5c9Pw=
github.com/gen2brain/beeep v0.0.0-20220518085355-d7852edf42fc h1:6ZZLxG+lB+Qbg+chtzAEeetwqjlPnY0BXbhL3lQWYOg=
github.com/gen2brain/beeep v0.0.0-20220518085355-d7852edf42fc/go.mod h1:/WeFVhhxMOGypVKS0w8DUJxUBbHypnWkUVnW7p5c9Pw=
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/OqtnntR4DfOY2+BgwR60cAcu/i3SE=
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
@ -33,8 +33,8 @@ github.com/microcosm-cc/bluemonday v1.0.18 h1:6HcxvXDAi3ARt3slx6nTesbvorIc3QeTzB
github.com/microcosm-cc/bluemonday v1.0.18/go.mod h1:Z0r70sCuXHig8YpBzCc5eGHAap2K7e/u082ZUpDRRqM=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
github.com/pelletier/go-toml/v2 v2.0.0-beta.8 h1:dy81yyLYJDwMTifq24Oi/IslOslRrDSb3jwDggjz3Z0=
github.com/pelletier/go-toml/v2 v2.0.0-beta.8/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU=
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/tview v0.0.0-20220307222120-9994674d60a8 h1:xe+mmCnDN82KhC010l3NfYlA8ZbOuzbXAzSYBa6wbMc=
@ -48,21 +48,23 @@ github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG0
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o=
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y=
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220526153639-5463443f8c37 h1:lUkvobShwKsOesNfWWlCS5q7fnbG1MEliIzwu886fn8=
golang.org/x/net v0.0.0-20220526153639-5463443f8c37/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220318055525-2edf467146b5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 h1:EH1Deb8WZJ0xc0WK//leUHXcX9aLE5SymusoTmMZye8=
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 h1:CBpWXWQpIRjzmkkA+M7q9Fqnwd2mZr3AFqexg8YTfoM=
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=

7
main.go

@ -1,8 +1,6 @@
package main
import (
"os"
"github.com/RasmusLindroth/tut/auth"
"github.com/RasmusLindroth/tut/config"
"github.com/RasmusLindroth/tut/ui"
@ -10,7 +8,7 @@ import (
"github.com/rivo/tview"
)
const version = "1.0.9"
const version = "1.0.10"
func main() {
util.MakeDirs()
@ -40,7 +38,4 @@ func main() {
if err := app.SetRoot(main.View, true).Run(); err != nil {
panic(err)
}
for _, f := range main.FileList {
os.Remove(f)
}
}

50
ui/cmdbar.go

@ -3,6 +3,7 @@ package ui
import (
"strings"
"github.com/RasmusLindroth/tut/config"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
@ -20,10 +21,6 @@ func NewCmdBar(tv *TutView) *CmdBar {
c.View.SetAutocompleteFunc(c.Autocomplete)
c.View.SetDoneFunc(c.DoneFunc)
if tv.tut.Config.General.ShowHelp {
c.ShowMsg("Press ? or :help to learn how tut functions")
}
return c
}
@ -91,12 +88,48 @@ func (c *CmdBar) DoneFunc(key tcell.Key) {
case ":followers":
c.tutView.FollowersCommand()
c.Back()
case ":list-placement":
if len(parts) < 2 {
break
}
switch parts[1] {
case "top":
c.tutView.ListPlacementCommand(config.ListPlacementTop)
c.Back()
case "right":
c.tutView.ListPlacementCommand(config.ListPlacementRight)
c.Back()
case "bottom":
c.tutView.ListPlacementCommand(config.ListPlacementBottom)
c.Back()
case "left":
c.tutView.ListPlacementCommand(config.ListPlacementLeft)
c.Back()
}
case ":list-split":
if len(parts) < 2 {
break
}
switch parts[1] {
case "column":
c.tutView.ListSplitCommand(config.ListColumn)
c.Back()
case "row":
c.tutView.ListSplitCommand(config.ListRow)
c.Back()
}
case ":muting":
c.tutView.MutingCommand()
c.Back()
case ":requests":
c.tutView.FollowRequestsCommand()
c.Back()
case ":proportions":
if len(parts) < 3 {
break
}
c.tutView.ProportionsCommand(parts[1], parts[2])
c.Back()
case ":profile":
c.tutView.ProfileCommand()
c.Back()
@ -128,7 +161,6 @@ func (c *CmdBar) DoneFunc(key tcell.Key) {
c.tutView.FavoritedCommand()
c.Back()
}
c.ClearInput()
case ":tag":
if len(parts) < 2 {
break
@ -170,7 +202,7 @@ func (c *CmdBar) DoneFunc(key tcell.Key) {
func (c *CmdBar) Autocomplete(curr string) []string {
var entries []string
words := strings.Split(":blocking,:boosts,:bookmarks,:compose,:favorites,:favorited,:followers,:following,:help,:h,:lists,:muting,:preferences,:profile,:requests,:saved,:tag,:timeline,:tl,:user,:window,:quit,:q", ",")
words := strings.Split(":blocking,:boosts,:bookmarks,:compose,:favorites,:favorited,:followers,:following,:help,:h,:lists,:list-placement,:list-split,:muting,:preferences,:profile,:proportions,:requests,:saved,:tag,:timeline,:tl,:user,:window,:quit,:q", ",")
if curr == "" {
return entries
}
@ -181,6 +213,12 @@ func (c *CmdBar) Autocomplete(curr string) []string {
if len(curr) > 8 && curr[:9] == ":timeline" {
words = strings.Split(":timeline home,:timeline notifications,:timeline local,:timeline federated,:timeline direct,:timeline favorited", ",")
}
if len(curr) > 14 && curr[:15] == ":list-placement" {
words = strings.Split(":list-placement top,:list-placement right,:list-placement bottom,:list-placement left", ",")
}
if len(curr) > 10 && curr[:11] == ":list-split" {
words = strings.Split(":list-split row,:list-split column", ",")
}
for _, word := range words {
if strings.HasPrefix(strings.ToLower(word), strings.ToLower(curr)) {

27
ui/commands.go

@ -6,6 +6,7 @@ import (
"github.com/RasmusLindroth/go-mastodon"
"github.com/RasmusLindroth/tut/api"
"github.com/RasmusLindroth/tut/config"
"github.com/RasmusLindroth/tut/util"
)
@ -167,3 +168,29 @@ func (tv *TutView) ProfileCommand() {
func (tv *TutView) PreferencesCommand() {
tv.SetPage(PreferenceFocus)
}
func (tv *TutView) ListPlacementCommand(lp config.ListPlacement) {
tv.tut.Config.General.ListPlacement = lp
tv.MainView.ForceUpdate()
}
func (tv *TutView) ListSplitCommand(ls config.ListSplit) {
tv.tut.Config.General.ListSplit = ls
tv.MainView.ForceUpdate()
}
func (tv *TutView) ProportionsCommand(lp string, cp string) {
lpi, err := strconv.Atoi(lp)
if err != nil {
tv.ShowError(fmt.Sprintf("Couldn't parse list proportion. Error: %v\n", err))
return
}
cpi, err := strconv.Atoi(cp)
if err != nil {
tv.ShowError(fmt.Sprintf("Couldn't parse content proportion. Error: %v\n", err))
return
}
tv.tut.Config.General.ListProportion = lpi
tv.tut.Config.General.ContentProportion = cpi
tv.MainView.ForceUpdate()
}

29
ui/input.go

@ -3,6 +3,7 @@ package ui
import (
"fmt"
"strconv"
"strings"
"github.com/RasmusLindroth/go-mastodon"
"github.com/RasmusLindroth/tut/api"
@ -70,6 +71,11 @@ func (tv *TutView) InputLoginView(event *tcell.EventKey) *tcell.EventKey {
tv.LoginView.Selected()
return nil
}
if tv.tut.Config.Input.GlobalExit.Match(event.Key(), event.Rune()) {
tv.tut.App.Stop()
tv.CleanExit(0)
return nil
}
return event
}
@ -136,6 +142,29 @@ func (tv *TutView) InputLeaderKey(event *tcell.EventKey) *tcell.EventKey {
tv.TagCommand(subaction)
case config.LeaderWindow:
tv.WindowCommand(subaction)
case config.LeaderListPlacement:
switch subaction {
case "top":
tv.ListPlacementCommand(config.ListPlacementTop)
case "right":
tv.ListPlacementCommand(config.ListPlacementRight)
case "bottom":
tv.ListPlacementCommand(config.ListPlacementBottom)
case "left":
tv.ListPlacementCommand(config.ListPlacementLeft)
}
case config.LeaderListSplit:
switch subaction {
case "row":
tv.ListSplitCommand(config.ListRow)
case "column":
tv.ListSplitCommand(config.ListColumn)
}
case config.LeaderProportions:
parts := strings.Split(subaction, " ")
if len(parts) == 2 {
tv.ProportionsCommand(parts[0], parts[1])
}
}
tv.Leader.ResetInactive()
return nil

12
ui/mainview.go

@ -6,15 +6,17 @@ import (
)
type MainView struct {
View *tview.Flex
View *tview.Flex
update chan bool
}
func NewMainView(tv *TutView, update chan bool) *MainView {
mv := &MainView{
View: mainViewUI(tv),
View: mainViewUI(tv),
update: update,
}
go func() {
for range update {
for range mv.update {
tv.tut.App.QueueUpdateDraw(func() {
*tv.MainView.View = *mainViewUI(tv)
tv.ShouldSync()
@ -24,6 +26,10 @@ func NewMainView(tv *TutView, update chan bool) *MainView {
return mv
}
func (mv *MainView) ForceUpdate() {
mv.update <- true
}
func feedList(mv *TutView, fh *FeedHolder) *tview.Flex {
iw := 3
if !mv.tut.Config.General.ShowIcons {

1
ui/media.go

@ -40,6 +40,7 @@ func openAvatar(tv *TutView, user mastodon.Account) {
)
return
}
tv.FileList = append(tv.FileList, f)
openMediaType(tv, []string{f}, "image")
}

5
ui/timeline.go

@ -2,7 +2,6 @@ package ui
import (
"fmt"
"os"
"github.com/RasmusLindroth/tut/feed"
)
@ -49,7 +48,7 @@ func NewTimeline(tv *TutView, update chan bool) *Timeline {
nf = NewTagFeed(tv, f.Subaction)
default:
fmt.Println("Invalid feed")
os.Exit(1)
tl.tutView.CleanExit(1)
}
tl.Feeds = append(tl.Feeds, &FeedHolder{
Feeds: []*Feed{nf},
@ -79,7 +78,7 @@ func (tl *Timeline) RemoveCurrent(quit bool) bool {
}
if len(tl.Feeds[tl.FeedFocusIndex].Feeds) == 1 && quit {
tl.tutView.tut.App.Stop()
os.Exit(0)
tl.tutView.CleanExit(0)
}
f := tl.Feeds[tl.FeedFocusIndex]

12
ui/tutview.go

@ -58,6 +58,13 @@ type TutView struct {
FileList []string
}
func (tv *TutView) CleanExit(code int) {
for _, f := range tv.FileList {
os.Remove(f)
}
os.Exit(code)
}
func NewLeader(tv *TutView) *Leader {
return &Leader{
tv: tv,
@ -140,12 +147,15 @@ func (tv *TutView) loggedIn(acc auth.Account) {
ClientSecret: acc.ClientSecret,
AccessToken: acc.AccessToken,
}
if tv.tut.Config.General.ShowHelp {
tv.Shared.Bottom.Cmd.ShowMsg("Press ? or :help to learn how tut functions")
}
client := mastodon.NewClient(conf)
me, err := client.GetAccountCurrentUser(context.Background())
if err != nil {
fmt.Printf("Couldn't login. Error %s\n", err)
tv.tut.App.Stop()
os.Exit(1)
tv.CleanExit(1)
}
filters, _ := client.GetFilters(context.Background())
ac := &api.AccountClient{

Loading…
Cancel
Save