diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/account.go | 8 | ||||
-rw-r--r-- | app/compose.go | 4 | ||||
-rw-r--r-- | app/msgviewer.go | 18 | ||||
-rw-r--r-- | app/terminal.go | 8 |
4 files changed, 38 insertions, 0 deletions
diff --git a/app/account.go b/app/account.go index 312ba89b..817b9b74 100644 --- a/app/account.go +++ b/app/account.go @@ -220,6 +220,14 @@ func (acct *AccountView) SelectedMessagePart() *PartInfo { return nil } +func (acct *AccountView) Terminal() *Terminal { + if acct.split == nil { + return nil + } + + return acct.split.Terminal() +} + func (acct *AccountView) isSelected() bool { return acct == SelectedAccount() } diff --git a/app/compose.go b/app/compose.go index 546184d8..76f28881 100644 --- a/app/compose.go +++ b/app/compose.go @@ -769,6 +769,10 @@ func (c *Composer) OnClose(fn func(composer *Composer)) { c.onClose = append(c.onClose, fn) } +func (c *Composer) Terminal() *Terminal { + return c.editor +} + func (c *Composer) Draw(ctx *ui.Context) { c.setTitle() c.width = ctx.Width() diff --git a/app/msgviewer.go b/app/msgviewer.go index bb63b28d..8ac22bcc 100644 --- a/app/msgviewer.go +++ b/app/msgviewer.go @@ -276,6 +276,24 @@ func (mv *MessageViewer) Invalidate() { ui.Invalidate() } +func (mv *MessageViewer) Terminal() *Terminal { + if mv.switcher == nil { + return nil + } + + nparts := len(mv.switcher.parts) + if nparts == 0 || mv.switcher.selected < 0 || mv.switcher.selected >= nparts { + return nil + } + + pv := mv.switcher.parts[mv.switcher.selected] + if pv == nil { + return nil + } + + return pv.term +} + func (mv *MessageViewer) Store() *lib.MessageStore { return mv.msg.Store() } diff --git a/app/terminal.go b/app/terminal.go index 1b177f3e..85d84db6 100644 --- a/app/terminal.go +++ b/app/terminal.go @@ -12,6 +12,10 @@ import ( "github.com/gdamore/tcell/v2" ) +type HasTerminal interface { + Terminal() *Terminal +} + type Terminal struct { closed int32 cmd *exec.Cmd @@ -113,6 +117,10 @@ func (term *Terminal) Show(visible bool) { term.visible = visible } +func (term *Terminal) Terminal() *Terminal { + return term +} + func (term *Terminal) MouseEvent(localX int, localY int, event tcell.Event) { ev, ok := event.(*tcell.EventMouse) if !ok { |