purebred-0.1.0.0: An mail user agent built around notmuch

Safe HaskellNone
LanguageHaskell2010

UI.Actions

Contents

Synopsis

Overview

Actions are composible functions. They can be sequenced and used in Keybindings.

Examples

This keybinding registered to back space scrolls a page up and continues with the event loop:

Keybinding (EvKey KBS []) (scrollPageUp `chain'` continue) ]

This keybinding is used to change the focus to a different widget:

Keybinding (EvKey (KChar q) []) (noop `chain'` (focus :: Action 'Threads 'ListOfThreads AppState) `chain` continue

Adding new Actions

New Actions are typically added when creating a Keybinding first. A simple Action to start off has a specific View and widget (see Name). You can access the full AppState in the Action's function including IO.

class Scrollable (n :: Name) where Source #

Scrollable is an abstraction over Brick's viewport scroller in order to support viewing larger amounts of text.

Methods

makeViewportScroller :: Proxy n -> ViewportScroll Name Source #

Instances
Scrollable ScrollingMailView Source # 
Instance details

Defined in UI.Actions

Methods

makeViewportScroller :: Proxy ScrollingMailView -> ViewportScroll Name Source #

Scrollable ScrollingHelpView Source # 
Instance details

Defined in UI.Actions

Methods

makeViewportScroller :: Proxy ScrollingHelpView -> ViewportScroll Name Source #

class Completable (n :: Name) where Source #

A function which is run at the end of a chained sequence of actions.

For example: the user changes the notmuch search terms to find a particular mail. To apply his changes, he completes his typed in text by pressing Enter.

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy n -> m () Source #

Instances
Completable SearchThreadsEditor Source # 
Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy SearchThreadsEditor -> m () Source #

Completable ScrollingMailViewFindWordEditor Source # 
Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ScrollingMailViewFindWordEditor -> m () Source #

Completable ComposeFrom Source # 
Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ComposeFrom -> m () Source #

Completable ComposeTo Source # 
Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ComposeTo -> m () Source #

Completable ComposeCc Source # 
Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ComposeCc -> m () Source #

Completable ComposeBcc Source # 
Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ComposeBcc -> m () Source #

Completable ComposeSubject Source # 
Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ComposeSubject -> m () Source #

Completable ComposeListOfAttachments Source # 
Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ComposeListOfAttachments -> m () Source #

Completable ManageMailTagsEditor Source # 
Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ManageMailTagsEditor -> m () Source #

Completable ManageThreadTagsEditor Source #

Applying tag operations on threads Note: notmuch does not support adding tags to threads themselves, instead we'll apply all tag operations on mails in the thread. Instead of reloading the thread, we'll apply all tag operations on the thread type as well, which are not persisted to the database. This strategy is faster since it does not need any database access above tagging mails, but it could pose a problem if tags don't show up in the UI.

Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ManageThreadTagsEditor -> m () Source #

Completable ManageFileBrowserSearchPath Source # 
Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ManageFileBrowserSearchPath -> m () Source #

Completable MailAttachmentOpenWithEditor Source # 
Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy MailAttachmentOpenWithEditor -> m () Source #

Completable MailAttachmentPipeToEditor Source # 
Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy MailAttachmentPipeToEditor -> m () Source #

Completable ConfirmDialog Source # 
Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ConfirmDialog -> m () Source #

Completable SaveToDiskPathEditor Source # 
Instance details

Defined in UI.Actions

Methods

complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy SaveToDiskPathEditor -> m () Source #

class HasEditor (n :: Name) where Source #

Abstraction to access editors (via it's lens) in the current context with a proxy type.

Methods

editorL :: Proxy n -> Lens' AppState (Editor Text Name) Source #

Instances
HasEditor SearchThreadsEditor Source # 
Instance details

Defined in UI.Actions

Methods

editorL :: Proxy SearchThreadsEditor -> Lens' AppState (Editor Text Name) Source #

HasEditor ScrollingMailViewFindWordEditor Source # 
Instance details

Defined in UI.Actions

Methods

editorL :: Proxy ScrollingMailViewFindWordEditor -> Lens' AppState (Editor Text Name) Source #

HasEditor ComposeFrom Source # 
Instance details

Defined in UI.Actions

Methods

editorL :: Proxy ComposeFrom -> Lens' AppState (Editor Text Name) Source #

HasEditor ComposeTo Source # 
Instance details

Defined in UI.Actions

Methods

editorL :: Proxy ComposeTo -> Lens' AppState (Editor Text Name) Source #

HasEditor ComposeCc Source # 
Instance details

Defined in UI.Actions

Methods

editorL :: Proxy ComposeCc -> Lens' AppState (Editor Text Name) Source #

HasEditor ComposeBcc Source # 
Instance details

Defined in UI.Actions

Methods

editorL :: Proxy ComposeBcc -> Lens' AppState (Editor Text Name) Source #

HasEditor ComposeSubject Source # 
Instance details

Defined in UI.Actions

Methods

editorL :: Proxy ComposeSubject -> Lens' AppState (Editor Text Name) Source #

HasEditor ManageMailTagsEditor Source # 
Instance details

Defined in UI.Actions

Methods

editorL :: Proxy ManageMailTagsEditor -> Lens' AppState (Editor Text Name) Source #

HasEditor ManageThreadTagsEditor Source # 
Instance details

Defined in UI.Actions

Methods

editorL :: Proxy ManageThreadTagsEditor -> Lens' AppState (Editor Text Name) Source #

HasEditor MailAttachmentOpenWithEditor Source # 
Instance details

Defined in UI.Actions

Methods

editorL :: Proxy MailAttachmentOpenWithEditor -> Lens' AppState (Editor Text Name) Source #

HasEditor MailAttachmentPipeToEditor Source # 
Instance details

Defined in UI.Actions

Methods

editorL :: Proxy MailAttachmentPipeToEditor -> Lens' AppState (Editor Text Name) Source #

HasEditor SaveToDiskPathEditor Source # 
Instance details

Defined in UI.Actions

Methods

editorL :: Proxy SaveToDiskPathEditor -> Lens' AppState (Editor Text Name) Source #

class HasName (a :: Name) where Source #

Generalisation in order to access the widget name from a phantom type

Methods

name :: Proxy a -> Name Source #

Instances
HasName SearchThreadsEditor Source # 
Instance details

Defined in UI.Actions

Methods

name :: Proxy SearchThreadsEditor -> Name Source #

HasName ListOfMails Source # 
Instance details

Defined in UI.Actions

Methods

name :: Proxy ListOfMails -> Name Source #

HasName ListOfThreads Source # 
Instance details

Defined in UI.Actions

Methods

name :: Proxy ListOfThreads -> Name Source #

HasName ScrollingMailView Source # 
Instance details

Defined in UI.Actions

Methods

name :: Proxy ScrollingMailView -> Name Source #

HasName ScrollingMailViewFindWordEditor Source # 
Instance details

Defined in UI.Actions

HasName ComposeFrom Source # 
Instance details

Defined in UI.Actions

Methods

name :: Proxy ComposeFrom -> Name Source #

HasName ComposeTo Source # 
Instance details

Defined in UI.Actions

Methods

name :: Proxy ComposeTo -> Name Source #

HasName ComposeCc Source # 
Instance details

Defined in UI.Actions

Methods

name :: Proxy ComposeCc -> Name Source #

HasName ComposeBcc Source # 
Instance details

Defined in UI.Actions

Methods

name :: Proxy ComposeBcc -> Name Source #

HasName ComposeSubject Source # 
Instance details

Defined in UI.Actions

Methods

name :: Proxy ComposeSubject -> Name Source #

HasName ComposeListOfAttachments Source # 
Instance details

Defined in UI.Actions

HasName ScrollingHelpView Source # 
Instance details

Defined in UI.Actions

Methods

name :: Proxy ScrollingHelpView -> Name Source #

HasName ManageMailTagsEditor Source # 
Instance details

Defined in UI.Actions

HasName ManageThreadTagsEditor Source # 
Instance details

Defined in UI.Actions

HasName ListOfFiles Source # 
Instance details

Defined in UI.Actions

Methods

name :: Proxy ListOfFiles -> Name Source #

HasName ManageFileBrowserSearchPath Source # 
Instance details

Defined in UI.Actions

HasName MailListOfAttachments Source # 
Instance details

Defined in UI.Actions

HasName MailAttachmentOpenWithEditor Source # 
Instance details

Defined in UI.Actions

HasName MailAttachmentPipeToEditor Source # 
Instance details

Defined in UI.Actions

HasName ConfirmDialog Source # 
Instance details

Defined in UI.Actions

Methods

name :: Proxy ConfirmDialog -> Name Source #

HasName SaveToDiskPathEditor Source # 
Instance details

Defined in UI.Actions

Actions

Brick Event Loop Actions

These actions wrap Brick's event loop functions. They are used to indicate whether we continue the event loop or halt (quit). These actions typically finish a sequence of chained Actions. Use them at the end of a chained sequence.

Note: While only quit and continue falls into this category, more Purebred functions fall into this category because we're missing ways to modularise them. See #294

continue :: Action v ctx (Next AppState) Source #

A noop used to continue the Brick event loop.

edit :: Action ComposeView ComposeListOfAttachments (Next AppState) Source #

Suspends Purebred to invoke a command for editing an attachment. Currently only supports re-editing the body text of an e-mail.

invokeEditor :: Action v ctx (Next AppState) Source #

Suspends Purebred and invokes the configured editor.

openWithCommand :: Action ViewMail MailAttachmentOpenWithEditor (Next AppState) Source #

Open the selected entity with the command given from the editor widget.

pipeToCommand :: Action ViewMail MailAttachmentPipeToEditor (Next AppState) Source #

Pipe the selected entity to the command given from the editor widget.

Keybinding Actions

These actions are used to sequence other actions together. Think of it like glue functions.

focus :: forall v a. (HasViewName v, HasName a, Focusable v a) => Action v a () Source #

Used to switch the focus from one widget to another on the same view.

done :: forall a v. (HasViewName v, Completable a) => Action v a () Source #

abort :: forall a v. (HasViewName v, Resetable v a) => Action v a () Source #

noop :: Action v ctx () Source #

A no-op action can be used at the start of a sequence with an immediate switch of focus to a different widget (see focus).

chain :: Action v ctx a -> Action v ctx b -> Action v ctx b Source #

Chain sequences of actions to create a keybinding

chain' :: forall v v' ctx ctx' a b. (HasName ctx, HasViewName v, HasName ctx', HasViewName v', ViewTransition v v') => Action v ctx a -> Action v' ctx' b -> Action v ctx b Source #

Special form of chain allowing to sequencing actions registered for a different view/widget. This is useful to perform actions on widget focus changes.

List specific Actions

listUp :: forall v ctx. (HasList ctx, Foldable (T ctx), Splittable (T ctx)) => Action v ctx () Source #

listDown :: forall v ctx. (HasList ctx, Foldable (T ctx), Splittable (T ctx)) => Action v ctx () Source #

listJumpToEnd :: forall v ctx. (HasList ctx, Foldable (T ctx), Splittable (T ctx)) => Action v ctx () Source #

listJumpToStart :: forall v ctx. (HasList ctx, Foldable (T ctx), Splittable (T ctx)) => Action v ctx () Source #

reloadList :: Action Threads ListOfThreads () Source #

Reloads the list of threads by executing the notmuch query given by the search widget.

toggleListItem :: forall v ctx. HasToggleableList ctx => Action v ctx () Source #

Selects a list item. Currently only used in the file browser to select a file for attaching.

untoggleListItems :: forall v ctx. HasToggleableList ctx => Action v ctx () Source #

Mail specific Actions

displayThreadMails :: Action Threads ListOfThreads () Source #

Sets the mail list to the mails for the selected thread. Does not select a mail; a movement action such as displayNextUnread should follow this action.

toggleHeaders :: Action ViewMail ScrollingMailView () Source #

Toggles whether we want to show all headers from an e-mail or a filtered list in the AppState.

switchComposeEditor :: Action Threads ListOfThreads () Source #

Action used to either start a composition of a new mail or switch the view to the composition editor if we've already been editing a new mail. The use case here is to continue editing an e-mail while still having the ability to browse existing e-mails.

replyMail :: Action ViewMail ScrollingMailView () Source #

Update the AppState with a quoted form of the first preferred entity in order to reply to the e-mail. | Update the AppState with a quoted version of the currently selected mail in order to reply to it.

encapsulateMail :: Action ViewMail ScrollingMailView () Source #

Update the AppState with a MIMEMessage. The instance will have the current selected MIMEMessage encapsulated as an inline message.

selectNextUnread :: Action ViewMail ListOfMails () Source #

Selects the next unread mail in a thread.

composeAsNew :: Action ViewMail ScrollingMailView () Source #

Edit an e-mail as a new mail. This is typically used by saving a mail under composition for later and continuing the draft. Another use case can be editing an already sent mail in order to send it to anther recipient.

createAttachments :: Action FileBrowser ListOfFiles () Source #

Adds all selected files as attachments to the e-mail.

setTags :: forall v ctx. HasToggleableList ctx => [TagOp] -> Action v ctx () Source #

Apply given tag operations on the currently selected thread or mail.

saveAttachmentToPath :: Action ViewMail SaveToDiskPathEditor () Source #

Save a currently selected attachment to the given path on disk. Shows an error if the path is invalid or can not be written to.

Actions for scrolling

scrollUp :: forall ctx v. Scrollable ctx => Action v ctx () Source #

scrollDown :: forall ctx v. Scrollable ctx => Action v ctx () Source #

scrollPageUp :: forall ctx v. Scrollable ctx => Action v ctx () Source #

scrollPageDown :: forall ctx v. Scrollable ctx => Action v ctx () Source #

scrollNextWord :: forall ctx v. Scrollable ctx => Action v ctx () Source #

removeHighlights :: Action ViewMail ScrollingMailView () Source #

Removes any highlighting done by searching in the body text

Actions for composing mails

delete :: Action ComposeView ComposeListOfAttachments () Source #

Delete an attachment from a mail currently being composed.

TODO: could this be generalised over a type class? (See https://github.com/purebred-mua/purebred/issues/366)

Actions only used for a specific widget context

enterDirectory :: Action FileBrowser ListOfFiles () Source #

Open a directory and set the contents in the AppState.

parentDirectory :: Action FileBrowser ListOfFiles () Source #

Go to the parent directory.

handleConfirm :: Action ComposeView ConfirmDialog () Source #

Action to deal with a choice from the confirmation dialog.

API

applySearch :: (MonadIO m, MonadState AppState m) => m () Source #

Take the notmuch query given by the user and update the AppState with notmuch query result.