Browse Source

42 (#110)

* optional redraw

* trim space from getsecret

* fix typo in ":timeline favorited" 

* update version
pull/118/head 0.0.42
Rasmus Lindroth 4 years ago committed by GitHub
parent
commit
1e3b1c38bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      cmdbar.go
  2. 8
      config.example.ini
  3. 10
      config.go
  4. 15
      feed.go
  5. 8
      go.mod
  6. 8
      go.sum
  7. 2
      main.go
  8. 2
      media.go
  9. 9
      ui.go
  10. 2
      util.go

2
cmdbar.go

@ -149,7 +149,7 @@ func (c *CmdBar) DoneFunc(key tcell.Key) {
c.app.UI.StatusView.AddFeed(NewNotificationFeed(c.app, false))
c.app.UI.SetFocus(LeftPaneFocus)
c.app.UI.CmdBar.ClearInput()
case "favrotied", "fav":
case "favorited", "fav":
c.app.UI.StatusView.AddFeed(NewNotificationFeed(c.app, false))
c.app.UI.SetFocus(LeftPaneFocus)
c.app.UI.CmdBar.ClearInput()

8
config.example.ini

@ -101,6 +101,14 @@ show-help=true
# default=false
short-hints=false
# If you don't want the whole UI to update, and only the text content you can
# set this option to true.
# This will lead to some artifacts being left on the screen when emojis are
# present. But it will keep the UI from flashing on every single toot in some
# terminals.
# default=true
redraw-ui=true
[media]
# Your image viewer
# default=xdg-open

10
config.go

@ -51,6 +51,7 @@ type GeneralConfig struct {
ContentProportion int
ShowIcons bool
ShowHelp bool
RedrawUI bool
}
type StyleConfig struct {
@ -296,6 +297,7 @@ func parseGeneral(cfg *ini.File) GeneralConfig {
general.HideNotificationText = cfg.Section("general").Key("hide-notification-text").MustBool(false)
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)
lp := cfg.Section("general").Key("list-placement").In("left", []string{"left", "right", "top", "bottom"})
switch lp {
@ -681,6 +683,14 @@ show-help=true
# default=false
short-hints=false
# If you don't want the whole UI to update, and only the text content you can
# set this option to true.
# This will lead to some artifacts being left on the screen when emojis are
# present. But it will keep the UI from flashing on every single toot in some
# terminals.
# default=true
redraw-ui=true
[media]
# Your image viewer
# default=xdg-open

15
feed.go

@ -736,9 +736,10 @@ func (t *TimelineFeed) DrawToot() {
t.index = t.app.UI.StatusView.GetCurrentItem()
text, controls := showTootOptions(t.app, t.statuses[t.index], t.showSpoiler)
t.showSpoiler = false
t.app.UI.StatusView.text.Clear()
t.app.UI.StatusView.SetText(text)
t.app.UI.StatusView.SetControls(controls)
t.app.UI.Root.Sync()
t.app.UI.ShouldSync()
}
func (t *TimelineFeed) RedrawControls() {
@ -875,7 +876,7 @@ func (t *ThreadFeed) DrawToot() {
t.showSpoiler = false
t.app.UI.StatusView.SetText(text)
t.app.UI.StatusView.SetControls(controls)
t.app.UI.Root.Sync()
t.app.UI.ShouldSync()
}
func (t *ThreadFeed) RedrawControls() {
@ -1072,7 +1073,7 @@ func (u *UserFeed) DrawToot() {
u.app.UI.StatusView.SetText(text)
u.app.UI.StatusView.SetControls(controls)
u.app.UI.Root.Sync()
u.app.UI.ShouldSync()
}
func (u *UserFeed) RedrawControls() {
@ -1372,7 +1373,7 @@ func (n *NotificationsFeed) DrawToot() {
n.app.UI.StatusView.SetText(text)
n.app.UI.StatusView.SetControls(controls)
n.app.UI.Root.Sync()
n.app.UI.ShouldSync()
}
func (n *NotificationsFeed) RedrawControls() {
@ -1573,7 +1574,7 @@ func (t *TagFeed) DrawToot() {
t.showSpoiler = false
t.app.UI.StatusView.SetText(text)
t.app.UI.StatusView.SetControls(controls)
t.app.UI.Root.Sync()
t.app.UI.ShouldSync()
}
func (t *TagFeed) RedrawControls() {
@ -1784,7 +1785,7 @@ func (u *UserListFeed) DrawToot() {
u.app.UI.StatusView.SetText(text)
u.app.UI.StatusView.SetControls(controls)
u.app.UI.Root.Sync()
u.app.UI.ShouldSync()
}
func (u *UserListFeed) GetSavedIndex() int {
@ -1898,7 +1899,7 @@ func (l *ListFeed) DrawToot() {
l.app.UI.StatusView.SetText(text)
l.app.UI.StatusView.SetControls("")
l.app.UI.Root.Sync()
l.app.UI.ShouldSync()
}
func (l *ListFeed) GetSavedIndex() int {

8
go.mod

@ -13,11 +13,11 @@ require (
github.com/mattn/go-mastodon v0.0.5-0.20211104150201-58c389181352
github.com/microcosm-cc/bluemonday v1.0.16
github.com/pelletier/go-toml/v2 v2.0.0-beta.4
github.com/rivo/tview v0.0.0-20211109175620-badfa0f0b301
github.com/rivo/tview v0.0.0-20211202162923-2a6de950f73b
github.com/rivo/uniseg v0.2.0
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1 // indirect
golang.org/x/net v0.0.0-20211203184738-4852103109b8
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/ini.v1 v1.64.0
gopkg.in/ini.v1 v1.66.2
)

8
go.sum

@ -257,6 +257,8 @@ github.com/rivo/tview v0.0.0-20211029142923-a4acb08f513e h1:dVBzRaVTERZmv0MRjt8/
github.com/rivo/tview v0.0.0-20211029142923-a4acb08f513e/go.mod h1:WIfMkQNY+oq/mWwtsjOYHIZBuwthioY2srOmljJkTnk=
github.com/rivo/tview v0.0.0-20211109175620-badfa0f0b301 h1:FbY5ESMtIcvCyBUQyI9QJUZFe3JtVfTUzBzG1CjrCDY=
github.com/rivo/tview v0.0.0-20211109175620-badfa0f0b301/go.mod h1:WIfMkQNY+oq/mWwtsjOYHIZBuwthioY2srOmljJkTnk=
github.com/rivo/tview v0.0.0-20211202162923-2a6de950f73b h1:EMgbQ+bOHWkl0Ptano8M0yrzVZkxans+Vfv7ox/EtO8=
github.com/rivo/tview v0.0.0-20211202162923-2a6de950f73b/go.mod h1:WIfMkQNY+oq/mWwtsjOYHIZBuwthioY2srOmljJkTnk=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
@ -395,6 +397,8 @@ golang.org/x/net v0.0.0-20211101193420-4a448f8816b3 h1:VrJZAjbekhoRn7n5FBujY31gb
golang.org/x/net v0.0.0-20211101193420-4a448f8816b3/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 h1:DZshvxDdVoeKIbudAdFEKi+f70l51luSy/7b76ibTY0=
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211203184738-4852103109b8 h1:PFkPt/jI9Del3hmFplBtRp8tDhSRpFu7CyRs7VmEC0M=
golang.org/x/net v0.0.0-20211203184738-4852103109b8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@ -472,6 +476,8 @@ golang.org/x/sys v0.0.0-20211103235746-7861aae1554b h1:1VkfZQv42XQlA/jchYumAnv1U
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1 h1:kwrAHlwJ0DUBZwQ238v+Uod/3eZ8B2K5rYsUHBQvzmI=
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 h1:TyHqChC80pFkXWraUUf6RuB5IqFdQieMLwwCJokV2pc=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/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=
@ -656,6 +662,8 @@ gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c=
gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.64.0 h1:Mj2zXEXcNb5joEiSA0zc3HZpTst/iyjNiR4CN8tDzOg=
gopkg.in/ini.v1 v1.64.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI=
gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

2
main.go

@ -9,7 +9,7 @@ import (
"github.com/gdamore/tcell/v2"
)
const version string = "0.0.41"
const version string = "0.0.42"
func main() {
newUser := false

2
media.go

@ -98,7 +98,7 @@ func (m *MediaView) Draw() {
items = append(items, ColorKey(m.app.Config, "", "E", "dit desc"))
items = append(items, ColorKey(m.app.Config, "", "Esc", " Done"))
m.TextBottom.SetText(strings.Join(items, " "))
m.app.UI.Root.Sync()
m.app.UI.ShouldSync()
}
func (m *MediaView) SetFocus(f MediaFocus) {

9
ui.go

@ -368,7 +368,7 @@ func (ui *UI) OpenMedia(status *mastodon.Status) {
}
openMediaType(ui.Root, ui.app.Config.Media, files, key)
ui.app.FileList = append(ui.app.FileList, files...)
ui.Root.Sync()
ui.ShouldSync()
}
}
@ -539,3 +539,10 @@ func (conf *Config) ClearContent(screen tcell.Screen, x int, y int, width int, h
screen.SetContent(x+width, y+height, tview.BoxDrawingsLightUpAndLeft, nil, tcell.StyleDefault.Foreground(conf.Style.Subtle))
return x + 1, y + 1, width - 1, height - 1
}
func (ui *UI) ShouldSync() {
if !ui.app.Config.General.RedrawUI {
return
}
ui.app.UI.Root.Sync()
}

2
util.go

@ -33,7 +33,7 @@ func CmdToString(cmd string) (string, error) {
cmd = strings.TrimPrefix(cmd, "!CMD!")
parts := strings.Split(cmd, " ")
s, err := exec.Command(parts[0], parts[1:]...).CombinedOutput()
return string(s), err
return strings.TrimSpace(string(s)), err
}
func getURLs(text string) []URL {

Loading…
Cancel
Save