aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
Commit message (Collapse)AuthorAgeFilesLines
* viewer: use textproto.WriteHeaderRobin Jarry2023-02-021-16/+13
| | | | | | | | | When [ui].show-headers is true, use textproto.WriteHeader instead of manually writing the header values. This allows displaying the original header buffer with on-the-wire format (and with lines wrapped). Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* dirlist: simplify getRUEString logicTim Culverhouse2023-01-291-14/+7
| | | | | | | Reuse the newly-added GetRUECount method to simplify getRUEString Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* tabs: use template for account tab nameTim Culverhouse2023-01-293-1/+44
| | | | | | | | | | | Use a go template to render the account tab display. Add config option for setting a specific template for the account. Add a method on Tab to allow setting a title, which may be different than the tab Name. The default template is {{.Account}}. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* compose: allow sending format=flowed messagesRobin Jarry2023-01-261-8/+13
| | | | | | | | | | | | | | | | | | | | Allow composing and sending messages with: Content-Type: text/plain; Format=Flowed This requires additional configuration in the text editor to actually produce the required trailing spaces at the end of lines that are part of the same paragraph. For example, with vim: "~/.vim/ftplugin/mail.vim setlocal textwidth=72 setlocal formatoptions=1jnwtcql setlocal comments+=nb:> Link: https://www.rfc-editor.org/rfc/rfc3676.html Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Moritz Poldrack <moritz@poldrack.dev>
* viewer: allow piping full headers in a filterRobin Jarry2023-01-261-9/+45
| | | | | | | | Allow defining a .headers special filter command that will be used only to process email headers (when [viewer].show-headers=true). Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Kt Programs <ktprograms@gmail.com>
* viewer: remove local redundant showHeaders variablesRobin Jarry2023-01-261-29/+25
| | | | | | | The config objects are now globally available. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Kt Programs <ktprograms@gmail.com>
* filters: rewrite colorize in cRobin Jarry2023-01-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since its introduction, we had multiple issues with the colorize awk script with regard to non-GNU awk compatibility. Also, this script is standalone and the color theme must be hard coded into it. Reading from an external configuration file (aerc's styleset) from a non-GNU awk is close to impossible (and even far from trivial with GNU awk). Rewrite the builtin colorize filter in C to allow getting the color theme from aerc's active styleset. The theme is configured using the existing styleset syntax and attributes under a separate [viewer] section (see examples and man page). Export the active styleset file path to AERC_STYLESET env var when invoking the filter command so that colorize can access it and use it. I have tested compilation (with clang-analyzer and gcc -fanalyzer) and basic operation on FreeBSD, Fedora (glibc) and Alpine (muslibc). More tests would probably be required on MacOSX and older Linux distros. I also added test vectors to give some confidence that this works as expected. The execution with these vectors passed valgrind --leak-check=full without errors. NB: the default theme has changed to be more minimal. Sample stylesets have more colorful examples. The awk -v theme=xxx option is no longer supported. usage: colorize [-h] [-s FILE] [-f FILE] options: -h show this help message -s FILE use styleset file (default $AERC_STYLESET) -f FILE read from filename (default stdin) Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* switch-account: also switch account configurationBence Ferdinandy2023-01-261-1/+1
| | | | | | | | | When switching accounts, headers were updated, but not the account configurations in the composer. Switch the account config also and add a debug log to send with the uri being used. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* status: print appropriate log message on pushBence Ferdinandy2023-01-261-0/+4
| | | | | | | | Increase logging usability, by logging all messages pushed to status at an appropriate loglevel. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* spinner: add spinner-interval config optionDean2023-01-111-9/+11
| | | | | | | | | | The default 200ms between each spinner frame can be unsuitable for spinners with many frames, so this adds a spinner-interval config option with type `time.Duration` to specify the interval between frames. The default is still the usual 200ms. Signed-off-by: Dean <gao.dean@hotmail.com> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* msglist: log template errorsRobin Jarry2023-01-111-0/+1
| | | | | | | | | | The template exec errors can be rather verbose and may be truncated when the table is rendered. Log them as errors so that they can be inspected by users. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
* style: add msglist_answered config optionMartin Lucina2023-01-101-0/+3
| | | | | | | | Add a style for messages that have been marked as answered, and a "msglist_answered" config option for it. Signed-off-by: Martin Lucina <martin@lucina.net> Acked-by: Robin Jarry <robin@jarry.cc>
* pgp: add configurable error level for opportunistic encryptionTim Culverhouse2023-01-061-1/+15
| | | | | | | | | | | | | | Add a user-configurable error level for when opportunistic encryption is enabled but the message cannot be encrypted. Set the default level to this as "warn". This config option *only* applies when opportunistic encryption is enabled. If a user tries to manually encrypt a message, an error will still be shown. Don't show encryption status until at least one recipient is added. Fixes: https://todo.sr.ht/~rjarry/aerc/95 Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: add missing panic handlers in goroutinesRobin Jarry2023-01-062-0/+3
| | | | | | | | These issues were all reported by the new custom analyzer introduced in previous commit. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* doc: fix English typosRobin Jarry2023-01-061-1/+1
| | | | | | | Reported by Lintian (Debian). Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* config: add columns based index formatRobin Jarry2023-01-062-96/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The index-format option comes from mutt and is neither user friendly, nor intuitive. Introduce a new way of configuring the message list contents. Replace index-format with multiple settings to make everything more intuitive. Reuse the table widget added in the previous commit. index-columns Comma-separated list of column names followed by optional alignment and width specifiers. column-separator String separator between columns. column-$name One setting for every name defined in index-columns. This supports golang text/template syntax and allows access to the same message information than before and much more. When index-format is still defined in aerc.conf (which will most likely happen when users will update after this patch), convert it to the new index-columns + column-$name and column-separator system and a warning is displayed on startup so that users are aware that they need to update their config. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* selector: implement dynamic heightRobin Jarry2023-01-041-3/+17
| | | | | | | | Depending on the number of lines in the prompt text, allow the selector dialog to grow in height. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* templates: add more fields and functionsRobin Jarry2023-01-041-1/+14
| | | | | | | | | | | Add functions and fields in preparation for more than only message templates. The idea is to reuse the same symbols for the message list format and other parts of the UI. Update the man page accordingly. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* templates: change fields as lazy functionsRobin Jarry2023-01-042-5/+4
| | | | | | | | | No need to pre-render fields that are not necessarily accessed in templates. Change fields to functions that are evaluated only when required. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* config: parse account from and aliases onceRobin Jarry2023-01-044-34/+14
| | | | | | | | | Instead of accepting any garbage for these configuration fields, parse them when parsing accounts.conf and store mail.Address objects. Reuse these objects everywhere. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* model: change flags array to bitmaskRobin Jarry2023-01-043-31/+8
| | | | | | | Using a list of integers is not optimal. Use a bit mask instead. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* send: add option to send&archiveBence Ferdinandy2023-01-041-1/+7
| | | | | | | | | Add `:send -a flat|month|year` to send, which archives the message being replied to. Extract most of archive logic into a separate function to make sure it behaves as manual archiving. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* split: close split on update of split viewTim Culverhouse2022-12-271-0/+3
| | | | | | | | | | | Commit 6b8e0b19d35a ("split: refactor to prevent stuck splits") introduced a regression where a split message viewer is not closed when a new message is selected, leading to every split view staying open in the background. Fixes: 6b8e0b19d35a ("split: refactor to prevent stuck splits") Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* split: refactor to prevent stuck splitsTim Culverhouse2022-12-252-93/+45
| | | | | | | | | | Refactor split logic (again...) to prevent stuck splits. Use callback from msgstore.Select to tell the split which message to display. This keeps the account from having to track displayed messages, which prevents race conditions in certain situations. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* wizard: debounce warning to ensure pasted passwords are entered correctlyMoritz Poldrack2022-12-201-1/+12
| | | | | | | | | | | | | When entering passwords from a password-manager the wizard shows it's warning right after the first character has been pasted and the rest of the password is lost. Debounce the displaying of the "stored in plaintext"-warning to only show after the password has been entered. Reported-by: qbit (@qbit:tapenet.org) Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* msglist: make width available externallyMoritz Poldrack2022-12-191-0/+6
| | | | | | | This will be reused in next commit. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* style: make marked more important than searchBence Ferdinandy2022-12-141-5/+4
| | | | | | | | | | Currently it's not possible to define combinations of marked and searched. Since searched messages are just a convenience, while marked message can be operated upon, make sure that when a message is both marked and a search result the marked styleset is applied. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* split: refactor split update logicTim Culverhouse2022-12-142-29/+41
| | | | | | | | | | | | | | | | | | | | | | Refactor split update logic to more simply update the split. Through the evolution of the split logic, additional variables were stored within the account which allows for cleaner updating of the split. Compare selected UID instead of pointer to message when deciding not to update split. Allow splits to be created and closed when no message is selected. The split will be filled with a ui.Fill (blank). The user will only see a border at the split location when no message is selected. Rename clearSplit to closeSplit, as it is only used in the case when the user doesn't want a split anymore. Ensure that the selected UID is reset to the magic UID when there are no messages left in the message store. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* msglist: add attachment indicatorBence Ferdinandy2022-12-141-0/+1
| | | | | | | | Add indicator of an attachment to the flags and make the character used to be configurable. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Jens Grassel <jens@wegtam.com>
* config: make various sections accessible via global varsRobin Jarry2022-12-1410-198/+168
| | | | | | | | | | | | | | | | | | | | There is only one instance of AercConfig which is associated to the Aerc widget. Everywhere we need to access configuration options, we need somehow to get a reference either to the Aerc widget or to a pointer to the AercConfig instance. This makes the code cluttered. Remove the AercConfig structure and every place where it is referenced. Instead, declare global variables for every configuration section and access them directly from the `config` module. Since bindings and ui sections can be "contextual" (i.e. per account, per folder or per subject), leave most local references intact. Replacing them with config.{Ui,Binds}.For{Account,Folder,Subject} would make this patch even more unreadable. This is something that may be addressed in the future. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* config: rework contextual sections implementationRobin Jarry2022-12-146-49/+18
| | | | | | | | | | | | | The current contextual binds and ui config API is awkward and cumbersome to use. Rework it to make it more elegant. Store the contextual sections as private fields of the UIConfig and KeyBindings structures. Add cache to avoid recomputation of the composed UIConfig and KeyBindings objects every time a contextual item is requested. Replace the cache from DirectoryList with that. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* compose: allow writing multipart/alternative messagesRobin Jarry2022-12-071-1/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new :multipart command that can be executed on the composer review screen. This command takes a MIME type as argument which needs to match a setting in the new [multipart-converters] section of aerc.conf. A part can be removed by using the -d flag. The [multipart-converters] section has MIME types associated with commands. These commands are executed with sh -c every time the main email body is updated to generate each part content. The commands are expected to output valid UTF-8 text. If a command fails, an explicit error will be printed next to the part MIME type to allow users to debug their issue but the email may still be sent anyway with an empty alternative part. This is mostly intended for people who *really* need to send html messages for their boss or for corporate reasons. For now, it is a manual and explicit action to convert a message in such a way. Here is an example configuration: [multipart-converters] text/html = pandoc -f markdown -t html And the associated binding to append an HTML alternative to a message: [compose::review] H = :multipart text/html<enter> hh = :multipart -d text/html<enter> Link: https://lists.sr.ht/~rjarry/aerc-discuss/%3CCO5KH4W57XNB.2PZLR1CNFK22H%40mashenka%3E Co-authored-by: Eric McConville <emcconville@emcconville.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* compose: show relevant bindings on review screenBence Ferdinandy2022-12-021-20/+48
| | | | | | | | | | Currently compose will always show only some hardcoded default commands. If hardcoded command is not bound to any key remove it from the list. If user adds new bindings to compose::review add them - without help text - at the bottom. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* logging: rename package to logRobin Jarry2022-12-0211-56/+56
| | | | | | | | | | Use the same name than the builtin "log" package. That way, we do not risk logging in the wrong place. Suggested-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* logging: homogenize levelsRobin Jarry2022-12-025-11/+11
| | | | | | | | | | | | | | | | | | The main goal is to ensure that by default, the log file (if configured) does not grow out of proportions. Most of the logging messages in aerc are actually for debugging and/or trace purposes. Define clear rules for logging levels. Enforce these rules everywhere. After this patch, here is what the log file looks like after starting up with a single account: INFO 2022/11/24 20:26:16.147164 aerc.go:176: Starting up version 0.13.0-100-g683981479c60 (go1.18.7 amd64 linux) INFO 2022/11/24 20:26:17.546448 account.go:254: [work] connected. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* msgviewer: add logs to display pager and filter commandsRobin Jarry2022-12-021-0/+2
| | | | | | | | That may be useful to debug some filter matchers. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* doc: extract accounts and binds into separate man pagesRobin Jarry2022-11-241-1/+1
| | | | | | | | | | | | | aerc-config(5) is getting too big and cluttered. Only keep aerc.conf settings in it. Move binds.conf settings in aerc-binds(5) and accounts.conf settings in aerc-accounts(5). Adjust all references accordingly. Update the README to reference the two new man pages. Update the Makefile to install them in proper locations. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
* aerc: fix popover menu regressionKoni Marti2022-11-221-0/+2
| | | | | | | | | | | | | | | Fix popover menu regression by triggering completions after the simulated key strokes have been processed. Commit 055c6dc6604f7f ("exline: don't draw completions for keybinds") removed a double-draw event and reinstated the tab completions correctly but it did not trigger the completion process again which was the expected behavior. Fixes: https://todo.sr.ht/~rjarry/aerc/104 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgviewer: fix parts indexKoni Marti2022-11-211-1/+4
| | | | | | | | Fix parts index by making an explicit copy of the index slice. Fixes: https://todo.sr.ht/~rjarry/aerc/103 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* config: move [filters] parsing to separate fileRobin Jarry2022-11-161-1/+1
| | | | | | | | | | The config.go file is getting too big. Move the aerc.conf [filters] section parsing logic into a dedicated filters.go file. No functional change. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* dirtree: fix mouse support for selecting foldersKoni Marti2022-11-131-5/+12
| | | | | | | | | Fix mouse support for selecting folders. Toggle foldable directories to expand or collapse when clicked on. Fixes: https://todo.sr.ht/~rjarry/aerc/99 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* filters: export more info to filter processesRobin Jarry2022-11-131-0/+8
| | | | | | | Export some more environment variables to the pager commands. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
* msgviewer: show error if MessageInfo has errorTim Culverhouse2022-11-091-2/+9
| | | | | | | | | | | | | | | | | MessageInfo structs can be returned from the workers with parser errors. MessageViews were previously prevented from opening if the error field was not nil, however the addition of message view splits have allowed these messages to have split views created. A panic can occur if a split is open and one of these messages is scrolled over. Prevent access to MessageInfo methods if the Error field is set. Display the error to the user in the split view. The partSwitcher will be nil if an error is set: check for this condition before calling it's methods. Reported-by: Ben Lee-Cohen <ben@lee-cohen.com> Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* dirtree: show dynamic folders properlyKoni Marti2022-11-091-0/+15
| | | | | | | | | | Show dynamic folders from notmuch queries using :cf when using the directory tree view. The current dirtree implementation would swallow the query list entry but show the folder contents correctly in the message list. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net>
* dirtree: prevent panic when no folder is foundKoni Marti2022-11-092-2/+2
| | | | | | | | | Prevent crash when no folder is found. Fixes: https://todo.sr.ht/~rjarry/aerc/100 Fixes: https://todo.sr.ht/~rjarry/aerc/101 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net>
* composer: add message previewKoni Marti2022-11-091-6/+8
| | | | | | | | | | Add message preview to the composer. Add preview option to the review window. Open the message in a message viewer before sending to check the headers and attachments. Implements: https://todo.sr.ht/~rjarry/aerc/86 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* lib: prepare attachments for multiple readsKoni Marti2022-11-091-15/+32
| | | | | | | | | | | Prepare attachments for multiple reads. The data for lib.PartAttachment is stored as an io.Reader which can only be read once. This will cause an issue when we want to call composer.WriteMessage multiple times, i.e. for a message preview. We fix this by keeping a copy of the data and create a new reader everytime the attachment is read. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* viewer: open rfc822 attachmentsKoni Marti2022-11-091-1/+8
| | | | | | | | | | Open message/rfc822 attachments from the message viewer when no filter is defined for this mimetype. When the rfc822 part is selected, call the eml command to open the attachment in a new message viewer. Suggested-by: Jens Grassel <jens@wegtam.com> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* ui: invalidate ui when queuing redrawTim Culverhouse2022-11-062-2/+0
| | | | | | | | | | | | | | | The QueueRedraw function should always be preceeded by a call to ui.Invalidate in order to make a redraw a occur. In one instance, this was not done and it was possible for the UI to not redraw itself (when a terminal closes, a UI redraw request is made but it is possible for the UI to not be invalidated as a result of the close). Move the call to Invalidate into the QueueRedraw function to ensure that every QueueRedraw call will redraw the screen. Fixes: https://todo.sr.ht/~rjarry/aerc/98 Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* split: close current split after replacing with newTim Culverhouse2022-11-061-3/+3
| | | | | | | | | | Close the current split view after replacing it with a new view. Previously we closed it before replacing it with the new split view which could create a race condition when attempting the replace. Reported-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>