tty_bind_char(): * Rebind the editline functions */
| 878 | * Rebind the editline functions |
| 879 | */ |
| 880 | protected void |
| 881 | tty_bind_char(EditLine *el, int force) |
| 882 | { |
| 883 | |
| 884 | unsigned char *t_n = el->el_tty.t_c[ED_IO]; |
| 885 | unsigned char *t_o = el->el_tty.t_ed.c_cc; |
| 886 | Char new[2], old[2]; |
| 887 | const ttymap_t *tp; |
| 888 | el_action_t *map, *alt; |
| 889 | const el_action_t *dmap, *dalt; |
| 890 | new[1] = old[1] = '\0'; |
| 891 | |
| 892 | map = el->el_map.key; |
| 893 | alt = el->el_map.alt; |
| 894 | if (el->el_map.type == MAP_VI) { |
| 895 | dmap = el->el_map.vii; |
| 896 | dalt = el->el_map.vic; |
| 897 | } else { |
| 898 | dmap = el->el_map.emacs; |
| 899 | dalt = NULL; |
| 900 | } |
| 901 | |
| 902 | for (tp = tty_map; tp->nch != (Int)-1; tp++) { |
| 903 | new[0] = t_n[tp->nch]; |
| 904 | old[0] = t_o[tp->och]; |
| 905 | if (new[0] == old[0] && !force) |
| 906 | continue; |
| 907 | /* Put the old default binding back, and set the new binding */ |
| 908 | keymacro_clear(el, map, old); |
| 909 | map[UC(old[0])] = dmap[UC(old[0])]; |
| 910 | keymacro_clear(el, map, new); |
| 911 | /* MAP_VI == 1, MAP_EMACS == 0... */ |
| 912 | map[UC(new[0])] = tp->bind[el->el_map.type]; |
| 913 | if (dalt) { |
| 914 | keymacro_clear(el, alt, old); |
| 915 | alt[UC(old[0])] = dalt[UC(old[0])]; |
| 916 | keymacro_clear(el, alt, new); |
| 917 | alt[UC(new[0])] = tp->bind[el->el_map.type + 1]; |
| 918 | } |
| 919 | } |
| 920 | } |
| 921 | |
| 922 | |
| 923 | private tcflag_t * |
no test coverage detected