Lines Matching refs:el
84 #include "el.h"
96 #define GoodStr(a) (el->el_terminal.t_str[a] != NULL && \
97 el->el_terminal.t_str[a][0] != '\0')
98 #define Str(a) el->el_terminal.t_str[a]
99 #define Val(a) el->el_terminal.t_val[a]
233 terminal_setflags(EditLine *el)
236 if (el->el_tty.t_tabs)
260 (void) fprintf(el->el_errfile,
262 (void) fprintf(el->el_errfile,
266 (void) fprintf(el->el_errfile, "no clear EOL capability.\n");
268 (void) fprintf(el->el_errfile, "no delete char capability.\n");
270 (void) fprintf(el->el_errfile, "no insert char capability.\n");
278 terminal_init(EditLine *el)
281 el->el_terminal.t_buf = el_calloc(TC_BUFSIZE,
282 sizeof(*el->el_terminal.t_buf));
283 if (el->el_terminal.t_buf == NULL)
285 el->el_terminal.t_cap = el_calloc(TC_BUFSIZE,
286 sizeof(*el->el_terminal.t_cap));
287 if (el->el_terminal.t_cap == NULL)
289 el->el_terminal.t_fkey = el_calloc(A_K_NKEYS,
290 sizeof(*el->el_terminal.t_fkey));
291 if (el->el_terminal.t_fkey == NULL)
293 el->el_terminal.t_loc = 0;
294 el->el_terminal.t_str = el_calloc(T_str,
295 sizeof(*el->el_terminal.t_str));
296 if (el->el_terminal.t_str == NULL)
298 el->el_terminal.t_val = el_calloc(T_val,
299 sizeof(*el->el_terminal.t_val));
300 if (el->el_terminal.t_val == NULL)
302 (void) terminal_set(el, NULL);
303 terminal_init_arrow(el);
306 terminal_end(el);
314 terminal_end(EditLine *el)
317 el_free(el->el_terminal.t_buf);
318 el->el_terminal.t_buf = NULL;
319 el_free(el->el_terminal.t_cap);
320 el->el_terminal.t_cap = NULL;
321 el->el_terminal.t_loc = 0;
322 el_free(el->el_terminal.t_str);
323 el->el_terminal.t_str = NULL;
324 el_free(el->el_terminal.t_val);
325 el->el_terminal.t_val = NULL;
326 el_free(el->el_terminal.t_fkey);
327 el->el_terminal.t_fkey = NULL;
328 terminal_free_display(el);
336 terminal_alloc(EditLine *el, const struct termcapstr *t, const char *cap)
340 char **tlist = el->el_terminal.t_str;
363 if (el->el_terminal.t_loc + 3 < TC_BUFSIZE) {
365 (void) strcpy(*str = &el->el_terminal.t_buf[
366 el->el_terminal.t_loc], cap);
367 el->el_terminal.t_loc += clen + 1; /* one for \0 */
383 memcpy(el->el_terminal.t_buf, termbuf, TC_BUFSIZE);
384 el->el_terminal.t_loc = tlen;
385 if (el->el_terminal.t_loc + 3 >= TC_BUFSIZE) {
386 (void) fprintf(el->el_errfile,
391 (void) strcpy(*str = &el->el_terminal.t_buf[el->el_terminal.t_loc],
393 el->el_terminal.t_loc += (size_t)clen + 1; /* one for \0 */
402 terminal_rebuffer_display(EditLine *el)
404 coord_t *c = &el->el_terminal.t_size;
406 terminal_free_display(el);
411 if (terminal_alloc_display(el) == -1)
417 terminal_alloc_buffer(EditLine *el)
420 coord_t *c = &el->el_terminal.t_size;
460 terminal_alloc_display(EditLine *el)
462 el->el_display = terminal_alloc_buffer(el);
463 if (el->el_display == NULL)
465 el->el_vdisplay = terminal_alloc_buffer(el);
466 if (el->el_vdisplay == NULL)
470 terminal_free_display(el);
479 terminal_free_display(EditLine *el)
481 terminal_free_buffer(&el->el_display);
482 terminal_free_buffer(&el->el_vdisplay);
491 terminal_move_to_line(EditLine *el, int where)
495 if (where == el->el_cursor.v)
498 if (where >= el->el_terminal.t_size.v) {
500 (void) fprintf(el->el_errfile,
505 if ((del = where - el->el_cursor.v) > 0) {
511 terminal__putc(el, '\n');
513 el->el_cursor.h = 0;
516 terminal_tputs(el, tgoto(Str(T_UP), -del, -del), -del);
520 terminal_tputs(el, Str(T_up), 1);
523 el->el_cursor.v = where;/* now where is here */
531 terminal_move_to_char(EditLine *el, int where)
536 if (where == el->el_cursor.h)
539 if (where > el->el_terminal.t_size.h) {
541 (void) fprintf(el->el_errfile,
547 terminal__putc(el, '\r'); /* do a CR */
548 el->el_cursor.h = 0;
551 del = where - el->el_cursor.h;
555 terminal_tputs(el, tgoto(Str(T_ch), where, where), where);
559 terminal_tputs(el, tgoto(Str(T_RI), del, del),
564 if ((el->el_cursor.h & 0370) !=
566 && (el->el_display[
567 el->el_cursor.v][where & 0370] !=
572 (el->el_cursor.h & 0370);
575 terminal__putc(el,
578 el->el_cursor.h = where & ~0x7;
587 * el->el_cursor.h!!!
589 terminal_overwrite(el,
590 (wchar_t *)&el->el_display[
591 el->el_cursor.v][el->el_cursor.h],
592 (size_t)(where - el->el_cursor.h));
597 terminal_tputs(el, tgoto(Str(T_LE), -del, -del),
609 terminal__putc(el, '\r');/* do a CR */
610 el->el_cursor.h = 0;
614 terminal__putc(el, '\b');
618 el->el_cursor.h = where; /* now where is here */
627 terminal_overwrite(EditLine *el, const wchar_t *cp, size_t n)
632 if (n > (size_t)el->el_terminal.t_size.h) {
634 (void) fprintf(el->el_errfile,
642 el, *cp++);
643 el->el_cursor.h++;
646 if (el->el_cursor.h >= el->el_terminal.t_size.h) { /* wrap? */
648 el->el_cursor.h = 0;
649 if (el->el_cursor.v + 1 < el->el_terminal.t_size.v)
650 el->el_cursor.v++;
655 if ((c = el->el_display[el->el_cursor.v]
656 [el->el_cursor.h]) != '\0') {
657 terminal_overwrite(el, &c, (size_t)1);
658 while (el->el_display[el->el_cursor.v]
659 [el->el_cursor.h] == MB_FILL_CHAR)
660 el->el_cursor.h++;
662 terminal__putc(el, ' ');
663 el->el_cursor.h = 1;
667 el->el_cursor.h = el->el_terminal.t_size.h - 1;
676 terminal_deletechars(EditLine *el, int num)
683 (void) fprintf(el->el_errfile, " ERROR: cannot delete \n");
687 if (num > el->el_terminal.t_size.h) {
689 (void) fprintf(el->el_errfile,
697 terminal_tputs(el, tgoto(Str(T_DC), num, num), num);
701 terminal_tputs(el, Str(T_dm), 1);
705 terminal_tputs(el, Str(T_dc), 1);
708 terminal_tputs(el, Str(T_ed), 1);
718 terminal_insertwrite(EditLine *el, wchar_t *cp, int num)
724 (void) fprintf(el->el_errfile, " ERROR: cannot insert \n");
728 if (num > el->el_terminal.t_size.h) {
730 (void) fprintf(el->el_errfile,
738 terminal_tputs(el, tgoto(Str(T_IC), num, num), num);
739 terminal_overwrite(el, cp, (size_t)num);
744 terminal_tputs(el, Str(T_im), 1);
746 el->el_cursor.h += num;
748 terminal__putc(el, *cp++);
752 terminal_tputs(el, Str(T_ip), 1);
754 terminal_tputs(el, Str(T_ei), 1);
759 terminal_tputs(el, Str(T_ic), 1);
761 terminal__putc(el, *cp++);
763 el->el_cursor.h++;
766 terminal_tputs(el, Str(T_ip), 1);
777 terminal_clear_EOL(EditLine *el, int num)
782 terminal_tputs(el, Str(T_ce), 1);
785 terminal__putc(el, ' ');
786 el->el_cursor.h += num; /* have written num spaces */
795 terminal_clear_screen(EditLine *el)
800 terminal_tputs(el, Str(T_cl), Val(T_li));
802 terminal_tputs(el, Str(T_ho), Val(T_li)); /* home */
804 terminal_tputs(el, Str(T_cd), Val(T_li));
806 terminal__putc(el, '\r');
807 terminal__putc(el, '\n');
816 terminal_beep(EditLine *el)
820 terminal_tputs(el, Str(T_bl), 1);
822 terminal__putc(el, '\007'); /* an ASCII bell; ^G */
827 terminal_get(EditLine *el, const char **term)
829 *term = el->el_terminal.t_name;
837 terminal_set(EditLine *el, const char *term)
860 el->el_flags |= EDIT_DISABLED;
862 (void) memset(el->el_terminal.t_cap, 0, TC_BUFSIZE);
864 i = tgetent(el->el_terminal.t_cap, term);
868 (void) fprintf(el->el_errfile,
871 (void) fprintf(el->el_errfile,
873 (void) fprintf(el->el_errfile,
879 terminal_alloc(el, t, NULL);
895 terminal_alloc(el, t, tgetstr(strchr(t->name, *t->name),
905 el->el_terminal.t_size.v = Val(T_co);
906 el->el_terminal.t_size.h = Val(T_li);
908 terminal_setflags(el);
911 (void) terminal_get_size(el, &lins, &cols);
912 if (terminal_change_size(el, lins, cols) == -1)
915 terminal_bind_arrow(el);
916 el->el_terminal.t_name = term;
926 terminal_get_size(EditLine *el, int *lins, int *cols)
935 if (ioctl(el->el_infd, TIOCGWINSZ, &ws) != -1) {
946 if (ioctl(el->el_infd, TIOCGSIZE, &ts) != -1) {
962 terminal_change_size(EditLine *el, int lins, int cols)
964 coord_t cur = el->el_cursor;
972 if (terminal_rebuffer_display(el) == -1)
974 re_clear_display(el);
975 el->el_cursor = cur;
984 terminal_init_arrow(EditLine *el)
986 funckey_t *arrow = el->el_terminal.t_fkey;
1029 terminal_reset_arrow(EditLine *el)
1031 funckey_t *arrow = el->el_terminal.t_fkey;
1045 keymacro_add(el, strA, &arrow[A_K_UP].fun, arrow[A_K_UP].type);
1046 keymacro_add(el, strB, &arrow[A_K_DN].fun, arrow[A_K_DN].type);
1047 keymacro_add(el, strC, &arrow[A_K_RT].fun, arrow[A_K_RT].type);
1048 keymacro_add(el, strD, &arrow[A_K_LT].fun, arrow[A_K_LT].type);
1049 keymacro_add(el, strH, &arrow[A_K_HO].fun, arrow[A_K_HO].type);
1050 keymacro_add(el, strF, &arrow[A_K_EN].fun, arrow[A_K_EN].type);
1051 keymacro_add(el, stOA, &arrow[A_K_UP].fun, arrow[A_K_UP].type);
1052 keymacro_add(el, stOB, &arrow[A_K_DN].fun, arrow[A_K_DN].type);
1053 keymacro_add(el, stOC, &arrow[A_K_RT].fun, arrow[A_K_RT].type);
1054 keymacro_add(el, stOD, &arrow[A_K_LT].fun, arrow[A_K_LT].type);
1055 keymacro_add(el, stOH, &arrow[A_K_HO].fun, arrow[A_K_HO].type);
1056 keymacro_add(el, stOF, &arrow[A_K_EN].fun, arrow[A_K_EN].type);
1058 if (el->el_map.type != MAP_VI)
1060 keymacro_add(el, &strA[1], &arrow[A_K_UP].fun, arrow[A_K_UP].type);
1061 keymacro_add(el, &strB[1], &arrow[A_K_DN].fun, arrow[A_K_DN].type);
1062 keymacro_add(el, &strC[1], &arrow[A_K_RT].fun, arrow[A_K_RT].type);
1063 keymacro_add(el, &strD[1], &arrow[A_K_LT].fun, arrow[A_K_LT].type);
1064 keymacro_add(el, &strH[1], &arrow[A_K_HO].fun, arrow[A_K_HO].type);
1065 keymacro_add(el, &strF[1], &arrow[A_K_EN].fun, arrow[A_K_EN].type);
1066 keymacro_add(el, &stOA[1], &arrow[A_K_UP].fun, arrow[A_K_UP].type);
1067 keymacro_add(el, &stOB[1], &arrow[A_K_DN].fun, arrow[A_K_DN].type);
1068 keymacro_add(el, &stOC[1], &arrow[A_K_RT].fun, arrow[A_K_RT].type);
1069 keymacro_add(el, &stOD[1], &arrow[A_K_LT].fun, arrow[A_K_LT].type);
1070 keymacro_add(el, &stOH[1], &arrow[A_K_HO].fun, arrow[A_K_HO].type);
1071 keymacro_add(el, &stOF[1], &arrow[A_K_EN].fun, arrow[A_K_EN].type);
1079 terminal_set_arrow(EditLine *el, const wchar_t *name, keymacro_value_t *fun,
1082 funckey_t *arrow = el->el_terminal.t_fkey;
1099 terminal_clear_arrow(EditLine *el, const wchar_t *name)
1101 funckey_t *arrow = el->el_terminal.t_fkey;
1117 terminal_print_arrow(EditLine *el, const wchar_t *name)
1120 funckey_t *arrow = el->el_terminal.t_fkey;
1125 keymacro_kprint(el, arrow[i].name,
1134 terminal_bind_arrow(EditLine *el)
1140 funckey_t *arrow = el->el_terminal.t_fkey;
1143 if (el->el_terminal.t_buf == NULL || el->el_map.key == NULL)
1146 map = el->el_map.type == MAP_VI ? el->el_map.alt : el->el_map.key;
1147 dmap = el->el_map.type == MAP_VI ? el->el_map.vic : el->el_map.emacs;
1149 terminal_reset_arrow(el);
1156 p = el->el_terminal.t_str[arrow[i].key];
1176 keymacro_clear(el, map, px);
1180 keymacro_add(el, px, &arrow[i].fun,
1184 keymacro_clear(el, map, px);
1188 keymacro_add(el, px, &arrow[i].fun,
1207 terminal_tputs(EditLine *el, const char *cap, int affcnt)
1212 terminal_outfile = el->el_outfile;
1223 terminal__putc(EditLine *el, wint_t c)
1230 return fputs(literal_get(el, c), el->el_outfile);
1235 return fputs(buf, el->el_outfile);
1242 terminal__flush(EditLine *el)
1245 (void) fflush(el->el_outfile);
1252 terminal_writec(EditLine *el, wint_t c)
1259 terminal_overwrite(el, visbuf, (size_t)vcnt);
1260 terminal__flush(el);
1269 terminal_telltc(EditLine *el, int argc __attribute__((__unused__)),
1275 (void) fprintf(el->el_outfile, "\n\tYour terminal has the\n");
1276 (void) fprintf(el->el_outfile, "\tfollowing characteristics:\n\n");
1277 (void) fprintf(el->el_outfile, "\tIt has %d columns and %d lines\n",
1279 (void) fprintf(el->el_outfile,
1281 (void) fprintf(el->el_outfile,
1283 (void) fprintf(el->el_outfile, "\tIt %s automatic margins\n",
1286 (void) fprintf(el->el_outfile, "\tIt %s magic margins\n",
1289 for (t = tstr, ts = el->el_terminal.t_str; t->name != NULL; t++, ts++) {
1293 ct_decode_string(*ts, &el->el_scratch),
1294 el->el_visual), &el->el_scratch);
1298 (void) fprintf(el->el_outfile, "\t%25s (%s) == %s\n",
1301 (void) fputc('\n', el->el_outfile);
1311 terminal_settc(EditLine *el, int argc __attribute__((__unused__)),
1323 strlcpy(what, ct_encode_string(argv[1], &el->el_scratch), sizeof(what));
1324 strlcpy(how, ct_encode_string(argv[2], &el->el_scratch), sizeof(how));
1334 terminal_alloc(el, ts, how);
1335 terminal_setflags(el);
1346 (void) fprintf(el->el_errfile,
1357 el->el_terminal.t_val[tv - tval] = 1;
1359 el->el_terminal.t_val[tv - tval] = 0;
1361 (void) fprintf(el->el_errfile,
1365 terminal_setflags(el);
1374 (void) fprintf(el->el_errfile,
1378 el->el_terminal.t_val[tv - tval] = (int) i;
1381 el->el_terminal.t_size.v = Val(T_co);
1384 el->el_terminal.t_size.h = Val(T_li);
1387 if (i && terminal_change_size(el, Val(T_li), Val(T_co)) == -1)
1398 terminal_gettc(EditLine *el, int argc __attribute__((__unused__)), char **argv)
1419 *(char **)how = el->el_terminal.t_str[ts - tstr];
1436 if (el->el_terminal.t_val[tv - tval])
1442 *(int *)how = el->el_terminal.t_val[tv - tval];
1452 terminal_echotc(EditLine *el, int argc __attribute__((__unused__)),
1488 (void) fprintf(el->el_outfile, fmts, EL_CAN_TAB ? "yes" : "no");
1491 (void) fprintf(el->el_outfile, fmts, Val(T_km) ? "yes" : "no");
1494 (void) fprintf(el->el_outfile, fmts, EL_HAS_MAGIC_MARGINS ?
1498 (void) fprintf(el->el_outfile, fmts, EL_HAS_AUTO_MARGINS ?
1502 (void) fprintf(el->el_outfile, fmtd, (int)el->el_tty.t_speed);
1506 (void) fprintf(el->el_outfile, fmtd, Val(T_li));
1509 (void) fprintf(el->el_outfile, fmtd, Val(T_co));
1518 ct_encode_string(*argv, &el->el_scratch)) == 0) {
1519 scap = el->el_terminal.t_str[t - tstr];
1524 scap = tgetstr(ct_encode_string(*argv, &el->el_scratch), &area);
1528 (void) fprintf(el->el_errfile,
1559 (void) fprintf(el->el_errfile,
1571 (void) fprintf(el->el_errfile,
1576 terminal_tputs(el, scap, 1);
1582 (void) fprintf(el->el_errfile,
1590 (void) fprintf(el->el_errfile,
1599 (void) fprintf(el->el_errfile,
1604 terminal_tputs(el, tgoto(scap, arg_cols, arg_rows), 1);
1609 (void) fprintf(el->el_errfile,
1617 (void) fprintf(el->el_errfile,
1624 (void) fprintf(el->el_errfile,
1633 (void) fprintf(el->el_errfile,
1640 (void) fprintf(el->el_errfile,
1648 (void) fprintf(el->el_errfile,
1655 (void) fprintf(el->el_errfile,
1660 terminal_tputs(el, tgoto(scap, arg_cols, arg_rows), arg_rows);