Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion tui/email_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tui
import (
"encoding/base64"
"fmt"
"os"
"strings"

"github.com/charmbracelet/bubbles/viewport"
Expand All @@ -12,6 +13,13 @@ import (
"github.com/floatpane/matcha/view"
)

// clearKittyGraphics sends the Kitty graphics protocol delete command directly to stdout
func clearKittyGraphics() {
// Delete all images: a=d (action=delete), d=A (delete all)
os.Stdout.WriteString("\x1b_Ga=d,d=A\x1b\\")
os.Stdout.Sync()
}

var (
emailHeaderStyle = lipgloss.NewStyle().BorderStyle(lipgloss.NormalBorder()).BorderBottom(true).Padding(0, 1)
attachmentBoxStyle = lipgloss.NewStyle().Border(lipgloss.NormalBorder(), false, false, false, true).PaddingLeft(2).MarginTop(1)
Expand Down Expand Up @@ -74,7 +82,8 @@ func (m *EmailView) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.focusOnAttachments = false
return m, nil
}
m.viewport.SetContent("\x1b_Ga=d\x1b\\")
// Clear Kitty graphics before returning to mailbox
clearKittyGraphics()
return m, func() tea.Msg { return BackToMailboxMsg{Mailbox: m.mailbox} }
}

Expand Down Expand Up @@ -110,16 +119,22 @@ func (m *EmailView) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
} else {
switch msg.String() {
case "r":
// Clear Kitty graphics before opening composer
clearKittyGraphics()
return m, func() tea.Msg { return ReplyToEmailMsg{Email: m.email} }
case "d":
accountID := m.accountID
uid := m.email.UID
// Clear Kitty graphics before transitioning
clearKittyGraphics()
return m, func() tea.Msg {
return DeleteEmailMsg{UID: uid, AccountID: accountID, Mailbox: m.mailbox}
}
case "a":
accountID := m.accountID
uid := m.email.UID
// Clear Kitty graphics before transitioning
clearKittyGraphics()
return m, func() tea.Msg {
return ArchiveEmailMsg{UID: uid, AccountID: accountID, Mailbox: m.mailbox}
}
Expand Down