aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/ui/interfaces.go5
-rw-r--r--lib/ui/tab.go8
-rw-r--r--widgets/compose.go8
-rw-r--r--widgets/msgviewer.go10
-rw-r--r--widgets/terminal.go12
5 files changed, 40 insertions, 3 deletions
diff --git a/lib/ui/interfaces.go b/lib/ui/interfaces.go
index a28c6c29..8ede22c7 100644
--- a/lib/ui/interfaces.go
+++ b/lib/ui/interfaces.go
@@ -20,6 +20,11 @@ type Closeable interface {
Close()
}
+type Visible interface {
+ // Indicate that this component is visible or not
+ Show(bool)
+}
+
type RootDrawable interface {
Initialize(ui *UI)
}
diff --git a/lib/ui/tab.go b/lib/ui/tab.go
index b992a8a2..b62764fb 100644
--- a/lib/ui/tab.go
+++ b/lib/ui/tab.go
@@ -153,9 +153,17 @@ func (tabs *Tabs) selectPriv(index int) bool {
if tabs.curIndex != index {
// only push valid tabs onto the history
if tabs.curIndex < len(tabs.tabs) {
+ prev := tabs.tabs[tabs.curIndex]
+ if vis, ok := prev.Content.(Visible); ok {
+ vis.Show(false)
+ }
tabs.pushHistory(tabs.curIndex)
}
tabs.curIndex = index
+ next := tabs.tabs[tabs.curIndex]
+ if vis, ok := next.Content.(Visible); ok {
+ vis.Show(true)
+ }
Invalidate()
}
return true
diff --git a/widgets/compose.go b/widgets/compose.go
index 4f36b297..3693ad18 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -700,6 +700,14 @@ func (c *Composer) Focus(focus bool) {
c.Unlock()
}
+func (c *Composer) Show(visible bool) {
+ c.Lock()
+ if vis, ok := c.focusable[c.focused].(ui.Visible); ok {
+ vis.Show(visible)
+ }
+ c.Unlock()
+}
+
func (c *Composer) Config() *config.AccountConfig {
return c.acctConfig
}
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index f38b186a..684c99cb 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -406,6 +406,12 @@ func (ps *PartSwitcher) Focus(focus bool) {
}
}
+func (ps *PartSwitcher) Show(visible bool) {
+ if ps.parts[ps.selected].term != nil {
+ ps.parts[ps.selected].term.Show(visible)
+ }
+}
+
func (ps *PartSwitcher) Event(event tcell.Event) bool {
return ps.parts[ps.selected].Event(event)
}
@@ -505,6 +511,10 @@ func (mv *MessageViewer) Focus(focus bool) {
mv.switcher.Focus(focus)
}
+func (mv *MessageViewer) Show(visible bool) {
+ mv.switcher.Show(visible)
+}
+
type PartViewer struct {
acctConfig *config.AccountConfig
err error
diff --git a/widgets/terminal.go b/widgets/terminal.go
index ca5a5ef2..c3c16db6 100644
--- a/widgets/terminal.go
+++ b/widgets/terminal.go
@@ -18,6 +18,7 @@ type Terminal struct {
ctx *ui.Context
destroyed bool
focus bool
+ visible bool
vterm *tcellterm.Terminal
running bool
@@ -29,8 +30,9 @@ type Terminal struct {
func NewTerminal(cmd *exec.Cmd) (*Terminal, error) {
term := &Terminal{
- cmd: cmd,
- vterm: tcellterm.New(),
+ cmd: cmd,
+ vterm: tcellterm.New(),
+ visible: true,
}
return term, nil
}
@@ -97,6 +99,10 @@ func (term *Terminal) Draw(ctx *ui.Context) {
term.draw()
}
+func (term *Terminal) Show(visible bool) {
+ term.visible = visible
+}
+
func (term *Terminal) draw() {
term.vterm.Draw()
if term.focus && !term.closed && term.ctx != nil {
@@ -149,7 +155,7 @@ func (term *Terminal) HandleEvent(ev tcell.Event) bool {
}
switch ev := ev.(type) {
case *views.EventWidgetContent:
- if term.focus {
+ if term.visible {
ui.QueueRedraw()
}
return true