Lines Matching defs:el

51 #include "el.h"
901 map_init(EditLine *el)
909 EL_ABORT((el->el_errfile, "Emacs map incorrect\n"));
911 EL_ABORT((el->el_errfile, "Vi command map incorrect\n"));
913 EL_ABORT((el->el_errfile, "Vi insert map incorrect\n"));
916 el->el_map.alt = el_calloc(N_KEYS, sizeof(*el->el_map.alt));
917 if (el->el_map.alt == NULL)
919 el->el_map.key = el_calloc(N_KEYS, sizeof(*el->el_map.key));
920 if (el->el_map.key == NULL)
922 el->el_map.emacs = el_map_emacs;
923 el->el_map.vic = el_map_vi_command;
924 el->el_map.vii = el_map_vi_insert;
925 el->el_map.help = el_calloc(EL_NUM_FCNS, sizeof(*el->el_map.help));
926 if (el->el_map.help == NULL)
928 (void) memcpy(el->el_map.help, el_func_help,
929 sizeof(*el->el_map.help) * EL_NUM_FCNS);
930 el->el_map.func = el_calloc(EL_NUM_FCNS, sizeof(*el->el_map.func));
931 if (el->el_map.func == NULL)
933 memcpy(el->el_map.func, el_func, sizeof(*el->el_map.func)
935 el->el_map.nfunc = EL_NUM_FCNS;
938 map_init_vi(el);
940 map_init_emacs(el);
944 map_end(el);
953 map_end(EditLine *el)
956 el_free(el->el_map.alt);
957 el->el_map.alt = NULL;
958 el_free(el->el_map.key);
959 el->el_map.key = NULL;
960 el->el_map.emacs = NULL;
961 el->el_map.vic = NULL;
962 el->el_map.vii = NULL;
963 el_free(el->el_map.help);
964 el->el_map.help = NULL;
965 el_free(el->el_map.func);
966 el->el_map.func = NULL;
974 map_init_nls(EditLine *el)
978 el_action_t *map = el->el_map.key;
990 map_init_meta(EditLine *el)
994 el_action_t *map = el->el_map.key;
995 el_action_t *alt = el->el_map.alt;
1005 if (el->el_map.type == MAP_VI)
1020 keymacro_add(el, buf, keymacro_map_cmd(el, (int) map[i]), XK_CMD);
1031 map_init_vi(EditLine *el)
1034 el_action_t *key = el->el_map.key;
1035 el_action_t *alt = el->el_map.alt;
1036 const el_action_t *vii = el->el_map.vii;
1037 const el_action_t *vic = el->el_map.vic;
1039 el->el_map.type = MAP_VI;
1040 el->el_map.current = el->el_map.key;
1042 keymacro_reset(el);
1049 map_init_meta(el);
1050 map_init_nls(el);
1052 tty_bind_char(el, 1);
1053 terminal_bind_arrow(el);
1061 map_init_emacs(EditLine *el)
1065 el_action_t *key = el->el_map.key;
1066 el_action_t *alt = el->el_map.alt;
1067 const el_action_t *emacs = el->el_map.emacs;
1069 el->el_map.type = MAP_EMACS;
1070 el->el_map.current = el->el_map.key;
1071 keymacro_reset(el);
1078 map_init_meta(el);
1079 map_init_nls(el);
1084 keymacro_add(el, buf, keymacro_map_cmd(el, EM_EXCHANGE_MARK), XK_CMD);
1086 tty_bind_char(el, 1);
1087 terminal_bind_arrow(el);
1095 map_set_editor(EditLine *el, wchar_t *editor)
1099 map_init_emacs(el);
1103 map_init_vi(el);
1114 map_get_editor(EditLine *el, const wchar_t **editor)
1119 switch (el->el_map.type) {
1135 map_print_key(EditLine *el, el_action_t *map, const wchar_t *in)
1142 ep = &el->el_map.help[el->el_map.nfunc];
1143 for (bp = el->el_map.help; bp < ep; bp++)
1145 (void) fprintf(el->el_outfile,
1150 keymacro_print(el, in);
1158 map_print_some_keys(EditLine *el, el_action_t *map, wint_t first, wint_t last)
1172 (void) fprintf(el->el_outfile,
1177 ep = &el->el_map.help[el->el_map.nfunc];
1178 for (bp = el->el_map.help; bp < ep; bp++) {
1183 (void) fprintf(el->el_outfile, "%-15s-> %ls\n",
1190 (void) fprintf(el->el_outfile,
1198 if (map == el->el_map.key) {
1201 (void) fprintf(el->el_outfile,
1203 (void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
1204 first, el->el_map.key[first]);
1208 (void) fprintf(el->el_outfile,
1210 (void) fprintf(el->el_outfile, "el->el_map.alt[%d] == %d\n",
1211 first, el->el_map.alt[first]);
1214 EL_ABORT((el->el_errfile, "Error printing keys\n"));
1222 map_print_all_keys(EditLine *el)
1226 (void) fprintf(el->el_outfile, "Standard key bindings\n");
1229 if (el->el_map.key[prev] == el->el_map.key[i])
1231 map_print_some_keys(el, el->el_map.key, prev, i - 1);
1234 map_print_some_keys(el, el->el_map.key, prev, i - 1);
1236 (void) fprintf(el->el_outfile, "Alternative key bindings\n");
1239 if (el->el_map.alt[prev] == el->el_map.alt[i])
1241 map_print_some_keys(el, el->el_map.alt, prev, i - 1);
1244 map_print_some_keys(el, el->el_map.alt, prev, i - 1);
1246 (void) fprintf(el->el_outfile, "Multi-character bindings\n");
1247 keymacro_print(el, L"");
1248 (void) fprintf(el->el_outfile, "Arrow key bindings\n");
1249 terminal_print_arrow(el, L"");
1257 map_bind(EditLine *el, int argc, const wchar_t **argv)
1273 map = el->el_map.key;
1280 map = el->el_map.alt;
1295 map_init_vi(el);
1299 map_init_emacs(el);
1303 ep = &el->el_map.help[el->el_map.nfunc];
1304 for (bp = el->el_map.help; bp < ep; bp++)
1305 (void) fprintf(el->el_outfile,
1310 (void) fprintf(el->el_errfile,
1318 map_print_all_keys(el);
1324 (void) fprintf(el->el_errfile,
1331 (void) terminal_clear_arrow(el, in);
1335 (void) keymacro_delete(el, in);
1337 (void) keymacro_delete(el, in);
1344 terminal_print_arrow(el, in);
1346 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));
1402 map_addfunc(EditLine *el, const wchar_t *name, const wchar_t *help,
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++;