summary refs log tree commit diff stats
path: root/widgets/compose.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-05-12 11:21:28 -0400
committerDrew DeVault <sir@cmpwn.com>2019-05-12 11:21:28 -0400
commitf37508a53980f38c530780650338797e81fe1e3c (patch)
tree17425d8d9426a4e8a51116cc299bca7be5baab4c /widgets/compose.go
parent2a4dd5cb87179d8ffc00bad2552880f9bd50b75f (diff)
downloadaerc-f37508a53980f38c530780650338797e81fe1e3c.tar.gz
Implement :{next,prev}-field in compose view
Diffstat (limited to 'widgets/compose.go')
-rw-r--r--widgets/compose.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/widgets/compose.go b/widgets/compose.go
index 10d14f7..f07e3ee 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -67,7 +67,7 @@ func NewComposer() *Composer {
 		grid:   grid,
 		editor: term,
 		// You have to backtab to get to "From", since you usually don't edit it
-		focused: 3,
+		focused: 1,
 		focusable: []ui.DrawableInteractive{
 			from,
 			to,
@@ -99,6 +99,21 @@ func (c *Composer) Focus(focus bool) {
 	c.focusable[c.focused].Focus(focus)
 }
 
+func (c *Composer) PrevField() {
+	c.focusable[c.focused].Focus(false)
+	c.focused--
+	if c.focused == -1 {
+		c.focused = len(c.focusable) - 1
+	}
+	c.focusable[c.focused].Focus(true)
+}
+
+func (c *Composer) NextField() {
+	c.focusable[c.focused].Focus(false)
+	c.focused = (c.focused + 1) % len(c.focusable)
+	c.focusable[c.focused].Focus(true)
+}
+
 func newHeaderEditor(name string, value string) *headerEditor {
 	return &headerEditor{
 		input: ui.NewTextInput(value),