aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* aerc: show effects of mailto: and mbox: immediatelyMoritz Poldrack2023-02-161-0/+6
| | | | | | | | | | | | When handling a mailto-Link or opening an mbox file, another update is required before the composer is shown. This is caused by the view not being invalidated and no redraw being queued. Invalidate the UI and queue a redraw when an IPC command is received. Fixes: 7a489cb0011a ("Add Unix socket for communicating with aerc") Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* compose: ensure signature uses standard delimiterMoritz Poldrack2023-02-121-0/+17
| | | | | | | | | | | | Since it has recently been a topic on IRC, and to guide users new to "raw" email, add a note on how signatures are detected and what they should look like. Prepend signature-file and signature-cmd with the standard delimiter if missing. Signed-off-by: Moritz Poldrack <git@moritz.sh> Signed-off-by: Robin Jarry <robin@jarry.cc>
* tabs: use template for compose tabsTim Culverhouse2023-02-122-9/+55
| | | | | | | | | | | | | | | | | | | | | | | | Use a template for compose tabs. Other available values: Account string Subject string To []*mail.Address From []*mail.Address Cc []*mail.Address Bcc []*mail.Address OriginalFrom []*mail.Address When you use To, From, CC, BCC, or OriginalFrom the title will only be updated when an editing field has lost focus. This is so we don't end up calling "PrepareHeader" on every keystroke, which will likely error out anyways since it will be an invalid header. Subject still updates every keystroke. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* config: warn for all deprecated settingsRobin Jarry2023-02-021-21/+22
| | | | | | | | | | index-format may be used in contextual [ui] sections. Display a warning for every converted section so that users don't miss any. Fixes: 535300cfdbfc ("config: add columns based index format") Reported-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* 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>