aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/dirlist.go
Commit message (Collapse)AuthorAgeFilesLines
* account: remember folder/message when reconnectingKoni Marti2023-06-261-1/+0
| | | | | | | | | | 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-171-0/+4
| | | | | | | | | | | | | | | | | 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>
* templates: use template interface consistentlyKoni Marti2023-05-161-3/+3
| | | | | | | | | | | | | | | 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: clear msglist for virtual nodesKoni Marti2023-05-161-0/+5
| | | | | | | | | 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>
* imap: use delimiter from serverMoritz Poldrack2023-05-161-2/+1
| | | | | | | | | 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>
* directory: add role to template fieldsTim Culverhouse2023-04-221-1/+1
| | | | | | | | | 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-221-22/+27
| | | | | | | | | | | | 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-221-3/+3
| | | | | | | | 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-221-22/+19
| | | | | | | | | | | | | | | | | 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>
* 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>
* dirlist: use templates instead of % mini languageRobin Jarry2023-02-201-91/+84
| | | | | | | | | | | 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>
* 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-291-0/+14
| | | | | | | | | | | 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>
* model: change flags array to bitmaskRobin Jarry2023-01-041-9/+3
| | | | | | | 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>
* config: make various sections accessible via global varsRobin Jarry2022-12-141-4/+2
| | | | | | | | | | | | | | | | | | | | 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-141-17/+1
| | | | | | | | | | | | | 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>
* logging: rename package to logRobin Jarry2022-12-021-3/+3
| | | | | | | | | | 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-021-1/+1
| | | | | | | | | | | | | | | | | | 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>
* dirtree: prevent panic when no folder is foundKoni Marti2022-11-091-1/+1
| | | | | | | | | 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>
* invalidatable: cleanup dead codeTim Culverhouse2022-10-121-2/+1
| | | | | | | | 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>
* dirlist: prevent race condition on accessing uiconfigTim Culverhouse2022-09-291-0/+4
| | | | | | | Prevent a race condition when accessing UI Config maps Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: move logic for dynamic folders to backendKoni Marti2022-09-291-13/+0
| | | | | | | | | | | | | | | Moves logic for creating dynamic folders from the dirlist widget to the backend. Since dynamic folders are notmuch-specific, the notmuch backend should be responsible for correctly setting up those folders. It does that by sending two DirectoryInfos: the first to create the message store, the second to fetch the directory content. This approach also fixes a deadlock introduced by 716ade8968715 ("worker: lock access to callback maps"). Reported-by: Bence Ferdinandy <bence@ferdinandy.com> Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* dirlist: avoid race from accessing ui config in Select debounceTim Culverhouse2022-09-261-1/+2
| | | | | Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* dirlist: don't invalidate on spinner.InvalidateTim Culverhouse2022-09-201-3/+0
| | | | | | | | The dirlist is invalidated explicitly after the spinner is stopped. For simplicitly, don't invalidate on spinner.Invalidate. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* fix: Set proper UIConfig for msgstoresTim Culverhouse2022-08-221-13/+16
| | | | | | | | | | | | | | | | | | | The merged UIConfig used to create new message stores is based on the selected directory. If the message store is created by other means than selecting (ListDirectories for maildir/notmuch/mbox, or check-mail) it may have an incorrect configuration if the user has folder-specific values for: - Threaded view - Client built threads - Client threads delay - Sort criteria - NewMessage bell Use the correct merged UIConfig when creating a new message store. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: homogenize operations and minor fixes (gocritic)Moritz Poldrack2022-08-041-5/+5
| | | | | | | | | | | | | | | | | | Apply GoDoc comment policy (comments for humans should have a space after the //; machine-readable comments shouldn't) Use strings.ReplaceAll instead of strings.Replace when appropriate Remove if/else chains by replacing them with switches Use short assignment/increment notation Replace single case switches with if statements Combine else and if when appropriate Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: removed unused code (deadcode, structcheck, unused)Moritz Poldrack2022-08-041-1/+0
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: remove unused structs and functions (unused)Moritz Poldrack2022-08-041-13/+0
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: apply new formatting rulesMoritz Poldrack2022-08-011-1/+0
| | | | | | | Run `make fmt`. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* logging: use level-based logger functionsRobin Jarry2022-07-231-6/+3
| | | | | | | | | | | | Do not pass logger objects around anymore. Shuffle some messages to make them consistent with the new logging API. Avoid using %v when a more specific verb exists for the argument types. The loggers are completely disabled (i.e. Sprintf is not even called) by default. They are only enabled when redirecting stdout to a file. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* threading: enable filtering of server-side threadsTim Culverhouse2022-07-101-1/+5
| | | | | | | | | | | | | | This patch enables the filtering of a threaded view which uses server-built threads. Filtering is done server-side, in order to preserve the use of server-built threads. In adding this feature, the filtering of notmuch folders was brought up to feature parity with the other workers. The filters function the same (ie: they can be stacked). The notmuch filters, however, still use notmuch syntax for the filtering. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* perf: reduce calls to GetUiConfigTim Culverhouse2022-07-031-1/+12
| | | | | | | | | | | | | | | | | | GetUiConfig was being called many times, and came up as a high CPU user in a cpuprofile. Every call would merge a UIConfig, which is a costly operation. Ideally, we would only need to have a config for every account X every directory. We also have a context for subjects. This patch stores all FOLDER and ACCOUNT level configs and reuses those merged objects. The SUBJECT contexts are not stored in favor of merging on-the-go, with a TODO comment to deprecate that feature and implement a better per-message styling option. I suspect this feature is not used very much. Before applying this patch with my setup, GetUiConfig is called 1159 times just to open aerc. After applying, this is reduced to 37. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* uiconfig: use pointer references to uiConfigTim Culverhouse2022-07-031-2/+2
| | | | | | | | This patch changes references to uiConfig in function signatures and structs to be pointers. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* dirlist: fix race condition in directory selectionMoritz Poldrack2022-06-261-23/+30
| | | | | | | This replaces a channel that is used like a context with a context. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Koni Marti <koni.marti@gmail.com>
* dirlist: fix ruestring counts from checkmailTim Culverhouse2022-06-141-11/+8
| | | | | | | | Commit 8b6f971 broke ruestring counts when AccurateCounts=true, which primarily occur from a checkmail. This restores the functionality. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* dirlist: fix panic when disconnecting with dirlist-tree=falseTim Culverhouse2022-06-071-14/+5
| | | | | | | | | | | | | | Commit 2027223a created a panic when attempting to clear the dirlist when the config option dirlist-tree is set to false. This patch fixes that panic by creating a dirlist.ClearList() function to prevent needing to check a callback. Tested with both dirlist-tree=false and true Fixes: 2027223ab302 ("fix: clear dirlist on disconnect") Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* fix: clear dirlist on disconnectTim Culverhouse2022-06-071-0/+15
| | | | | | | | | | | | | | A message of Done:Disconnect will trigger an update of the dirlist. An update of the dirlist will issue a ListDirectories message, which causes an imap: client not ready error by trying to use the imap connection - which is disconnected. By not issuing the update, we prevent using a disconnected client. This patch checks for connection state prior to updating the dirlist. A disconnected state will clear out the dirlist. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* dirlist: update RUE counts for imap/maildir on move|copy|delete|archiveTim Culverhouse2022-06-071-8/+4
| | | | | | | | | | | | | | | | | | | When moving/copying/deleting/archiving a message in imap, the RUE counts displayed in the dirlist would not update properly. Maildir has (had) an implementation that recounts the entire directory and updates the DirectoryInfo after one of these actions. This patch implements a more efficient method of updating, and also enables it to apply to IMAP without any additional requests. Upon completion of the action, the counts are manually updated with the count of messages in the action and recent and/or unseen states of those messages. This is more efficient for maildir, because we aren't counting everything in the store. For IMAP, we get the updates for free because we are only performing the update after confirmation from the server that the action has happened. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* fix: rue string count accuracyTim Culverhouse2022-06-071-8/+4
| | | | | | | | | | | | | | | | The countRUE function was inaccurately counting flags. If a message was unread and recent, it was only counted as recent. The two flags are not mutually exclusive. A previous count for a mailbox with 1 recent, 1 unread, and 5 existing would be : 1/0/5 An accurate count of this state would be: 1/1/5 This patch fixes the count. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* feat: add background mail polling option for all workersTim Culverhouse2022-05-311-25/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | Check for new mail (recent, unseen, exists counts) with an external command, or for imap with the STATUS command, at start or on reconnection and every X time duration IMAP: The selected folder is skipped, per specification. Additional config options are included for including/excluding folders explicitly. Maildir/Notmuch: An external command will be run in the background to check for new mail. An optional timeout can be used with maildir/notmuch. Default is 10s New account options: check-mail check-mail-cmd (maildir/notmuch only) check-mail-timeout (maildir/notmuch only), default 10s check-mail-include (IMAP only) check-mail-exclude (IMAP only) If unset, or set less than or equal to 0, check-mail will be ignored Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* dirlist: add format specifier to compact folder nameKoni Marti2022-04-291-0/+4
| | | | | | | | | | | Add the format specifier %N to the dirlist-format to display compacted folder names. A folder such as INBOX/WORK/PROJECT will be compacted to I/W/PROJECT in the directoy list. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* style: add style config options for dirlist_unread and dirlist_recentTim Culverhouse2022-04-271-3/+14
| | | | | | | | Adds two style options: dirlist_unread and dirlist_recent. These options apply in layers, in the same way as msglist_* styles do. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* Initialization fix for dynamic foldersAivars Vaivods2022-04-141-0/+9
| | | | | | | | | | | | | | | | | | | There is an issue with backends, that provide dynamic folders, namely when opening folder, that isn't defined in config file, you get empty folder. To actually get messages listed, you need to open that folder twice. At first attempt only DirectoryInfo is fetched and new MessageStore created. Second attempt populates previously created MessageStore with list of messages. For pre-configured folders, DirectoryInfos are fetched upon connection to backend and, when folder is opened, MessageStore is updated with list of messages. Fixes: https://todo.sr.ht/~rjarry/aerc/30 Signed-off-by: Aivars Vaivods <aivars@vaivods.lv> Acked-by: Robin Jarry <robin@jarry.cc>
* logging: added a log on panicMoritz Poldrack2022-03-231-0/+3
| | | | | | | | | | | | | Since panics still regularly "destroy" the terminal, it is hard to get a stack trace for panics you do not anticipate. This commit adds a panic handler that automatically creates a logfile inside the current working directory. It has to be added to every goroutine that is started and will repair the terminal on a panic. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* scrollable: extract scrolling behavior for reuseKoni Marti2022-03-031-49/+11
| | | | | | | | | Extract the vertical scrolling ability into its own Scrollable struct that can be embedded and reused across any ui element that relies on scrolling. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* ui: make dirlist-delay context-awareinwit2022-02-241-1/+1
| | | | | | | | | | | | | | Allow this in aerc.conf: dirlist-delay=200ms ... [ui:account=CrappyO365Account] dirlist-delay=2000ms Fixes: https://todo.sr.ht/~rjarry/aerc/26 Signed-off-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* dirtree: implement foldable tree for directory listKoni Marti2022-02-231-1/+34
| | | | | | | | | | | | | | implement a foldable tree for the directory list. Expand all parent directories when a hidden directory is selected with the change-folder command. folders-sort considers the top-level directories only. The folders and foldersexclude filters work with the full directory path. Enable tree view by adding 'dirlist-tree=true' to the config file. Implements: https://todo.sr.ht/~sircmpwn/aerc2/228 Signed-off-by: Koni Marti <koni.marti@gmail.com>
* dirlist: use shorter delay before listing directory contentsRobin Jarry2022-01-291-1/+1
| | | | | | | | | | | | 1 second is a bit excessive. Use 200ms which should cover most quick folder changes. Add an option to make that delay configurable by the users. References: https://todo.sr.ht/~rjarry/aerc/16 Fixes: cb3090956cfd ("dirlist: skip unnecessary change-folder action") Suggested-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc>