Lines Matching defs:el

46 #include "el.h"
891 map_init(EditLine *el)
899 EL_ABORT((el->errfile, "Emacs map incorrect\n"));
901 EL_ABORT((el->errfile, "Vi command map incorrect\n"));
903 EL_ABORT((el->errfile, "Vi insert map incorrect\n"));
906 el->el_map.alt = (el_action_t *)el_malloc(sizeof(el_action_t) * N_KEYS);
907 if (el->el_map.alt == NULL)
909 el->el_map.key = (el_action_t *)el_malloc(sizeof(el_action_t) * N_KEYS);
910 if (el->el_map.key == NULL)
912 el->el_map.emacs = el_map_emacs;
913 el->el_map.vic = el_map_vi_command;
914 el->el_map.vii = el_map_vi_insert;
915 el->el_map.help = (el_bindings_t *) el_malloc(sizeof(el_bindings_t) *
917 if (el->el_map.help == NULL)
919 (void) memcpy(el->el_map.help, help__get(),
921 el->el_map.func = (el_func_t *)el_malloc(sizeof(el_func_t) *
923 if (el->el_map.func == NULL)
925 memcpy(el->el_map.func, func__get(), sizeof(el_func_t) * EL_NUM_FCNS);
926 el->el_map.nfunc = EL_NUM_FCNS;
929 map_init_vi(el);
931 map_init_emacs(el);
941 map_end(EditLine *el)
944 el_free((ptr_t) el->el_map.alt);
945 el->el_map.alt = NULL;
946 el_free((ptr_t) el->el_map.key);
947 el->el_map.key = NULL;
948 el->el_map.emacs = NULL;
949 el->el_map.vic = NULL;
950 el->el_map.vii = NULL;
951 el_free((ptr_t) el->el_map.help);
952 el->el_map.help = NULL;
953 el_free((ptr_t) el->el_map.func);
954 el->el_map.func = NULL;
962 map_init_nls(EditLine *el)
966 el_action_t *map = el->el_map.key;
978 map_init_meta(EditLine *el)
982 el_action_t *map = el->el_map.key;
983 el_action_t *alt = el->el_map.alt;
993 if (el->el_map.type == MAP_VI)
1008 key_add(el, buf, key_map_cmd(el, (int) map[i]), XK_CMD);
1019 map_init_vi(EditLine *el)
1022 el_action_t *key = el->el_map.key;
1023 el_action_t *alt = el->el_map.alt;
1024 const el_action_t *vii = el->el_map.vii;
1025 const el_action_t *vic = el->el_map.vic;
1027 el->el_map.type = MAP_VI;
1028 el->el_map.current = el->el_map.key;
1030 key_reset(el);
1037 map_init_meta(el);
1038 map_init_nls(el);
1040 tty_bind_char(el, 1);
1041 term_bind_arrow(el);
1049 map_init_emacs(EditLine *el)
1053 el_action_t *key = el->el_map.key;
1054 el_action_t *alt = el->el_map.alt;
1055 const el_action_t *emacs = el->el_map.emacs;
1057 el->el_map.type = MAP_EMACS;
1058 el->el_map.current = el->el_map.key;
1059 key_reset(el);
1066 map_init_meta(el);
1067 map_init_nls(el);
1072 key_add(el, buf, key_map_cmd(el, EM_EXCHANGE_MARK), XK_CMD);
1074 tty_bind_char(el, 1);
1075 term_bind_arrow(el);
1083 map_set_editor(EditLine *el, char *editor)
1087 map_init_emacs(el);
1091 map_init_vi(el);
1102 map_get_editor(EditLine *el, const char **editor)
1107 switch (el->el_map.type) {
1123 map_print_key(EditLine *el, el_action_t *map, const char *in)
1130 ep = &el->el_map.help[el->el_map.nfunc];
1131 for (bp = el->el_map.help; bp < ep; bp++)
1133 (void) fprintf(el->el_outfile,
1138 key_print(el, in);
1146 map_print_some_keys(EditLine *el, el_action_t *map, int first, int last)
1160 (void) fprintf(el->el_outfile,
1165 ep = &el->el_map.help[el->el_map.nfunc];
1166 for (bp = el->el_map.help; bp < ep; bp++) {
1171 (void) fprintf(el->el_outfile, "%-15s-> %s\n",
1178 (void) fprintf(el->el_outfile,
1186 if (map == el->el_map.key) {
1189 (void) fprintf(el->el_outfile,
1191 (void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
1192 first, el->el_map.key[first]);
1196 (void) fprintf(el->el_outfile,
1198 (void) fprintf(el->el_outfile, "el->el_map.alt[%d] == %d\n",
1199 first, el->el_map.alt[first]);
1202 EL_ABORT((el->el_errfile, "Error printing keys\n"));
1210 map_print_all_keys(EditLine *el)
1214 (void) fprintf(el->el_outfile, "Standard key bindings\n");
1217 if (el->el_map.key[prev] == el->el_map.key[i])
1219 map_print_some_keys(el, el->el_map.key, prev, i - 1);
1222 map_print_some_keys(el, el->el_map.key, prev, i - 1);
1224 (void) fprintf(el->el_outfile, "Alternative key bindings\n");
1227 if (el->el_map.alt[prev] == el->el_map.alt[i])
1229 map_print_some_keys(el, el->el_map.alt, prev, i - 1);
1232 map_print_some_keys(el, el->el_map.alt, prev, i - 1);
1234 (void) fprintf(el->el_outfile, "Multi-character bindings\n");
1235 key_print(el, "");
1236 (void) fprintf(el->el_outfile, "Arrow key bindings\n");
1237 term_print_arrow(el, "");
1245 map_bind(EditLine *el, int argc, const char **argv)
1261 map = el->el_map.key;
1268 map = el->el_map.alt;
1288 map_init_vi(el);
1292 map_init_emacs(el);
1296 ep = &el->el_map.help[el->el_map.nfunc];
1297 for (bp = el->el_map.help; bp < ep; bp++)
1298 (void) fprintf(el->el_outfile,
1303 (void) fprintf(el->el_errfile,
1311 map_print_all_keys(el);
1317 (void) fprintf(el->el_errfile,
1324 (void) term_clear_arrow(el, in);
1328 (void) key_delete(el, in);
1330 (void) key_delete(el, in);
1337 term_print_arrow(el, in);
1339 map_print_key(el, map, in);
1353 (void) fprintf(el->el_errfile,
1358 term_set_arrow(el, in, key_map_str(el, out), ntype);
1360 key_add(el, in, key_map_str(el, out), ntype);
1365 if ((cmd = parse_cmd(el, argv[argc])) == -1) {
1366 (void) fprintf(el->el_errfile,
1371 term_set_arrow(el, in, key_map_cmd(el, cmd), ntype);
1374 key_add(el, in, key_map_cmd(el, cmd), ntype);
1377 key_clear(el, map, in);
1384 EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
1395 map_addfunc(EditLine *el, const char *name, const char *help, el_func_t func)
1398 int nf = el->el_map.nfunc + 1;
1403 if ((p = el_realloc(el->el_map.func, nf * sizeof(el_func_t))) == NULL)
1405 el->el_map.func = (el_func_t *) p;
1406 if ((p = el_realloc(el->el_map.help, nf * sizeof(el_bindings_t)))
1409 el->el_map.help = (el_bindings_t *) p;
1411 nf = el->el_map.nfunc;
1412 el->el_map.func[nf] = func;
1414 el->el_map.help[nf].name = name;
1415 el->el_map.help[nf].func = nf;
1416 el->el_map.help[nf].description = help;
1417 el->el_map.nfunc++;