Changes between Version 1 and Version 2 of CustomKeyBindings

12/08/08 16:51:41 (9 years ago)
judah (IP:



  • CustomKeyBindings

    v1 v2  
    1 Documentation is TODO. 
     1= Custom Key Bindings = 
     3As of version 0.4.1, the user may specify custom key bindings in their `.haskeline` file.  The two new settings are: 
     4 - {{{keyseq: <string> <key>}}} (POSIX-only: add a new key sequence) 
     5 - {{{bind: <key> <key>}}} (bind the first key to the actions of the second key) 
     7where {{{<string>}}} is a Haskell string and {{{<key>}}} is either: 
     8 - a single character 
     9 - `f<n>` (a function key) 
     10 - `left, right, down, up` 
     11 - `backspace, delete, home, end, killline` 
     12 - `return, tab, escape` 
     13 - `ctrl-<key>`, `shift-<key>`, `meta-<key>` 
     15Note that the `meta-` key is `ALT` on Windows. 
     17These features are pretty new, so feedback and suggestions are encouraged. 
     19 == Examples == 
     21The following lines will cause the backspace key to move one character to the left nondestructively, and meta-backspace to delete the character to the left of the cursor: 
     23bind: backspace left 
     24bind: meta-backspace backspace 
     28=== Control-left/right === 
     30The following instructions will make `ctrl-left` and `ctrl-right` skip words. 
     32First, we check `KeyBindings` to see that `M-B` and `M-F` are bound by default to the commands we want.  So the necessary `bind` commands are: 
     34bind: ctrl-left meta-b 
     35bind: ctrl-right meta-f 
     38That's sufficient on Windows, but for POSIX systems a couple more steps are needed.  Normally Haskeline looks up a key sequence in the system `terminfo` database; however `ctrl-left` and `ctrl-right` don't have a standard capability name, so Haskeline needs to be told manually what their key sequence is.   
     40To find out their control sequences, you can do something like: 
     42$ ghc -e getLine 
     43<press ctrl-left, then return>^[[5D 
     45$ ghc -e getLine 
     46<press ctrl-right, then return>^[[5C 
     50Thus we add the following lines (which will be ignored on Windows): 
     52keyseq: "\ESC[5D" ctrl-left 
     53keyseq: "\ESC[5C" ctrl-right