aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* msglist: style search resultsTim Culverhouse2022-11-061-0/+5
| | | | | | | | Add option to style search results in the message list. Set default style for results. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgviewer: warn user when pager is not in PATHTim Culverhouse2022-11-061-1/+11
| | | | | | | | | Warn user when configured pager is not in PATH. Attempt fallbacks, and throw error if none of the fallbacks are in PATH. Fixes: https://todo.sr.ht/~rjarry/aerc/94 Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* compose: warn user when editor is not in PATHTim Culverhouse2022-11-062-5/+30
| | | | | | | | | Warn user when configured editor is not in path. Attempt fallbacks, and throw error if none of the fallbacks are in PATH. Fixes: https://todo.sr.ht/~rjarry/aerc/94 Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* status: add warning style and methodsTim Culverhouse2022-11-063-0/+14
| | | | | | | | Add a warning style to default statusline. Add methods to status, aerc, and account to push a warning message. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* threadbuilder: sort siblings by sort criteriaKoni Marti2022-11-061-0/+1
| | | | | | | | | | | | | | Sort the client-side thread siblings according to the sort criteria. Activate this option by setting "sort-thread-siblings" to true in the ui section of aerc.conf. "sort-thread-siblings" is false by default and the siblings will be sorted based on their uid number. Note that this options will only work with client-side threading and when the backend supports sorting. Also, it comes with a slight performance penalty. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* auto-completion: add option to require a min number of charsRobin Jarry2022-11-062-6/+30
| | | | | | | | | | When doing address completion via commands that take a while to run, having the completion trigger even with a single character can be non-optimal. Add an option to allow requiring a minimum number of characters to actually run the completion command. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* msglist: display reversed thread orderingKoni Marti2022-10-272-56/+65
| | | | | | | | Reverse the ordering of the message threads. Implements: https://todo.sr.ht/~rjarry/aerc/54 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* threads: reverse thread orderingKoni Marti2022-10-271-0/+1
| | | | | | | | | | | Add reverse-thread-order option to the ui config to enable reverse display of the mesage threads. Default order is the the intial message is on the top with all the replies being displayed below. The reverse options will put the initial message at the bottom with the replies on top. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* store: reverse message list order with iteratorsKoni Marti2022-10-272-20/+37
| | | | | | | | | | | | | | | | | Reverse the order of the messages in the message list. The complexity of reversing the order is abstracted away by the iterators. To reverse the message list, add the following to your aerc.conf: [ui] reverse-msglist-order=true Thanks to |cos| for sharing his initial implementation of reversing the order in the message list [0]. [0]: https://git.netizen.se/aerc/commit/?h=topic/asc_sort_imap Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* listbox: implement horizontal scrollingKoni Marti2022-10-261-1/+62
| | | | | | | | | | | | | | | Implement horizontal scrolling for selected lines that are longer than dialog width. The following keys can be used: Ctrl-a, Home jump to beginning of line Ctrl-e, End jump to end of line Left move one character back Right move one character forward Ctrl+b move one word back Ctrl+w move one word forward Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* split: prevent opening split when no messages are selectedTim Culverhouse2022-10-191-6/+16
| | | | | | | | | The [v]split command panics when it is run with no message selected, or when messages aren't loaded. Check for a valid selected message before creating a split, and report an error if one isn't selected. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* command/help: remove helpClose functionTim Culverhouse2022-10-191-20/+0
| | | | | | | | | | | | | The helpClose function is used to call UpdateScreen on MessageViewer, which has the effect of invalidating and redrawing the message view. This logic is redundant with the addition of tcell-term and the main event loop. Remove the helpClose calls. Remove the UpdateScreen methods from messageviewer: those functions are only used by the helpClose function. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Koni Marti <koni.marti@gmail.com>
* terminal: properly handle cursor displayTim Culverhouse2022-10-191-15/+13
| | | | | | | | | The terminal widget reports if the cursor should be displayed. Properly handle this output to report cursor display back to aerc. Reported-by: staceee Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgview: add separate date formattingBence Ferdinandy2022-10-191-6/+20
| | | | | | | | | | The ThisDayTimeFormat and friends are missing from the message view which just uses the message list's default setting. This might not be desirable since the amount of space available is different. Introduce separate settings for formatting dates in the message view. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* dirtree: fix folder scrollingKoni Marti2022-10-191-3/+2
| | | | | | | | Fix scrolling by correcting the index calculation. Fixes: https://todo.sr.ht/~rjarry/aerc/93 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net>
* ui: add :split and :vsplit view optionsTim Culverhouse2022-10-181-0/+153
| | | | | | | | | | | Add :split and :vsplit commands, which split the message list view to include a message viewer. Each command takes an int, or a delta value ("+1", "-1"). The int value is the resulting size of the message list, and a new message viewer will be displayed below / to the right of the message list. This viewer *does not* set seen flags. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgviewer: simplify filter and pager command handlingTim Culverhouse2022-10-181-92/+30
| | | | | | | | | | | | | | | | | | | Refactor the filtering and paging logic to use several fewer goroutines. Fixes data race condition with the timing of filter -> pager -> terminal, can be found when switching message views fast. Check if filter -> pager process is currently running before calling it to start again. Fixes data race between fetching message body and terminal starting. Both can initiate the copying process, and for long running filters and fast message fetching, it is possible to have fetched a message but still be running the filter when the terminal starts. Move StripAnsi to it's own file in lib/parse, similar to the hyperlinks parser. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* compose: warn before sending without attachmentJason Cox2022-10-172-0/+24
| | | | | | | | | | Prevent the embarrassing forgotten attachment scenario by warning the user before sending a message that may need an attachment but does not have one. Whether a message needs an attachment is determined by testing a configurable regex against the message body. Signed-off-by: Jason Cox <dev@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
* switch-account: fix out-of-bounds panicKoni Marti2022-10-171-0/+3
| | | | | | | | | | Fix out-of-bounds panic by updating the focused int variable when headers change in the switch-account commands. Fixes: d371c1ac8 ("commands: add switch-account command for composer") Reported-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* filters: export mime type and filename in envRobin Jarry2022-10-161-1/+6
| | | | | | | | | | | Export AERC_MIME_TYPE and AERC_FILENAME in the filters command environment. This allows dynamic coloring with tools that require a filename and/or a mime type to determine the syntax. Update docs and add example use in the default config file. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* msgpart: factorize mime type and filename constructionRobin Jarry2022-10-161-13/+7
| | | | | | | Reduce code duplication. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* filters: append well known dirs to exec PATHRobin Jarry2022-10-161-0/+6
| | | | | | | | | | | | | | | | | | | To allow referencing built-in filters without hard coding a path during installation, append the following folders to the exec PATH when running the filter commands: ~/.config/aerc/filters ~/.local/share/aerc/filters $PREFIX/share/aerc/filters /usr/share/aerc/filters If a filter script has the same name than a command in the default exec PATH, it will not shadow it. In that edge case, the absolute path to the filter script must be specified. Suggested-by: Teo Luppi <me@luppi.uk> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* compose: don't lock call to composer.grid.MouseEventTim Culverhouse2022-10-121-1/+3
| | | | | | | | | | | | | | | | The MouseEvent method of the composer passes on the mouse event to it's underlying grid while the composer is locked. The underlying grid then passes on the mouse event to child objects of the grid, which are referenced via fields of the composer (c.editor is a field in composer but a child of c.grid, for example). When the grid attempts to pass on the mouse event, it is referencing a pointer which is locked, and a deadlock occurs due to the original lock in composer.MouseEvent. Unlock before calling the grid.MouseEvent, and lock the composer again after it is called. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* mailto: allow attaching of filesMoritz Poldrack2022-10-121-0/+10
| | | | | | | | | | | Some programs like Skanpage allow sharing files via email and attaching them automatically from the mailto: link. This patch introduces parsing of the attach query argument in mailto links and attaches the listed files. A potential file:// URL has it's prefix removed. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* invalidatable: cleanup dead codeTim Culverhouse2022-10-1216-128/+27
| | | | | | | | Remove invalidatable type and all associated calls. All items can directly invalidate the UI. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* compose: avoid deadlock when adding new headerRobin Jarry2022-10-111-1/+5
| | | | | | | | | | | | AddEditor acquires the lock and calls FocusEditor which also attempts to acquire it. Since the lock is not re-entrant, it ends in deadlock. Add an internal focusEditor fonction that does not acquire the lock. Fixes: bf2bf8c242cb ("compose: prevent out of bounds access") Reported-by: Moritz Poldrack <moritz@poldrack.dev> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Thomas Vigouroux <thomas.vigouroux@protonmail.com>
* compose: fix mouse focus of header editorsRobin Jarry2022-10-111-0/+6
| | | | | | | | | The algorithm is broken, there may be more than one header editor with focused=true. Reset the focused flag before forwarding the mouse event to the composer grid. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* terminal: use Invalidate and QueueRedrawTim Culverhouse2022-10-071-14/+2
| | | | | | | | | | | | | | | | | | | The terminal widget uses it's own redraw logic to improve performance. With the addition of a main event loop, the redraw logic can happen in the main loop via the standard Invalidate logic. Use the Invalidate method to mark aerc invalid, and immediately trigger a redraw with ui.QueueRedraw. The follow up call to QueueRedraw is needed because the terminal update happens in a separate goroutine. This can result in the main event loop finishing it's process of the current event, redrawing the screen, and the terminal having additional updates to be drawn. This fixes race conditions by drawing and calling screen.Show in a separate goroutine. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* aerc: use single event loopTim Culverhouse2022-10-074-34/+19
| | | | | | | | | Combine tcell events with WorkerMessages to better synchronize state with IO and UI. Remove Tick loop for rendering. Use events to trigger renders. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* compose: avoid double lock in MouseEventTim Culverhouse2022-10-051-2/+5
| | | | | | | | | | | | | The MouseEvent locks the composer, and also calls FocusEditor which attempts to lock the composer. This results in a deadlock. No need to call FocusEditor which takes a name as parameter and needs to iterate over all editors to find the correct one. We already have the headerEditor object, use it directly. Fixes: bf2bf8c242cb ("compose: prevent out of bounds access") Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc>
* viewer: option to not mark message as seenKoni Marti2022-10-041-2/+2
| | | | | | | | | | | | | | | | | Add option to open a message in the message viewer without setting the seen flag. Enables the message viewer to be used as a preview pane without changing the message flags unintentionally. Before, the message viewer would set the seen flag by default. The IMAP backend will now always fetch the message body with the peek option enabled (same as we fetch the headers). An "auto-mark-read" option is added to the ui config which is set to true by default. If set the false, the seen flag is not set by the message viewer. Co-authored-by: "James Cook" <falsifian@falsifian.org> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* bindings: properly check for exKey keystrokesTim Culverhouse2022-10-031-1/+9
| | | | | | | | | | | | | | | | | | | | | When checking for an exKey, aerc inspects the key and the rune of the event vs the exkey binding. Runes should only be inspected if the key is a tcell.KeyRune. Some Ctrl-[:alpha:] keys report a rune in tcell, but aerc does not have these bound to the keystroke definition. Only <C-x> has a rune bound, and is one of the very few <C-> keys that can actually be bound to exKey Only compare the Rune field if the key is of type KeyRune. Otherwise, compare the Key. Also compare any modifiers with the keystroke/key event. These changes allow for any control or alt key combination to be bound to the exkey. Update documentaiton to reflect that the default keybind is ':', and not <semicolon> Fixes: https://todo.sr.ht/~rjarry/aerc/67 Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* logging: substitute %w for %vKoni Marti2022-10-022-2/+2
| | | | | | | | | | | | | | | | Subsitute the format specifier %w for %v in the logging facility. The logging functions use a fmt.Sprintf call behind the scene which does not recognize %w. %w should be used in fmt.Errorf when you want to wrap errors. Hence, the log entries that use %w are improperly formatted like this: ERROR 2022/10/02 09:13:57.724529 worker.go:439: could not get message info %!w(*fmt.wrapError=&{could not get structure: [snip] }) ^ Links: https://go.dev/blog/go1.13-errors Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Moritz Poldrack <moritz@poldrack.dev>