Home | History | Annotate | Download | only in src

Lines Matching refs:el

76 #include "el.h"
87 #define GoodStr(a) (el->el_terminal.t_str[a] != NULL && \
88 el->el_terminal.t_str[a][0] != '\0')
89 #define Str(a) el->el_terminal.t_str[a]
90 #define Val(a) el->el_terminal.t_val[a]
224 terminal_setflags(EditLine *el)
227 if (el->el_tty.t_tabs)
251 (void) fprintf(el->el_errfile,
253 (void) fprintf(el->el_errfile,
257 (void) fprintf(el->el_errfile, "no clear EOL capability.\n");
259 (void) fprintf(el->el_errfile, "no delete char capability.\n");
261 (void) fprintf(el->el_errfile, "no insert char capability.\n");
269 terminal_init(EditLine *el)
272 el->el_terminal.t_buf = el_malloc(TC_BUFSIZE *
273 sizeof(*el->el_terminal.t_buf));
274 if (el->el_terminal.t_buf == NULL)
276 el->el_terminal.t_cap = el_malloc(TC_BUFSIZE *
277 sizeof(*el->el_terminal.t_cap));
278 if (el->el_terminal.t_cap == NULL)
280 el->el_terminal.t_fkey = el_malloc(A_K_NKEYS *
281 sizeof(*el->el_terminal.t_fkey));
282 if (el->el_terminal.t_fkey == NULL)
284 el->el_terminal.t_loc = 0;
285 el->el_terminal.t_str = el_malloc(T_str *
286 sizeof(*el->el_terminal.t_str));
287 if (el->el_terminal.t_str == NULL)
289 (void) memset(el->el_terminal.t_str, 0, T_str *
290 sizeof(*el->el_terminal.t_str));
291 el->el_terminal.t_val = el_malloc(T_val *
292 sizeof(*el->el_terminal.t_val));
293 if (el->el_terminal.t_val == NULL)
295 (void) memset(el->el_terminal.t_val, 0, T_val *
296 sizeof(*el->el_terminal.t_val));
297 (void) terminal_set(el, NULL);
298 terminal_init_arrow(el);
306 terminal_end(EditLine *el)
309 el_free(el->el_terminal.t_buf);
310 el->el_terminal.t_buf = NULL;
311 el_free(el->el_terminal.t_cap);
312 el->el_terminal.t_cap = NULL;
313 el->el_terminal.t_loc = 0;
314 el_free(el->el_terminal.t_str);
315 el->el_terminal.t_str = NULL;
316 el_free(el->el_terminal.t_val);
317 el->el_terminal.t_val = NULL;
318 el_free(el->el_terminal.t_fkey);
319 el->el_terminal.t_fkey = NULL;
320 terminal_free_display(el);
328 terminal_alloc(EditLine *el, const struct termcapstr *t, const char *cap)
332 char **tlist = el->el_terminal.t_str;
355 if (el->el_terminal.t_loc + 3 < TC_BUFSIZE) {
357 (void) strcpy(*str = &el->el_terminal.t_buf[
358 el->el_terminal.t_loc], cap);
359 el->el_terminal.t_loc += clen + 1; /* one for \0 */
375 memcpy(el->el_terminal.t_buf, termbuf, TC_BUFSIZE);
376 el->el_terminal.t_loc = tlen;
377 if (el->el_terminal.t_loc + 3 >= TC_BUFSIZE) {
378 (void) fprintf(el->el_errfile,
383 (void) strcpy(*str = &el->el_terminal.t_buf[el->el_terminal.t_loc],
385 el->el_terminal.t_loc += (size_t)clen + 1; /* one for \0 */
394 terminal_rebuffer_display(EditLine *el)
396 coord_t *c = &el->el_terminal.t_size;
398 terminal_free_display(el);
403 if (terminal_alloc_display(el) == -1)
413 terminal_alloc_display(EditLine *el)
417 coord_t *c = &el->el_terminal.t_size;
432 el->el_display = b;
447 el->el_vdisplay = b;
456 terminal_free_display(EditLine *el)
461 b = el->el_display;
462 el->el_display = NULL;
468 b = el->el_vdisplay;
469 el->el_vdisplay = NULL;
483 terminal_move_to_line(EditLine *el, int where)
487 if (where == el->el_cursor.v)
490 if (where > el->el_terminal.t_size.v) {
492 (void) fprintf(el->el_errfile,
498 if ((del = where - el->el_cursor.v) > 0) {
501 el->el_display[el->el_cursor.v][0] != '\0') {
503 (el->el_terminal.t_size.h - 1);
506 el->el_display[el->el_cursor.v][h] ==
512 terminal_move_to_char(el, (int)h);
513 terminal_overwrite(el, &el->el_display
514 [el->el_cursor.v][el->el_cursor.h],
515 (size_t)(el->el_terminal.t_size.h -
516 el->el_cursor.h));
521 terminal_tputs(el, tgoto(Str(T_DO), del,
526 terminal__putc(el, '\n');
528 el->el_cursor.h = 0;
534 terminal_tputs(el, tgoto(Str(T_UP), -del, -del), -del);
538 terminal_tputs(el, Str(T_up), 1);
541 el->el_cursor.v = where;/* now where is here */
549 terminal_move_to_char(EditLine *el, int where)
554 if (where == el->el_cursor.h)
557 if (where > el->el_terminal.t_size.h) {
559 (void) fprintf(el->el_errfile,
566 terminal__putc(el, '\r'); /* do a CR */
567 el->el_cursor.h = 0;
570 del = where - el->el_cursor.h;
574 terminal_tputs(el, tgoto(Str(T_ch), where, where), where);
578 terminal_tputs(el, tgoto(Str(T_RI), del, del),
583 if ((el->el_cursor.h & 0370) !=
586 && (el->el_display[
587 el->el_cursor.v][where & 0370] !=
593 (el->el_cursor.h & 0370);
596 terminal__putc(el,
599 el->el_cursor.h = where & ~0x7;
608 * el->el_cursor.h!!!
610 terminal_overwrite(el, &el->el_display[
611 el->el_cursor.v][el->el_cursor.h],
612 (size_t)(where - el->el_cursor.h));
617 terminal_tputs(el, tgoto(Str(T_LE), -del, -del),
629 terminal__putc(el, '\r');/* do a CR */
630 el->el_cursor.h = 0;
634 terminal__putc(el, '\b');
638 el->el_cursor.h = where; /* now where is here */
647 terminal_overwrite(EditLine *el, const Char *cp, size_t n)
652 if (n > (size_t)el->el_terminal.t_size.h) {
654 (void) fprintf(el->el_errfile,
662 terminal__putc(el, *cp++);
663 el->el_cursor.h++;
666 if (el->el_cursor.h >= el->el_terminal.t_size.h) { /* wrap? */
668 el->el_cursor.h = 0;
669 el->el_cursor.v++;
674 if ((c = el->el_display[el->el_cursor.v]
675 [el->el_cursor.h]) != '\0') {
676 terminal_overwrite(el, &c, (size_t)1);
678 while (el->el_display[el->el_cursor.v]
679 [el->el_cursor.h] == MB_FILL_CHAR)
680 el->el_cursor.h++;
683 terminal__putc(el, ' ');
684 el->el_cursor.h = 1;
688 el->el_cursor.h = el->el_terminal.t_size.h - 1;
697 terminal_deletechars(EditLine *el, int num)
704 (void) fprintf(el->el_errfile, " ERROR: cannot delete \n");
708 if (num > el->el_terminal.t_size.h) {
710 (void) fprintf(el->el_errfile,
718 terminal_tputs(el, tgoto(Str(T_DC), num, num), num);
722 terminal_tputs(el, Str(T_dm), 1);
726 terminal_tputs(el, Str(T_dc), 1);
729 terminal_tputs(el, Str(T_ed), 1);
739 terminal_insertwrite(EditLine *el, Char *cp, int num)
745 (void) fprintf(el->el_errfile, " ERROR: cannot insert \n");
749 if (num > el->el_terminal.t_size.h) {
751 (void) fprintf(el->el_errfile,
759 terminal_tputs(el, tgoto(Str(T_IC), num, num), num);
760 terminal_overwrite(el, cp, (size_t)num);
765 terminal_tputs(el, Str(T_im), 1);
767 el->el_cursor.h += num;
769 terminal__putc(el, *cp++);
773 terminal_tputs(el, Str(T_ip), 1);
775 terminal_tputs(el, Str(T_ei), 1);
780 terminal_tputs(el, Str(T_ic), 1);
782 terminal__putc(el, *cp++);
784 el->el_cursor.h++;
787 terminal_tputs(el, Str(T_ip), 1);
798 terminal_clear_EOL(EditLine *el, int num)
803 terminal_tputs(el, Str(T_ce), 1);
806 terminal__putc(el, ' ');
807 el->el_cursor.h += num; /* have written num spaces */
816 terminal_clear_screen(EditLine *el)
821 terminal_tputs(el, Str(T_cl), Val(T_li));
823 terminal_tputs(el, Str(T_ho), Val(T_li)); /* home */
825 terminal_tputs(el, Str(T_cd), Val(T_li));
827 terminal__putc(el, '\r');
828 terminal__putc(el, '\n');
837 terminal_beep(EditLine *el)
841 terminal_tputs(el, Str(T_bl), 1);
843 terminal__putc(el, '\007'); /* an ASCII bell; ^G */
848 terminal_get(EditLine *el, const char **term)
850 *term = el->el_terminal.t_name;
858 terminal_set(EditLine *el, const char *term)
881 el->el_flags |= EDIT_DISABLED;
883 (void) memset(el->el_terminal.t_cap, 0, TC_BUFSIZE);
885 i = tgetent(el->el_terminal.t_cap, term);
889 (void) fprintf(el->el_errfile,
892 (void) fprintf(el->el_errfile,
894 (void) fprintf(el->el_errfile,
900 terminal_alloc(el, t, NULL);
916 terminal_alloc(el, t, tgetstr(strchr(t->name, *t->name),
926 el->el_terminal.t_size.v = Val(T_co);
927 el->el_terminal.t_size.h = Val(T_li);
929 terminal_setflags(el);
932 (void) terminal_get_size(el, &lins, &cols);
933 if (terminal_change_size(el, lins, cols) == -1)
936 terminal_bind_arrow(el);
937 el->el_terminal.t_name = term;
947 terminal_get_size(EditLine *el, int *lins, int *cols)
956 if (ioctl(el->el_infd, TIOCGWINSZ, &ws) != -1) {
967 if (ioctl(el->el_infd, TIOCGSIZE, &ts) != -1) {
983 terminal_change_size(EditLine *el, int lins, int cols)
992 if (terminal_rebuffer_display(el) == -1)
994 re_clear_display(el);
1003 terminal_init_arrow(EditLine *el)
1005 funckey_t *arrow = el->el_terminal.t_fkey;
1048 terminal_reset_arrow(EditLine *el)
1050 funckey_t *arrow = el->el_terminal.t_fkey;
1064 keymacro_add(el, strA, &arrow[A_K_UP].fun, arrow[A_K_UP].type);
1065 keymacro_add(el, strB, &arrow[A_K_DN].fun, arrow[A_K_DN].type);
1066 keymacro_add(el, strC, &arrow[A_K_RT].fun, arrow[A_K_RT].type);
1067 keymacro_add(el, strD, &arrow[A_K_LT].fun, arrow[A_K_LT].type);
1068 keymacro_add(el, strH, &arrow[A_K_HO].fun, arrow[A_K_HO].type);
1069 keymacro_add(el, strF, &arrow[A_K_EN].fun, arrow[A_K_EN].type);
1070 keymacro_add(el, stOA, &arrow[A_K_UP].fun, arrow[A_K_UP].type);
1071 keymacro_add(el, stOB, &arrow[A_K_DN].fun, arrow[A_K_DN].type);
1072 keymacro_add(el, stOC, &arrow[A_K_RT].fun, arrow[A_K_RT].type);
1073 keymacro_add(el, stOD, &arrow[A_K_LT].fun, arrow[A_K_LT].type);
1074 keymacro_add(el, stOH, &arrow[A_K_HO].fun, arrow[A_K_HO].type);
1075 keymacro_add(el, stOF, &arrow[A_K_EN].fun, arrow[A_K_EN].type);
1077 if (el->el_map.type != MAP_VI)
1079 keymacro_add(el, &strA[1], &arrow[A_K_UP].fun, arrow[A_K_UP].type);
1080 keymacro_add(el, &strB[1], &arrow[A_K_DN].fun, arrow[A_K_DN].type);
1081 keymacro_add(el, &strC[1], &arrow[A_K_RT].fun, arrow[A_K_RT].type);
1082 keymacro_add(el, &strD[1], &arrow[A_K_LT].fun, arrow[A_K_LT].type);
1083 keymacro_add(el, &strH[1], &arrow[A_K_HO].fun, arrow[A_K_HO].type);
1084 keymacro_add(el, &strF[1], &arrow[A_K_EN].fun, arrow[A_K_EN].type);
1085 keymacro_add(el, &stOA[1], &arrow[A_K_UP].fun, arrow[A_K_UP].type);
1086 keymacro_add(el, &stOB[1], &arrow[A_K_DN].fun, arrow[A_K_DN].type);
1087 keymacro_add(el, &stOC[1], &arrow[A_K_RT].fun, arrow[A_K_RT].type);
1088 keymacro_add(el, &stOD[1], &arrow[A_K_LT].fun, arrow[A_K_LT].type);
1089 keymacro_add(el, &stOH[1], &arrow[A_K_HO].fun, arrow[A_K_HO].type);
1090 keymacro_add(el, &stOF[1], &arrow[A_K_EN].fun, arrow[A_K_EN].type);
1098 terminal_set_arrow(EditLine *el, const Char *name, keymacro_value_t *fun,
1101 funckey_t *arrow = el->el_terminal.t_fkey;
1118 terminal_clear_arrow(EditLine *el, const Char *name)
1120 funckey_t *arrow = el->el_terminal.t_fkey;
1136 terminal_print_arrow(EditLine *el, const Char *name)
1139 funckey_t *arrow = el->el_terminal.t_fkey;
1144 keymacro_kprint(el, arrow[i].name,
1153 terminal_bind_arrow(EditLine *el)
1159 funckey_t *arrow = el->el_terminal.t_fkey;
1162 if (el->el_terminal.t_buf == NULL || el->el_map.key == NULL)
1165 map = el->el_map.type == MAP_VI ? el->el_map.alt : el->el_map.key;
1166 dmap = el->el_map.type == MAP_VI ? el->el_map.vic : el->el_map.emacs;
1168 terminal_reset_arrow(el);
1175 p = el->el_terminal.t_str[arrow[i].key];
1195 keymacro_clear(el, map, px);
1199 keymacro_add(el, px, &arrow[i].fun,
1203 keymacro_clear(el, map, px);
1207 keymacro_add(el, px, &arrow[i].fun,
1226 terminal_tputs(EditLine *el, const char *cap, int affcnt)
1231 terminal_outfile = el->el_outfile;
1242 terminal__putc(EditLine *el, Int c)
1252 return fputs(buf, el->el_outfile);
1259 terminal__flush(EditLine *el)
1262 (void) fflush(el->el_outfile);
1269 terminal_writec(EditLine *el, Int c)
1276 terminal_overwrite(el, visbuf, (size_t)vcnt);
1277 terminal__flush(el);
1286 terminal_telltc(EditLine *el, int argc __attribute__((__unused__)),
1292 (void) fprintf(el->el_outfile, "\n\tYour terminal has the\n");
1293 (void) fprintf(el->el_outfile, "\tfollowing characteristics:\n\n");
1294 (void) fprintf(el->el_outfile, "\tIt has %d columns and %d lines\n",
1296 el->el_outfile,
1298 (void) fprintf(el->el_outfile,
1300 (void) fprintf(el->el_outfile, "\tIt %s automatic margins\n",
1303 (void) fprintf(el->el_outfile, "\tIt %s magic margins\n",
1306 for (t = tstr, ts = el->el_terminal.t_str; t->name != NULL; t++, ts++) {
1310 ct_decode_string(*ts, &el->el_scratch)),
1311 &el->el_scratch);
1315 (void) fprintf(el->el_outfile, "\t%25s (%s) == %s\n",
1318 (void) fputc('\n', el->el_outfile);
1328 terminal_settc(EditLine *el, int argc __attribute__((__unused__)),
1338 strncpy(what, ct_encode_string(argv[1], &el->el_scratch), sizeof(what));
1340 strncpy(how, ct_encode_string(argv[2], &el->el_scratch), sizeof(how));
1351 terminal_alloc(el, ts, how);
1352 terminal_setflags(el);
1368 el->el_terminal.t_val[tv - tval] = 1;
1370 el->el_terminal.t_val[tv - tval] = 0;
1372 (void) fprintf(el->el_errfile,
1376 terminal_setflags(el);
1377 if (terminal_change_size(el, Val(T_li), Val(T_co)) == -1)
1386 (void) fprintf(el->el_errfile,
1390 el->el_terminal.t_val[tv - tval] = (int) i;
1391 el->el_terminal.t_size.v = Val(T_co);
1392 el->el_terminal.t_size.h = Val(T_li);
1394 if (terminal_change_size(el, Val(T_li), Val(T_co))
1407 terminal_gettc(EditLine *el, int argc __attribute__((__unused__)), char **argv)
1428 *(char **)how = el->el_terminal.t_str[ts - tstr];
1445 if (el->el_terminal.t_val[tv - tval])
1451 *(int *)how = el->el_terminal.t_val[tv - tval];
1461 terminal_echotc(EditLine *el, int argc __attribute__((__unused__)),
1497 (void) fprintf(el->el_outfile, fmts, EL_CAN_TAB ? "yes" : "no");
1500 (void) fprintf(el->el_outfile, fmts, Val(T_km) ? "yes" : "no");
1503 (void) fprintf(el->el_outfile, fmts, EL_HAS_MAGIC_MARGINS ?
1507 (void) fprintf(el->el_outfile, fmts, EL_HAS_AUTO_MARGINS ?
1511 (void) fprintf(el->el_outfile, fmtd, (int)el->el_tty.t_speed);
1515 (void) fprintf(el->el_outfile, fmtd, Val(T_li));
1518 (void) fprintf(el->el_outfile, fmtd, Val(T_co));
1527 ct_encode_string(*argv, &el->el_scratch)) == 0) {
1528 scap = el->el_terminal.t_str[t - tstr];
1533 scap = tgetstr(ct_encode_string((Char*)*argv, &el->el_scratch), &area);
1537 (void) fprintf(el->el_errfile,
1568 (void) fprintf(el->el_errfile,
1580 (void) fprintf(el->el_errfile,
1585 terminal_tputs(el, scap, 1);
1591 (void) fprintf(el->el_errfile,
1599 (void) fprintf(el->el_errfile,
1608 (void) fprintf(el->el_errfile,
1613 terminal_tputs(el, tgoto(scap, arg_cols, arg_rows), 1);
1618 (void) fprintf(el->el_errfile,
1626 (void) fprintf(el->el_errfile,
1633 (void) fprintf(el->el_errfile,
1642 (void) fprintf(el->el_errfile,
1649 (void) fprintf(el->el_errfile,
1657 (void) fprintf(el->el_errfile,
1664 (void) fprintf(el->el_errfile,
1669 terminal_tputs(el, tgoto(scap, arg_cols, arg_rows), arg_rows);