Browse Source

34 (#88)

* Store all links if they are not mentions

* smarter auto complete

* allow keys from view

* force redraw

* update version

Co-authored-by: davidoskky <davidoskky@yahoo.it>
remotes/origin/35 0.0.34
Rasmus Lindroth 5 years ago committed by GitHub
parent
commit
a9d2ef3149
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      feed.go
  2. 22
      linkoverlay.go
  3. 7
      main.go
  4. 36
      media.go
  5. 1
      messagebox.go
  6. 16
      statusview.go
  7. 4
      util.go

8
feed.go

@ -17,7 +17,6 @@ const (
ThreadFeedType
UserFeedType
UserListFeedType
UserSearchFeedType
NotificationFeedType
TagFeedType
ListFeedType
@ -633,6 +632,7 @@ func (t *TimelineFeed) DrawToot() {
t.showSpoiler = false
t.app.UI.StatusView.SetText(text)
t.app.UI.StatusView.SetControls(controls)
t.app.UI.Root.Sync()
}
func (t *TimelineFeed) RedrawControls() {
@ -754,6 +754,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()
}
func (t *ThreadFeed) RedrawControls() {
@ -935,6 +936,7 @@ func (u *UserFeed) DrawToot() {
u.app.UI.StatusView.SetText(text)
u.app.UI.StatusView.SetControls(controls)
u.app.UI.Root.Sync()
}
func (u *UserFeed) RedrawControls() {
@ -1210,6 +1212,7 @@ func (n *NotificationsFeed) DrawToot() {
n.app.UI.StatusView.SetText(text)
n.app.UI.StatusView.SetControls(controls)
n.app.UI.Root.Sync()
}
func (n *NotificationsFeed) RedrawControls() {
@ -1388,6 +1391,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()
}
func (t *TagFeed) RedrawControls() {
@ -1583,6 +1587,7 @@ func (u *UserListFeed) DrawToot() {
u.app.UI.StatusView.SetText(text)
u.app.UI.StatusView.SetControls(controls)
u.app.UI.Root.Sync()
}
func (u *UserListFeed) GetSavedIndex() int {
@ -1693,6 +1698,7 @@ func (l *ListFeed) DrawToot() {
l.app.UI.StatusView.SetText(text)
l.app.UI.StatusView.SetControls("")
l.app.UI.Root.Sync()
}
func (l *ListFeed) GetSavedIndex() int {

22
linkoverlay.go

@ -48,20 +48,38 @@ type LinkOverlay struct {
}
func (l *LinkOverlay) SetLinks(urls []URL, status *mastodon.Status) {
realUrls := []URL{}
l.urls = []URL{}
l.mentions = []mastodon.Mention{}
l.tags = []mastodon.Tag{}
if urls != nil {
l.urls = urls
if status != nil {
for _, url := range urls {
isNotMention := true
for _, mention := range status.Mentions {
if mention.URL == url.URL {
isNotMention = false
}
}
if isNotMention {
realUrls = append(realUrls, url)
}
}
} else {
realUrls = urls
}
l.urls = realUrls
}
if status != nil {
l.mentions = status.Mentions
l.tags = status.Tags
}
l.List.Clear()
for _, url := range urls {
for _, url := range realUrls {
l.List.AddItem(url.Text, "", 0, nil)
}
for _, mention := range l.mentions {

7
main.go

@ -9,7 +9,7 @@ import (
"github.com/gdamore/tcell/v2"
)
const version string = "0.0.33"
const version string = "0.0.34"
func main() {
newUser := false
@ -261,7 +261,10 @@ func main() {
return nil
}
switch event.Key() {
case tcell.KeyTab, tcell.KeyDown:
case tcell.KeyTAB:
app.UI.MediaOverlay.InputField.AutocompleteTab()
return nil
case tcell.KeyDown:
app.UI.MediaOverlay.InputField.AutocompleteNext()
return nil
case tcell.KeyBacktab, tcell.KeyUp:

36
media.go

@ -98,6 +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()
}
func (m *MediaView) SetFocus(f MediaFocus) {
@ -170,15 +171,16 @@ func (m *MediaView) EditDesc() {
type MediaInput struct {
app *App
View *tview.InputField
text string
autocompleteIndex int
autocompleteList []string
originalText string
isAutocompleteChange bool
}
func (m *MediaInput) AddRune(r rune) {
newText := m.View.GetText() + string(r)
m.View.SetText(newText)
m.text = newText
m.View.SetText(m.text)
m.saveAutocompleteState()
}
@ -192,7 +194,7 @@ func (m *MediaInput) HandleChanges(text string) {
func (m *MediaInput) saveAutocompleteState() {
text := m.View.GetText()
m.originalText = text
m.text = text
m.autocompleteList = FindFiles(text)
m.autocompleteIndex = 0
}
@ -209,6 +211,34 @@ func (m *MediaInput) AutocompletePrev() {
m.showAutocomplete()
}
func (m *MediaInput) AutocompleteTab() {
if len(m.autocompleteList) == 0 {
return
}
same := ""
for i := 0; i < len(m.autocompleteList[0]); i++ {
match := true
c := m.autocompleteList[0][i]
for _, item := range m.autocompleteList {
if i >= len(item) || c != item[i] {
match = false
break
}
}
if !match {
break
}
same += string(c)
}
if same != m.text {
m.text = same
m.View.SetText(same)
m.saveAutocompleteState()
} else {
m.AutocompleteNext()
}
}
func (m *MediaInput) AutocompleteNext() {
if len(m.autocompleteList) == 0 {
return

1
messagebox.go

@ -228,6 +228,7 @@ func (m *MessageBox) Draw() {
m.View.ScrollToEnd()
m.maxIndex, _ = m.View.GetScrollOffset()
m.View.ScrollTo(m.Index, 0)
m.app.UI.Root.Sync()
}
func (m *MessageBox) EditText() {

16
statusview.go

@ -256,10 +256,22 @@ func (t *StatusView) inputBoth(event *tcell.EventKey) {
t.end()
}
}
if len(t.feeds) > 0 && t.focus == LeftPaneFocus {
allowedLeft := t.lastList == LeftPaneFocus || t.focus == LeftPaneFocus
allowedNotification := t.lastList == NotificationPaneFocus || t.focus == NotificationPaneFocus
if t.focus == RightPaneFocus {
switch event.Rune() {
case 'g', 'G', 'j', 'k', 'h', 'l', 'q', 'Q':
allowedLeft = false
}
switch event.Key() {
case tcell.KeyEsc:
allowedLeft = false
}
}
if len(t.feeds) > 0 && allowedLeft {
feed := t.feeds[t.feedIndex]
feed.Input(event)
} else if t.focus == NotificationPaneFocus {
} else if allowedNotification {
t.notificationView.feed.Input(event)
}
}

4
util.go

@ -58,8 +58,8 @@ func getURLs(text string) []URL {
url.Text = a.Val
case "class":
url.Classes = strings.Split(a.Val, " ")
if strings.Contains(a.Val, "hashtag") ||
strings.Contains(a.Val, "mention") {
if strings.Contains(a.Val, "hashtag") {
appendUrl = false
}
}

Loading…
Cancel
Save