diff --git a/feed.go b/feed.go index 4f9b49f..a5e6683 100644 --- a/feed.go +++ b/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 { diff --git a/linkoverlay.go b/linkoverlay.go index ed4490f..7eaa7eb 100644 --- a/linkoverlay.go +++ b/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 { diff --git a/main.go b/main.go index c36c7d9..5ab81c1 100644 --- a/main.go +++ b/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: diff --git a/media.go b/media.go index bf52daf..f22a0c1 100644 --- a/media.go +++ b/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 diff --git a/messagebox.go b/messagebox.go index c4c81e8..4754bd7 100644 --- a/messagebox.go +++ b/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() { diff --git a/statusview.go b/statusview.go index 4b1738e..6fc1a60 100644 --- a/statusview.go +++ b/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) } } diff --git a/util.go b/util.go index 7f5192e..33d266e 100644 --- a/util.go +++ b/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 } }