summary refs log tree commit diff stats
path: root/widgets/account.go
diff options
context:
space:
mode:
authorJeffas <dev@jeffas.io>2019-09-05 23:32:36 +0100
committerDrew DeVault <sir@cmpwn.com>2019-09-11 11:41:34 -0400
commitf6216bb6213a15cdcdf50089f3c4a8e9a30d9337 (patch)
tree3075b68379ae7c13cb9eedc53b7cf033672478a9 /widgets/account.go
parenta441e3b3a55d11e7cc9444298051ff339d1b7519 (diff)
downloadaerc-f6216bb6213a15cdcdf50089f3c4a8e9a30d9337.tar.gz
Add Mouseable
This adds the Mouseable interface. When this is implemented for a
component that item can accept and process mouseevents.

At the top level when a mouse event is received it is passed to the
grid's handler and then it trickles down until it reaches a component
that can actually handle it, such as the tablist, dirlist or msglist.

A mouse event is passed so that components can handle other things such
as scrolling with the mousewheel. The components themselves then perform
the necessary actions.

Clicking emails in the messagelist opens them in a new tab.

Textinputs can be clicked to position the cursor inside them.

Mouseevents are not forwarded to the terminal at the moment.

Elements which do not handle mouse events are not required to implement
the Mouseable interface.
Diffstat (limited to 'widgets/account.go')
-rw-r--r--widgets/account.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 688b660..1220753 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -17,6 +17,7 @@ import (
 
 type AccountView struct {
 	acct    *config.AccountConfig
+	aerc    *Aerc
 	conf    *config.AercConfig
 	dirlist *DirectoryList
 	grid    *ui.Grid
@@ -26,7 +27,7 @@ type AccountView struct {
 	worker  *types.Worker
 }
 
-func NewAccountView(conf *config.AercConfig, acct *config.AccountConfig,
+func NewAccountView(aerc *Aerc, conf *config.AercConfig, acct *config.AccountConfig,
 	logger *log.Logger, host TabHost) *AccountView {
 
 	grid := ui.NewGrid().Rows([]ui.GridSpec{
@@ -42,6 +43,7 @@ func NewAccountView(conf *config.AercConfig, acct *config.AccountConfig,
 			Color(tcell.ColorDefault, tcell.ColorRed)
 		return &AccountView{
 			acct:   acct,
+			aerc:   aerc,
 			grid:   grid,
 			host:   host,
 			logger: logger,
@@ -53,11 +55,12 @@ func NewAccountView(conf *config.AercConfig, acct *config.AccountConfig,
 		grid.AddChild(ui.NewBordered(dirlist, ui.BORDER_RIGHT))
 	}
 
-	msglist := NewMessageList(conf, logger)
+	msglist := NewMessageList(conf, logger, aerc)
 	grid.AddChild(msglist).At(0, 1)
 
 	view := &AccountView{
 		acct:    acct,
+		aerc:    aerc,
 		conf:    conf,
 		dirlist: dirlist,
 		grid:    grid,
@@ -124,6 +127,10 @@ func (acct *AccountView) Draw(ctx *ui.Context) {
 	acct.grid.Draw(ctx)
 }
 
+func (acct *AccountView) MouseEvent(localX int, localY int, event tcell.Event) {
+	acct.grid.MouseEvent(localX, localY, event)
+}
+
 func (acct *AccountView) Focus(focus bool) {
 	// TODO: Unfocus children I guess
 }