Add image viewing
MODIFY
shortcuts/shortcuts.go
shortcuts/shortcuts.go
@@ -31,6 +31,8 @@ var (
chatview, tcell.NewEventKey(tcell.KeyRune, 's', tcell.ModNone))
DeleteSelectedMessage = addShortcut("toggle_selected_message_spoilers", "Toggle spoilers in selected message",
chatview, tcell.NewEventKey(tcell.KeyDelete, 0, tcell.ModNone))
+ ViewSelectedMessageImages = addShortcut("view_selected_message_images", "Open selected message's attached images in feh",
+ chatview, tcell.NewEventKey(tcell.KeyRune, 'o', tcell.ModNone))
ExpandSelectionToLeft = addShortcut("expand_selection_word_to_left", "Expand selection word to left",
multilineTextInput, tcell.NewEventKey(tcell.KeyLeft, 0, tcell.ModShift))

MODIFY
ui/window.go
ui/window.go
@@ -7,6 +7,7 @@ import (
"strings"
"time"
"unicode"
+ "os/exec"
"github.com/mattn/go-runewidth"
"github.com/mdp/qrterminal/v3"
@@ -385,6 +386,22 @@ func NewWindow(doRestart chan bool, app *tview.Application, session *discordgo.S
return nil
}
+ if shortcuts.ViewSelectedMessageImages.Equals(event) {
+ links := make([]string, 0, len(message.Attachments))
+ for _, file := range message.Attachments {
+ links = append(links, file.URL)
+ }
+ if len(links) > 0 {
+ cmd := exec.Command("feh", links...)
+ err := cmd.Start()
+ if err != nil {
+ window.ShowErrorDialog(err.Error())
+ }
+ }
+
+ return nil
+ }
+
return event
})
window.messageContainer = window.chatView.GetPrimitive()

Add image viewing