Changes between Version 1 and Version 2 of CustomKeyBindings

Show
Ignore:
Timestamp:
12/08/08 16:51:41 (6 years ago)
Author:
judah (IP: 76.170.234.70)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CustomKeyBindings

    v1 v2  
    1 Documentation is TODO. 
     1= Custom Key Bindings = 
     2 
     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) 
     6 
     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>` 
     14  
     15Note that the `meta-` key is `ALT` on Windows. 
     16 
     17These features are pretty new, so feedback and suggestions are encouraged. 
     18 
     19 == Examples == 
     20 
     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: 
     22{{{ 
     23bind: backspace left 
     24bind: meta-backspace backspace 
     25}}} 
     26 
     27 
     28=== Control-left/right === 
     29 
     30The following instructions will make `ctrl-left` and `ctrl-right` skip words. 
     31 
     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: 
     33{{{ 
     34bind: ctrl-left meta-b 
     35bind: ctrl-right meta-f 
     36}}} 
     37 
     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.   
     39 
     40To find out their control sequences, you can do something like: 
     41{{{ 
     42$ ghc -e getLine 
     43<press ctrl-left, then return>^[[5D 
     44"\ESC[5D" 
     45$ ghc -e getLine 
     46<press ctrl-right, then return>^[[5C 
     47"\ESC[5C" 
     48}}} 
     49 
     50Thus we add the following lines (which will be ignored on Windows): 
     51{{{ 
     52keyseq: "\ESC[5D" ctrl-left 
     53keyseq: "\ESC[5C" ctrl-right 
     54}}} 
     55