Lines Matching defs:el

48 #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_malloc(sizeof(*el->el_map.alt) * N_KEYS);
907 if (el->el_map.alt == NULL)
909 el->el_map.key = el_malloc(sizeof(*el->el_map.key) * 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_malloc(sizeof(*el->el_map.help) * EL_NUM_FCNS);
916 if (el->el_map.help == NULL)
918 (void) memcpy(el->el_map.help, help__get(),
919 sizeof(*el->el_map.help) * EL_NUM_FCNS);
920 el->el_map.func = el_malloc(sizeof(*el->el_map.func) * EL_NUM_FCNS);
921 if (el->el_map.func == NULL)
923 memcpy(el->el_map.func, func__get(), sizeof(*el->el_map.func)
925 el->el_map.nfunc = EL_NUM_FCNS;
928 map_init_vi(el);
930 map_init_emacs(el);
940 map_end(EditLine *el)
943 el_free(el->el_map.alt);
944 el->el_map.alt = NULL;
945 el_free(el->el_map.key);
946 el->el_map.key = NULL;
947 el->el_map.emacs = NULL;
948 el->el_map.vic = NULL;
949 el->el_map.vii = NULL;
950 el_free(el->el_map.help);
951 el->el_map.help = NULL;
952 el_free(el->el_map.func);
953 el->el_map.func = NULL;
961 map_init_nls(EditLine *el)
965 el_action_t *map = el->el_map.key;
977 map_init_meta(EditLine *el)
981 el_action_t *map = el->el_map.key;
982 el_action_t *alt = el->el_map.alt;
992 if (el->el_map.type == MAP_VI)
1007 keymacro_add(el, buf, keymacro_map_cmd(el, (int) map[i]), XK_CMD);
1018 map_init_vi(EditLine *el)
1021 el_action_t *key = el->el_map.key;
1022 el_action_t *alt = el->el_map.alt;
1023 const el_action_t *vii = el->el_map.vii;
1024 const el_action_t *vic = el->el_map.vic;
1026 el->el_map.type = MAP_VI;
1027 el->el_map.current = el->el_map.key;
1029 keymacro_reset(el);
1036 map_init_meta(el);
1037 map_init_nls(el);
1039 tty_bind_char(el, 1);
1040 terminal_bind_arrow(el);
1048 map_init_emacs(EditLine *el)
1052 el_action_t *key = el->el_map.key;
1053 el_action_t *alt = el->el_map.alt;
1054 const el_action_t *emacs = el->el_map.emacs;
1056 el->el_map.type = MAP_EMACS;
1057 el->el_map.current = el->el_map.key;
1058 keymacro_reset(el);
1065 map_init_meta(el);
1066 map_init_nls(el);
1071 keymacro_add(el, buf, keymacro_map_cmd(el, EM_EXCHANGE_MARK), XK_CMD);
1073 tty_bind_char(el, 1);
1074 terminal_bind_arrow(el);
1082 map_set_editor(EditLine *el, Char *editor)
1086 map_init_emacs(el);
1090 map_init_vi(el);
1101 map_get_editor(EditLine *el, const Char **editor)
1106 switch (el->el_map.type) {
1122 map_print_key(EditLine *el, el_action_t *map, const Char *in)
1129 ep = &el->el_map.help[el->el_map.nfunc];
1130 for (bp = el->el_map.help; bp < ep; bp++)
1132 (void) fprintf(el->el_outfile,
1137 keymacro_print(el, in);
1145 map_print_some_keys(EditLine *el, el_action_t *map, Int first, Int last)
1159 (void) fprintf(el->el_outfile,
1164 ep = &el->el_map.help[el->el_map.nfunc];
1165 for (bp = el->el_map.help; bp < ep; bp++) {
1170 (void) fprintf(el->el_outfile, "%-15s-> " FSTR "\n",
1177 (void) fprintf(el->el_outfile,
1185 if (map == el->el_map.key) {
1188 (void) fprintf(el->el_outfile,
1190 (void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
1191 first, el->el_map.key[first]);
1195 (void) fprintf(el->el_outfile,
1197 (void) fprintf(el->el_outfile, "el->el_map.alt[%d] == %d\n",
1198 first, el->el_map.alt[first]);
1201 EL_ABORT((el->el_errfile, "Error printing keys\n"));
1209 map_print_all_keys(EditLine *el)
1213 (void) fprintf(el->el_outfile, "Standard key bindings\n");
1216 if (el->el_map.key[prev] == el->el_map.key[i])
1218 map_print_some_keys(el, el->el_map.key, prev, i - 1);
1221 map_print_some_keys(el, el->el_map.key, prev, i - 1);
1223 (void) fprintf(el->el_outfile, "Alternative key bindings\n");
1226 if (el->el_map.alt[prev] == el->el_map.alt[i])
1228 map_print_some_keys(el, el->el_map.alt, prev, i - 1);
1231 map_print_some_keys(el, el->el_map.alt, prev, i - 1);
1233 (void) fprintf(el->el_outfile, "Multi-character bindings\n");
1234 keymacro_print(el, STR(""));
1235 (void) fprintf(el->el_outfile, "Arrow key bindings\n");
1236 terminal_print_arrow(el, STR(""));
1244 map_bind(EditLine *el, int argc, const Char **argv)
1260 map = el->el_map.key;
1267 map = el->el_map.alt;
1287 map_init_vi(el);
1291 map_init_emacs(el);
1295 ep = &el->el_map.help[el->el_map.nfunc];
1296 for (bp = el->el_map.help; bp < ep; bp++)
1297 (void) fprintf(el->el_outfile,
1302 (void) fprintf(el->el_errfile,
1310 map_print_all_keys(el);
1316 (void) fprintf(el->el_errfile,
1323 (void) terminal_clear_arrow(el, in);
1327 (void) keymacro_delete(el, in);
1329 (void) keymacro_delete(el, in);
1336 terminal_print_arrow(el, in);
1338 map_print_key(el, map, in);
1352 (void) fprintf(el->el_errfile,
1357 terminal_set_arrow(el, in, keymacro_map_str(el, out), ntype);
1359 keymacro_add(el, in, keymacro_map_str(el, out), ntype);
1364 if ((cmd = parse_cmd(el, argv[argc])) == -1) {
1365 (void) fprintf(el->el_errfile,
1371 terminal_set_arrow(el, in, keymacro_map_str(el, out), ntype);
1374 keymacro_add(el, in, keymacro_map_cmd(el, cmd), ntype);
1377 keymacro_clear(el, map, in);
1385 EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
1396 map_addfunc(EditLine *el, const Char *name, const Char *help, el_func_t func)
1399 size_t nf = (size_t)el->el_map.nfunc + 1;
1404 if ((p = el_realloc(el->el_map.func, nf *
1405 sizeof(*el->el_map.func))) == NULL)
1407 el->el_map.func = p;
1408 if ((p = el_realloc(el->el_map.help, nf * sizeof(*el->el_map.help)))
1411 el->el_map.help = p;
1413 nf = (size_t)el->el_map.nfunc;
1414 el->el_map.func[nf] = func;
1416 el->el_map.help[nf].name = name;
1417 el->el_map.help[nf].func = (int)nf;
1418 el->el_map.help[nf].description = help;
1419 el->el_map.nfunc++;