aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* dirtree: modify drawing of the dirtreeTim Culverhouse2023-05-162-19/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update the dirtree drawing structure to be a bit more compact. The dirtree is drawn with one column left for a flag, which indicates if a parent is collapsed or expanded. Only draw the "flag" when the parent is collapsed. Change the flag to a '+' character to match common UI patterns of expanding lists having a '+' box. Don't draw the '>' character in the dirtree. This character is nice in the threaded message view, but clutters up the dirtree. I know this is a matter of preference, but this approach is similar to most other UI tree view and gives the dirtree an extra column of space. The original dirtree looks like this: ┌Inbox ├─>Sub └─>Sub And collapsed: -Inbox This patch changes it to: Inbox ├─Sub └─Sub And collapsed: +Inbox Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* compose: do not strip leading space from signatureRobin Jarry2023-04-271-2/+1
| | | | | | | | | | Only strip the leading whitespace when a delimiter needs to be prepended. Fixes: bba715975690 ("compose: only add delimiter when a signature is defined") Reported-by: Jason Cox <dev@jasoncarloscox.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Jason Cox <dev@jasoncarloscox.com>
* term: fix handling of failed commandTim Culverhouse2023-04-261-1/+2
| | | | | | | | | | | | | | | | | | | | | A panic occurs when a terminal is launched with a command that fails: :term blabla The underlying terminal does not need to be closed if the command failed to start: all resources are cleaned up upon failure to start already. Don't attempt to close terminal if the command didn't start. With the above fix in place, the tab will linger around until a redraw occurs, as there is nothing queuing a redraw on this behavior. Add a QueueRedraw in the tabs.Remove method to clean up the tabbar. The issue in tcell-term that causes this panic has been address there as well, released as 0.7.1. Update aerc's version. Reported-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* term: add config options for TERM and osc8Tim Culverhouse2023-04-241-0/+3
| | | | | | | | Add config options for setting the TERM environment variable used in tcell-term and for enabling or disabling OSC8 escape sequence output. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry<robin@jarry.cc>
* tcell-term: upgrade to latest releaseTim Culverhouse2023-04-231-16/+19
| | | | | | | | | | | | | | | | | Upgrade tcell-term to latest release. This is a complete rewrite of tcell-term, and includes many minor bug fixes and overall improvements. Notably: - Improved parsing - One fewer goroutine - Improved API - Improved redraw messaging - Improved key support - Improved mouse support Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry<robin@jarry.cc>
* mailto: add template parameterKoni Marti2023-04-221-2/+6
| | | | | | | | | Add template parameter to the mailto query and set the config.Template.NewMessage template file as default. Fixes: https://todo.sr.ht/~rjarry/aerc/145 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry<robin@jarry.cc>
* directory: add role to template fieldsTim Culverhouse2023-04-226-7/+15
| | | | | | | | | Add .Role as a template field for use in distinguishing between mailboxes with a given IANA role, or custom role defined by aerc ("query" for notmuch queries, for example). Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry<robin@jarry.cc>
* directory: use directory to store rue countsTim Culverhouse2023-04-222-40/+37
| | | | | | | | | | | | Store the Directory RUE counts on the Directory data model. Use DirectoryInfo messages to update the Directory model. Access Directories via the dirlist instead of via the msgstore. Remove unused fields on DirectoryInfo, all backends now give accurate counts. Move refetch logic into dirlist Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry<robin@jarry.cc>
* dirstore: store directory model in dirstoreTim Culverhouse2023-04-222-4/+4
| | | | | | | | Use the dirstore to store models.Directory data structures. This will be used in subsequent commits for accessing directory data. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* listDirectories: refactor listdirectories handlingTim Culverhouse2023-04-223-52/+60
| | | | | | | | | | | | | | | | | ListDirectories is called when connecting, reconnecting, and creation/deletion of a directory. The code is not in the same style as other areas of aerc. Refactor to match coding style of the rest of aerc by creating an Update function which handles necessary updates in the dirlist. This style does not use a callback, making it clearer what is happening in the message flow, and operates similar to how the msgstore receives updates. Use a map in the dirstore to reduce duplicate storage of directory names. Directly add or remove directories from the map when created / deleted to prevent a new ListDirectories message, and a flash of the UI. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgstore: create from types.Directory messageTim Culverhouse2023-04-221-27/+27
| | | | | | | | | | | | | | | Create msgstores when a types.Directory message is received. This removes a quirk from the IMAP worker that msgstores are created on the first DirectoryInfo, and updated on the second. This path requires three messages in order to get an updated message store. By creating from types.Directory, we ensure that any subsequent DirectoryInfo can be routed to a msgstore. Remove the field DirInfo from the msgstore initializer, it isn't needed at initialization and isn't available with this refactor. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgstore: fetch message list based on OpenDirectory msgTim Culverhouse2023-04-221-0/+1
| | | | | | | | | | | | | | | Fetching the message list is done in a convoluted way. The UI receives a DirectoryInfo message, which creates a message store. It then receives a second DirectoryInfo (an oddity from the IMAP worker), and this DirectoryInfo is passed to the message store which then requests a fetch of the message list via store.Sort. Use the OpenDirectory done response to tell the message store to fetch messages. This makes the code easier to follow, and does not rely on quirks from the IMAP worker. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* term: ignore redraw events when not visibleRobin Jarry2023-04-153-3/+27
| | | | | | | | | | | | | | | | Another attempt at fixing the high CPU usage when terminal tabs are running interactive tui applications and the message list tab is selected. There are cases where a terminal widget can be visible but not focused (composer, message viewer, attachment selector, etc.). Define a new Visible interface with a single Show() method. Call that method when changing tabs to make sure that terminal widget content events only trigger redraws when they are visible. Fixes: 382aea4a9426 ("terminal: avoid high cpu usage when not focused") Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Koni Marti <koni.marti@gmail.com>
* dialog: avoid panic when window is too smallRobin Jarry2023-04-151-2/+14
| | | | | | | | | Avoid negative offsets and limit height to the parent context height. Fixes: https://todo.sr.ht/~rjarry/aerc/142 Reported-by: Akspecs <akspecs@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Koni Marti <koni.marti@gmail.com>
* terminal: avoid high cpu usage when not focusedRobin Jarry2023-04-041-1/+3
| | | | | | | | | | | | | | | | When running dynamic tui applications (such as btop, htop, etc.) in the embedded :terminal and focusing an account tab, every tui application change triggers a full redraw of the whole window. When the message list is focused, this leads to high cpu usage because of the computationally intensive templates parsing and ansi sequence handling. Only redraw when the terminal is focused. Do not use tcell Watch and Unwatch functions since these completely disable all widget updates, including title changes and terminal close events. Reported-by: John Mcenroy <handplanet@outlook.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: John Mcenroy <handplanet@outlook.com>
* config: replace triggers with hooksMoritz Poldrack2023-04-011-7/+6
| | | | | | | | | | | | | Deprecate triggers and replace them with hooks. Now that aerc supports running arbitrary ex commands over IPC, it is possible to run internal aerc commands *and* shell commands via external shell scripts. Hooks only allow running shell commands. Hooks info is passed via environment variables. Implements: https://todo.sr.ht/~rjarry/aerc/136 Signed-off-by: Moritz Poldrack <git@moritz.sh> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* tabs: make sure to close tab contentRobin Jarry2023-04-014-18/+22
| | | | | | | | Rework how tabs are closed. Change the aerc.RemoveTab and aerc.ReplaceTab functions to accept a new boolean argument. If true, make sure to close the tab content. Signed-off-by: Robin Jarry <robin@jarry.cc>
* config: remove subject contextual ui sectionsRobin Jarry2023-03-311-4/+1
| | | | | | | | | | We have been wanting to remove this for a while now. The only use case is styleset and changing the whole styleset based on an email subject does not make much sense. The same feature can be achieve with dynamic msglist* styles based on any email header value in the stylesets now. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* styleset: allow dynamic msglist stylingRobin Jarry2023-03-311-4/+9
| | | | | | | | | | | Add support for dynamic msglist*.$HEADER,$VALUE.$ATTR = $VALUE where $VALUE can be either a fixed string or a regular expression. This is intended as a replacement of contextual ui sections based on subject values. Implements: https://todo.sr.ht/~rjarry/aerc/18 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* smtp: replace smtp-starttls with schema optionMarcin Serwin2023-03-261-14/+6
| | | | | | | | | The "smtp-starttls" options is now ignored in favor of more detailed schema specification, similarly to IMAP. Fixes: https://todo.sr.ht/~rjarry/aerc/149 Signed-off-by: Marcin Serwin <marcin.serwin0@protonmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* account: fix crash/race on initRobin Jarry2023-03-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | When an account is initialized too quickly, setTitle may be called before acct.tab is initialized, leading to a crash: runtime error: invalid memory address or nil pointer dereference goroutine 1 [running]: panic({0xa49820, 0x1059510}) runtime/panic.go:890 +0x262 git.sr.ht/~rjarry/aerc/lib/ui.(*Tab).SetTitle(...) git.sr.ht/~rjarry/aerc/lib/ui/tab.go:37 git.sr.ht/~rjarry/aerc/widgets.(*AccountView).setTitle(0xc000838000) git.sr.ht/~rjarry/aerc/widgets/account.go:617 +0x2a0 git.sr.ht/~rjarry/aerc/widgets.(*AccountView).onMessage(0xc000838000, {0xbffc60?, 0xc0000f1080?}) git.sr.ht/~rjarry/aerc/widgets/account.go:364 +0x13e8 git.sr.ht/~rjarry/aerc/widgets.(*Aerc).HandleMessage(0xc0000f4000, {0xbffc60, 0xc0000f1080}) git.sr.ht/~rjarry/aerc/widgets/aerc.go:174 +0x5f main.main() git.sr.ht/~rjarry/aerc/aerc.go:252 +0x965 Avoid this. Fixes: 6b39c0dae1e1 ("tabs: use template for account tab name") Signed-off-by: Robin Jarry <robin@jarry.cc>
* templates: separate thread prefix from subjectRobin Jarry2023-03-081-5/+4
| | | | | | | | Extract {{.ThreadPrefix}} from {{.Subject}} so that the prefix can be styled in a different color. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* msglist: fix inconsistent thread subject deduplicationRobin Jarry2023-03-081-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When threading is enabled, some messages which have different base subjects are hidden whereas some others which have similar subjects are displayed: [PATCH aerc v3 1/3] mk: remove smart rebuild when GOFLAGS have changed ├─>[PATCH aerc v3 2/3] mk: only install changed/missing files │ └─>Re: [PATCH aerc v3 2/3] mk: only install changed/missing files │ └─>Re: [PATCH aerc v3 2/3] mk: only install changed/missing files ├─> └─>Re: [PATCH aerc v3 1/3] mk: remove smart rebuild when GOFLAGS have changed This happens because we are using the "previous" message to get the subject base instead of the current one. Compute the base subject from the current message. Here is the result: [PATCH aerc v3 1/3] mk: remove smart rebuild when GOFLAGS have changed ├─>[PATCH aerc v3 2/3] mk: only install changed/missing files │ └─> │ └─> ├─>[PATCH aerc v3 3/3] mk: speed up notmuch detection └─>Re: [PATCH aerc v3 1/3] mk: remove smart rebuild when GOFLAGS have changed Fixes: 535300cfdbfc ("config: add columns based index format") Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* statusline: avoid races when updating status stackTim Culverhouse2023-03-071-0/+10
| | | | | | | | | The statusline stack is written and read from separate goroutines without a lock. Make the statusline thread-safe by adding locks for access to the stack. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* ipc: allow triggering internal commands via IPCMoritz Poldrack2023-03-071-0/+6
| | | | | | | | | | | | | | | | | | | | | In order to make automation easier, it's useful to be able to send commands to aerc via IPC. This can be done by calling the aerc binary followed by a colon and the command to run. For example: aerc :read && aerc :remark && aerc :archive month Security to ensure no malicious commands are run is deferred to the user. By default the socket is only writable by the user. This is considered sufficient as the potential harm an attacker gaining write-access to a user's session can cause is significantly greater than "can delete some emails". To ensure users with an according threat model, it is possible to disable command IPC. mailto-handling is unaffected even though it works over IPC as it is absolutely non-destructive. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* ui: parse strings for ansi stylesTim Culverhouse2023-03-021-9/+14
| | | | | | | | | Parse UI strings for ANSI styles. If there are styles in the string, use those as the display style in tcell. This is in preparation for a template function which can apply arbitrary styles to UI elements. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* pgp: automatically determine signer from senderwitcher2023-03-021-12/+31
| | | | | | | | | | | | | | | | | | | | This patch automatically determines the signing account from the sender of the email (i.e. the From email header). To reflect this in the compose view after changing the From field, the restriction in updateCrypto() to only run the update if the signing key is empty has been lifted, so the key always gets updated when calling updateCrypt(). Additionally, a Signer() method has been added to the Composer to avoid specifying the same logic twice; once in updateCrypto() and once in WriteMessage(). If the From header is not populated for any reason the Signer() method falls back to the from field specified in accounts.conf. Signed-off-by: witcher <witcher@wiredspace.de> Acked-by: Robin Jarry <robin@jarry.cc>
* pgp: fix segfault for opportunistic encryptionwitcher2023-03-021-3/+6
| | | | | | | | | | | | | | | | | Commit 2af81a743048 ("pgp: add configurable error level for opportunistic encryption") introduced a bug where if the pgp-opportunistic-encrypt attribute is set to true and a new message is composed, aerc would crash. This is because no recipients have been specified, so checkEncryption() would fail early and *not* call updateCrypto(), which would then cause a segfault in SetEncrypt() later on. To avoid this, when the function would have returned early, it instead does *not* set c.encrypt to true and still calls updateCrypto(). Fixes: 2af81a743048 ("pgp: add configurable error level for opportunistic encryption") Signed-off-by: witcher <witcher@wiredspace.de> Acked-by: Robin Jarry <robin@jarry.cc>
* compose: only add delimiter when a signature is definedRobin Jarry2023-02-241-0/+4
| | | | | | | | | | | Inserting a solitary "-- " delimiter without any signature after it makes no sense. Skip the whole delimiter check if the signature is empty. Trim leading and trailing white space along the way. Fixes: a553b33ebcbd ("compose: ensure signature uses standard delimiter") Reported-by: Ben Cohen <ben@bencohen.net> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Ben Cohen <ben@bencohen.net>
* dirlist: use templates instead of % mini languageRobin Jarry2023-02-202-123/+107
| | | | | | | | | | | Replace dirlist-format with two settings: dirlist-left & dirlist-right. These two settings take aerc-templates(7) and may be left empty. Add automatic translation of dirlist-format to these new settings. Display a warning on startup if dirlist-format has been converted. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* statusline: add column based render formatRobin Jarry2023-02-204-58/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the spirit of commit 535300cfdbfc ("config: add columns based index format"), reuse the column definitions and table widget. Add automatic translation of render-format to column definitions. Allow empty columns to be compatible with the %m (mute) flag. Rename the State object to AccountState to be more precise. Reuse that object in state.TempateData to expose account state info. Move actual status line rendering in StatusLine.Draw(). Add new template fields for status specific data: {{.ConnectionInfo}} Connection state. {{.ContentInfo}} General status information (e.g. filter, search) {{.StatusInfo}} Combination of {{.ConnectionInfo}} and {{.StatusInfo}} {{.TrayInfo}} General on/off information (e.g. passthrough, threading, sorting) {{.PendingKeys}} Currently pressed key sequence that does not match any key binding and/or is incomplete. Display a warning on startup if render-format has been converted to status-columns. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* statusline: move files to lib/stateRobin Jarry2023-02-201-13/+12
| | | | | | | | These modules will not handle statusline rendering after next commit. Move them in lib/state to make next commit easier to review. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* ui/table: do not require width at constructionRobin Jarry2023-02-201-4/+4
| | | | | | | | | The width is only required when rendering the table in Draw. Remove the redundant width attribute. Fixes: 012be0192c88 ("ui: add reusable table widget") Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* triggers: use templates instead of % mini languageRobin Jarry2023-02-202-7/+16
| | | | | | | | | | | | | | | | | | | | | Since previous commit, all commands now support expanding text/template markup. Reuse that for the new-email trigger command. Update commands.ExecuteCommand to take optional *AccountConfig and *MessageInfo arguments. If these are nil, fallback to using the currently selected account and message (if any). Pass the proper *AccountConfig and *MessageInfo objects when firing the trigger command so that these are used instead of the currently selected ones. If new-email contains % placeholders, try to convert them to template markup reusing the same conversion added in commit 535300cfdbfc ("config: add columns based index format"). Warn the user that they need to update their configuration file. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
* templates: unify data interfaceRobin Jarry2023-02-203-74/+37
| | | | | | | | | | | | | | | | | | | | | | | Require that all aerc template data objects implement the same TemplateData interface. Implement that interface in two different places: 1) state.TemplateData (renamed/moved from templates.TemplateData). This structure (along with all its methods) needs to be decoupled from the templates package to break the import cycle with the config package. This allows much simpler construction of this object and ensure that values are calculated only when requested. 2) config.dummyData (extracted from templates). This is only used in the config package to validate user templates. Putting it here allows also to break an import cycle. Use state.TemplateData everywhere (including for account tabs title rendering). Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
* account: fix segfault when message store is not initializedRobin Jarry2023-02-201-0/+3
| | | | | | | | | | | | | | | | Fix the following error: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x130 pc=0x8769b4] goroutine 1 [running]: git.sr.ht/~rjarry/aerc/lib.(*MessageStore).Uids(0x40ffa5?) git.sr.ht/~rjarry/aerc/lib/msgstore.go:579 +0x14 git.sr.ht/~rjarry/aerc/widgets.(*AccountView).SelectedMessage(0xc0000f41c0) git.sr.ht/~rjarry/aerc/widgets/account.go:198 +0x33 Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>