aboutsummaryrefslogtreecommitdiffstats
path: root/config/binds.go
Commit message (Collapse)AuthorAgeFilesLines
* config: add reload helper functionsKoni Marti2024-08-201-1/+1
| | | | | | | | | | Add reload helper function to reload config files. Store the initially used config files for the reloading. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* binds: fix FormatKeyStrokes to properly display certain keystrokesVitaly Ovchinnikov2024-04-131-1/+1
| | | | | | | | | | Fix FormatKeyStrokes so it properly displays the strokes that are not directly listed in `keyNames`, like ctrl+left, ctrl+pgup etc. Add a test to check that the strokes are now formatted. Signed-off-by: Vitaly Ovchinnikov <v@ovch.ru> Acked-by: Robin Jarry <robin@jarry.cc>
* binds: refactor parser to be more tolerantTim Culverhouse2024-02-221-97/+44
| | | | | | | | Refactor the bind parser to construct arbitrary modified keys instead of only relying on built in maps. Add additional tests to cover edge cases. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* binds: allow account and folder binds to coexistJason Cox2024-02-141-0/+6
| | | | | | | | | | | | | | | | | | | | | When loading binds, account-specific binds are first applied, and then folder-specific binds are applied. However, in the process of merging the account-specific binds with the general binds, the folder-specific binds are lost. As a result, if both account- and folder-specific binds exist, the folder-specific binds will do nothing when in the specified account. The following minimal binds.conf reproduces this behavior: [messages] [messages:account=<ACCOUNT>] [messages:folder=<FOLDER>] q = :quit<Enter> Fix this issue by ensuring contextual binds are preserved when merging. Changelog-fixed: Allow account- and folder-specific binds to coexist. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
* log: move package to libRobin Jarry2024-02-141-1/+1
| | | | | | | This has nothing to do at the root of the source tree. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
* aerc: replace tcell keys with vaxis keysTim Culverhouse2024-02-121-234/+224
| | | | | | | Replace all instances of tcell key usage with vaxis keys Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* binds: parse annotations from keybind configKoni Marti2024-02-111-5/+16
| | | | | | | | | | | | | | | | | | | | | Parse inline comments in binds.conf as annotations to the corresponding keybinds. Note that a space is required before the comment symbol, so the comment delimiter is " # ". Example: p = :postpone<Enter> # I'll work on it later where "I'll work on it later" is the annotation. When a comment symbol ("#") is needed in the value part of the keybind, it should be escaped ("\#"). Comment symbols can be used without restriction in the annotation itself. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Reviewed-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* config: print file path in error messageMichal Siedlaczek2024-01-251-10/+19
| | | | | | | | | In case of a config parsing error, print the file path of the file in which the error occurred. Fixes: https://todo.sr.ht/~rjarry/aerc/218 Signed-off-by: Michal Siedlaczek <michal@siedlaczek.me> Acked-by: Robin Jarry <robin@jarry.cc>
* main: add flags to override config filesBence Ferdinandy2024-01-211-6/+8
| | | | | | | | | | | | Add --aerc-conf, --binds-conf and --accounts-conf CLI flags, which respectively override the default aerc.conf, binds.conf and accounts.conf configuration files. If the specified files do not exist or cannot be read, exit with an error. Implements: https://todo.sr.ht/~rjarry/aerc/209 Changelog-added: CLI flags to override paths to config files. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* binds: allow <a-0> to <a-9>Erik Terpstra2023-11-121-0/+10
| | | | | | | | Add support for Alt+<number> keys. Update documentation for it. Changelog-added: Allow binding commands to `Alt+<number>` keys. Signed-off-by: Erik Terpstra <erik@nixhub.nl> Acked-by: Robin Jarry <robin@jarry.cc>
* complete: allow setting the completion key bindingRobin Jarry2023-11-021-10/+22
| | | | | | | | | | | | | | | | | | | | | Until now, if less than complete-min-chars were entered or if completion-delay had not expired yet, the only way to force trigger completion was to press <tab>. In some cases, <tab> is already bound to another action (for example :next-field in the compose::editor context). This makes forcing the completion impossible. Allow defining a key to trigger manual completion via the new $complete special entry in binds.conf. Leave the default binding to <tab>. Set it to <C-o> in the [compose::editor] to avoid conflicting with the existing <tab> binding. Changelog-added: Customize key to trigger completion with `$complete` in `binds.conf`. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
* binds: remove duplicated and empty bindingsVitaly Ovchinnikov2023-11-021-0/+48
| | | | | | | | | | | | | Add keybindings filtering, so if the context binding is defined, the parent one is removed and is not shown in the list at all. Also add keybinding removing, so if the context defines an empty binding, both this and parent one are removed from the list. This way you can disable and hide specific bindings in contexts. Changelog-added: Disable parent context bindings by declaring them empty. Signed-off-by: Vitaly Ovchinnikov <v@ovch.ru> Acked-by: Robin Jarry <robin@jarry.cc>
* binds: better processing of contextual bindsVitaly Ovchinnikov2023-10-131-2/+5
| | | | | | | | | | | | | | | | | Fix bindings for groups like [compose::review:account=acc1], adds a proper handling of $noinherit=true for contextual bindings. Without the patch contexts like [compose::review:account=acc1] are matching the [view] context which produces errors. Replacing `Contains` with `HasPrefix` seems to be the right thing there. Another change lets you really drop all the previous bindings if the contextual binding has $noinherit=true. Without that the parent bindings are still there regardless of $noinherit flag. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Reviewed-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* binds: improve display of key sequencesRobin Jarry2023-09-191-4/+20
| | | | | | | | | | Do not replace all spaces by <space>, it makes the bindings completely unreadable. Only replace trailing and leading spaces with <space> since these are the only one that actually matter. The others are implicit and it improves the readability level by over 9000. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* binds: control and alt modifiers for deleteVitaly Ovchinnikov2023-09-191-0/+2
| | | | | | | | Add Control and Alt modifiers to Delete key, so C-Delete and A-Delete kebyoard shortcuts could be bound. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Acked-by: Robin Jarry <robin@jarry.cc>
* wizard: allow ? in passwordsRobin Jarry2023-08-041-0/+1
| | | | | | | | | | | | There is a default ? bind in the global context to show the current key bindings. It is completely useless in the wizard context and prevents users from typing ? if this character is in their password. Disable globals in the wizard bindings (equivalent of $noinherit=true). Reported-by: Brad <super1337@posteo.net> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
* wizard: properly initialize configurationRobin Jarry2023-07-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The wizard constructs an AccountConfig object by hand without initializing default values. This causes a crash when replying to an email (rr) just after completing the account creation: ~/.config/aerc/aerc.conf not found, installing the system default~/.config/aerc/binds.conf not found, installing the system defaultpanic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x90 pc=0x5d1550] ... regexp.(*Regexp).doExecute(0x7fc1089aa108?, {0x0?, 0x0?}, {0x0?, 0x0?, 0xc000fe5408?}, {0xc000698120?, 0x10?}, 0xad3a40?, 0x2, ...) regexp/exec.go:527 +0x90 regexp.(*Regexp).FindString(0x44e372?, {0xc000698120, 0x27}) regexp/regexp.go:852 +0x6c git.sr.ht/~rjarry/aerc/commands/msg.trimLocalizedRe({0xc000698120, 0x27}, 0xc00003e420?) git.sr.ht/~rjarry/aerc/commands/msg/reply.go:332 +0x36 git.sr.ht/~rjarry/aerc/commands/msg.reply.Execute({}, 0xc0002ba180, {0xc0002f8800?, 0x2, 0x2}) git.sr.ht/~rjarry/aerc/commands/msg/reply.go:157 +0x765 ... Extract the account parsing and initialization into a function. Reuse that function in both accounts.conf parsing and the wizard. Fixes: 40cc540357d9 ("reply: allow to override localized Re regexp in configuration") Reported-by: Mechiel Lukkien <mechiel@ueber.net> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Andrew Yu <andrew@andrewyu.org>
* bindings: add backspace keyVitaly Ovchinnikov2023-06-101-0/+1
| | | | | | | | Add `<backspace>` option to bindings, so it can be used to leave the message view similar to some file managers. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Acked-by: Robin Jarry <robin@jarry.cc>
* config: report accounts.conf format errorsRobin Jarry2023-03-261-1/+3
| | | | | | | | | | | When accounts.conf cannot be parsed, return an error instead of assuming that the file is non existent and wrongfully opening the new account wizard. Use the same ini delimiters for all configuration files. Fixes: https://todo.sr.ht/~rjarry/aerc/151 Reported-by: Jon Fineman <jon@fineman.me> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* wizard: fix panic on any key pressRobin Jarry2022-12-191-205/+202
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using :new-account, aerc crashes when entering a letter with the following trace: panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x66930e] goroutine 1 [running]: git.sr.ht/~rjarry/aerc/log.PanicHandler() git.sr.ht/~rjarry/aerc/log/panic-logger.go:51 +0x73e panic({0xa2b200, 0x10204e0}) runtime/panic.go:890 +0x262 git.sr.ht/~rjarry/aerc/config.(*KeyBindings).GetBinding(0xc000370000?, {0xc000634c48?, 0xc000118900?, 0x5843da?}) git.sr.ht/~rjarry/aerc/config/binds.go:331 +0x2e git.sr.ht/~rjarry/aerc/widgets.(*Aerc).Event(0xc000370000, {0xbd1e60?, 0xc00112e000?}) git.sr.ht/~rjarry/aerc/widgets/aerc.go:309 +0x196 git.sr.ht/~rjarry/aerc/lib/ui.(*UI).HandleEvent(0xc00031e840, {0xbd1e60?, 0xc00112e000}) git.sr.ht/~rjarry/aerc/lib/ui/ui.go:141 +0x162 main.main() git.sr.ht/~rjarry/aerc/aerc.go:246 +0xa89 The issue is that the keyNames map is empty when defaultBindsConfig() is called and ParseBinding("<C-q>", ":quit<Enter>") returns an error: Unknown key 'C-q' which is (unfortunately) ignored and nil is inserted in the wizard bindings. Fix that by initializing keyNames at the module level and remove init(). Fixes: c05c2ffe0424 ("config: make various sections accessible via global vars") Reported-by: Moritz Poldrack <moritz@poldrack.dev> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Moritz Poldrack <moritz@poldrack.dev>
* config: make various sections accessible via global varsRobin Jarry2022-12-141-31/+31
| | | | | | | | | | | | | | | | | | | | 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-28/+62
| | | | | | | | | | | | | 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-4/+4
| | | | | | | | | | 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>
* config: add log-file and log-level settingsRobin Jarry2022-11-211-1/+1
| | | | | | | | | | | Allow configuring persistent logging to file with a log level. When redirecting the output of aerc to a file these two settings are ignored and all messages are printed to stdout. Suggested-by: Moritz Poldrack <moritz@poldrack.dev> Suggested-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* config: move binds.conf parsing in binds.goRobin Jarry2022-11-161-0/+205
| | | | | | | | | | The config.go file is getting too big. Move all binds.conf parsing logic into binds.go where it belongs. No functional change. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* config: rename bindings -> bindsRobin Jarry2022-11-161-0/+440
For consistency with binds.conf Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>