Commit graph

22 commits

Author SHA1 Message Date
Robin Jarry
1b91b68e73 bindings: fix FormatKeyStrokes for <tab> and <enter>
Sometimes, a <tab> or <enter> key in a binding will be formatted as
a <c-i> or <c-m> respectively. This is because these keys are
equivalent. Prefer their canonical name instead of the control modifier
variant.

Fixes: 5e600d7ab4 ("binds: fix ctrl-i and ctrl-m key definitions")
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Koni Marti <koni.marti@gmail.com>
2022-08-10 09:51:29 +02:00
Moritz Poldrack
978d35d356 lint: homogenize operations and minor fixes (gocritic)
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>
2022-08-04 21:58:01 +02:00
Moritz Poldrack
aaf0a0c656 lint: apply new formatting rules
Run `make fmt`.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-01 10:44:52 +02:00
Robin Jarry
5e600d7ab4 binds: fix ctrl-i and ctrl-m key definitions
On all terminals, ctrl-i sends a tab character (0x09). For some reason,
tcell.ModCtrl+tcell.KeyCtrlI is interpreted as ctrl-tab.

Similarly, ctrl-m sends a new line (0x0a) and
tcell.ModCtrl+tcell.KeyCtrlM is interpreted as ctrl-enter.

Remove control modifier for these two key definitions only. All others
do not work without them.

Fixes: 7a6c808c04 ("bindings: prepare for more modifers")
Fixes: https://todo.sr.ht/~rjarry/aerc/56
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2022-07-17 19:00:47 +02:00
Ivan Oleynikov
f21916ce0a binds: fix incorrect key names for c-] and c-[
The left and right square brackets are inverted. Fix that.

Signed-off-by: Ivan Oleynikov <ivan.oleynikov95@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-25 11:22:12 +02:00
Koni Marti
029ff63929 binds: allow to bind a command to < and >
Allow to bind to < and > by using \< and \> in binds.conf. Ensure that
the single \ can still be properly used to bind to other commands.

For example, the following binds would work now:
\< = :prev-tab<Enter>
\> = :next-tab<Enter>
\ = :filter<space>

Fixes: https://todo.sr.ht/~rjarry/aerc/37
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Sebastian LaVine <mail@smlavine.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-17 12:16:38 +02:00
Robin Jarry
77b3a141a4 review: display actual bindings for commands
Parse the actual user bindings to determine what shortcuts are available
in the compose::review stage. Add a predefined list of commands for
which we want to display the keyboard shortcuts.

Fixes: https://todo.sr.ht/~rjarry/aerc/14
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-02-02 22:12:08 +01:00
Robin Jarry
b96326517d bindings: fix ctrl-h binding not working
For some unknown reason. tcell does not include the ctrl modifier for
the ctrl-h key event.

Fixes: 7a6c808c04 ("bindings: prepare for more modifers")
Fixes: https://todo.sr.ht/~rjarry/aerc/8
Signed-off-by: Robin Jarry <robin@jarry.cc>
2022-01-20 13:23:35 +01:00
Jonathan Bartlett
175d0efeb2 binds: add account specific bindings
When using aerc for multiple accounts often bindings might differ
slightly between accounts. For example:

* Account A archives to one directory (:archive)
* Account B archives to monthly directories (:archive month)

Add account specific bindings to allow the user to add a "context" to a
binding group using a context specifier and a regular expression.

Currently the only context specifier is 'account'.

The regular expression is validated against the accounts loaded from
accounts.conf and the configuration fails to load if there are no
matches.

Contextual bindings are merged with global bindings, with contextual
bindings taking precedence, when that context is active.

Bindings are be configured using a generic pattern of
'view:context=regexp'. E.g.:

    # Globally Applicable Archiving
    [messages]
    A = :read<Enter>:archive<Enter>

    # Monthly Archiving for 'Mailbox' Account
    [messages:account=Mailbox$]
    A = :read<Enter>:archive month<Enter>

In the above example all accounts matching the regular expression will
archive in the monthly format - all others will use the global binding.

Signed-off-by: Jonathan Bartlett <jonathan@jonnobrow.co.uk>
2021-12-11 21:45:41 +01:00
Robin Jarry
1a75906bcb bindings: support more modified keys
Add new supported keys:

  Ctrl+Enter
  Ctrl+Up
  Ctrl+Down
  Ctrl+Left
  Ctrl+Right
  Ctrl+PageUp
  Ctrl+PageDown

Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-10-28 16:22:28 +02:00
Robin Jarry
7a6c808c04 bindings: prepare for more modifers
Prepare to support more modifiers in key bindings.

tcell has some premade ctrl-modified keys but not all keys are
supported. Other keys must be explicitly checked with a modifier mask.

Update the KeyStroke type to carry a modifier mask. Update code
accordingly.

No functional change.

Link: https://github.com/gdamore/tcell/blob/master/key.go#L265-L275
Link: https://github.com/gdamore/tcell/blob/master/key.go#L384-L419
Signed-off-by: Robin Jarry <robin@jarry.cc>
2021-10-28 16:21:37 +02:00
y0ast
03650474e2 update tcell to v2 and enable TrueColor support
Also update to the tcell v2 PaletteColor api, which should keep the chosen
theme of the user intact.

Note, that if $TRUECOLOR is defined and a truecolor given, aerc will now stop
clipping the value to one of the theme colors.
Generally this is desired behaviour though.
2020-12-18 07:23:22 +01:00
Wagner Riffel
feacca3c5c all: use fmt.Errorf for fomartting errors
Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
2019-09-04 16:30:57 -10:00
Reto Brunner
1c419d1b4d lowercase all key bindings 2019-07-17 15:58:46 -04:00
Drew DeVault
c4c8648cc7 Change ex command to C-x when using terminal 2019-05-24 12:45:48 -04:00
Drew DeVault
f77d7c2c3d Add distinct keybindings for each compose view 2019-05-14 14:27:28 -04:00
Drew DeVault
6d01332b55 Rig up terminal keybinding group 2019-03-21 17:44:44 -04:00
Drew DeVault
f5bf4a9324 Add context-specific keybindings 2019-03-21 17:37:19 -04:00
Drew DeVault
79b459ecb0 Add additional context to key binding set 2019-03-21 16:35:35 -04:00
Drew DeVault
f47a927ab6 Fix special key bindings (e.g. <C-d>) 2019-03-15 21:54:44 -04:00
Drew DeVault
24dfc47126 Rig up key bindings 2019-03-15 01:46:14 -04:00
Drew DeVault
8d20e9218e Implement key bindings subsystem
Which is not yet rigged up
2019-03-15 01:31:23 -04:00