aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
Commit message (Collapse)AuthorAgeFilesLines
* wizard: do not require full nameRobin Jarry2023-08-261-8/+7
| | | | | | | | Allow users to omit their full name. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* wizard: factorize ui layoutRobin Jarry2023-08-261-219/+156
| | | | | | | | | | Avoid code duplication. Use a struct to store all fields along with their respective labels. Generate a ui.Grid at once with the correct padding between the fields. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* wizard: better url generationRobin Jarry2023-08-261-44/+40
| | | | | | | | | Prepare for other protocols. Do not expect that there will be an username/password. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* wizard: add protocol & transport fieldsRobin Jarry2023-08-262-89/+152
| | | | | | | | | | | | | In preparation for other protocols, add a new "Protocol" field both in the source and outgoing sections. For now, there is only one source protocol and one outgoing protocol. Rename the "mode" fields to "transport". They will be reused later to include different authentication mechanisms. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* wizard: autofill improvementsRobin Jarry2023-08-261-18/+30
| | | | | | | | | | | | | | * Do not determine the IMAP server based on the email domain. It will most of the time be incorrect. * Only mirror the email address in usernames if they are unset. * Only mirror the IMAP username & password into their SMTP counterparts if these are unset. * Try to guess the SMTP server based on the IMAP server only if the former is empty. * Only display the password warning if the user did type a password. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* wizard: rename incoming to sourceRobin Jarry2023-08-261-138/+136
| | | | | | | | | | | | | | | | | | | Rename stuff in preparation of support for other protocols. Match the terminology from accounts.conf. This patch is more or less the result of the following command (with some manual tweaks and cleanups): sed -i -r -e 's/_INCOMING/_SOURCE/g' \ -e 's/IMAP_//g' \ -e 's/SMTP_//g' \ -e 's/([\.[:space:]])imap/\1source/g' \ -e 's/([\.[:space:]])smtp/\1outgoing/g' \ widgets/account-wizard.go Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* wizard: allow setting special copy-to folderRobin Jarry2023-08-261-16/+7
| | | | | | | | | | | Instead of a boolean, allow specifying the exact folder where to copy sent messages. Depending on the IMAP provider, the folders may be different. Instead of putting a default value which may not be correct, leave it empty. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* wizard: fix typo in validationRobin Jarry2023-08-261-1/+1
| | | | | | | | Require that smtpServer is not empty. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* wizard: close open fileRobin Jarry2023-08-261-0/+1
| | | | | | | | Avoid leaking open file descriptors. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* dirlist: apply unread style on top of recent styleKeenan Gugeler2023-08-251-4/+4
| | | | | | | | | In the documentation, we specify that the `dirlist_recent` style applies on top of the `dirlist_unread` style, but the switch statement we had only applied one of the two. Signed-off-by: Keenan Gugeler <me@kgugeler.ca> Acked-by: Robin Jarry <robin@jarry.cc>
* review: don't replace space escapesKeenan Gugeler2023-08-251-1/+0
| | | | | | | | | | Currently we replace `<space>` in the output column in the review pane. This causes the default actions `:attach<space>` and `:detach<space>` to not be correctly named, and causes a mismatch between `binds.conf` and the displayed bindings. Signed-off-by: Keenan Gugeler <me@kgugeler.ca> Acked-by: Robin Jarry <robin@jarry.cc>
* review: sort unknown review commandsKeenan Gugeler2023-08-251-0/+7
| | | | | | | | | | Currently, the unknown commands in the review window appear in an undefined order, since `go-ini` gives us a `map`. Instead, we should sort them by inputs, otherwise the ordering can get confusing between restarts of aerc. Signed-off-by: Keenan Gugeler <me@kgugeler.ca> Acked-by: Robin Jarry <robin@jarry.cc>
* colorize: only emit osc8 if [general].enable-osc8=trueRobin Jarry2023-08-241-0/+3
| | | | | | | | | | | | | | | | Some old versions of less do not handle OSC 8 escape sequences. Even if aerc's embedded terminal is configured to handle them, less corrupts them making the output unreadable. 8;id=colorize-1;https://foobar.com/stuff/https://foobar.com/stuff/ When [general].enable-osc8 is set to false (its default value) do not attempt to generate OSC 8 sequences with the built-in colorize filter. These sequences would be stripped out anyway. Reported-by: Omar Polo <op@omarpolo.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Kirill Chibisov <contact@kchibisov.com>
* terminal: avoid races between close and drawRobin Jarry2023-08-111-27/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix races where a goroutine calls Terminal.Draw and another one calls Terminal.Close or Terminal.Destroy. The closing thread will eventually set term.vterm to nil just before the drawing thread calls term.vterm.Draw(), causing this crash: Error: runtime error: invalid memory address or nil pointer dereference goroutine 1 [running]: panic({0xb09140, 0x10b5860}) runtime/panic.go:890 +0x263 git.sr.ht/~rockorager/tcell-term.(*VT).Draw(0x0) git.sr.ht/~rockorager/tcell-term@v0.8.0/vt.go:424 +0x50 git.sr.ht/~rjarry/aerc/widgets.(*Terminal).draw(0xc001c658b0) git.sr.ht/~rjarry/aerc/widgets/terminal.go:116 +0x29 git.sr.ht/~rjarry/aerc/widgets.(*Terminal).Draw(0xc001c658b0, 0xc002b08150) git.sr.ht/~rjarry/aerc/widgets/terminal.go:108 +0x1b4 git.sr.ht/~rjarry/aerc/lib/ui.(*Grid).Draw(0xc001d0c360, 0xc0008ddb30) git.sr.ht/~rjarry/aerc/lib/ui/grid.go:126 +0x225 git.sr.ht/~rjarry/aerc/widgets.(*Composer).Draw(0xc001c13180, 0xc0008ddb30) git.sr.ht/~rjarry/aerc/widgets/compose.go:747 +0x8f git.sr.ht/~rjarry/aerc/lib/ui.(*TabContent).Draw(0xc0003cc5b0, 0xc0008ddb30) git.sr.ht/~rjarry/aerc/lib/ui/tab.go:468 +0x1f4 git.sr.ht/~rjarry/aerc/lib/ui.(*Grid).Draw(0xc0001b2900, 0xc000037050) git.sr.ht/~rjarry/aerc/lib/ui/grid.go:126 +0x225 git.sr.ht/~rjarry/aerc/widgets.(*Aerc).Draw(0xc000000180, 0xc000037050) git.sr.ht/~rjarry/aerc/widgets/aerc.go:193 +0x209 git.sr.ht/~rjarry/aerc/lib/ui.(*UI).Render(0xc000414040) git.sr.ht/~rjarry/aerc/lib/ui/ui.go:105 +0x62 main.main() git.sr.ht/~rjarry/aerc/main.go:279 +0xbac Use an atomic to determine if the terminal is closed or not. Never set vterm to nil (it is not necessary). Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Koni Marti <koni.marti@gmail.com> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
* style: add msglist_gutter and msglist_pill to configKonstantin Shelekhin2023-08-111-2/+3
| | | | | | | | | | Allow a user to change the default style of the message list scrollbar. There is no easy way to set the default style for an object directly in code, so I've updated every built-in theme to preserve the existing style. Signed-off-by: Konstantin Shelekhin <k.shelekhin@ftml.net> Acked-by: Robin Jarry <robin@jarry.cc>
* account: fix contextual sortKoni Marti2023-08-041-4/+11
| | | | | | | | | | | | Fix contextual sort. Pass a folder-specific sort criteria to the message store when it is created. Before, the message store would receive the sort criteria from the UI config of the currently selected directory (if any was selected at all). Fixes: https://todo.sr.ht/~rjarry/aerc/121 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* filters: put libexec/filters dirs before default PATHRobin Jarry2023-08-041-1/+4
| | | | | | | | | | | | | | | | | | Some distro packages install binaries in /usr/bin that clash with some of aerc's builtin filters (for example, colorize and wrap). The issue is that aerc filters dir (usually /usr/libexec/aerc/filters) is *after* /usr/bin, making the builtin filters not accessible when these distro packages are installed. Since this mostly concerns colorize and wrap, move $LIBEXEC/aerc/filters at the beginning of the exec PATH when running filter commands. If the intent is **really** to execute /usr/bin/colorize or /usr/bin/html, then their absolute paths should be used. Link: https://archlinux.org/packages/extra/x86_64/talkfilters/ Link: https://tracker.debian.org/pkg/colorize Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io>
* hooks: add account and folder to mail-received envRobin Jarry2023-08-041-0/+2
| | | | | | | | Add AERC_ACCOUNT and AERC_FOLDER to the environment of the mail-received hook command. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io>
* msglist: fetch headers even when not focusedRobin Jarry2023-08-041-0/+2
| | | | | | | | | | | | | | Do not rely on MessageList.Draw only to fetch missing headers. In Draw, report the current scroll offset and length to the message store and use them to determine if a new message UID should be candidate for fetching headers. This allows the mail-received hook to work even when the message list is not focused. Fixes: https://todo.sr.ht/~rjarry/aerc/147 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tristan Partin <tristan@partin.io>
* templates: attach directly from templatesKoni Marti2023-08-031-1/+1
| | | | | | | | | | | | | | | | | | Attach a file from templates. Add a split template function. {{- .Attach "LICENSE" -}} or {{range (exec "find ./doc -type f -name *.scd" "" | split "\n") -}} {{with . }} {{- $.Attach . -}} {{- end}} {{- end}} Fixes: https://todo.sr.ht/~rjarry/aerc/109 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* wizard: display warning when focus is lostKoni Marti2023-08-031-16/+13
| | | | | | | | | | | | | | | Display the warning that the password is stored in plaintext after the focus of the password input field is lost. The current behavior of showing the warning after the first character is entered is ackward and confusing. It also eliminates the need to debounce the warning when a password is pasted. Reported-by: Brad <super1337@posteo.net> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* composer: reopen the email file when editor is closedRobin Jarry2023-08-021-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some text editors save changes in a temp file before moving it over to the destination instead of rewriting the original file in place. This protects against all sorts of corruption, like writing partial files in disk-full scenarios for example. When this is the case, aerc's open file descriptor points to a different file, one that was never written to by the editor. For text editors that *do* overwrite the file (i.e. the same filesystem inode id), depending on timing, kernel version, operating system, filesystem options, caching, etc. Reading from aerc's file descriptor after the text editor has modified the same file on disk may not return the updated data. This behaviour can be easily observed with the following C program: #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(void) { int fd; ssize_t n; char buf[BUFSIZ]; unlink("test.txt"); fd = open("test.txt", O_CREAT|O_RDWR, 0644); write(fd, "Bonjour\n", strlen("Bonjour\n")); fsync(fd); lseek(fd, 0, SEEK_SET); n = read(fd, buf, sizeof(buf)); buf[n] = '\0'; printf("before: %s\n", buf); system("vim test.txt"); lseek(fd, 0, SEEK_SET); n = read(fd, buf, sizeof(buf)); buf[n] = '\0'; printf("after: %s\n", buf); return 0; } Most of the time, before and after texts will be identical even if you modified the test.txt file contents in the editor. The only reliable way to ensure to read the latest contents from the disk is to close and reopen the file after the text editor has exited. Do exactly that in termClosed before anything else. Fixes: 801caf812377 ("compose: factorize body read in a method") Fixes: https://todo.sr.ht/~rjarry/aerc/184 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Ronald Evers <ronald@ch10.nl>
* compose: fix panic when adding empty header with uppercase lettersRobin Jarry2023-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Running `:header Hello` causes a panic: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa09328] goroutine 1 [running]: git.sr.ht/~rjarry/aerc/widgets.(*Composer).AddEditor git.sr.ht/~rjarry/aerc/widgets/compose.go:1302 git.sr.ht/~rjarry/aerc/commands/compose.Header.Execute git.sr.ht/~rjarry/aerc/commands/compose/header.go:83 git.sr.ht/~rjarry/aerc/commands.(*Commands).ExecuteCommand git.sr.ht/~rjarry/aerc/commands/commands.go:133 main.execCommand git.sr.ht/~rjarry/aerc/main.go:71 This is because addEditor() converts the header name to lowercase before updating the c.editors map. After this, c.editors[header] (with `header` containing uppercase letters) returns nil causes a nil pointer access. This is a side effect of splitting AddEditor into public and private functions. focusEditor also converts the argument to lowercase. Fix and simplify this. Only call focusEditor with whatever the user provided. Fixes: 11e5390fa0ac ("compose: implement embedded headers in editor") Reported-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
* compose: allow removing headersRobin Jarry2023-07-311-0/+13
| | | | | | | | Allow removing headers from the compose window when edit-headers=false (the default) with :header -d <name>. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
* compose: only add signature if missingRobin Jarry2023-07-171-1/+21
| | | | | | | | | Allow putting signatures in the templates. Do not add a duplicate signature during :recall and :recover. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: allow changing edit-headers on the flyRobin Jarry2023-07-172-13/+18
| | | | | | | | | Add -e|-E flags to all compose commands to allow switching between edit-headers = true/false without restarting aerc. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: implement embedded headers in editorKoni Marti2023-07-171-51/+235
| | | | | | | | | Implement embedded header mode in the composer widget. To activate it, use set [compose].edit-headers=true in aerc.conf. Signed-off-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* compose: always use cr-lf line endingsRobin Jarry2023-07-171-16/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | .eml files are universally formatted with DOS line-endings, per RFC5322. Make sure to replace line endings with CRLF before sending the message. Always present CRLF files to the text editor. If the editor forces LF line endings, convert them back to CRLF. Text editors (vim and nvim at least) detect the .eml extension and force dos line endings. Emacs seems not to care and will use whatever line endings are present in the file. Kakoune seems to force unix line endings and does not care about the contents of the file. Notes: * add explicit calls to Truncate() to ensure any trailing content is stripped from the file when overwriting with shorter content. * NewCRLFReader cannot be reused since we need buffered and unbuffered versions of it (for GetBody and {Set,append}Contents, respectively). Link: https://datatracker.ietf.org/doc/html/rfc5322 Link: https://github.com/vim/vim/blob/v8.2.3583/runtime/ftplugin/mail.vim#L29-L35 Link: https://github.com/neovim/neovim/blob/v0.6.0/runtime/ftplugin/mail.vim#L29-L35 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: improve error handlingRobin Jarry2023-07-171-23/+27
| | | | | | | | | On error, return to the caller instead of logging a warning and trying to continue. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: factorize body read in a methodRobin Jarry2023-07-171-33/+25
| | | | | | | | | | | | | | In preparation for allowing headers in the text editor, put code related to reading the email body in a method and use it where needed. Never close the email temp file, always keep it opened in read-write mode. This will be also required to update embedded header values when running :edit after modifying email headers from the compose::review screen. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* compose: only allow setting content at creationRobin Jarry2023-07-172-14/+30
| | | | | | | | | | | | | Add a parameter for the initial value of the body to be inserted *before* the signature when composing a message. Make AppendContents and SetContents private methods to ensure there is no other way to change the composer contents from the outside after creation. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Koni Marti <koni.marti@gmail.com>
* styles: add style for folded threadsKoni Marti2023-07-161-0/+5
| | | | | | | | | Add a style for folded threads. Use msglist_thread_folded in the stylesheet like "msglist_thread_folded.dim = true" Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* templates: add ThreadCount and ThreadFoldedKoni Marti2023-07-161-2/+15
| | | | | | | | | | | | | | Add the number of threads and a flag to indicated folded threads to the template data. Use {{.ThreadCount}} and {{.ThreadFolded}} in template expression for the message list. column-subject = {{.ThreadPrefix}}{{if .ThreadFolded}}[{{.ThreadCount}}] {{end}}{{.Subject}} Update default configuration accordingly. Signed-off-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* msglist: simplified threads renderingKoni Marti2023-07-161-55/+39
| | | | | | | | | | | Simplifies the rendering of threads by removing a thread specific loop and just add the relevent threading information. Since the uids are ordered based on the thread structure already by the threadbuilder, it is not necessary to loop over the threads slice. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* wizard: properly initialize configurationRobin Jarry2023-07-151-15/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The wizard constructs an AccountConfig object by hand without initializing default values. This causes a crash when replying to an email (rr) just after completing the account creation: ~/.config/aerc/aerc.conf not found, installing the system default~/.config/aerc/binds.conf not found, installing the system defaultpanic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x90 pc=0x5d1550] ... regexp.(*Regexp).doExecute(0x7fc1089aa108?, {0x0?, 0x0?}, {0x0?, 0x0?, 0xc000fe5408?}, {0xc000698120?, 0x10?}, 0xad3a40?, 0x2, ...) regexp/exec.go:527 +0x90 regexp.(*Regexp).FindString(0x44e372?, {0xc000698120, 0x27}) regexp/regexp.go:852 +0x6c git.sr.ht/~rjarry/aerc/commands/msg.trimLocalizedRe({0xc000698120, 0x27}, 0xc00003e420?) git.sr.ht/~rjarry/aerc/commands/msg/reply.go:332 +0x36 git.sr.ht/~rjarry/aerc/commands/msg.reply.Execute({}, 0xc0002ba180, {0xc0002f8800?, 0x2, 0x2}) git.sr.ht/~rjarry/aerc/commands/msg/reply.go:157 +0x765 ... Extract the account parsing and initialization into a function. Reuse that function in both accounts.conf parsing and the wizard. Fixes: 40cc540357d9 ("reply: allow to override localized Re regexp in configuration") Reported-by: Mechiel Lukkien <mechiel@ueber.net> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Andrew Yu <andrew@andrewyu.org>
* viewer: avoid high cpu usage when selecting part with no filterRobin Jarry2023-07-101-5/+10
| | | | | | | | | | | | | | | | When selecting a message part that has no filter configured, aerc uses very high CPU. This is due to a recursive UI invalidation. PartViewer.Draw() calls newNoFilterConfigured which calls ui.Grid.AddChild which in turn calls ui.Invalidate() which causes the whole UI to be redrawn. Call newNoFilterConfigured only once when creating a new part viewer (only when there is no filter command). Reported-by: Willow Barraco <contact@willowbarraco.fr> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Willow Barraco <contact@willowbarraco.fr>
* account: remember folder/message when reconnectingKoni Marti2023-06-263-4/+6
| | | | | | | | | | Remember selected folder and message when reconnecting. This is mostly useful for the imap backend when logouts or reconnects happen a lot. Fixes: https://todo.sr.ht/~rjarry/aerc/159 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* worker: add context to cancellable requestsTim Culverhouse2023-06-201-1/+4
| | | | | | | | | | | | | Add a Context field to requests which we may want to cancel when changing directories. Add a Cancelled meta-message to inform the UI that a request was cancelled (as opposed to Done or Error). Delete callbacks when a request is Cancelled. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgstore: pass context from dirlist to msgstoreTim Culverhouse2023-06-201-19/+22
| | | | | | | | | | | | | Most, if not all, requests to the worker that may need cancellation are sent by the msgstore. These requests are typically only relevant when the msgstore is the selected one. Pass a context from the dirlister to the msgstore when it is selected. This context will be passed in future commits to worker requests. The context is cancelled when a new directory is selected. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* account: create new store when creating foldersKoni Marti2023-06-173-26/+40
| | | | | | | | | | | | | | | | | Add a correct message store entry to the DirStore for newly created directories. This is currently not done, so the directory name does either not show up in the directory list or contains a nil message store. Either way, such a directory cannot be used in the current session and aerc needs to be restarted/reconnected. This affects the :mkdir and :archive commands (archive when a new directory is created). To reproduce on imap: create a new directory (:mkdir testdir), try to move a message into it (:move testdir). It will not show up because there is not message store. Fixes: 8ced001d ("listDirectories: refactor listdirectories handling") Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* save: new option for saving attachmentsVitaly Ovchinnikov2023-06-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new `-A` option to `:save` that works in the same manner as `-a`, but saves all the named parts of an email, not just attachments. The reason is that I have an email with this structure: multipart/related multipart/alternative text/plain text/html image/png (image001.png) image/png (image002.png) image/png (image003.png) text/plain (env.txt) Where the `env.txt` is a "real" attachment, while the images are just a part of the HTML version of the email. However, in this particular email it was important to see them which can't be done with text UI and opening the HTML part with the browser also didn't work. Saving them to a temorary folder did the job and this can be useful in other scenarios. So before the patch we could do `:save -ap /some/path` and get just the `env.txt` saved there. After the patch we could also do `:save -Ap /some/path` and get all the images and the text file saved into the folder. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Tested-by: Moritz Poldrack <moritz@poldrack.dev>
* compose: quit composing when editor returns errorMoritz Poldrack2023-06-011-0/+6
| | | | | | | | | | When the editor crashes, or the user forces it to exit with an error code, it is safe to assume that they can't (if the command failed) or don't want to (if :cq'd) continue composing a meaningful message. Suggested-by: tristan957 Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* ui: fix deadlocks in message channelRobin Jarry2023-05-203-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are several ways the ui message channel can fill up leading to deadlocks. 1) Invalidate() changes the value of uiState to DIRTY. The following call sequence: QueueRedraw() Invalidate() QueueRedraw() Leads to multiple nil messages being queued in the message channel whereas one could assume that the second QueueRedraw() would do nothing. This is caused by the tri-state nature of uiState. 2) We use the same channel to convey state change, keyboard events and redraw requests. Since a keyboard event almost always triggers a redraw, we end up trying to append a redraw message in the same goroutine that reads from the channel. This triggers a deadlock when there are more than 50 pending messages. Solve the issue by using multiple channels, one per type of message that needs to be sent to the main ui thread. Remove QueueRedraw() and merge its functionality in Invalidate(). Only use a DIRTY/CLEAN state to determine if something needs to be queued in the redraw channel. Use a channel for quitting instead of an atomic. Restructure some code functions to have a cleaner API. Use a for loop in the main thread and select from all channels. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Koni Marti <koni.marti@gmail.com> Tested-by: Maarten van Gompel <proycon@anaproy.nl>
* templates: use template interface consistentlyKoni Marti2023-05-166-20/+22
| | | | | | | | | | | | | | | Use the template interface consistently. Before, we have exported the state.TemplateData struct and used it in most places instead of the models.TemplateData interface. This lead to some inconsistencies, i.e. Role() has been defined on the exported struct but not on the interface. Unexport the state.TemplateData struct, add a DataSetter interface to set the data needed for the template data and call the Data() method which returns a models.TemplateData interface when the template data is needed. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* dirtree: fixup to apply correct patchset versionRobin Jarry2023-05-161-2/+7
| | | | | | | | I had applied v2 instead of v4... It is time to automate these things a bit better. Fixes: 6e038c7fd510 ("dirtree: modify drawing of the dirtree") Signed-off-by: Robin Jarry <robin@jarry.cc>
* dirtree: clear msglist for virtual nodesKoni Marti2023-05-163-0/+25
| | | | | | | | | Clear the message list when a virtual node is selected. Add a VirtualNodeCallback to the Dirlist interface. Reported-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* config: update default pagerMoritz Poldrack2023-05-161-1/+1
| | | | | | | | | | | Since aercs embedded terminal now behaves correctly, a messages contents are at the bottom of the pager by default, this has already sparked confusion as this is uncommon and not matching previous behaviour. Thanks: Stacy Harper <contact@stacyharper.net> Suggested-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* imap: use delimiter from serverMoritz Poldrack2023-05-162-13/+10
| | | | | | | | | To accommodate servers that use a delimiter other than "/" ("." being a common alternative), the delimiter is fetched from the server when connecting. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* compose: warn before sending with empty subjectJason Cox2023-05-161-5/+17
| | | | | | | | Ask user whether they want to abort before sending if the subject header is empty and they have enabled the warn-empty-subject config option. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* commands: add OptionsProvider and OptionCompleterKoni Marti2023-05-161-4/+4
| | | | | | | | | | | | | | | | | | | Improve command completion by supporting option flags and option arguments completion. Option completion is activated when the command implements the OptionsProvider interface. Implementing the OptionCompleter allows the completion of individual option arguments. The completion interfaces harmonizes the completion behavior in aerc, makes the completion code clearer and simplifies the completion functionality. With this patch, the Complete method on commands will only have to deal with the actual completion, i.e. paths, folders, etc and not worry about options. To remove all options and its mandatory arguments from args, use commands.Operands(). Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>