+/* tty_bind_char():
+ * Rebind the editline functions
+ */
+private void
+tty_bind_char(el)
+ EditLine *el;
+{
+ unsigned char *t_n = el->el_tty.t_c[ED_IO];
+ unsigned char *t_o = el->el_tty.t_ed.c_cc;
+ unsigned char new[2], old[2];
+ ttymap_t *tp;
+ el_action_t *dmap, *dalt, *map, *alt;
+ new[1] = old[1] = '\0';
+
+
+ map = el->el_map.key;
+ alt = el->el_map.alt;
+ if (el->el_map.type == MAP_VI) {
+ dmap = el->el_map.vii;
+ dalt = el->el_map.vic;
+ }
+ else {
+ dmap = el->el_map.emacs;
+ dalt = NULL;
+ }
+
+ for (tp = tty_map; tp->nch != -1; tp++) {
+ new[0] = t_n[tp->nch];
+ old[0] = t_o[tp->och];
+ if (new[0] == old[0])
+ continue;
+ /* Put the old default binding back, and set the new binding */
+ key_clear(el, map, old);
+ map[old[0]] = dmap[old[0]];
+ key_clear(el, map, new);
+ /* MAP_VI == 1, MAP_EMACS == 0... */
+ map[new[0]] = tp->bind[el->el_map.type];
+ if (dalt) {
+ key_clear(el, alt, old);
+ alt[old[0]] = dalt[old[0]];
+ key_clear(el, alt, new);
+ alt[new[0]] = tp->bind[el->el_map.type+1];
+ }
+ }
+}
+