summary refs log tree commit diff stats
path: root/worker/imap/create.go
blob: 6ce71ef6c98cf58a153f770b8fe33d4c45e25e4d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package imap

import (
	"git.sr.ht/~sircmpwn/aerc/worker/types"
)

func (imapw *IMAPWorker) handleCreateDirectory(msg *types.CreateDirectory) {
	if err := imapw.client.Create(msg.Directory); err != nil {
		if msg.Quiet {
			return
		}
		imapw.worker.PostMessage(&types.Error{
			Message: types.RespondTo(msg),
			Error:   err,
		}, nil)
	} else {
		imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil)
	}
}
x">children } func (stack *Stack) OnInvalidate(onInvalidate func(d Drawable)) { stack.onInvalidate = append(stack.onInvalidate, onInvalidate) } func (stack *Stack) Invalidate() { for _, fn := range stack.onInvalidate { fn(stack) } } func (stack *Stack) Draw(ctx *Context) { if len(stack.children) > 0 { stack.Peek().Draw(ctx) } else { ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault) } } func (stack *Stack) MouseEvent(localX int, localY int, event tcell.Event) { if len(stack.children) > 0 { switch element := stack.Peek().(type) { case Mouseable: element.MouseEvent(localX, localY, event) } } } func (stack *Stack) Push(d Drawable) { if len(stack.children) != 0 { stack.Peek().OnInvalidate(nil) } stack.children = append(stack.children, d) d.OnInvalidate(stack.invalidateFromChild) stack.Invalidate() } func (stack *Stack) Pop() Drawable { if len(stack.children) == 0 { panic(fmt.Errorf("Tried to pop from an empty UI stack")) } d := stack.children[len(stack.children)-1] stack.children = stack.children[:len(stack.children)-1] stack.Invalidate() d.OnInvalidate(nil) if len(stack.children) != 0 { stack.Peek().OnInvalidate(stack.invalidateFromChild) } return d } func (stack *Stack) Peek() Drawable { if len(stack.children) == 0 { panic(fmt.Errorf("Tried to peek from an empty stack")) } return stack.children[len(stack.children)-1] } func (stack *Stack) invalidateFromChild(d Drawable) { stack.Invalidate() }