Commit Graph

88 Commits

Author SHA1 Message Date
Tim Culverhouse 3a614e45fc threading: enable toggle-threads for server-side threads
Enable the :toggle-threads command to work for workers which have Thread
capability. The implementation of that feature has the side effect that
the threading-enabled config option now sets the default view (threaded
or not threaded) for any worker, not just IMAP or notmuch.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 21:15:12 +02:00
Tim Culverhouse 635530b12d msglist: fix panic for index-out-of-range
I didn't save the stack trace, but msglist.Selected() can create a panic
for index out of range due to the math operations in the map. My stack
trace resulted in a [-9]. This patch reuses the msgstore.Selected()
method, which already has bounds checking.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 20:40:22 +02:00
Tim Culverhouse 4240f1fbfd perf: reduce calls to GetUiConfig
GetUiConfig was being called many times, and came up as a high CPU user
in a cpuprofile. Every call would merge a UIConfig, which is a costly
operation. Ideally, we would only need to have a config for every
account X every directory. We also have a context for subjects. This
patch stores all FOLDER and ACCOUNT level configs and reuses those
merged objects. The SUBJECT contexts are not stored in favor of merging
on-the-go, with a TODO comment to deprecate that feature and implement a
better per-message styling option. I suspect this feature is not used
very much.

Before applying this patch with my setup, GetUiConfig is called 1159
times just to open aerc. After applying, this is reduced to 37.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-03 21:32:24 +02:00
Tim Culverhouse d09636ee0b refactor: refactor pgp implementation
This commit refactors the internal PGP implementation to make way for
GPG integration.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-27 09:46:11 +02:00
Koni Marti 9f4da4de0c msglist: update message counter upon filter change
Update message counter in msglist when the filter is changed (either set or
cleared in the msgstore).

When we apply a filter, we change the number of uids in the message
store. This can unintentionally trigger the storeUpdate() function of
the msglist which checks the number of uids for new messages and
advances the pointer by the difference in the number of messages. This
can be avoided when we update the message counter upon changing the
filter.

Fixes: https://todo.sr.ht/~rjarry/aerc/23
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-20 10:00:50 +01:00
Koni Marti 515a8b56f6 scrollable: extract scrolling behavior for reuse
Extract the vertical scrolling ability into its own Scrollable struct
that can be embedded and reused across any ui element that relies on
scrolling.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-03 21:11:05 +01:00
Robin Jarry c26d08103b aerc: always check SelectedAccount return value
aerc.SelectedAccount() is used in lots of places. Most of them without
checking the return value.

In some cases, the currently selected tab is not related to any account
(widget.Terminal for example). This can lead to unexpected crashes when
accessing account specific configuration.

When possible, return an error when no account is currently selected.
If no error can be returned, fallback to non-account specific
configuration.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Koni Marti <koni.marti@gmail.com>
2022-02-25 13:56:53 +01:00
Koni Marti 7811620eb8 threading: implement on-the-fly message threading
implement message threading on the message store level using the
jwz algorithm. Build threads on-the-fly when new message headers arrive.

Use the references header to create the threads and the in-reply-to
header as a fall-back option in case no references header is present.

Does not run when the worker provides its own threading (e.g. imap
server threads).

Include only those message headers that have been fetched and are
stored in the message store.

References: https://www.jwz.org/doc/threading.html
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Inwit <inwit@sindominio.net>
Tested-by: akspecs <akspecs@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-02-24 13:00:12 +01:00
y0ast dc2a2c2dfd messages: allow displaying email threads
Display threads in the message list. For now, only supported by the
notmuch backend and on IMAP when the server supports the THREAD
extension.

Setting threading-enable=true is global and will cause the message list
to be empty with maildir:// accounts.

Co-authored-by: Kevin Kuehler <keur@xcf.berkeley.edu>
Co-authored-by: Reto Brunner <reto@labrat.space>
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-13 15:05:59 +01:00
Robin Jarry 84146e23b3 index: add this-week-time-format
Also allow specific time format for messages received within the last
7 days.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-06 17:34:20 +01:00
Robin Jarry 0d645bcebd go.mod: change base git url
I'm not sure what are the implications but it seems required.

Link: https://github.com/golang/go/issues/20883
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-11-05 10:21:45 +01:00
Robin Jarry 42b4302ba3 index: allow dynamic formatting of message dates
When a message has been sent today (or this year) allow formatting the
date differently.

For example, with:

 [ui]
 index-format=%-25.25n   %-25.25D   %s
 timestamp-format=2006 Jan 02, 15:04 GMT-0700
 this-day-time-format=Today at 15:04
 this-year-time-format=Jan 02

The message list would look like this (spaces collapsed):

 Robin Jarry        Today at 16:30             [PATCH 1/2] bindings: prepare for more modifers
 bugzilla@dpdk.org  Oct 26                     [dpdk-dev] [Bug 839] pdump: any subsequent runs of pdump_autotest fail
 Holger Levsen      2020 Mar 15, 13:44 GMT+01  +1 (Re: FTP Team -- call for volunteers)

Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-10-28 16:30:59 +02:00
Shaw Vrana 3c14c2cb34 Reapply 'Fix nil pointer deref on Envelope'
The commit bf16ccde48 appears to have been
unintentionally dropped by commit 905cb9dfd3
(Implement style configuration).
2021-01-03 09:08:27 +01:00
y0ast 03650474e2 update tcell to v2 and enable TrueColor support
Also update to the tcell v2 PaletteColor api, which should keep the chosen
theme of the user intact.

Note, that if $TRUECOLOR is defined and a truecolor given, aerc will now stop
clipping the value to one of the theme colors.
Generally this is desired behaviour though.
2020-12-18 07:23:22 +01:00
Chris Vittal f9bba3d17d Apply relevant msglist styles in order
Allow styles to be layered over a base style. The list of styles to
apply is layered over the base style in order, such that if the layer
does not differ from the base it is not used. The order that these
styles are applied in is, from first to last:

msglist_default
msglist_unread
msglist_read    (exclusive with unread, so technically the same level)
msglist_flagged
msglist_deleted
msglist_marked

So, msglist_marked style dominates.

This fixes an issue where the msglist_deleted style was not being applied.
2020-11-01 09:50:58 +01:00
Reto Brunner 75cbf76732 refactor ParseMessageFormat to use a ctx object 2020-10-14 08:42:26 +02:00
y0ast f09e3966a7 correctly apply msglist_read color 2020-09-01 19:09:27 +02:00
Kalyan Sriram 905cb9dfd3 Implement style configuration.
Introduce the ability to configure stylesets, allowing customization of
aerc's look (color scheme, font weight, etc). Default styleset is
installed to /path/to/aerc/stylesets/default.
2020-08-06 21:42:06 +02:00
Reto Brunner 3d784c5d8c Revert "Implement style configuration."
This reverts commit 1ff687ca2b.
2020-07-30 23:22:32 +02:00
Kalyan Sriram 1ff687ca2b Implement style configuration.
Introduce the ability to configure stylesets, allowing customization of
aerc's look (color scheme, font weight, etc). Default styleset is
installed to /path/to/aerc/stylesets/default.
2020-07-30 19:35:59 +02:00
Andrew Jeffery bf16ccde48 Fix nil pointer deref on Envelope
The Envelope was nil but being deref'ed for the Subject. This was
experienced when switching tabs on IMAP.
2020-07-02 09:12:37 +02:00
Jeffas d841c8c251 Add scrollbar
This transplants the logic for drawing the scrollbar from dirlist and
the completion popover and adds it to the msglist.
2020-06-09 21:52:16 +02:00
Jeffas 15b72df1da Rework msglist scrolling
This changes the scrolling to be done on the draw, when the height is
updated, ensuring that the selected item is kept on screen during
resizing.

Also, this ensures that messages will fill the screen when resizing the
window, for instance, shrinking and then growing drags down more
messages if possible.

This is a transplant of the dirlist scrolling logic.
2020-06-09 21:52:10 +02:00
Drew DeVault caad1b2c06 Revert "Add Style configuration"
This reverts commit 0f78f06610.
2020-05-28 10:32:42 -04:00
Drew DeVault 76a91813d8 Revert "Remove duration from the status methods"
This reverts commit f06d683688.
2020-05-28 10:32:32 -04:00
Reto Brunner f06d683688 Remove duration from the status methods
We always set 10 seconds anyhow, might as well do that without repeating ourselfs.
2020-05-27 08:11:40 +02:00
Reto Brunner 0f78f06610 Add Style configuration
The following functionalities are added to configure aerc ui styles.
- Read stylesets from file with very basic fnmatch wildcard matching
- Add default styleset
- Support different stylesets as part of UiConfig allowing contextual
  styles.
- Move widgets/ui elements to use the stylesets.
- Add configuration manual for the styleset
2020-05-27 07:57:10 +02:00
Ray Ganardi 58db517c8d pgp: fail gracefully from email decryption
Aerc panics when there's an error on email decryption.
Instead, an error message should be shown.
2020-05-25 09:30:20 -04:00
Drew DeVault f3158b36f1 Initial support for PGP decryption & signatures 2020-03-03 16:49:52 -05:00
Jeffas e661ead57b Only show spinner while sorting if no uids
This fixes the problem where we already have messages and then have to
sort again.
2020-02-28 23:03:34 -05:00
Jeffas b55813f2c0 Don't show empty message while sorting
This changes the ui to show the spinner while we are sorting. It only
shows one line of the spinner since there are an unknown number of
messages at this time.
2020-02-28 22:06:01 -05:00
Wiktor Kwapisiewicz 1455ad97a9 Fix crash on mouse scrolling before messages load
Using mouse scroll before messages load will trigger a panic as
`ml.store` has not been assigned yet and is `nil`.
2020-02-22 11:06:15 -05:00
Reto Brunner e78b7b85e4 config: Strongly type context type
The go compiler can't help much with untyped int constants.
Even though the only valid constants are 0-3 it will happily accept 4 as input.

Let's let the go compiler worry about correctness here. This also allows people
not very familiar with the code to use it properly via auto completion.
2020-01-24 12:25:59 -05:00
Srivathsan Murali b2fa5a16f5 Contextual UI Configuration
+ Adds parsing of contextual ui sections to aerc config.
+ Add GetUiConfig method for AercConfig that is used to get the
  specialized UI config.
+ Add UiConfig method to AccountView to get specialized UI Config.
+ Modifies Aerc codebase to use specialized UIConfig instead.
+ Adds documentation for Contextual UI Configuration
2020-01-24 10:50:21 -05:00
Reto Brunner b9d2938f9f msglist: highlight marked messages
Note that, until we get color configuration, this means that the user *must*
have the %Z verb in the index format else it'll be horribly confusing
as no visual indication is provided
2019-12-21 09:27:53 -05:00
Srivathsan Murali c655afa32b Complete the F rune.
%F now shows the auth name or recepient name/address if the
message is from you.
2019-11-17 13:19:20 -05:00
Drew DeVault f1b365dfc3 Revert "Show spinner when fetching contents"
This reverts commit 1339faf788.
2019-10-09 19:57:53 -04:00
Jeffas 1339faf788 Show spinner when fetching contents
The spinner should be shown when fetching the contents as we don't know
at that point whether there are some messages or not.
2019-10-09 19:46:43 -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
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
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
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
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
Kevin Kuehler f81e4bd41c Implement :filter, :clear
Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
2019-07-19 11:30:32 -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 bf02ad30ca Fix jumping around in search 2019-06-26 20:52:34 -04:00