Lines Matching refs:el

53 #include "el.h"
898 map_init(EditLine *el)
906 EL_ABORT((el->errfile, "Emacs map incorrect\n"));
908 EL_ABORT((el->errfile, "Vi command map incorrect\n"));
910 EL_ABORT((el->errfile, "Vi insert map incorrect\n"));
913 el->el_map.alt = el_malloc(sizeof(*el->el_map.alt) * N_KEYS);
914 if (el->el_map.alt == NULL)
916 el->el_map.key = el_malloc(sizeof(*el->el_map.key) * N_KEYS);
917 if (el->el_map.key == NULL)
919 el->el_map.emacs = el_map_emacs;
920 el->el_map.vic = el_map_vi_command;
921 el->el_map.vii = el_map_vi_insert;
922 el->el_map.help = el_malloc(sizeof(*el->el_map.help) * EL_NUM_FCNS);
923 if (el->el_map.help == NULL)
925 (void) memcpy(el->el_map.help, help__get(),
926 sizeof(*el->el_map.help) * EL_NUM_FCNS);
927 el->el_map.func = el_malloc(sizeof(*el->el_map.func) * EL_NUM_FCNS);
928 if (el->el_map.func == NULL)
930 memcpy(el->el_map.func, func__get(), sizeof(*el->el_map.func)
932 el->el_map.nfunc = EL_NUM_FCNS;
935 map_init_vi(el);
937 map_init_emacs(el);
947 map_end(EditLine *el)
950 el_free(el->el_map.alt);
951 el->el_map.alt = NULL;
952 el_free(el->el_map.key);
953 el->el_map.key = NULL;
954 el->el_map.emacs = NULL;
955 el->el_map.vic = NULL;
956 el->el_map.vii = NULL;
957 el_free(el->el_map.help);
958 el->el_map.help = NULL;
959 el_free(el->el_map.func);
960 el->el_map.func = NULL;
968 map_init_nls(EditLine *el)
972 el_action_t *map = el->el_map.key;
984 map_init_meta(EditLine *el)
988 el_action_t *map = el->el_map.key;
989 el_action_t *alt = el->el_map.alt;
999 if (el->el_map.type == MAP_VI)
1014 keymacro_add(el, buf, keymacro_map_cmd(el, (int) map[i]), XK_CMD);
1025 map_init_vi(EditLine *el)
1028 el_action_t *key = el->el_map.key;
1029 el_action_t *alt = el->el_map.alt;
1030 const el_action_t *vii = el->el_map.vii;
1031 const el_action_t *vic = el->el_map.vic;
1033 el->el_map.type = MAP_VI;
1034 el->el_map.current = el->el_map.key;
1036 keymacro_reset(el);
1043 map_init_meta(el);
1044 map_init_nls(el);
1046 tty_bind_char(el, 1);
1047 terminal_bind_arrow(el);
1055 map_init_emacs(EditLine *el)
1059 el_action_t *key = el->el_map.key;
1060 el_action_t *alt = el->el_map.alt;
1061 const el_action_t *emacs = el->el_map.emacs;
1063 el->el_map.type = MAP_EMACS;
1064 el->el_map.current = el->el_map.key;
1065 keymacro_reset(el);
1072 map_init_meta(el);
1073 map_init_nls(el);
1078 keymacro_add(el, buf, keymacro_map_cmd(el, EM_EXCHANGE_MARK), XK_CMD);
1080 tty_bind_char(el, 1);
1081 terminal_bind_arrow(el);
1089 map_set_editor(EditLine *el, Char *editor)
1093 map_init_emacs(el);
1097 map_init_vi(el);
1108 map_get_editor(EditLine *el, const Char **editor)
1113 switch (el->el_map.type) {
1129 map_print_key(EditLine *el, el_action_t *map, const Char *in)
1136 ep = &el->el_map.help[el->el_map.nfunc];
1137 for (bp = el->el_map.help; bp < ep; bp++)
1139 (void) fprintf(el->el_outfile,
1144 keymacro_print(el, in);
1152 map_print_some_keys(EditLine *el, el_action_t *map, wint_t first, wint_t last)
1166 (void) fprintf(el->el_outfile,
1171 ep = &el->el_map.help[el->el_map.nfunc];
1172 for (bp = el->el_map.help; bp < ep; bp++) {
1177 (void) fprintf(el->el_outfile, "%-15s-> " FSTR "\n",
1184 (void) fprintf(el->el_outfile,
1192 if (map == el->el_map.key) {
1195 (void) fprintf(el->el_outfile,
1197 (void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
1198 first, el->el_map.key[first]);
1202 (void) fprintf(el->el_outfile,
1204 (void) fprintf(el->el_outfile, "el->el_map.alt[%d] == %d\n",
1205 first, el->el_map.alt[first]);
1208 EL_ABORT((el->el_errfile, "Error printing keys\n"));
1216 map_print_all_keys(EditLine *el)
1220 (void) fprintf(el->el_outfile, "Standard key bindings\n");
1223 if (el->el_map.key[prev] == el->el_map.key[i])
1225 map_print_some_keys(el, el->el_map.key, prev, i - 1);
1228 map_print_some_keys(el, el->el_map.key, prev, i - 1);
1230 (void) fprintf(el->el_outfile, "Alternative key bindings\n");
1233 if (el->el_map.alt[prev] == el->el_map.alt[i])
1235 map_print_some_keys(el, el->el_map.alt, prev, i - 1);
1238 map_print_some_keys(el, el->el_map.alt, prev, i - 1);
1240 (void) fprintf(el->el_outfile, "Multi-character bindings\n");
1241 keymacro_print(el, STR(""));
1242 (void) fprintf(el->el_outfile, "Arrow key bindings\n");
1243 terminal_print_arrow(el, STR(""));
1251 map_bind(EditLine *el, int argc, const Char **argv)
1267 map = el->el_map.key;
1274 map = el->el_map.alt;
1294 map_init_vi(el);
1298 map_init_emacs(el);
1302 ep = &el->el_map.help[el->el_map.nfunc];
1303 for (bp = el->el_map.help; bp < ep; bp++)
1304 (void) fprintf(el->el_outfile,
1309 (void) fprintf(el->el_errfile,
1317 map_print_all_keys(el);
1323 (void) fprintf(el->el_errfile,
1330 (void) terminal_clear_arrow(el, in);
1334 (void) keymacro_delete(el, in);
1336 (void) keymacro_delete(el, in);
1343 terminal_print_arrow(el, in);
1345 map_print_key(el, map, in);
1359 (void) fprintf(el->el_errfile,
1364 terminal_set_arrow(el, in, keymacro_map_str(el, out), ntype);
1366 keymacro_add(el, in, keymacro_map_str(el, out), ntype);
1371 if ((cmd = parse_cmd(el, argv[argc])) == -1) {
1372 (void) fprintf(el->el_errfile,
1378 terminal_set_arrow(el, in, keymacro_map_cmd(el, cmd), ntype);
1381 keymacro_add(el, in, keymacro_map_cmd(el, cmd), ntype);
1384 keymacro_clear(el, map, in);
1392 EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
1403 map_addfunc(EditLine *el, const Char *name, const Char *help, el_func_t func)
1406 size_t nf = el->el_map.nfunc + 1;
1411 if ((p = el_realloc(el->el_map.func, nf *
1412 sizeof(*el->el_map.func))) == NULL)
1414 el->el_map.func = p;
1415 if ((p = el_realloc(el->el_map.help, nf * sizeof(*el->el_map.help)))
1418 el->el_map.help = p;
1420 nf = (size_t)el->el_map.nfunc;
1421 el->el_map.func[nf] = func;
1423 el->el_map.help[nf].name = name;
1424 el->el_map.help[nf].func = (int)nf;
1425 el->el_map.help[nf].description = help;
1426 el->el_map.nfunc++;