Commit graph

314 commits

Author SHA1 Message Date
Jeffas
00b9ca5032 Fix selected account to return for messageviewer
This ensures that the selectedaccount is returned if currently selected
tab is a messageviewer. This also makes it more extensible for adding
other ways of getting the selected account.
2019-10-02 15:40:23 -04:00
Jeffas
90d26da58a Add sorting functionality
There is a command and config option. The criteria are a list of the
sort criterion and each can be individually reversed.

This only includes support for sorting in the maildir backend currently.
The other backends are not supported in this patch.
2019-09-20 14:56:02 -04:00
Drew DeVault
956f1366a5 Revert "Fix out-of-order messages by sorting as we display"
This reverts commit ac99d9ed62.
2019-09-18 10:21:45 -04:00
Wagner Riffel
ecc26b53c9 widgets: remove duplicate import
Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
2019-09-12 23:42:08 -04:00
Jeffas
e2d5c456dc Add signatures
This adds the ability for per-account signatures in the accounts.conf
config file. The signature is added to emails in the editor at the
bottom of the email. This includes when forwarding, replying to, and
composing emails.

There are two config options: signature-file and signature-cmd. The
former allows a signature to be read from a file and the latter allows
an arbitrary command to be executed to return the signature.

The config options have been documented in aerc-config
2019-09-12 16:18:34 -04:00
Reto Brunner
a93b4de6f3 Add modify-labels command
This adds the event type as well as the command implementation, but no backend
supports it yet.
2019-09-12 16:17:24 -04:00
Jeffas
618a500341 Add display of unread messages in dirlist
Add an onUpdateDirs handler. This is used to invalidate the dirlist and
redraw with the correct number of recent/unread/total messages is shown.

A config option and formatting options are provided.
2019-09-11 12:37:43 -04:00
Devon Johnson
572d9ff728 Fix segfault on delete 2019-09-11 12:24:37 -04:00
Jeffas
f6216bb621 Add Mouseable
This adds the Mouseable interface. When this is implemented for a
component that item can accept and process mouseevents.

At the top level when a mouse event is received it is passed to the
grid's handler and then it trickles down until it reaches a component
that can actually handle it, such as the tablist, dirlist or msglist.

A mouse event is passed so that components can handle other things such
as scrolling with the mousewheel. The components themselves then perform
the necessary actions.

Clicking emails in the messagelist opens them in a new tab.

Textinputs can be clicked to position the cursor inside them.

Mouseevents are not forwarded to the terminal at the moment.

Elements which do not handle mouse events are not required to implement
the Mouseable interface.
2019-09-11 11:41:34 -04:00
Wagner Riffel
e28f45b5aa widgets: gofmt
Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
2019-09-04 16:30:57 -10:00
Wagner Riffel
1d04c2a292 widgets: rewrite references to os.SET_SEEK to io.SeekStart
Os.SET_SEEK is deprecated, it's recommended to use contants from io
package

Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
2019-09-04 16:30:57 -10:00
Wagner Riffel
6838c23478 all: purge redundant underscores
Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
2019-09-04 16:30:57 -10:00
a3v
2257b29a82 Use sort.Stable for sorting displayed messages
With sort.Sort, sometimes two messages with the same timestamp will switch
places every time the message list is redrawn
2019-09-02 10:27:54 +09:00
Paul Spooren
e4104a8674 Allow custom spinner via config file
Allows to set `ui.spinner=` to a string which is then split by
`ui.spinner-delimiter=` (Default: comma) instead of having a hard coded
animation.

This implementation doesn't use INIs capabilities to split strings as
it trims whitespaces breaking the default animation.

Signed-off-by: Paul Spooren <mail@aparcar.org>
2019-08-30 10:32:28 +09:00
Stephen Brennan
ac99d9ed62 Fix out-of-order messages by sorting as we display
Sometimes I observe out-of-order messages when using a maildir inbox. It
appears that the UIDs for these messages are returned out of order by
the MessageStore. In order for a maildir MessageStore to return messages
in most recently received order, it must have already opened all
messages and parsed the date to use as a sort key. Rather than implement
that, simply sort messages by time as we display. This fix shows my
emails in order.
2019-08-29 08:44:08 +09:00
Christopher Vittal
ecd803aae4 Add :prompt command
Usage:
    :prompt <prompt> <command...>

Displays the prompt on the status bar, waits for user input, then
appends that input as the last argument to the command and executes it.
The input is passed as one argument to the command, unless it is empty,
in which case no extra argument is added.
2019-08-26 09:48:39 +09:00
Daniel Xu
6fcc047c31 Only compile regex portion of folder filter
The code was trying to compile the `~` as well. In this case, it was
trying to match a literal `~` to the front of the supplied regex.

Fixes: 334ca89bea ("folder filter: only assume regex if filter is
~fmt")

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
2019-08-20 16:03:37 +09:00
Drew DeVault
334ca89bea folder filter: only assume regex if filter is ~fmt 2019-08-20 13:04:58 +09:00
Jelle Besseling
1f5293931a Add forwarding as attachment feature
This allows a single message to be forward as attachment with the
:forward -a command
2019-08-20 10:05:51 +09:00
Jelle Besseling
36c6030e81 Add addresses argument to forward command 2019-08-20 10:04:29 +09:00
Christopher Vittal
cc639a1e65 Add support for <C-j> as '<Enter>' in ExLine 2019-08-19 15:23:07 +09:00
Daniel Xu
9fd6054ca1 Support regex filters for folders
It's nice to be able to filter the folders displayed in the side
bar. Basic string matching can get verbose with enough folders
whitelisted.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
2019-08-19 15:22:59 +09:00
Drew DeVault
4fc6fee734 Revert "add close command at global level"
This reverts commit f0a0c5aa73.
2019-08-13 10:55:50 +09:00
Aditya Srivastava
f0a0c5aa73 add close command at global level 2019-08-13 10:49:34 +09:00
Drew DeVault
5493af8c8f Prevent drawing terminal with nil cmd 2019-08-12 09:51:45 +09:00
Jelle Besseling
4478c6a4b7 Ignore scroll command when msgstore is nil
Fixes ~sircmpwn/aerc2#205. Many functions do a nil check on the store,
so this changes Store() so it returns nil when msglist is nil.

It also places the Scroll() behind the nil check in the next-message command.

https://todo.sr.ht/~sircmpwn/aerc2/205
2019-08-12 08:58:57 +09:00
Reto Brunner
072b5f453c Close backends prior to shutdown
We need some way to signal the backends that we are about to shutdown,
allowing them to clean up (for example in notmuch committing the db changes).
This commit implements a hook which gets called upon shutdown, providing
backends implement the io.Closer interface.
2019-08-08 10:24:03 +09:00
Jelle Besseling
3650b72ca6 Implement next-folder using NextPrev with amount
This fixes ~sircmpwn/aerc2#182

https://todo.sr.ht/~sircmpwn/aerc2/182
2019-08-07 15:02:11 +09:00
Daniel Bridges
0a52124102 Allow cc/bcc command to receive no arguments 2019-08-07 14:07:48 +09:00
Kevin Kuehler
0ceea02720 cc/bcc: Append to existing headers if called twice
Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
2019-08-07 14:07:22 +09:00
Ben Cohen
302bc1cda6 Fixing #231 (alternative preferred mimetypes) 2019-08-03 10:47:58 -04:00
Daniel Bridges
f4b7741463 Add cc and bcc commands 2019-08-03 10:43:55 -04:00
Ben Burwell
c9a909fee3 Fix sending attachments with less than 512 bytes 2019-08-02 09:34:10 -04:00
Ben Burwell
bb620e0900 Include body MIME terminator in multipart messages
Before, the text/plain part of the multipart MIME message was not being
correctly terminated with its boundary. The multipart writer writes the
terminator when its Close is called, but since the call to Close() was
deferred, it was not being called until after the attachments were being
written resulting in the boundary not being included at all.
2019-08-02 09:34:08 -04:00
Reto Brunner
9570f4b4d0 msglist: add initialization state
Make the msglist aware of whether we are still initializing or not.
We never stopped spinning the msglist if we didn't get any Directories back
from types.ListDirectories.
With this change, we can set the init state from the account and display
the spinner only if we don't know whether we have directories or not and else
the "no messages" string from the config.
2019-08-02 09:26:10 -04:00
Ben Burwell
152f8c9519 Ring bell when new messages arrive
Add a "new-message-bell" option to the UI section of aerc.conf. A new
hook into the message store allows the msglist widget to detect new
messages being added to the displayed list. When new messages are
delivered, and the new-message-bell option is enabled (as it is by
default), the terminal will beep.
2019-07-29 15:01:49 -04:00
Jeffas
989730d470 Add index option to change-tab
This allows selection of a tab using its index. It attempts to parse the
given argument as a number, if it fails then it uses it as a name.

Also supports relative indexes using prefixed + or -.
2019-07-27 12:40:28 -04:00
Galen Abell
0ee7d30187 Add :detach command
Add a command for removing attachments from a composed message. Syntax
is :detach [path], with path being an optional argument specifying the
path of one existing attachment. If no path is specified, the first
attachment is removed.
2019-07-27 12:37:55 -04:00
Galen Abell
a669233614 Fix review message not filling entire space
Adding an attachment, switching to a different tab, and switching back
to the review message caused the "filled space" in the review message to
disappear, since there was one too many rows in the layout.
2019-07-27 12:37:54 -04:00
Jeffas
cded067bc3 Add tab completion to textinputs
This adds tab completion to textinput components. They can be configured
with a completion function. This function is called when the user
presses <tab>. The first completion is initially shown to the user
inserted into the text. Repeated presses of <tab> or <backtab> cycle
through the completions list. The completions list is invalidated when
any other non-tab-like key is pressed.

Also changed is some logic for current completion generation so that
all available commands are returned when <tab> is pressed with no
current text and similarly for arguments of commands.
2019-07-26 14:39:42 -04:00
Galen Abell
8635c70fda Add command history and cycling
Aerc will keep track of the previous 1000 commands, which the user can
cycle through using the arrow keys while in the ex-line. Pressing up
will move backwards in history while pressing down will move forward.
2019-07-26 14:29:34 -04:00
Daniel Bridges
67fb0938a6 Support configurable header layout in compose widget 2019-07-26 14:22:04 -04:00
Jeffas
1b673b5ea7 Move msgstore map to dirstore
This map represents a mapping from directory names to their associated
messagestores anyway so they should be under dirstore. This simply moves
them there and adds some methods required to interact with them.
2019-07-26 14:15:27 -04:00
Jeffas
dc4c36adbf Add new-email trigger
This patch sets up the trigger config section of aerc.conf.

Each trigger has its own function which is called from the place where
it is triggered. Currently only the new-email trigger is implemented.

The triggers make use of format strings. For instance, in the new-email
trigger this allows the user to select the trigger command and also the
information extracted from the command and placed into their command.

To actually execute the trigger commands the keypresses are simulated.

Further triggers can be implemented in the future.

Formatting of the command is moved to a new package.
2019-07-26 14:00:24 -04:00
Jeffas
0950e39f53 Show the directory being selected in gray 2019-07-25 18:15:49 -04:00
Jeffas
e42b95a617 Add change tab command
This command allows the user to change tab by giving the tab name. This
can be tab completed too. The previous tab is stored in the tabs module
so that when a new tab is created it is still possible to go to the
previous one.

Normal invocation is :ct folder
Previous tab is :ct -
2019-07-23 10:27:59 -04:00
Drew DeVault
97bee661b7 Fix alternatives config 2019-07-19 17:26:43 -04:00
Drew DeVault
d8518909cc Add [a]ttach to the review message prompts 2019-07-19 16:12:26 -04:00
Drew DeVault
7a489cb001 Add Unix socket for communicating with aerc 2019-07-19 14:15:48 -04:00
Kevin Kuehler
f81e4bd41c Implement :filter, :clear
Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
2019-07-19 11:30:32 -04:00
Galen Abell
7899d15d60 Add :attach command for compose
Allow users to add attachments to emails in the Compose view. Syntax is
:attach <path>, where path is a valid file. Attachments will show up in
the pre-send review screen.
2019-07-19 10:30:47 -04:00
Jeffas
fb124139f3 Add option to always show mimetype in viewer
A user may want to be able to see what mimetype they are viewing, so
that they can determine what program it may be opened in or for some
other reason.

The config option is under the [viewer] section and is called
'always-show-mime'. It defaults to false to preserve the current
behaviour.
2019-07-17 17:34:43 -04:00
Jeffas
4a5aa7dc27 Remove passing of showHeaders explicitly
Where it is needed the configs are already available so just extract the
value from these.
2019-07-17 17:33:31 -04:00
Jeffas
1d1fe7c7ef Ensure new partswitcher doesn't start on multipart 2019-07-17 17:31:49 -04:00
Daniel Bridges
dfc048fe28 Display user specified headers in viewer if present 2019-07-17 17:26:43 -04:00
Jeffas
d7975132b6 Show currently pressed keys in statusline
This patch adds the currently pressed keys to the statusline. This is
useful when keybindings are multiple keys long and you might forget
which keys are already pressed.
2019-07-17 17:12:52 -04:00
Drew DeVault
dbd583c969 Revert "Ensure new partswitcher doesn't start on multipart"
This reverts commit 41390bc3e1.
2019-07-17 16:09:40 -04:00
Jeffas
8534720e72 When reviewing an email don't pass characters on
This stops characters being passed to the focused box when reviewing an
email. To edit headers the user should go back to the edit page.
2019-07-17 16:00:02 -04:00
Jeffas
41390bc3e1 Ensure new partswitcher doesn't start on multipart 2019-07-17 15:59:09 -04:00
Drew DeVault
5b2336d0d7 Don't initialize an invalid pty size 2019-07-13 11:13:48 -04:00
Jeffas
3b09c07e7a Add clickable tabs
This introduces a new interface `Clickable`. I'd imagine this would be
implemented for most widgets eventually and would allow for programs run
in the terminal to also have their mouse events forwarded to them.

For the tabs it was relatively simple to check that the position of the
click is within the boxes for the tabs. For other components I'd imagine
that some state representing their currently drawn bounding box would be
useful.
2019-07-11 19:45:53 -04:00
Jeffas
0b3aca4167 Add backtab to tutorial navigation
This allows users to use backtab (Shift+tab) to go back through the
fields in the tutorial, like C-K. This then mimics the other methods in
having a forward and backward variant.

Also documented this in the wizard help paragraph.
2019-07-11 19:38:12 -04:00
Daniel Bridges
217e85a55d Fix crashes when operating on empty folder (#216) 2019-07-10 13:21:38 -04:00
Ben Burwell
c610c3cd9d Factor IMAP-specific structs out of UI models
Before, we were using several IMAP-specific concepts to represent
information being displayed in the UI. Factor these structures out of
the IMAP package to make it easier for other backends to provide the
required information.
2019-07-08 16:06:28 -04:00
Ben Burwell
cce7cb4808 Factor UI models out of the worker message package
Before, the information needed to display different parts of the UI was
tightly coupled to the specific messages being sent back and forth to
the backend worker. Separating out a models package allows us to be more
specific about exactly what a backend is able to and required to
provide for the UI.
2019-07-08 16:06:23 -04:00
Drew DeVault
363aab5cc1 Make :pipe command more generic 2019-07-05 12:21:12 -04:00
Drew DeVault
f7387f8c60 Sort out dirstore once and for all 2019-07-04 12:31:27 -04:00
Reto Brunner
b12eba55c3 dirlist: simplify nextPrev() considerably
Assuming we always have a sorted dirlist
(other code depends on that already), we don't need to loop over the
dirStore.
Any filtering done should be performed elsewhere
2019-07-04 12:24:16 -04:00
Reto Brunner
0abca31c15 dirlist: remove the additional filtering in Draw() 2019-07-04 12:24:16 -04:00
Reto Brunner
d7fecf7740 dirlist: sync dirstore in filterDirsByFoldersConfig
Also sets the public List() method to return the unfiltered
list of directories directly from the store.
2019-07-04 12:24:16 -04:00
Gregory Mullen
f9d26eef58 Add IMAP folder tab completion
Credit for this fix goes to Reto; I guess if we're not gonna be mutt
we should probabaly do things correctly.
2019-07-04 11:28:04 -04:00
Ben Burwell
8d9d94f0ee Use go-message implementation of GenerateMessageID
Now that this is available in the upstream, we no longer need to
maintain a parallel implementation.
2019-07-04 11:24:19 -04:00
Drew DeVault
491e360178 Revert "Remove dirs field and references to it"
This reverts commit 0e55637aac.
2019-07-02 19:43:41 -04:00
Robert Günzler
0e55637aac Remove dirs field and references to it
This fixes prev/next-folder that broke after
546dfcd76d
2019-06-30 10:33:50 -04:00
Gregory Mullen
546dfcd76d Add new lib/dirstore to source completions from 2019-06-29 14:24:19 -04:00
Gregory Mullen
2a0961701c Implement basic tab completion support
Tab completion currently only works on commands. Contextual completion
will be added in the future.
2019-06-29 14:24:19 -04:00
Stefan Rakel
59df06fe28 Reopening mailcontent file to fix #166
Because editors like vim use backupfiles and rename them to the original
name, the file handle used can point to the wrong file. Reopening the
file should fix this.
2019-06-27 09:25:27 -04:00
Drew DeVault
bf02ad30ca Fix jumping around in search 2019-06-26 20:52:34 -04:00
Drew DeVault
91a75cd98b Implement :search, :next-result, :prev-result 2019-06-26 20:50:54 -04:00
Daniel Lublin
61c94e54cd account-wizard: look up imap and smtp server by SRV records (#100) 2019-06-25 10:31:28 -04:00
Drew DeVault
ceeb30abeb Fix Cc & Bcc handling in replies 2019-06-21 14:33:09 -04:00
Noah Loomans
d1654def19 account-wizard: automatically replace imap.* with smtp.*
Many email providers use the imap sub-domain for imap and the smtp
sub-domain for smtp. FastMail is an example of this[1]. This is a small
quality-of-life improvement which automatically replaces imap.* with
smtp.* when going from the imap screen to the smtp screen in the wizard

[1]: https://www.fastmail.com/help/technical/servernamesandports.html
2019-06-18 19:40:02 -04:00
Reto Brunner
99c363b724 Set empty message in dirlist if no folder exist. 2019-06-14 10:42:26 -04:00
Reto Brunner
626f91c483 imap: respect the folder config option 2019-06-14 10:42:24 -04:00
Drew DeVault
408a9e7b10 Fix automatic scrolling when messages arrive/leave 2019-06-11 10:08:44 -04:00
Kevin Kuehler
a54f4adb8f lib/ui/tab: Add Replace method
Also expose a light wrapper method in aerc.go for tab replacement

Signed-off-by: Kevin Kuehler <kkuehler@brave.com>
2019-06-11 09:34:45 -04:00
Kevin Kuehler
32f970e053 Move select functionality from msglist to msgstore
Remove msglist Next and Prev commands

Signed-off-by: Kevin Kuehler <kkuehler@brave.com>
2019-06-11 09:34:36 -04:00
Clayton Craft
dd178262bb Select user's preferred mimetype in MessageViewer
This implements selecting the most preferred mimetype under the
'View->Alternatives' configuration setting when viewing a message.
Mimetypes in the alternatives array are weighted by their position,
where the lower the index in the array the higher the priority, so this
is taken into account during selection.

If no message part matches a mimetype in the alternatives array, then it
selects the first mimetype in the message.
2019-06-09 11:49:11 -04:00
Robert Günzler
acfe7d7625 Add archive command
Adds an archive command that moves the current message into the folder
specified in the account config entry.

Supports three layouts at this point:

- flat: puts all messages next to each other
- year: creates a folder per year
- month: same as above, plus folders per month

This also adds a "-p" argument to "cp" and "mv" that works like
"--parents" on mkdir(1). We use this to auto-create the directories
for the archive layout.
2019-06-09 11:33:50 -04:00
Yash Srivastav
5f651b32e5 msglist: use distinct style for unread emails 2019-06-08 10:59:51 -04:00
Drew DeVault
da62f63aad Truncate long subject lines 2019-06-07 16:22:04 -04:00
Yash Srivastav
fca7321639 Message list: implement index-format option 2019-06-07 16:22:01 -04:00
Drew DeVault
0647ea6483 Move ANSI stripping from filters to Go 2019-06-07 11:14:50 -04:00
Drew DeVault
668f7f9e5d Remove unnecessary branch 2019-06-07 10:19:29 -04:00
Drew DeVault
a974027efe Execute the editor with the shell
Fixes #164
2019-06-07 10:15:35 -04:00
Drew DeVault
150a271b36 Add binding to toggle headers 2019-06-07 10:08:09 -04:00
Yash Srivastav
b83e7c9fa6 implements ability to view headers in message view 2019-06-07 09:20:24 -04:00
Lucas F. Souza
2279ac3ab3 Skip rendering dirlist if sidebar width is 0 2019-06-07 09:20:06 -04:00
Drew DeVault
92dc31bad0 Use SetAddressList for From header 2019-06-05 13:58:07 -04:00
JanUlrich
0771eaf24c Introduce :new-account -t
Adding the [-t] temporary flag to the new-account command
- when using -t a newly created account will not be stored into the
accounts.conf

Issue #134
2019-06-05 09:32:43 -04:00