aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/account-wizard.go98
-rw-r--r--widgets/account.go47
-rw-r--r--widgets/aerc.go9
-rw-r--r--widgets/compose.go21
-rw-r--r--widgets/msgviewer.go20
5 files changed, 96 insertions, 99 deletions
diff --git a/widgets/account-wizard.go b/widgets/account-wizard.go
index 6f93367f..4e51926d 100644
--- a/widgets/account-wizard.go
+++ b/widgets/account-wizard.go
@@ -136,18 +136,18 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
})
basics := ui.NewGrid().Rows([]ui.GridSpec{
- {ui.SIZE_EXACT, 8}, // Introduction
- {ui.SIZE_EXACT, 1}, // Account name (label)
- {ui.SIZE_EXACT, 1}, // (input)
- {ui.SIZE_EXACT, 1}, // Padding
- {ui.SIZE_EXACT, 1}, // Full name (label)
- {ui.SIZE_EXACT, 1}, // (input)
- {ui.SIZE_EXACT, 1}, // Padding
- {ui.SIZE_EXACT, 1}, // Email address (label)
- {ui.SIZE_EXACT, 1}, // (input)
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_EXACT, ui.Const(8)}, // Introduction
+ {ui.SIZE_EXACT, ui.Const(1)}, // Account name (label)
+ {ui.SIZE_EXACT, ui.Const(1)}, // (input)
+ {ui.SIZE_EXACT, ui.Const(1)}, // Padding
+ {ui.SIZE_EXACT, ui.Const(1)}, // Full name (label)
+ {ui.SIZE_EXACT, ui.Const(1)}, // (input)
+ {ui.SIZE_EXACT, ui.Const(1)}, // Padding
+ {ui.SIZE_EXACT, ui.Const(1)}, // Email address (label)
+ {ui.SIZE_EXACT, ui.Const(1)}, // (input)
+ {ui.SIZE_WEIGHT, ui.Const(1)},
}).Columns([]ui.GridSpec{
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
})
basics.AddChild(
ui.NewText("\nWelcome to aerc! Let's configure your account.\n\n" +
@@ -209,23 +209,23 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
})
incoming := ui.NewGrid().Rows([]ui.GridSpec{
- {ui.SIZE_EXACT, 3}, // Introduction
- {ui.SIZE_EXACT, 1}, // Username (label)
- {ui.SIZE_EXACT, 1}, // (input)
- {ui.SIZE_EXACT, 1}, // Padding
- {ui.SIZE_EXACT, 1}, // Password (label)
- {ui.SIZE_EXACT, 1}, // (input)
- {ui.SIZE_EXACT, 1}, // Padding
- {ui.SIZE_EXACT, 1}, // Server (label)
- {ui.SIZE_EXACT, 1}, // (input)
- {ui.SIZE_EXACT, 1}, // Padding
- {ui.SIZE_EXACT, 1}, // Connection mode (label)
- {ui.SIZE_EXACT, 2}, // (input)
- {ui.SIZE_EXACT, 1}, // Padding
- {ui.SIZE_EXACT, 1}, // Connection string
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_EXACT, ui.Const(3)}, // Introduction
+ {ui.SIZE_EXACT, ui.Const(1)}, // Username (label)
+ {ui.SIZE_EXACT, ui.Const(1)}, // (input)
+ {ui.SIZE_EXACT, ui.Const(1)}, // Padding
+ {ui.SIZE_EXACT, ui.Const(1)}, // Password (label)
+ {ui.SIZE_EXACT, ui.Const(1)}, // (input)
+ {ui.SIZE_EXACT, ui.Const(1)}, // Padding
+ {ui.SIZE_EXACT, ui.Const(1)}, // Server (label)
+ {ui.SIZE_EXACT, ui.Const(1)}, // (input)
+ {ui.SIZE_EXACT, ui.Const(1)}, // Padding
+ {ui.SIZE_EXACT, ui.Const(1)}, // Connection mode (label)
+ {ui.SIZE_EXACT, ui.Const(2)}, // (input)
+ {ui.SIZE_EXACT, ui.Const(1)}, // Padding
+ {ui.SIZE_EXACT, ui.Const(1)}, // Connection string
+ {ui.SIZE_WEIGHT, ui.Const(1)},
}).Columns([]ui.GridSpec{
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
})
incoming.AddChild(ui.NewText("\nConfigure incoming mail (IMAP)"))
incoming.AddChild(
@@ -283,26 +283,26 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
})
outgoing := ui.NewGrid().Rows([]ui.GridSpec{
- {ui.SIZE_EXACT, 3}, // Introduction
- {ui.SIZE_EXACT, 1}, // Username (label)
- {ui.SIZE_EXACT, 1}, // (input)
- {ui.SIZE_EXACT, 1}, // Padding
- {ui.SIZE_EXACT, 1}, // Password (label)
- {ui.SIZE_EXACT, 1}, // (input)
- {ui.SIZE_EXACT, 1}, // Padding
- {ui.SIZE_EXACT, 1}, // Server (label)
- {ui.SIZE_EXACT, 1}, // (input)
- {ui.SIZE_EXACT, 1}, // Padding
- {ui.SIZE_EXACT, 1}, // Connection mode (label)
- {ui.SIZE_EXACT, 2}, // (input)
- {ui.SIZE_EXACT, 1}, // Padding
- {ui.SIZE_EXACT, 1}, // Connection string
- {ui.SIZE_EXACT, 1}, // Padding
- {ui.SIZE_EXACT, 1}, // Copy to sent (label)
- {ui.SIZE_EXACT, 2}, // (input)
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_EXACT, ui.Const(3)}, // Introduction
+ {ui.SIZE_EXACT, ui.Const(1)}, // Username (label)
+ {ui.SIZE_EXACT, ui.Const(1)}, // (input)
+ {ui.SIZE_EXACT, ui.Const(1)}, // Padding
+ {ui.SIZE_EXACT, ui.Const(1)}, // Password (label)
+ {ui.SIZE_EXACT, ui.Const(1)}, // (input)
+ {ui.SIZE_EXACT, ui.Const(1)}, // Padding
+ {ui.SIZE_EXACT, ui.Const(1)}, // Server (label)
+ {ui.SIZE_EXACT, ui.Const(1)}, // (input)
+ {ui.SIZE_EXACT, ui.Const(1)}, // Padding
+ {ui.SIZE_EXACT, ui.Const(1)}, // Connection mode (label)
+ {ui.SIZE_EXACT, ui.Const(2)}, // (input)
+ {ui.SIZE_EXACT, ui.Const(1)}, // Padding
+ {ui.SIZE_EXACT, ui.Const(1)}, // Connection string
+ {ui.SIZE_EXACT, ui.Const(1)}, // Padding
+ {ui.SIZE_EXACT, ui.Const(1)}, // Copy to sent (label)
+ {ui.SIZE_EXACT, ui.Const(2)}, // (input)
+ {ui.SIZE_WEIGHT, ui.Const(1)},
}).Columns([]ui.GridSpec{
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
})
outgoing.AddChild(ui.NewText("\nConfigure outgoing mail (SMTP)"))
outgoing.AddChild(
@@ -374,10 +374,10 @@ func NewAccountWizard(conf *config.AercConfig, aerc *Aerc) *AccountWizard {
})
complete := ui.NewGrid().Rows([]ui.GridSpec{
- {ui.SIZE_EXACT, 7}, // Introduction
- {ui.SIZE_WEIGHT, 1}, // Previous / Finish / Finish & open tutorial
+ {ui.SIZE_EXACT, ui.Const(7)}, // Introduction
+ {ui.SIZE_WEIGHT, ui.Const(1)}, // Previous / Finish / Finish & open tutorial
}).Columns([]ui.GridSpec{
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
})
complete.AddChild(ui.NewText(
"\nConfiguration complete!\n\n" +
diff --git a/widgets/account.go b/widgets/account.go
index 20ed3456..313a364a 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -45,45 +45,38 @@ func NewAccountView(aerc *Aerc, conf *config.AercConfig, acct *config.AccountCon
config.UI_CONTEXT_ACCOUNT: acct.Name,
})
- grid := ui.NewGrid().Rows([]ui.GridSpec{
- {ui.SIZE_WEIGHT, 1},
+ view := &AccountView{
+ acct: acct,
+ aerc: aerc,
+ conf: conf,
+ host: host,
+ logger: logger,
+ }
+
+ view.grid = ui.NewGrid().Rows([]ui.GridSpec{
+ {ui.SIZE_WEIGHT, ui.Const(1)},
}).Columns([]ui.GridSpec{
- {ui.SIZE_EXACT, acctUiConf.SidebarWidth},
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_EXACT, func() int {
+ return view.UiConfig().SidebarWidth
+ }},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
})
worker, err := worker.NewWorker(acct.Source, logger)
if err != nil {
host.SetStatus(fmt.Sprintf("%s: %s", acct.Name, err)).
Color(tcell.ColorDefault, tcell.ColorRed)
- return &AccountView{
- acct: acct,
- aerc: aerc,
- grid: grid,
- host: host,
- logger: logger,
- }
+ return view
}
+ view.worker = worker
- dirlist := NewDirectoryList(conf, acct, logger, worker)
+ view.dirlist = NewDirectoryList(conf, acct, logger, worker)
if acctUiConf.SidebarWidth > 0 {
- grid.AddChild(ui.NewBordered(dirlist, ui.BORDER_RIGHT))
+ view.grid.AddChild(ui.NewBordered(view.dirlist, ui.BORDER_RIGHT))
}
- msglist := NewMessageList(conf, logger, aerc)
- grid.AddChild(msglist).At(0, 1)
-
- view := &AccountView{
- acct: acct,
- aerc: aerc,
- conf: conf,
- dirlist: dirlist,
- grid: grid,
- host: host,
- logger: logger,
- msglist: msglist,
- worker: worker,
- }
+ view.msglist = NewMessageList(conf, logger, aerc)
+ view.grid.AddChild(view.msglist).At(0, 1)
go worker.Backend.Run()
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 829873ad..4913be34 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -56,11 +56,11 @@ func NewAerc(conf *config.AercConfig, logger *log.Logger,
statusbar.Push(statusline)
grid := ui.NewGrid().Rows([]ui.GridSpec{
- {ui.SIZE_EXACT, 1},
- {ui.SIZE_WEIGHT, 1},
- {ui.SIZE_EXACT, 1},
+ {ui.SIZE_EXACT, ui.Const(1)},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
+ {ui.SIZE_EXACT, ui.Const(1)},
}).Columns([]ui.GridSpec{
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
})
grid.AddChild(tabs.TabStrip)
grid.AddChild(tabs.TabContent).At(1, 0)
@@ -552,7 +552,6 @@ func (aerc *Aerc) CloseDialog() {
return
}
-
func (aerc *Aerc) GetPassword(title string, prompt string) (chText chan string, chErr chan error) {
chText = make(chan string, 1)
chErr = make(chan error, 1)
diff --git a/widgets/compose.go b/widgets/compose.go
index 01b8dd80..b68c406f 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -673,13 +673,15 @@ func (c *Composer) updateGrid() {
)
if c.grid == nil {
- c.grid = ui.NewGrid().Columns([]ui.GridSpec{{ui.SIZE_WEIGHT, 1}})
+ c.grid = ui.NewGrid().Columns([]ui.GridSpec{
+ {ui.SIZE_WEIGHT, ui.Const(1)},
+ })
}
c.grid.Rows([]ui.GridSpec{
- {ui.SIZE_EXACT, height},
- {ui.SIZE_EXACT, 1},
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_EXACT, ui.Const(height)},
+ {ui.SIZE_EXACT, ui.Const(1)},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
})
if c.header != nil {
@@ -768,15 +770,18 @@ type reviewMessage struct {
}
func newReviewMessage(composer *Composer, err error) *reviewMessage {
- spec := []ui.GridSpec{{ui.SIZE_EXACT, 2}, {ui.SIZE_EXACT, 1}}
+ spec := []ui.GridSpec{
+ {ui.SIZE_EXACT, ui.Const(2)},
+ {ui.SIZE_EXACT, ui.Const(1)},
+ }
for i := 0; i < len(composer.attachments)-1; i++ {
- spec = append(spec, ui.GridSpec{ui.SIZE_EXACT, 1})
+ spec = append(spec, ui.GridSpec{ui.SIZE_EXACT, ui.Const(1)})
}
// make the last element fill remaining space
- spec = append(spec, ui.GridSpec{ui.SIZE_WEIGHT, 1})
+ spec = append(spec, ui.GridSpec{ui.SIZE_WEIGHT, ui.Const(1)})
grid := ui.NewGrid().Rows(spec).Columns([]ui.GridSpec{
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
})
if err != nil {
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index ce859706..f06b787f 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -69,7 +69,7 @@ func NewMessageViewer(acct *AccountView,
)
rows := []ui.GridSpec{
- {ui.SIZE_EXACT, headerHeight},
+ {ui.SIZE_EXACT, ui.Const(headerHeight)},
}
if msg.PGPDetails() != nil {
@@ -77,16 +77,16 @@ func NewMessageViewer(acct *AccountView,
if msg.PGPDetails().IsSigned && msg.PGPDetails().IsEncrypted {
height = 2
}
- rows = append(rows, ui.GridSpec{ui.SIZE_EXACT, height})
+ rows = append(rows, ui.GridSpec{ui.SIZE_EXACT, ui.Const(height)})
}
rows = append(rows, []ui.GridSpec{
- {ui.SIZE_EXACT, 1},
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_EXACT, ui.Const(1)},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
}...)
grid := ui.NewGrid().Rows(rows).Columns([]ui.GridSpec{
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
})
switcher := &PartSwitcher{}
@@ -373,7 +373,7 @@ func (ps *PartSwitcher) MouseEvent(localX int, localY int, event tcell.Event) {
if localY < y && ps.parts[ps.selected].term != nil {
ps.parts[ps.selected].term.MouseEvent(localX, localY, event)
}
- for i, _ := range ps.parts {
+ for i := range ps.parts {
if localY != y+i {
continue
}
@@ -511,11 +511,11 @@ func NewPartViewer(acct *AccountView, conf *config.AercConfig,
}
grid := ui.NewGrid().Rows([]ui.GridSpec{
- {ui.SIZE_EXACT, 3}, // Message
- {ui.SIZE_EXACT, 1}, // Selector
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_EXACT, ui.Const(3)}, // Message
+ {ui.SIZE_EXACT, ui.Const(1)}, // Selector
+ {ui.SIZE_WEIGHT, ui.Const(1)},
}).Columns([]ui.GridSpec{
- {ui.SIZE_WEIGHT, 1},
+ {ui.SIZE_WEIGHT, ui.Const(1)},
})
selecter := NewSelecter([]string{"Save message", "Pipe to command"}, 0).