Safe Haskell | None |
---|---|
Language | Haskell2010 |
UI.Actions
Contents
Synopsis
- class Scrollable (n :: Name) where
- makeViewportScroller :: Proxy n -> ViewportScroll Name
- class Completable (n :: Name) where
- class HasEditor (n :: Name) where
- class HasName (a :: Name) where
- quit :: Action v ctx (Next AppState)
- continue :: Action v ctx (Next AppState)
- edit :: Action ComposeView ComposeListOfAttachments (Next AppState)
- invokeEditor :: Action v ctx (Next AppState)
- openWithCommand :: Action ViewMail MailAttachmentOpenWithEditor (Next AppState)
- pipeToCommand :: Action ViewMail MailAttachmentPipeToEditor (Next AppState)
- focus :: forall v a. (HasViewName v, HasName a, Focusable v a) => Action v a ()
- done :: forall a v. (HasViewName v, Completable a) => Action v a ()
- abort :: forall a v. (HasViewName v, Resetable v a) => Action v a ()
- noop :: Action v ctx ()
- chain :: Action v ctx a -> Action v ctx b -> Action v ctx b
- 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
- listUp :: forall v ctx. (HasList ctx, Foldable (T ctx), Splittable (T ctx)) => Action v ctx ()
- listDown :: forall v ctx. (HasList ctx, Foldable (T ctx), Splittable (T ctx)) => Action v ctx ()
- listJumpToEnd :: forall v ctx. (HasList ctx, Foldable (T ctx), Splittable (T ctx)) => Action v ctx ()
- listJumpToStart :: forall v ctx. (HasList ctx, Foldable (T ctx), Splittable (T ctx)) => Action v ctx ()
- reloadList :: Action Threads ListOfThreads ()
- toggleListItem :: forall v ctx. HasToggleableList ctx => Action v ctx ()
- untoggleListItems :: forall v ctx. HasToggleableList ctx => Action v ctx ()
- displayMail :: Action ViewMail ScrollingMailView ()
- setUnread :: Action ViewMail ScrollingMailView ()
- displayThreadMails :: Action Threads ListOfThreads ()
- toggleHeaders :: Action ViewMail ScrollingMailView ()
- switchComposeEditor :: Action Threads ListOfThreads ()
- replyMail :: Action ViewMail ScrollingMailView ()
- encapsulateMail :: Action ViewMail ScrollingMailView ()
- selectNextUnread :: Action ViewMail ListOfMails ()
- composeAsNew :: Action ViewMail ScrollingMailView ()
- createAttachments :: Action FileBrowser ListOfFiles ()
- openAttachment :: Action ViewMail ctx (Next AppState)
- setTags :: forall v ctx. HasToggleableList ctx => [TagOp] -> Action v ctx ()
- saveAttachmentToPath :: Action ViewMail SaveToDiskPathEditor ()
- scrollUp :: forall ctx v. Scrollable ctx => Action v ctx ()
- scrollDown :: forall ctx v. Scrollable ctx => Action v ctx ()
- scrollPageUp :: forall ctx v. Scrollable ctx => Action v ctx ()
- scrollPageDown :: forall ctx v. Scrollable ctx => Action v ctx ()
- scrollNextWord :: forall ctx v. Scrollable ctx => Action v ctx ()
- removeHighlights :: Action ViewMail ScrollingMailView ()
- delete :: Action ComposeView ComposeListOfAttachments ()
- enterDirectory :: Action FileBrowser ListOfFiles ()
- parentDirectory :: Action FileBrowser ListOfFiles ()
- handleConfirm :: Action ComposeView ConfirmDialog ()
- applySearch :: (MonadIO m, MonadState AppState m) => m ()
- initialCompose :: [Mailbox] -> Compose
Overview
Actions are composible functions. They can be sequenced and used in Keybinding
s.
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 (KCharq
) []) (noop
`chain'
` (focus
:: Action 'Threads 'ListOfThreadsAppState
) `chain
`continue
Adding new Actions
New Action
s 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 # | |
Defined in UI.Actions Methods makeViewportScroller :: Proxy ScrollingMailView -> ViewportScroll Name Source # | |
Scrollable ScrollingHelpView Source # | |
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.
Instances
Completable SearchThreadsEditor Source # | |
Defined in UI.Actions Methods complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy SearchThreadsEditor -> m () Source # | |
Completable ScrollingMailViewFindWordEditor Source # | |
Defined in UI.Actions Methods complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ScrollingMailViewFindWordEditor -> m () Source # | |
Completable ComposeFrom Source # | |
Defined in UI.Actions Methods complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ComposeFrom -> m () Source # | |
Completable ComposeTo Source # | |
Completable ComposeCc Source # | |
Completable ComposeBcc Source # | |
Defined in UI.Actions Methods complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ComposeBcc -> m () Source # | |
Completable ComposeSubject Source # | |
Defined in UI.Actions Methods complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ComposeSubject -> m () Source # | |
Completable ComposeListOfAttachments Source # | |
Defined in UI.Actions Methods complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ComposeListOfAttachments -> m () Source # | |
Completable ManageMailTagsEditor Source # | |
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. |
Defined in UI.Actions Methods complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ManageThreadTagsEditor -> m () Source # | |
Completable ManageFileBrowserSearchPath Source # | |
Defined in UI.Actions Methods complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ManageFileBrowserSearchPath -> m () Source # | |
Completable MailAttachmentOpenWithEditor Source # | |
Defined in UI.Actions Methods complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy MailAttachmentOpenWithEditor -> m () Source # | |
Completable MailAttachmentPipeToEditor Source # | |
Defined in UI.Actions Methods complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy MailAttachmentPipeToEditor -> m () Source # | |
Completable ConfirmDialog Source # | |
Defined in UI.Actions Methods complete :: (MonadIO m, MonadMask m, MonadState AppState m) => Proxy ConfirmDialog -> m () Source # | |
Completable SaveToDiskPathEditor Source # | |
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.
Instances
HasEditor SearchThreadsEditor Source # | |
Defined in UI.Actions | |
HasEditor ScrollingMailViewFindWordEditor Source # | |
Defined in UI.Actions | |
HasEditor ComposeFrom Source # | |
Defined in UI.Actions | |
HasEditor ComposeTo Source # | |
HasEditor ComposeCc Source # | |
HasEditor ComposeBcc Source # | |
Defined in UI.Actions | |
HasEditor ComposeSubject Source # | |
Defined in UI.Actions | |
HasEditor ManageMailTagsEditor Source # | |
Defined in UI.Actions | |
HasEditor ManageThreadTagsEditor Source # | |
Defined in UI.Actions | |
HasEditor MailAttachmentOpenWithEditor Source # | |
Defined in UI.Actions | |
HasEditor MailAttachmentPipeToEditor Source # | |
Defined in UI.Actions | |
HasEditor SaveToDiskPathEditor Source # | |
Defined in UI.Actions |
class HasName (a :: Name) where Source #
Generalisation in order to access the widget name from a phantom type
Instances
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
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 #
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.
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.
initialCompose :: [Mailbox] -> Compose Source #