Commit graph

122 commits

Author SHA1 Message Date
Reto Brunner
ea2646fc03 Change MarkedMessages to return uids
Especially if one tries to interact with all marked messages there could be
the case that not all headers are fetched yet, hence the messageInfo is still nil.

This segfaults a lot of commands which in principle only need the uid to complete.

If we switch to uids, this issue can be alleviated for those commands.
2020-05-11 09:47:34 -04:00
Jeffas
3102ac3680 Add recall command
This command allows recalling the selected postponed email to edit in
the composer. The command only allows recalling from the postpone
directory.
2020-04-24 12:59:21 -04:00
Jeffas
2a0430ab90 Set the store on the message list if it is nil 2020-02-28 20:54:15 -05:00
Jeffas
583b129c94 Don't set the store on an update to it
Updates to a store can be asynchronous so we shouldn't select it just
because it had an update. Selection of the stores should be driven by
explicit user commands.
2020-02-28 19:00:23 -05:00
Reto Brunner
d44bdc9fb9 Revert "Only fetch the directory contents when we are switching directories"
This reverts commit bd4df53009.

I did not properly untangle the opening / dirlist update of each other.
This interferes with the imap worker, hence the revert
2020-02-19 08:37:20 +01:00
Reto Brunner
bd4df53009 Only fetch the directory contents when we are switching directories
Previously, sending a DirectoryInfo assumed that a directory change
happened. However we don't want that if we only want to update the
unread message count.
2020-02-16 10:41:15 -05:00
Reto Brunner
ea0df7bee4 dirlist: adapt to dynamic UIconfig 2020-01-28 10:36:01 -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
2705d8460d add LabelList event 2019-12-21 11:20:11 -05:00
Reto Brunner
98418764b6 AccountView: implement ProvidesMessages 2019-12-21 09:27:48 -05: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
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
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
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
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
Kevin Kuehler
f81e4bd41c Implement :filter, :clear
Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
2019-07-19 11:30:32 -04:00
Daniel Bridges
217e85a55d Fix crashes when operating on empty folder (#216) 2019-07-10 13:21:38 -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
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
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
Drew DeVault
150a271b36 Add binding to toggle headers 2019-06-07 10:08:09 -04:00
Lucas F. Souza
2279ac3ab3 Skip rendering dirlist if sidebar width is 0 2019-06-07 09:20:06 -04:00
Kevin Kuehler
753adb9069 widget: Add ProvidesMessage interface
Consists of 3 functions
* Store: Access to MessageStore type
* SelectedAccount: Access to Account widget that the target widget
belongs to
* SelectedMessage: Current message (selected in msglist or the one we
are viewing)

Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
2019-06-02 10:16:29 -04:00
Kevin Kuehler
5090a4c802 Only add message to store if store exists
Prevents the program from panicing when changing folders too quickly.
onMessage can race store creation for an AccountView.

Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
2019-06-02 09:43:55 -04:00
Drew DeVault
2dc436555d Load IMAP worker for imap+insecure 2019-05-20 19:28:04 -04:00
Drew DeVault
5de1bb8cc3 Verify TLS certificates
I was partway done implementing a UI for users to approve untrusted
certs with, but let's just make them configure their servers right
instead.
2019-05-20 14:03:00 -04:00
Simon Ser
a15ea01cfb Update internal state and draw from the same goroutine
This commit introduces a new Aerc.Tick function that should be called to
refresh the internal state. This in turn makes each AccountView process worker
events.

The UI goroutine repeatedly refreshes the internal state before drawing a new
frame. The reason for this is that many worker messages may need to be
processed for a single frame, and drawing the UI is far slower than refreshing
the internal state. This has been confirmed in my testing (calling Aerc.Tick
only once per frame results in a slower display).

Many synchronization code has been removed. We can now write widgets without
having to care so much about races. The remaining sync users are:

- widgets/spinner: the spinner value is updated from inside an internal
  goroutine
- lib/ui/invalidatable: Invalidate may be called from any goroutine
- lib/ui/grid: same
- lib/ui/ui: an internal goroutine needs read access to UI.exit
- worker/types/worker: Worker.callbacks is used for both worker and UI
  callbacks

The exact goroutine requirements for Drawable have been documented.
2019-05-19 11:51:16 -04:00
Drew DeVault
98da4c9509 s/aerc2/aerc/g 2019-05-17 20:57:10 -04:00
Drew DeVault
fcdcd32de7 Remove unimplemented color configuration
Will probably end up doing this differently anyway
2019-05-17 11:52:38 -04:00
Drew DeVault
475b697bdf Implement (basic form) of :reply 2019-05-16 12:15:34 -04:00
Drew DeVault
db213fd0ae Implement :copy (aka :cp) 2019-05-14 16:44:59 -04:00
Drew DeVault
026e8a17ca Handle incoming emails gracefully 2019-05-13 20:16:55 -04:00
Drew DeVault
17bd2dc4db Populate "From" header from config for new emails 2019-05-13 16:04:01 -04:00
Simon Ser
5685a17674 lib/ui: introduce Invalidatable
Many Drawable implementations have their own Invalidate and OnInvalidate
functions, with an unexported onInvalidate field. However OnInvalidate and
Invalidate are usually not called in the same goroutine. This results in a race
on this field, e.g.:

    Read at 0x00c000094748 by goroutine 7:
      git.sr.ht/~sircmpwn/aerc2/widgets.NewDirectoryList.func1()
          /home/simon/src/aerc2/widgets/dirlist.go:85 +0x56
      git.sr.ht/~sircmpwn/aerc2/widgets.(*Spinner).Start.func1()
          /home/simon/src/aerc2/widgets/spinner.go:93 +0x1bb

    Previous write at 0x00c000094748 by main goroutine:
      [failed to restore the stack]

    Goroutine 7 (running) created at:
      git.sr.ht/~sircmpwn/aerc2/widgets.(*Spinner).Start()
          /home/simon/src/aerc2/widgets/spinner.go:46 +0x8f
      git.sr.ht/~sircmpwn/aerc2/widgets.NewDirectoryList()
          /home/simon/src/aerc2/widgets/dirlist.go:37 +0x286
      git.sr.ht/~sircmpwn/aerc2/widgets.NewAccountView()
          /home/simon/src/aerc2/widgets/account.go:50 +0x5ca
      git.sr.ht/~sircmpwn/aerc2/widgets.NewAerc()
          /home/simon/src/aerc2/widgets/aerc.go:60 +0x800
      main.main()
          /home/simon/src/aerc2/aerc.go:65 +0x33e

To fix this, introduce a new type, Invalidatable, which protects the field.
Unfortunately the Drawable must be passed to the callback function in
Invalidate, so we still need to re-implement this in each Invalidatable user.
2019-04-27 14:30:28 -04:00
Drew DeVault
0abafa60e1 Make message viewer real, part two 2019-03-31 12:35:51 -04:00
Drew DeVault
2958579ee7 Correct color of error messages 2019-03-30 13:05:00 -04:00
Drew DeVault
77ede6eb5a Add body fetching support code 2019-03-29 22:36:15 -04:00
Drew DeVault
312a53e5ff Implement :delete-message 2019-03-20 23:23:38 -04:00
Drew DeVault
589db742cb Move exline handling up to aerc, add :term 2019-03-17 16:19:15 -04:00
Drew DeVault
1170893e39 Add basic terminal widget 2019-03-17 14:02:33 -04:00
Drew DeVault
ef6178a12a Move MessageStore into its own file 2019-03-15 21:36:06 -04:00
Drew DeVault
77c76ba462 Implement default in accounts.conf 2019-03-15 21:33:08 -04:00
Drew DeVault
a729179f9f Implement sidebar-width config option 2019-03-15 20:40:28 -04:00
Drew DeVault
24dfc47126 Rig up key bindings 2019-03-15 01:46:14 -04:00
Drew DeVault
24daef89e0 Implement :{next,prev}-message 2019-03-14 23:41:25 -04:00
Drew DeVault
4ec7f5dea5 Use cached message store when re-opening dirs 2019-03-14 22:41:43 -04:00
Drew DeVault
62946ff6c5 Implement :cd command 2019-03-14 22:34:34 -04:00
Drew DeVault
11f0a7267f Implement message store side of message fetching 2019-03-14 21:51:29 -04:00
Drew DeVault
0f8b7a1203 Lay out message list widget basic design 2019-03-14 21:37:00 -04:00
Drew DeVault
b3896476a0 Fetch valid UIDs from server after opening dir 2019-03-10 23:45:00 -04:00
Drew DeVault
289e3b09ea Improve error reporting 2019-03-10 21:26:53 -04:00
Drew DeVault
d394fd1f3b Flesh out command parsing & handling 2019-03-10 21:23:22 -04:00
Drew DeVault
b60999c39e Start building out command subsystem 2019-03-10 21:15:24 -04:00
Elias Naur
607ece8302 Fix build 2019-02-10 17:11:19 -05:00
Drew DeVault
12284487b4 Implement Container interface in widgets/ 2019-01-20 15:08:30 -05:00
Drew DeVault
8492a21a51 Send commands up to the top-level aerc widget 2019-01-14 08:14:03 -05:00
Drew DeVault
a409a9faa5 Handle errors from worker initialization 2019-01-13 20:06:18 -05:00
Drew DeVault
c047b068c2 Swap message list placeholder for spinner 2019-01-13 20:04:18 -05:00
Drew DeVault
f87fe502a6 Handle connection errors properly 2019-01-13 19:41:21 -05:00
Drew DeVault
cf66462000 Simplify approach to directory list
This doesn't really need to be abstract tbh
2019-01-13 15:32:52 -05:00
Drew DeVault
755aa9af73 Filter dirlist according to user config 2019-01-13 14:32:22 -05:00
Drew DeVault
2349b7de86 Add directory list widget 2019-01-13 14:26:46 -05:00
Drew DeVault
c286d3da6b Move ex line into account 2019-01-13 13:33:43 -05:00
Drew DeVault
b76deea963 Move status line into account, update behavior 2019-01-13 13:25:56 -05:00
Drew DeVault
0911cd5050 Initialize worker in account widget 2019-01-13 13:03:28 -05:00
Drew DeVault
648ca983f6 Add basic account widget, populate real acct views 2019-01-13 12:39:06 -05:00